diff options
Diffstat (limited to 'framework/Web/UI/TClientScriptManager.php')
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index eec347eb..677daa9b 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -3,6 +3,7 @@ * TClientScriptManager and TClientSideOptions class file. * * @author Qiang Xue <qiang.xue@gmail.com> + * @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering) * @link http://www.pradosoft.com/ * @copyright Copyright © 2005-2011 PradoSoft * @license http://www.pradosoft.com/license/ @@ -16,6 +17,7 @@ * TClientScriptManager manages javascript and CSS stylesheets for a page. * * @author Qiang Xue <qiang.xue@gmail.com> + * @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering) * @version $Id$ * @package System.Web.UI * @since 3.0 @@ -107,6 +109,16 @@ class TClientScriptManager extends TApplicationComponent || count($this->_headScriptFiles) || count($this->_headScripts); } + public static function getPradoPackages() + { + return self::$_pradoPackages; + } + + public static function getPradoScripts() + { + return self::$_pradoScripts; + } + /** * Registers Prado javascript by library name. See "Web/Javascripts/source/packages.php" * for library names. @@ -192,6 +204,37 @@ class TClientScriptManager extends TApplicationComponent } /** + * Returns the URLs of all script files referenced on the page + * @return array Combined list of all script urls used in the page + */ + public function getScriptUrls() + { + $scripts = array(); + + $packages=array_keys($this->_registeredPradoScripts); + $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; + list($path,$baseUrl)=$this->getPackagePathUrl($base); + foreach ($packages as $p) + { + foreach (self::$_pradoScripts[$p] as $dep) + { + foreach (self::$_pradoPackages[$dep] as $script) + { + if (!in_array($url=$baseUrl.'/'.$script,$scripts)) + $scripts[]=$url; + } + } + } + + $scripts = array_merge($scripts, array_values($this->_headScriptFiles)); + $scripts = array_merge($scripts, array_values($this->_scriptFiles)); + + $scripts = array_unique($scripts); + + return $scripts; + } + + /** * Publishes a javascript library path and register packages to be loaded. * See TClientScriptLoader for component that enables users to register custom javascript libraries. * @param string javascript library base path @@ -424,6 +467,23 @@ class TClientScriptManager extends TApplicationComponent } /** + * Returns the URLs of all stylesheet files referenced on the page + * @return array Combined list of all stylesheet urls used in the page + */ + public function getStyleSheetUrls() + { + $stylesheets = array_values($this->_styleSheets); + + foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) + if (substr($url,strlen($url)-4)=='.css') + $stylesheets[] = $url; + + $stylesheets = array_unique($stylesheets); + + return $stylesheets; + } + + /** * Registers a javascript file in the page head * @param string a unique key identifying the file * @param string URL to the javascript file @@ -714,6 +774,11 @@ class TClientScriptManager extends TApplicationComponent $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); } + public function getHiddenFields() + { + return $this->_hiddenFields; + } + /** * Checks whether page rendering has not begun yet */ |