@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Default web accessible base path for storing private files |
| 57 | 57 | */ |
| 58 | - const DEFAULT_BASEPATH = 'assets'; |
|
| 58 | + const DEFAULT_BASEPATH='assets'; |
|
| 59 | 59 | /** |
| 60 | 60 | * @var string base web accessible path for storing private files |
| 61 | 61 | */ |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * @var boolean whether to use timestamp checking to ensure files are published with up-to-date versions. |
| 69 | 69 | */ |
| 70 | - private $_checkTimestamp = false; |
|
| 70 | + private $_checkTimestamp=false; |
|
| 71 | 71 | /** |
| 72 | 72 | * @var TApplication application instance |
| 73 | 73 | */ |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * @var array published assets |
| 77 | 77 | */ |
| 78 | - private $_published = []; |
|
| 78 | + private $_published=[]; |
|
| 79 | 79 | /** |
| 80 | 80 | * @var boolean whether the module is initialized |
| 81 | 81 | */ |
| 82 | - private $_initialized = false; |
|
| 82 | + private $_initialized=false; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Initializes the module. |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function init($config) |
| 90 | 90 | { |
| 91 | - $application = $this->getApplication(); |
|
| 92 | - if($this->_basePath === null) |
|
| 93 | - $this->_basePath = dirname($application->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
| 91 | + $application=$this->getApplication(); |
|
| 92 | + if($this->_basePath===null) |
|
| 93 | + $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
| 94 | 94 | if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
| 95 | 95 | throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
| 96 | - if($this->_baseUrl === null) |
|
| 97 | - $this->_baseUrl = rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\') . '/' . self::DEFAULT_BASEPATH; |
|
| 96 | + if($this->_baseUrl===null) |
|
| 97 | + $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\').'/'.self::DEFAULT_BASEPATH; |
|
| 98 | 98 | $application->setAssetManager($this); |
| 99 | - $this->_initialized = true; |
|
| 99 | + $this->_initialized=true; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | throw new TInvalidOperationException('assetmanager_basepath_unchangeable'); |
| 120 | 120 | else |
| 121 | 121 | { |
| 122 | - $this->_basePath = Prado::getPathOfNamespace($value); |
|
| 123 | - if($this->_basePath === null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
|
| 122 | + $this->_basePath=Prado::getPathOfNamespace($value); |
|
| 123 | + if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
|
| 124 | 124 | throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | if($this->_initialized) |
| 143 | 143 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
| 144 | 144 | else |
| 145 | - $this->_baseUrl = rtrim($value, '/'); |
|
| 145 | + $this->_baseUrl=rtrim($value, '/'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -159,30 +159,30 @@ discard block |
||
| 159 | 159 | * @throws TInvalidDataValueException if the file path to be published is |
| 160 | 160 | * invalid |
| 161 | 161 | */ |
| 162 | - public function publishFilePath($path, $checkTimestamp = false) |
|
| 162 | + public function publishFilePath($path, $checkTimestamp=false) |
|
| 163 | 163 | { |
| 164 | 164 | if(isset($this->_published[$path])) |
| 165 | 165 | return $this->_published[$path]; |
| 166 | - elseif(empty($path) || ($fullpath = realpath($path)) === false) |
|
| 166 | + elseif(empty($path) || ($fullpath=realpath($path))===false) |
|
| 167 | 167 | throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
| 168 | 168 | elseif(is_file($fullpath)) |
| 169 | 169 | { |
| 170 | - $dir = $this->hash(dirname($fullpath)); |
|
| 171 | - $fileName = basename($fullpath); |
|
| 172 | - $dst = $this->_basePath . DIRECTORY_SEPARATOR . $dir; |
|
| 173 | - if(!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 170 | + $dir=$this->hash(dirname($fullpath)); |
|
| 171 | + $fileName=basename($fullpath); |
|
| 172 | + $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
|
| 173 | + if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 174 | 174 | $this->copyFile($fullpath, $dst); |
| 175 | - return $this->_published[$path] = $this->_baseUrl . '/' . $dir . '/' . $fileName; |
|
| 175 | + return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
|
| 176 | 176 | } |
| 177 | 177 | else |
| 178 | 178 | { |
| 179 | - $dir = $this->hash($fullpath); |
|
| 180 | - if(!is_dir($this->_basePath . DIRECTORY_SEPARATOR . $dir) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 179 | + $dir=$this->hash($fullpath); |
|
| 180 | + if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 181 | 181 | { |
| 182 | 182 | Prado::trace("Publishing directory $fullpath", 'Prado\Web\TAssetManager'); |
| 183 | - $this->copyDirectory($fullpath, $this->_basePath . DIRECTORY_SEPARATOR . $dir); |
|
| 183 | + $this->copyDirectory($fullpath, $this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
| 184 | 184 | } |
| 185 | - return $this->_published[$path] = $this->_baseUrl . '/' . $dir; |
|
| 185 | + return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | * @param $values List of published assets |
| 200 | 200 | * @since 3.1.6 |
| 201 | 201 | */ |
| 202 | - protected function setPublished($values = []) |
|
| 202 | + protected function setPublished($values=[]) |
|
| 203 | 203 | { |
| 204 | - $this->_published = $values; |
|
| 204 | + $this->_published=$values; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function getPublishedPath($path) |
| 215 | 215 | { |
| 216 | - $path = realpath($path); |
|
| 216 | + $path=realpath($path); |
|
| 217 | 217 | if(is_file($path)) |
| 218 | - return $this->_basePath . DIRECTORY_SEPARATOR . $this->hash(dirname($path)) . DIRECTORY_SEPARATOR . basename($path); |
|
| 218 | + return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash(dirname($path)).DIRECTORY_SEPARATOR.basename($path); |
|
| 219 | 219 | else |
| 220 | - return $this->_basePath . DIRECTORY_SEPARATOR . $this->hash($path); |
|
| 220 | + return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash($path); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function getPublishedUrl($path) |
| 231 | 231 | { |
| 232 | - $path = realpath($path); |
|
| 232 | + $path=realpath($path); |
|
| 233 | 233 | if(is_file($path)) |
| 234 | - return $this->_baseUrl . '/' . $this->hash(dirname($path)) . '/' . basename($path); |
|
| 234 | + return $this->_baseUrl.'/'.$this->hash(dirname($path)).'/'.basename($path); |
|
| 235 | 235 | else |
| 236 | - return $this->_baseUrl . '/' . $this->hash($path); |
|
| 236 | + return $this->_baseUrl.'/'.$this->hash($path); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | protected function hash($dir) |
| 246 | 246 | { |
| 247 | - return sprintf('%x', crc32($dir . Prado::getVersion())); |
|
| 247 | + return sprintf('%x', crc32($dir.Prado::getVersion())); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | @mkdir($dst); |
| 262 | 262 | @chmod($dst, PRADO_CHMOD); |
| 263 | 263 | } |
| 264 | - $dstFile = $dst . DIRECTORY_SEPARATOR . basename($src); |
|
| 264 | + $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
|
| 265 | 265 | if(@filemtime($dstFile) < @filemtime($src)) |
| 266 | 266 | { |
| 267 | 267 | Prado::trace("Publishing file $src to $dstFile", 'Prado\Web\TAssetManager'); |
@@ -284,22 +284,22 @@ discard block |
||
| 284 | 284 | @mkdir($dst); |
| 285 | 285 | @chmod($dst, PRADO_CHMOD); |
| 286 | 286 | } |
| 287 | - if($folder = @opendir($src)) |
|
| 287 | + if($folder=@opendir($src)) |
|
| 288 | 288 | { |
| 289 | - while($file = @readdir($folder)) |
|
| 289 | + while($file=@readdir($folder)) |
|
| 290 | 290 | { |
| 291 | - if($file === '.' || $file === '..' || $file === '.svn' || $file === '.git') |
|
| 291 | + if($file==='.' || $file==='..' || $file==='.svn' || $file==='.git') |
|
| 292 | 292 | continue; |
| 293 | - elseif(is_file($src . DIRECTORY_SEPARATOR . $file)) |
|
| 293 | + elseif(is_file($src.DIRECTORY_SEPARATOR.$file)) |
|
| 294 | 294 | { |
| 295 | - if(@filemtime($dst . DIRECTORY_SEPARATOR . $file) < @filemtime($src . DIRECTORY_SEPARATOR . $file)) |
|
| 295 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$file) < @filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
| 296 | 296 | { |
| 297 | - @copy($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file); |
|
| 298 | - @chmod($dst . DIRECTORY_SEPARATOR . $file, PRADO_CHMOD); |
|
| 297 | + @copy($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
| 298 | + @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | else |
| 302 | - $this->copyDirectory($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file); |
|
| 302 | + $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
| 303 | 303 | } |
| 304 | 304 | closedir($folder); |
| 305 | 305 | } else { |
@@ -318,26 +318,26 @@ discard block |
||
| 318 | 318 | * @param boolean Wether or not to check the time stamp of the file for publishing. Defaults to false. |
| 319 | 319 | * @return string URL path to the directory where the tar file was extracted. |
| 320 | 320 | */ |
| 321 | - public function publishTarFile($tarfile, $md5sum, $checkTimestamp = false) |
|
| 321 | + public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false) |
|
| 322 | 322 | { |
| 323 | 323 | if(isset($this->_published[$md5sum])) |
| 324 | 324 | return $this->_published[$md5sum]; |
| 325 | - elseif(($fullpath = realpath($md5sum)) === false || !is_file($fullpath)) |
|
| 325 | + elseif(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
|
| 326 | 326 | throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
| 327 | 327 | else |
| 328 | 328 | { |
| 329 | - $dir = $this->hash(dirname($fullpath)); |
|
| 330 | - $fileName = basename($fullpath); |
|
| 331 | - $dst = $this->_basePath . DIRECTORY_SEPARATOR . $dir; |
|
| 332 | - if(!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 329 | + $dir=$this->hash(dirname($fullpath)); |
|
| 330 | + $fileName=basename($fullpath); |
|
| 331 | + $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
|
| 332 | + if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 333 | 333 | { |
| 334 | - if(@filemtime($dst . DIRECTORY_SEPARATOR . $fileName) < @filemtime($fullpath)) |
|
| 334 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName) < @filemtime($fullpath)) |
|
| 335 | 335 | { |
| 336 | 336 | $this->copyFile($fullpath, $dst); |
| 337 | 337 | $this->deployTarFile($tarfile, $dst); |
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | - return $this->_published[$md5sum] = $this->_baseUrl . '/' . $dir; |
|
| 340 | + return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
@@ -350,11 +350,11 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | protected function deployTarFile($path, $destination) |
| 352 | 352 | { |
| 353 | - if(($fullpath = realpath($path)) === false || !is_file($fullpath)) |
|
| 353 | + if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
|
| 354 | 354 | throw new TIOException('assetmanager_tarfile_invalid', $path); |
| 355 | 355 | else |
| 356 | 356 | { |
| 357 | - $tar = new TTarFileExtractor($fullpath); |
|
| 357 | + $tar=new TTarFileExtractor($fullpath); |
|
| 358 | 358 | return $tar->extract($destination); |
| 359 | 359 | } |
| 360 | 360 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class THttpRequestUrlFormat extends \Prado\TEnumerable |
| 29 | 29 | { |
| 30 | - const Get = 'Get'; |
|
| 31 | - const Path = 'Path'; |
|
| 32 | - const HiddenPath = 'HiddenPath'; |
|
| 30 | + const Get='Get'; |
|
| 31 | + const Path='Path'; |
|
| 32 | + const HiddenPath='HiddenPath'; |
|
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -20,9 +20,9 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class THttpUtility |
| 22 | 22 | { |
| 23 | - private static $_encodeTable = ['<' => '<','>' => '>','"' => '"']; |
|
| 24 | - private static $_decodeTable = ['<' => '<','>' => '>','"' => '"']; |
|
| 25 | - private static $_stripTable = ['<' => '','>' => '','"' => '']; |
|
| 23 | + private static $_encodeTable=['<' => '<', '>' => '>', '"' => '"']; |
|
| 24 | + private static $_decodeTable=['<' => '<', '>' => '>', '"' => '"']; |
|
| 25 | + private static $_stripTable=['<' => '', '>' => '', '"' => '']; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * HTML-encodes a string. |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct($response) |
| 36 | 36 | { |
| 37 | - $this->_response = $response; |
|
| 37 | + $this->_response=$response; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * prefix for cache variable name used to store parsed themes |
| 48 | 48 | */ |
| 49 | - const THEME_CACHE_PREFIX = 'prado:theme:'; |
|
| 49 | + const THEME_CACHE_PREFIX='prado:theme:'; |
|
| 50 | 50 | /** |
| 51 | 51 | * Extension name of skin files |
| 52 | 52 | */ |
| 53 | - const SKIN_FILE_EXT = '.skin'; |
|
| 53 | + const SKIN_FILE_EXT='.skin'; |
|
| 54 | 54 | /** |
| 55 | 55 | * @var string theme path |
| 56 | 56 | */ |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * @var string theme name |
| 68 | 68 | */ |
| 69 | - private $_name = ''; |
|
| 69 | + private $_name=''; |
|
| 70 | 70 | /** |
| 71 | 71 | * @var array list of css files |
| 72 | 72 | */ |
| 73 | - private $_cssFiles = []; |
|
| 73 | + private $_cssFiles=[]; |
|
| 74 | 74 | /** |
| 75 | 75 | * @var array list of js files |
| 76 | 76 | */ |
| 77 | - private $_jsFiles = []; |
|
| 77 | + private $_jsFiles=[]; |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Constructor. |
@@ -84,75 +84,75 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function __construct($themePath, $themeUrl) |
| 86 | 86 | { |
| 87 | - $this->_themeUrl = $themeUrl; |
|
| 88 | - $this->_themePath = realpath($themePath); |
|
| 89 | - $this->_name = basename($themePath); |
|
| 90 | - $cacheValid = false; |
|
| 87 | + $this->_themeUrl=$themeUrl; |
|
| 88 | + $this->_themePath=realpath($themePath); |
|
| 89 | + $this->_name=basename($themePath); |
|
| 90 | + $cacheValid=false; |
|
| 91 | 91 | // TODO: the following needs to be cleaned up (Qiang) |
| 92 | - if(($cache = $this->getApplication()->getCache()) !== null) |
|
| 92 | + if(($cache=$this->getApplication()->getCache())!==null) |
|
| 93 | 93 | { |
| 94 | - $array = $cache->get(self::THEME_CACHE_PREFIX . $themePath); |
|
| 94 | + $array=$cache->get(self::THEME_CACHE_PREFIX.$themePath); |
|
| 95 | 95 | if(is_array($array)) |
| 96 | 96 | { |
| 97 | - list($skins, $cssFiles, $jsFiles, $timestamp) = $array; |
|
| 98 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 97 | + list($skins, $cssFiles, $jsFiles, $timestamp)=$array; |
|
| 98 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 99 | 99 | { |
| 100 | - if(($dir = opendir($themePath)) === false) |
|
| 100 | + if(($dir=opendir($themePath))===false) |
|
| 101 | 101 | throw new TIOException('theme_path_inexistent', $themePath); |
| 102 | - $cacheValid = true; |
|
| 103 | - while(($file = readdir($dir)) !== false) |
|
| 102 | + $cacheValid=true; |
|
| 103 | + while(($file=readdir($dir))!==false) |
|
| 104 | 104 | { |
| 105 | - if($file === '.' || $file === '..') |
|
| 105 | + if($file==='.' || $file==='..') |
|
| 106 | 106 | continue; |
| 107 | - elseif(basename($file, '.css') !== $file) |
|
| 108 | - $this->_cssFiles[] = $themeUrl . '/' . $file; |
|
| 109 | - elseif(basename($file, '.js') !== $file) |
|
| 110 | - $this->_jsFiles[] = $themeUrl . '/' . $file; |
|
| 111 | - elseif(basename($file, self::SKIN_FILE_EXT) !== $file && filemtime($themePath . DIRECTORY_SEPARATOR . $file) > $timestamp) |
|
| 107 | + elseif(basename($file, '.css')!==$file) |
|
| 108 | + $this->_cssFiles[]=$themeUrl.'/'.$file; |
|
| 109 | + elseif(basename($file, '.js')!==$file) |
|
| 110 | + $this->_jsFiles[]=$themeUrl.'/'.$file; |
|
| 111 | + elseif(basename($file, self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file) > $timestamp) |
|
| 112 | 112 | { |
| 113 | - $cacheValid = false; |
|
| 113 | + $cacheValid=false; |
|
| 114 | 114 | break; |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | closedir($dir); |
| 118 | 118 | if($cacheValid) |
| 119 | - $this->_skins = $skins; |
|
| 119 | + $this->_skins=$skins; |
|
| 120 | 120 | } |
| 121 | 121 | else |
| 122 | 122 | { |
| 123 | - $cacheValid = true; |
|
| 124 | - $this->_cssFiles = $cssFiles; |
|
| 125 | - $this->_jsFiles = $jsFiles; |
|
| 126 | - $this->_skins = $skins; |
|
| 123 | + $cacheValid=true; |
|
| 124 | + $this->_cssFiles=$cssFiles; |
|
| 125 | + $this->_jsFiles=$jsFiles; |
|
| 126 | + $this->_skins=$skins; |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | if(!$cacheValid) |
| 131 | 131 | { |
| 132 | - $this->_cssFiles = []; |
|
| 133 | - $this->_jsFiles = []; |
|
| 134 | - $this->_skins = []; |
|
| 135 | - if(($dir = opendir($themePath)) === false) |
|
| 132 | + $this->_cssFiles=[]; |
|
| 133 | + $this->_jsFiles=[]; |
|
| 134 | + $this->_skins=[]; |
|
| 135 | + if(($dir=opendir($themePath))===false) |
|
| 136 | 136 | throw new TIOException('theme_path_inexistent', $themePath); |
| 137 | - while(($file = readdir($dir)) !== false) |
|
| 137 | + while(($file=readdir($dir))!==false) |
|
| 138 | 138 | { |
| 139 | - if($file === '.' || $file === '..') |
|
| 139 | + if($file==='.' || $file==='..') |
|
| 140 | 140 | continue; |
| 141 | - elseif(basename($file, '.css') !== $file) |
|
| 142 | - $this->_cssFiles[] = $themeUrl . '/' . $file; |
|
| 143 | - elseif(basename($file, '.js') !== $file) |
|
| 144 | - $this->_jsFiles[] = $themeUrl . '/' . $file; |
|
| 145 | - elseif(basename($file, self::SKIN_FILE_EXT) !== $file) |
|
| 141 | + elseif(basename($file, '.css')!==$file) |
|
| 142 | + $this->_cssFiles[]=$themeUrl.'/'.$file; |
|
| 143 | + elseif(basename($file, '.js')!==$file) |
|
| 144 | + $this->_jsFiles[]=$themeUrl.'/'.$file; |
|
| 145 | + elseif(basename($file, self::SKIN_FILE_EXT)!==$file) |
|
| 146 | 146 | { |
| 147 | - $template = new TTemplate(file_get_contents($themePath . '/' . $file), $themePath, $themePath . '/' . $file); |
|
| 147 | + $template=new TTemplate(file_get_contents($themePath.'/'.$file), $themePath, $themePath.'/'.$file); |
|
| 148 | 148 | foreach($template->getItems() as $skin) |
| 149 | 149 | { |
| 150 | 150 | if(!isset($skin[2])) // a text string, ignored |
| 151 | 151 | continue; |
| 152 | - elseif($skin[0] !== -1) |
|
| 152 | + elseif($skin[0]!==-1) |
|
| 153 | 153 | throw new TConfigurationException('theme_control_nested', $skin[1], dirname($themePath)); |
| 154 | - $type = $skin[1]; |
|
| 155 | - $id = isset($skin[2]['skinid'])?$skin[2]['skinid']:0; |
|
| 154 | + $type=$skin[1]; |
|
| 155 | + $id=isset($skin[2]['skinid']) ? $skin[2]['skinid'] : 0; |
|
| 156 | 156 | unset($skin[2]['skinid']); |
| 157 | 157 | if(isset($this->_skins[$type][$id])) |
| 158 | 158 | throw new TConfigurationException('theme_skinid_duplicated', $type, $id, dirname($themePath)); |
@@ -163,15 +163,15 @@ discard block |
||
| 163 | 163 | throw new TConfigurationException('theme_databind_forbidden',dirname($themePath),$type,$id); |
| 164 | 164 | } |
| 165 | 165 | */ |
| 166 | - $this->_skins[$type][$id] = $skin[2]; |
|
| 166 | + $this->_skins[$type][$id]=$skin[2]; |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | closedir($dir); |
| 171 | 171 | sort($this->_cssFiles); |
| 172 | 172 | sort($this->_jsFiles); |
| 173 | - if($cache !== null) |
|
| 174 | - $cache->set(self::THEME_CACHE_PREFIX . $themePath, [$this->_skins,$this->_cssFiles,$this->_jsFiles,time()]); |
|
| 173 | + if($cache!==null) |
|
| 174 | + $cache->set(self::THEME_CACHE_PREFIX.$themePath, [$this->_skins, $this->_cssFiles, $this->_jsFiles, time()]); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | protected function setName($value) |
| 190 | 190 | { |
| 191 | - $this->_name = $value; |
|
| 191 | + $this->_name=$value; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | protected function setBaseUrl($value) |
| 206 | 206 | { |
| 207 | - $this->_themeUrl = rtrim($value, '/'); |
|
| 207 | + $this->_themeUrl=rtrim($value, '/'); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | protected function setBasePath($value) |
| 222 | 222 | { |
| 223 | - $this->_themePath = $value; |
|
| 223 | + $this->_themePath=$value; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function setSkins($value) |
| 238 | 238 | { |
| 239 | - $this->_skins = $value; |
|
| 239 | + $this->_skins=$value; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function applySkin($control) |
| 252 | 252 | { |
| 253 | - $type = get_class($control); |
|
| 254 | - if(($id = $control->getSkinID()) === '') |
|
| 255 | - $id = 0; |
|
| 253 | + $type=get_class($control); |
|
| 254 | + if(($id=$control->getSkinID())==='') |
|
| 255 | + $id=0; |
|
| 256 | 256 | if(isset($this->_skins[$type][$id])) |
| 257 | 257 | { |
| 258 | 258 | foreach($this->_skins[$type][$id] as $name => $value) |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | switch($value[0]) |
| 264 | 264 | { |
| 265 | 265 | case TTemplate::CONFIG_EXPRESSION: |
| 266 | - $value = $this->evaluateExpression($value[1]); |
|
| 266 | + $value=$this->evaluateExpression($value[1]); |
|
| 267 | 267 | break; |
| 268 | 268 | case TTemplate::CONFIG_ASSET: |
| 269 | - $value = $this->_themeUrl . '/' . ltrim($value[1], '/'); |
|
| 269 | + $value=$this->_themeUrl.'/'.ltrim($value[1], '/'); |
|
| 270 | 270 | break; |
| 271 | 271 | case TTemplate::CONFIG_DATABIND: |
| 272 | 272 | $control->bindProperty($name, $value[1]); |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | if(!is_array($value)) |
| 289 | 289 | { |
| 290 | - if(strpos($name, '.') === false) // is simple property or custom attribute |
|
| 290 | + if(strpos($name, '.')===false) // is simple property or custom attribute |
|
| 291 | 291 | { |
| 292 | 292 | if($control->hasProperty($name)) |
| 293 | 293 | { |
| 294 | 294 | if($control->canSetProperty($name)) |
| 295 | 295 | { |
| 296 | - $setter = 'set' . $name; |
|
| 296 | + $setter='set'.$name; |
|
| 297 | 297 | $control->$setter($value); |
| 298 | 298 | } |
| 299 | 299 | else |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | protected function setStyleSheetFiles($value) |
| 327 | 327 | { |
| 328 | - $this->_cssFiles = $value; |
|
| 328 | + $this->_cssFiles=$value; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -341,6 +341,6 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | protected function setJavaScriptFiles($value) |
| 343 | 343 | { |
| 344 | - $this->_jsFiles = $value; |
|
| 344 | + $this->_jsFiles=$value; |
|
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | \ No newline at end of file |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * Only framework developers should use this method. |
| 30 | 30 | * @param TControl the naming container control |
| 31 | 31 | */ |
| 32 | - protected function initRecursive($namingContainer = null) |
|
| 32 | + protected function initRecursive($namingContainer=null) |
|
| 33 | 33 | { |
| 34 | 34 | $this->ensureChildControls(); |
| 35 | 35 | parent::initRecursive($namingContainer); |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * template file extension. |
| 35 | 35 | */ |
| 36 | - const EXT_TEMPLATE = '.tpl'; |
|
| 36 | + const EXT_TEMPLATE='.tpl'; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @var ITemplate the parsed template structure shared by the same control class |
| 40 | 40 | */ |
| 41 | - private static $_template = []; |
|
| 41 | + private static $_template=[]; |
|
| 42 | 42 | /** |
| 43 | 43 | * @var ITemplate the parsed template structure specific for this control instance |
| 44 | 44 | */ |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @var string master control class name |
| 52 | 52 | */ |
| 53 | - private $_masterClass = ''; |
|
| 53 | + private $_masterClass=''; |
|
| 54 | 54 | /** |
| 55 | 55 | * @var array list of TContent controls |
| 56 | 56 | */ |
| 57 | - private $_contents = []; |
|
| 57 | + private $_contents=[]; |
|
| 58 | 58 | /** |
| 59 | 59 | * @var array list of TContentPlaceHolder controls |
| 60 | 60 | */ |
| 61 | - private $_placeholders = []; |
|
| 61 | + private $_placeholders=[]; |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Returns the template object associated with this control object. |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function getTemplate() |
| 68 | 68 | { |
| 69 | - if($this->_localTemplate === null) |
|
| 69 | + if($this->_localTemplate===null) |
|
| 70 | 70 | { |
| 71 | - $class = get_class($this); |
|
| 71 | + $class=get_class($this); |
|
| 72 | 72 | if(!isset(self::$_template[$class])) |
| 73 | - self::$_template[$class] = $this->loadTemplate(); |
|
| 73 | + self::$_template[$class]=$this->loadTemplate(); |
|
| 74 | 74 | return self::$_template[$class]; |
| 75 | 75 | } |
| 76 | 76 | else |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function setTemplate($value) |
| 87 | 87 | { |
| 88 | - $this->_localTemplate = $value; |
|
| 88 | + $this->_localTemplate=$value; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function getIsSourceTemplateControl() |
| 97 | 97 | { |
| 98 | - if(($template = $this->getTemplate()) !== null) |
|
| 98 | + if(($template=$this->getTemplate())!==null) |
|
| 99 | 99 | return $template->getIsSourceTemplate(); |
| 100 | 100 | else |
| 101 | 101 | return false; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function getTemplateDirectory() |
| 108 | 108 | { |
| 109 | - if(($template = $this->getTemplate()) !== null) |
|
| 109 | + if(($template=$this->getTemplate())!==null) |
|
| 110 | 110 | return $template->getContextPath(); |
| 111 | 111 | else |
| 112 | 112 | return ''; |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | protected function loadTemplate() |
| 120 | 120 | { |
| 121 | - Prado::trace("Loading template " . get_class($this), '\Prado\Web\UI\TTemplateControl'); |
|
| 122 | - $template = $this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
|
| 121 | + Prado::trace("Loading template ".get_class($this), '\Prado\Web\UI\TTemplateControl'); |
|
| 122 | + $template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
|
| 123 | 123 | return $template; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function createChildControls() |
| 132 | 132 | { |
| 133 | - if($tpl = $this->getTemplate()) |
|
| 133 | + if($tpl=$this->getTemplate()) |
|
| 134 | 134 | { |
| 135 | 135 | foreach($tpl->getDirective() as $name => $value) |
| 136 | 136 | { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | if(isset($this->_contents[$id])) |
| 154 | 154 | throw new TConfigurationException('templatecontrol_contentid_duplicated', $id); |
| 155 | 155 | else |
| 156 | - $this->_contents[$id] = $object; |
|
| 156 | + $this->_contents[$id]=$object; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | if(isset($this->_placeholders[$id])) |
| 168 | 168 | throw new TConfigurationException('templatecontrol_placeholderid_duplicated', $id); |
| 169 | 169 | else |
| 170 | - $this->_placeholders[$id] = $object; |
|
| 170 | + $this->_placeholders[$id]=$object; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function setMasterClass($value) |
| 185 | 185 | { |
| 186 | - $this->_masterClass = $value; |
|
| 186 | + $this->_masterClass=$value; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | { |
| 205 | 205 | if(isset($this->_placeholders[$id])) |
| 206 | 206 | { |
| 207 | - $placeholder = $this->_placeholders[$id]; |
|
| 208 | - $controls = $placeholder->getParent()->getControls(); |
|
| 209 | - $loc = $controls->remove($placeholder); |
|
| 207 | + $placeholder=$this->_placeholders[$id]; |
|
| 208 | + $controls=$placeholder->getParent()->getControls(); |
|
| 209 | + $loc=$controls->remove($placeholder); |
|
| 210 | 210 | $controls->insertAt($loc, $content); |
| 211 | 211 | } |
| 212 | 212 | else |
@@ -221,15 +221,15 @@ discard block |
||
| 221 | 221 | * Only framework developers should use this method. |
| 222 | 222 | * @param TControl the naming container control |
| 223 | 223 | */ |
| 224 | - protected function initRecursive($namingContainer = null) |
|
| 224 | + protected function initRecursive($namingContainer=null) |
|
| 225 | 225 | { |
| 226 | 226 | $this->ensureChildControls(); |
| 227 | - if($this->_masterClass !== '') |
|
| 227 | + if($this->_masterClass!=='') |
|
| 228 | 228 | { |
| 229 | - $master = Prado::createComponent($this->_masterClass); |
|
| 229 | + $master=Prado::createComponent($this->_masterClass); |
|
| 230 | 230 | if(!($master instanceof TTemplateControl)) |
| 231 | 231 | throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid'); |
| 232 | - $this->_master = $master; |
|
| 232 | + $this->_master=$master; |
|
| 233 | 233 | $this->getControls()->clear(); |
| 234 | 234 | $this->getControls()->add($master); |
| 235 | 235 | $master->ensureChildControls(); |
@@ -248,38 +248,38 @@ discard block |
||
| 248 | 248 | * @param Boolean $throwExceptions Wheter or not to throw exceptions |
| 249 | 249 | * @author Daniel Sampedro <[email protected]> |
| 250 | 250 | */ |
| 251 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
| 251 | + public function tryToUpdateView($arObj, $throwExceptions=false) |
|
| 252 | 252 | { |
| 253 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
| 254 | - foreach (array_keys($objAttrs) as $key) |
|
| 253 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
| 254 | + foreach(array_keys($objAttrs) as $key) |
|
| 255 | 255 | { |
| 256 | 256 | try |
| 257 | 257 | { |
| 258 | - if ($key != "RELATIONS") |
|
| 258 | + if($key!="RELATIONS") |
|
| 259 | 259 | { |
| 260 | - $control = $this->{$key}; |
|
| 261 | - if ($control instanceof TTextBox) |
|
| 262 | - $control->Text = $arObj->{$key}; |
|
| 263 | - elseif ($control instanceof TCheckBox) |
|
| 264 | - $control->Checked = (boolean) $arObj->{$key}; |
|
| 265 | - elseif ($control instanceof TDatePicker) |
|
| 266 | - $control->Date = $arObj->{$key}; |
|
| 260 | + $control=$this->{$key}; |
|
| 261 | + if($control instanceof TTextBox) |
|
| 262 | + $control->Text=$arObj->{$key}; |
|
| 263 | + elseif($control instanceof TCheckBox) |
|
| 264 | + $control->Checked=(boolean) $arObj->{$key}; |
|
| 265 | + elseif($control instanceof TDatePicker) |
|
| 266 | + $control->Date=$arObj->{$key}; |
|
| 267 | 267 | } |
| 268 | 268 | else |
| 269 | 269 | { |
| 270 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
| 270 | + foreach($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
| 271 | 271 | { |
| 272 | - $relControl = $this->{$relKey}; |
|
| 273 | - switch ($relValues[0]) |
|
| 272 | + $relControl=$this->{$relKey}; |
|
| 273 | + switch($relValues[0]) |
|
| 274 | 274 | { |
| 275 | 275 | case TActiveRecord::BELONGS_TO: |
| 276 | 276 | case TActiveRecord::HAS_ONE: |
| 277 | - $relControl->Text = $arObj->{$relKey}; |
|
| 277 | + $relControl->Text=$arObj->{$relKey}; |
|
| 278 | 278 | break; |
| 279 | 279 | case TActiveRecord::HAS_MANY: |
| 280 | - if ($relControl instanceof TListControl) |
|
| 280 | + if($relControl instanceof TListControl) |
|
| 281 | 281 | { |
| 282 | - $relControl->DataSource = $arObj->{$relKey}; |
|
| 282 | + $relControl->DataSource=$arObj->{$relKey}; |
|
| 283 | 283 | $relControl->dataBind(); |
| 284 | 284 | } |
| 285 | 285 | break; |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | break; |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | - catch (Exception $ex) |
|
| 291 | + catch(Exception $ex) |
|
| 292 | 292 | { |
| 293 | - if ($throwExceptions) |
|
| 293 | + if($throwExceptions) |
|
| 294 | 294 | throw $ex; |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -302,26 +302,26 @@ discard block |
||
| 302 | 302 | * @param Boolean $throwExceptions Wheter or not to throw exceptions |
| 303 | 303 | * @author Daniel Sampedro <[email protected]> |
| 304 | 304 | */ |
| 305 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
| 305 | + public function tryToUpdateAR($arObj, $throwExceptions=false) |
|
| 306 | 306 | { |
| 307 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
| 308 | - foreach (array_keys($objAttrs) as $key) |
|
| 307 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
| 308 | + foreach(array_keys($objAttrs) as $key) |
|
| 309 | 309 | { |
| 310 | 310 | try |
| 311 | 311 | { |
| 312 | - if ($key == "RELATIONS") |
|
| 312 | + if($key=="RELATIONS") |
|
| 313 | 313 | break; |
| 314 | - $control = $this->{$key}; |
|
| 315 | - if ($control instanceof TTextBox) |
|
| 316 | - $arObj->{$key} = $control->Text; |
|
| 317 | - elseif ($control instanceof TCheckBox) |
|
| 318 | - $arObj->{$key} = $control->Checked; |
|
| 319 | - elseif ($control instanceof TDatePicker) |
|
| 320 | - $arObj->{$key} = $control->Date; |
|
| 314 | + $control=$this->{$key}; |
|
| 315 | + if($control instanceof TTextBox) |
|
| 316 | + $arObj->{$key}=$control->Text; |
|
| 317 | + elseif($control instanceof TCheckBox) |
|
| 318 | + $arObj->{$key}=$control->Checked; |
|
| 319 | + elseif($control instanceof TDatePicker) |
|
| 320 | + $arObj->{$key}=$control->Date; |
|
| 321 | 321 | } |
| 322 | - catch (Exception $ex) |
|
| 322 | + catch(Exception $ex) |
|
| 323 | 323 | { |
| 324 | - if ($throwExceptions) |
|
| 324 | + if($throwExceptions) |
|
| 325 | 325 | throw $ex; |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * file containing javascript packages and their cross dependencies |
| 36 | 36 | */ |
| 37 | - const PACKAGES_FILE = 'Web/Javascripts/packages.php'; |
|
| 37 | + const PACKAGES_FILE='Web/Javascripts/packages.php'; |
|
| 38 | 38 | /** |
| 39 | 39 | * file containing css packages and their cross dependencies |
| 40 | 40 | */ |
| 41 | - const CSS_PACKAGES_FILE = 'Web/Javascripts/css-packages.php'; |
|
| 41 | + const CSS_PACKAGES_FILE='Web/Javascripts/css-packages.php'; |
|
| 42 | 42 | /** |
| 43 | 43 | * @var TPage page who owns this manager |
| 44 | 44 | */ |
@@ -46,39 +46,39 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @var array registered hidden fields, indexed by hidden field names |
| 48 | 48 | */ |
| 49 | - private $_hiddenFields = []; |
|
| 49 | + private $_hiddenFields=[]; |
|
| 50 | 50 | /** |
| 51 | 51 | * @var array javascript blocks to be rendered at the beginning of the form |
| 52 | 52 | */ |
| 53 | - private $_beginScripts = []; |
|
| 53 | + private $_beginScripts=[]; |
|
| 54 | 54 | /** |
| 55 | 55 | * @var array javascript blocks to be rendered at the end of the form |
| 56 | 56 | */ |
| 57 | - private $_endScripts = []; |
|
| 57 | + private $_endScripts=[]; |
|
| 58 | 58 | /** |
| 59 | 59 | * @var array javascript files to be rendered in the form |
| 60 | 60 | */ |
| 61 | - private $_scriptFiles = []; |
|
| 61 | + private $_scriptFiles=[]; |
|
| 62 | 62 | /** |
| 63 | 63 | * @var array javascript files to be rendered in page head section |
| 64 | 64 | */ |
| 65 | - private $_headScriptFiles = []; |
|
| 65 | + private $_headScriptFiles=[]; |
|
| 66 | 66 | /** |
| 67 | 67 | * @var array javascript blocks to be rendered in page head section |
| 68 | 68 | */ |
| 69 | - private $_headScripts = []; |
|
| 69 | + private $_headScripts=[]; |
|
| 70 | 70 | /** |
| 71 | 71 | * @var array CSS files |
| 72 | 72 | */ |
| 73 | - private $_styleSheetFiles = []; |
|
| 73 | + private $_styleSheetFiles=[]; |
|
| 74 | 74 | /** |
| 75 | 75 | * @var array CSS declarations |
| 76 | 76 | */ |
| 77 | - private $_styleSheets = []; |
|
| 77 | + private $_styleSheets=[]; |
|
| 78 | 78 | /** |
| 79 | 79 | * @var array registered PRADO script libraries |
| 80 | 80 | */ |
| 81 | - private $_registeredScripts = []; |
|
| 81 | + private $_registeredScripts=[]; |
|
| 82 | 82 | /** |
| 83 | 83 | * Client-side javascript library dependencies, loads from PACKAGES_FILE; |
| 84 | 84 | * @var array |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | /** |
| 98 | 98 | * @var array registered PRADO style libraries |
| 99 | 99 | */ |
| 100 | - private $_registeredStyles = []; |
|
| 100 | + private $_registeredStyles=[]; |
|
| 101 | 101 | /** |
| 102 | 102 | * Client-side style library dependencies, loads from CSS_PACKAGES_FILE; |
| 103 | 103 | * @var array |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | private $_renderedHiddenFields; |
| 118 | 118 | |
| 119 | - private $_renderedScriptFiles = []; |
|
| 119 | + private $_renderedScriptFiles=[]; |
|
| 120 | 120 | |
| 121 | 121 | private $_expandedScripts; |
| 122 | 122 | private $_expandedStyles; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function __construct(TPage $owner) |
| 129 | 129 | { |
| 130 | - $this->_page = $owner; |
|
| 130 | + $this->_page=$owner; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | public function registerPradoScript($name) |
| 159 | 159 | { |
| 160 | 160 | $this->registerPradoScriptInternal($name); |
| 161 | - $params = func_get_args(); |
|
| 161 | + $params=func_get_args(); |
|
| 162 | 162 | $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoScript', $params); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -170,50 +170,50 @@ discard block |
||
| 170 | 170 | // $this->checkIfNotInRender(); |
| 171 | 171 | if(!isset($this->_registeredScripts[$name])) |
| 172 | 172 | { |
| 173 | - if(self::$_scripts === null) |
|
| 173 | + if(self::$_scripts===null) |
|
| 174 | 174 | { |
| 175 | - $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::PACKAGES_FILE; |
|
| 176 | - list($folders, $packages, $deps) = include($packageFile); |
|
| 177 | - self::$_scriptsFolders = $folders; |
|
| 178 | - self::$_scripts = $deps; |
|
| 179 | - self::$_scriptsPackages = $packages; |
|
| 175 | + $packageFile=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
| 176 | + list($folders, $packages, $deps)=include($packageFile); |
|
| 177 | + self::$_scriptsFolders=$folders; |
|
| 178 | + self::$_scripts=$deps; |
|
| 179 | + self::$_scriptsPackages=$packages; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if (isset(self::$_scripts[$name])) |
|
| 183 | - $this->_registeredScripts[$name] = true; |
|
| 182 | + if(isset(self::$_scripts[$name])) |
|
| 183 | + $this->_registeredScripts[$name]=true; |
|
| 184 | 184 | else |
| 185 | 185 | throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
| 186 | 186 | |
| 187 | - if(($packages = array_keys($this->_registeredScripts)) !== []) |
|
| 187 | + if(($packages=array_keys($this->_registeredScripts))!==[]) |
|
| 188 | 188 | { |
| 189 | - $packagesUrl = []; |
|
| 190 | - $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
|
| 191 | - foreach ($packages as $p) |
|
| 189 | + $packagesUrl=[]; |
|
| 190 | + $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
| 191 | + foreach($packages as $p) |
|
| 192 | 192 | { |
| 193 | - foreach (self::$_scripts[$p] as $dep) |
|
| 193 | + foreach(self::$_scripts[$p] as $dep) |
|
| 194 | 194 | { |
| 195 | - foreach (self::$_scriptsPackages[$dep] as $script) |
|
| 195 | + foreach(self::$_scriptsPackages[$dep] as $script) |
|
| 196 | 196 | { |
| 197 | - if (!isset($this->_expandedScripts[$script])) |
|
| 197 | + if(!isset($this->_expandedScripts[$script])) |
|
| 198 | 198 | { |
| 199 | - list($base, $subPath) = $this->getScriptPackageFolder($script); |
|
| 200 | - list($path, $baseUrl) = $this->getPackagePathUrl($base); |
|
| 199 | + list($base, $subPath)=$this->getScriptPackageFolder($script); |
|
| 200 | + list($path, $baseUrl)=$this->getPackagePathUrl($base); |
|
| 201 | 201 | |
| 202 | - $this->_expandedScripts[$script] = true; |
|
| 202 | + $this->_expandedScripts[$script]=true; |
|
| 203 | 203 | if($isDebug) |
| 204 | 204 | { |
| 205 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
| 206 | - $packagesUrl[] = $url; |
|
| 205 | + if(!in_array($url=$baseUrl.'/'.$subPath, $packagesUrl)) |
|
| 206 | + $packagesUrl[]=$url; |
|
| 207 | 207 | } else { |
| 208 | - $minPath = preg_replace('/^(.*)(?<!\.min)\.js$/', "\\1.min.js", $subPath); |
|
| 209 | - if (!in_array($url = $baseUrl . '/' . $minPath, $packagesUrl)) |
|
| 208 | + $minPath=preg_replace('/^(.*)(?<!\.min)\.js$/', "\\1.min.js", $subPath); |
|
| 209 | + if(!in_array($url=$baseUrl.'/'.$minPath, $packagesUrl)) |
|
| 210 | 210 | { |
| 211 | - if(!is_file($filePath = $path . DIRECTORY_SEPARATOR . $minPath)) |
|
| 211 | + if(!is_file($filePath=$path.DIRECTORY_SEPARATOR.$minPath)) |
|
| 212 | 212 | { |
| 213 | - file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base . '/' . $subPath))); |
|
| 213 | + file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$subPath))); |
|
| 214 | 214 | chmod($filePath, PRADO_CHMOD); |
| 215 | 215 | } |
| 216 | - $packagesUrl[] = $url; |
|
| 216 | + $packagesUrl[]=$url; |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -229,26 +229,26 @@ discard block |
||
| 229 | 229 | /** |
| 230 | 230 | * @return string Prado javascript library base asset url. |
| 231 | 231 | */ |
| 232 | - public function getPradoScriptAssetUrl($script = 'prado') |
|
| 232 | + public function getPradoScriptAssetUrl($script='prado') |
|
| 233 | 233 | { |
| 234 | 234 | if(!isset(self::$_scriptsFolders[$script])) |
| 235 | 235 | $this->registerPradoScriptInternal($script); |
| 236 | 236 | |
| 237 | - $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
|
| 238 | - $assets = Prado::getApplication()->getAssetManager(); |
|
| 237 | + $base=Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
|
| 238 | + $assets=Prado::getApplication()->getAssetManager(); |
|
| 239 | 239 | return $assets->getPublishedUrl($base); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | 243 | * @return string Prado javascript library base asset path in local filesystem. |
| 244 | 244 | */ |
| 245 | - public function getPradoScriptAssetPath($script = 'prado') |
|
| 245 | + public function getPradoScriptAssetPath($script='prado') |
|
| 246 | 246 | { |
| 247 | 247 | if(!isset(self::$_scriptsFolders[$script])) |
| 248 | 248 | $this->registerPradoScriptInternal($script); |
| 249 | 249 | |
| 250 | - $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
|
| 251 | - $assets = Prado::getApplication()->getAssetManager(); |
|
| 250 | + $base=Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
|
| 251 | + $assets=Prado::getApplication()->getAssetManager(); |
|
| 252 | 252 | return $assets->getPublishedPath($base); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -258,9 +258,9 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function getScriptUrls() |
| 260 | 260 | { |
| 261 | - $scripts = array_values($this->_headScriptFiles); |
|
| 262 | - $scripts = array_merge($scripts, array_values($this->_scriptFiles)); |
|
| 263 | - $scripts = array_unique($scripts); |
|
| 261 | + $scripts=array_values($this->_headScriptFiles); |
|
| 262 | + $scripts=array_merge($scripts, array_values($this->_scriptFiles)); |
|
| 263 | + $scripts=array_unique($scripts); |
|
| 264 | 264 | |
| 265 | 265 | return $scripts; |
| 266 | 266 | } |
@@ -271,14 +271,14 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | protected function getPackagePathUrl($base) |
| 273 | 273 | { |
| 274 | - $assets = Prado::getApplication()->getAssetManager(); |
|
| 275 | - if(strpos($base, $assets->getBaseUrl()) === false) |
|
| 274 | + $assets=Prado::getApplication()->getAssetManager(); |
|
| 275 | + if(strpos($base, $assets->getBaseUrl())===false) |
|
| 276 | 276 | { |
| 277 | 277 | return [$assets->getPublishedPath($base), $assets->publishFilePath($base)]; |
| 278 | 278 | } |
| 279 | 279 | else |
| 280 | 280 | { |
| 281 | - return [$assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base]; |
|
| 281 | + return [$assets->getBasePath().str_replace($assets->getBaseUrl(), '', $base), $base]; |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
@@ -288,14 +288,14 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | protected function getScriptPackageFolder($script) |
| 290 | 290 | { |
| 291 | - list($base, $subPath) = explode("/", $script, 2); |
|
| 291 | + list($base, $subPath)=explode("/", $script, 2); |
|
| 292 | 292 | |
| 293 | 293 | if(!array_key_exists($base, self::$_scriptsFolders)) |
| 294 | 294 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
| 295 | 295 | |
| 296 | - $namespace = self::$_scriptsFolders[$base]; |
|
| 297 | - if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
| 298 | - $namespace = $dir; |
|
| 296 | + $namespace=self::$_scriptsFolders[$base]; |
|
| 297 | + if(($dir=Prado::getPathOfNameSpace($namespace))!==null) { |
|
| 298 | + $namespace=$dir; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | return [$namespace, $subPath]; |
@@ -307,14 +307,14 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | protected function getStylePackageFolder($script) |
| 309 | 309 | { |
| 310 | - list($base, $subPath) = explode("/", $script, 2); |
|
| 310 | + list($base, $subPath)=explode("/", $script, 2); |
|
| 311 | 311 | |
| 312 | 312 | if(!array_key_exists($base, self::$_stylesFolders)) |
| 313 | 313 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
| 314 | 314 | |
| 315 | - $namespace = self::$_stylesFolders[$base]; |
|
| 316 | - if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
| 317 | - $namespace = $dir; |
|
| 315 | + $namespace=self::$_stylesFolders[$base]; |
|
| 316 | + if(($dir=Prado::getPathOfNameSpace($namespace))!==null) { |
|
| 317 | + $namespace=$dir; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | return [$namespace, $subPath]; |
@@ -326,15 +326,15 @@ discard block |
||
| 326 | 326 | * @param array additional callback options |
| 327 | 327 | * @return string javascript statement that creates a new callback request. |
| 328 | 328 | */ |
| 329 | - public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options = null) |
|
| 329 | + public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null) |
|
| 330 | 330 | { |
| 331 | - $options = !is_array($options) ? [] : $options; |
|
| 332 | - $class = new \ReflectionClass($callbackHandler); |
|
| 333 | - $clientSide = $callbackHandler->getActiveControl()->getClientSide(); |
|
| 334 | - $options = array_merge($options, $clientSide->getOptions()->toArray()); |
|
| 335 | - $optionString = TJavaScript::encode($options); |
|
| 331 | + $options=!is_array($options) ? [] : $options; |
|
| 332 | + $class=new \ReflectionClass($callbackHandler); |
|
| 333 | + $clientSide=$callbackHandler->getActiveControl()->getClientSide(); |
|
| 334 | + $options=array_merge($options, $clientSide->getOptions()->toArray()); |
|
| 335 | + $optionString=TJavaScript::encode($options); |
|
| 336 | 336 | $this->registerPradoScriptInternal('ajax'); |
| 337 | - $id = $callbackHandler->getUniqueID(); |
|
| 337 | + $id=$callbackHandler->getUniqueID(); |
|
| 338 | 338 | return "new Prado.CallbackRequest('{$id}',{$optionString})"; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -345,12 +345,12 @@ discard block |
||
| 345 | 345 | */ |
| 346 | 346 | public function registerCallbackControl($class, $options) |
| 347 | 347 | { |
| 348 | - $optionString = TJavaScript::encode($options); |
|
| 349 | - $code = "new {$class}({$optionString});"; |
|
| 350 | - $this->_endScripts[sprintf('%08X', crc32($code))] = $code; |
|
| 348 | + $optionString=TJavaScript::encode($options); |
|
| 349 | + $code="new {$class}({$optionString});"; |
|
| 350 | + $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
|
| 351 | 351 | $this->registerPradoScriptInternal('ajax'); |
| 352 | 352 | |
| 353 | - $params = func_get_args(); |
|
| 353 | + $params=func_get_args(); |
|
| 354 | 354 | $this->_page->registerCachingAction('Page.ClientScript', 'registerCallbackControl', $params); |
| 355 | 355 | } |
| 356 | 356 | |
@@ -362,18 +362,18 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | public function registerPostBackControl($class, $options) |
| 364 | 364 | { |
| 365 | - if($class === null) { |
|
| 365 | + if($class===null) { |
|
| 366 | 366 | return; |
| 367 | 367 | } |
| 368 | - if(!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
| 369 | - $options['FormID'] = $form->getClientID(); |
|
| 370 | - $optionString = TJavaScript::encode($options); |
|
| 371 | - $code = "new {$class}({$optionString});"; |
|
| 368 | + if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
|
| 369 | + $options['FormID']=$form->getClientID(); |
|
| 370 | + $optionString=TJavaScript::encode($options); |
|
| 371 | + $code="new {$class}({$optionString});"; |
|
| 372 | 372 | |
| 373 | - $this->_endScripts[sprintf('%08X', crc32($code))] = $code; |
|
| 373 | + $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
|
| 374 | 374 | $this->registerPradoScriptInternal('prado'); |
| 375 | 375 | |
| 376 | - $params = func_get_args(); |
|
| 376 | + $params=func_get_args(); |
|
| 377 | 377 | $this->_page->registerCachingAction('Page.ClientScript', 'registerPostBackControl', $params); |
| 378 | 378 | } |
| 379 | 379 | |
@@ -385,22 +385,22 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | public function registerDefaultButton($panel, $button) |
| 387 | 387 | { |
| 388 | - $panelID = is_string($panel)?$panel:$panel->getUniqueID(); |
|
| 388 | + $panelID=is_string($panel) ? $panel : $panel->getUniqueID(); |
|
| 389 | 389 | |
| 390 | 390 | if(is_string($button)) |
| 391 | - $buttonID = $button; |
|
| 391 | + $buttonID=$button; |
|
| 392 | 392 | else |
| 393 | 393 | { |
| 394 | 394 | $button->setIsDefaultButton(true); |
| 395 | - $buttonID = $button->getUniqueID(); |
|
| 395 | + $buttonID=$button->getUniqueID(); |
|
| 396 | 396 | } |
| 397 | - $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
|
| 398 | - $code = "new Prado.WebUI.DefaultButton($options);"; |
|
| 397 | + $options=TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
|
| 398 | + $code="new Prado.WebUI.DefaultButton($options);"; |
|
| 399 | 399 | |
| 400 | - $this->_endScripts['prado:' . $panelID] = $code; |
|
| 400 | + $this->_endScripts['prado:'.$panelID]=$code; |
|
| 401 | 401 | $this->registerPradoScriptInternal('prado'); |
| 402 | 402 | |
| 403 | - $params = [$panelID,$buttonID]; |
|
| 403 | + $params=[$panelID, $buttonID]; |
|
| 404 | 404 | $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
| 405 | 405 | } |
| 406 | 406 | |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | protected function getDefaultButtonOptions($panelID, $buttonID) |
| 413 | 413 | { |
| 414 | - $options['ID'] = TControl::convertUniqueIdToClientId($panelID); |
|
| 415 | - $options['Panel'] = TControl::convertUniqueIdToClientId($panelID); |
|
| 416 | - $options['Target'] = TControl::convertUniqueIdToClientId($buttonID); |
|
| 417 | - $options['EventTarget'] = $buttonID; |
|
| 418 | - $options['Event'] = 'click'; |
|
| 414 | + $options['ID']=TControl::convertUniqueIdToClientId($panelID); |
|
| 415 | + $options['Panel']=TControl::convertUniqueIdToClientId($panelID); |
|
| 416 | + $options['Target']=TControl::convertUniqueIdToClientId($buttonID); |
|
| 417 | + $options['EventTarget']=$buttonID; |
|
| 418 | + $options['Event']='click'; |
|
| 419 | 419 | return $options; |
| 420 | 420 | } |
| 421 | 421 | |
@@ -427,10 +427,10 @@ discard block |
||
| 427 | 427 | { |
| 428 | 428 | $this->registerPradoScriptInternal('jquery'); |
| 429 | 429 | if($target instanceof TControl) |
| 430 | - $target = $target->getClientID(); |
|
| 431 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();'; |
|
| 430 | + $target=$target->getClientID(); |
|
| 431 | + $this->_endScripts['prado:focus']='jQuery(\'#'.$target.'\').focus();'; |
|
| 432 | 432 | |
| 433 | - $params = func_get_args(); |
|
| 433 | + $params=func_get_args(); |
|
| 434 | 434 | $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
| 435 | 435 | } |
| 436 | 436 | |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | public function registerPradoStyle($name) |
| 443 | 443 | { |
| 444 | 444 | $this->registerPradoStyleInternal($name); |
| 445 | - $params = func_get_args(); |
|
| 445 | + $params=func_get_args(); |
|
| 446 | 446 | $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoStyle', $params); |
| 447 | 447 | } |
| 448 | 448 | |
@@ -454,39 +454,39 @@ discard block |
||
| 454 | 454 | // $this->checkIfNotInRender(); |
| 455 | 455 | if(!isset($this->_registeredStyles[$name])) |
| 456 | 456 | { |
| 457 | - if(self::$_styles === null) |
|
| 457 | + if(self::$_styles===null) |
|
| 458 | 458 | { |
| 459 | - $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::CSS_PACKAGES_FILE; |
|
| 460 | - list($folders, $packages, $deps) = include($packageFile); |
|
| 461 | - self::$_stylesFolders = $folders; |
|
| 462 | - self::$_styles = $deps; |
|
| 463 | - self::$_stylesPackages = $packages; |
|
| 459 | + $packageFile=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
| 460 | + list($folders, $packages, $deps)=include($packageFile); |
|
| 461 | + self::$_stylesFolders=$folders; |
|
| 462 | + self::$_styles=$deps; |
|
| 463 | + self::$_stylesPackages=$packages; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - if (isset(self::$_styles[$name])) |
|
| 467 | - $this->_registeredStyles[$name] = true; |
|
| 466 | + if(isset(self::$_styles[$name])) |
|
| 467 | + $this->_registeredStyles[$name]=true; |
|
| 468 | 468 | else |
| 469 | 469 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
| 470 | 470 | |
| 471 | - if(($packages = array_keys($this->_registeredStyles)) !== []) |
|
| 471 | + if(($packages=array_keys($this->_registeredStyles))!==[]) |
|
| 472 | 472 | { |
| 473 | - $packagesUrl = []; |
|
| 474 | - $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
|
| 475 | - foreach ($packages as $p) |
|
| 473 | + $packagesUrl=[]; |
|
| 474 | + $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
| 475 | + foreach($packages as $p) |
|
| 476 | 476 | { |
| 477 | - foreach (self::$_styles[$p] as $dep) |
|
| 477 | + foreach(self::$_styles[$p] as $dep) |
|
| 478 | 478 | { |
| 479 | - foreach (self::$_stylesPackages[$dep] as $style) |
|
| 479 | + foreach(self::$_stylesPackages[$dep] as $style) |
|
| 480 | 480 | { |
| 481 | - if (!isset($this->_expandedStyles[$style])) |
|
| 481 | + if(!isset($this->_expandedStyles[$style])) |
|
| 482 | 482 | { |
| 483 | - list($base, $subPath) = $this->getStylePackageFolder($style); |
|
| 484 | - list($path, $baseUrl) = $this->getPackagePathUrl($base); |
|
| 483 | + list($base, $subPath)=$this->getStylePackageFolder($style); |
|
| 484 | + list($path, $baseUrl)=$this->getPackagePathUrl($base); |
|
| 485 | 485 | |
| 486 | - $this->_expandedStyles[$style] = true; |
|
| 486 | + $this->_expandedStyles[$style]=true; |
|
| 487 | 487 | // TODO minify css? |
| 488 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
| 489 | - $packagesUrl[] = $url; |
|
| 488 | + if(!in_array($url=$baseUrl.'/'.$subPath, $packagesUrl)) |
|
| 489 | + $packagesUrl[]=$url; |
|
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | } |
@@ -519,14 +519,14 @@ discard block |
||
| 519 | 519 | * @param string URL to the CSS file |
| 520 | 520 | * @param string media type of the CSS (such as 'print', 'screen', etc.). Defaults to empty, meaning the CSS applies to all media types. |
| 521 | 521 | */ |
| 522 | - public function registerStyleSheetFile($key, $url, $media = '') |
|
| 522 | + public function registerStyleSheetFile($key, $url, $media='') |
|
| 523 | 523 | { |
| 524 | - if($media === '') |
|
| 525 | - $this->_styleSheetFiles[$key] = $url; |
|
| 524 | + if($media==='') |
|
| 525 | + $this->_styleSheetFiles[$key]=$url; |
|
| 526 | 526 | else |
| 527 | - $this->_styleSheetFiles[$key] = [$url,$media]; |
|
| 527 | + $this->_styleSheetFiles[$key]=[$url, $media]; |
|
| 528 | 528 | |
| 529 | - $params = func_get_args(); |
|
| 529 | + $params=func_get_args(); |
|
| 530 | 530 | $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
| 531 | 531 | } |
| 532 | 532 | |
@@ -535,11 +535,11 @@ discard block |
||
| 535 | 535 | * @param string a unique key identifying the CSS block |
| 536 | 536 | * @param string CSS block |
| 537 | 537 | */ |
| 538 | - public function registerStyleSheet($key, $css, $media = '') |
|
| 538 | + public function registerStyleSheet($key, $css, $media='') |
|
| 539 | 539 | { |
| 540 | - $this->_styleSheets[$key] = $css; |
|
| 540 | + $this->_styleSheets[$key]=$css; |
|
| 541 | 541 | |
| 542 | - $params = func_get_args(); |
|
| 542 | + $params=func_get_args(); |
|
| 543 | 543 | $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheet', $params); |
| 544 | 544 | } |
| 545 | 545 | |
@@ -549,17 +549,17 @@ discard block |
||
| 549 | 549 | */ |
| 550 | 550 | public function getStyleSheetUrls() |
| 551 | 551 | { |
| 552 | - $stylesheets = array_values( |
|
| 552 | + $stylesheets=array_values( |
|
| 553 | 553 | array_map(function($e) { |
| 554 | 554 | return is_array($e) ? $e[0] : $e; |
| 555 | 555 | }, $this->_styleSheetFiles) |
| 556 | 556 | ); |
| 557 | 557 | |
| 558 | 558 | foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) |
| 559 | - if (substr($url, strlen($url) - 4) == '.css') |
|
| 560 | - $stylesheets[] = $url; |
|
| 559 | + if(substr($url, strlen($url) - 4)=='.css') |
|
| 560 | + $stylesheets[]=$url; |
|
| 561 | 561 | |
| 562 | - $stylesheets = array_unique($stylesheets); |
|
| 562 | + $stylesheets=array_unique($stylesheets); |
|
| 563 | 563 | |
| 564 | 564 | return $stylesheets; |
| 565 | 565 | } |
@@ -581,9 +581,9 @@ discard block |
||
| 581 | 581 | public function registerHeadScriptFile($key, $url) |
| 582 | 582 | { |
| 583 | 583 | $this->checkIfNotInRender(); |
| 584 | - $this->_headScriptFiles[$key] = $url; |
|
| 584 | + $this->_headScriptFiles[$key]=$url; |
|
| 585 | 585 | |
| 586 | - $params = func_get_args(); |
|
| 586 | + $params=func_get_args(); |
|
| 587 | 587 | $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScriptFile', $params); |
| 588 | 588 | } |
| 589 | 589 | |
@@ -595,9 +595,9 @@ discard block |
||
| 595 | 595 | public function registerHeadScript($key, $script) |
| 596 | 596 | { |
| 597 | 597 | $this->checkIfNotInRender(); |
| 598 | - $this->_headScripts[$key] = $script; |
|
| 598 | + $this->_headScripts[$key]=$script; |
|
| 599 | 599 | |
| 600 | - $params = func_get_args(); |
|
| 600 | + $params=func_get_args(); |
|
| 601 | 601 | $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScript', $params); |
| 602 | 602 | } |
| 603 | 603 | |
@@ -608,9 +608,9 @@ discard block |
||
| 608 | 608 | */ |
| 609 | 609 | public function registerScriptFile($key, $url) |
| 610 | 610 | { |
| 611 | - $this->_scriptFiles[$key] = $url; |
|
| 611 | + $this->_scriptFiles[$key]=$url; |
|
| 612 | 612 | |
| 613 | - $params = func_get_args(); |
|
| 613 | + $params=func_get_args(); |
|
| 614 | 614 | $this->_page->registerCachingAction('Page.ClientScript', 'registerScriptFile', $params); |
| 615 | 615 | } |
| 616 | 616 | |
@@ -622,9 +622,9 @@ discard block |
||
| 622 | 622 | public function registerBeginScript($key, $script) |
| 623 | 623 | { |
| 624 | 624 | $this->checkIfNotInRender(); |
| 625 | - $this->_beginScripts[$key] = $script; |
|
| 625 | + $this->_beginScripts[$key]=$script; |
|
| 626 | 626 | |
| 627 | - $params = func_get_args(); |
|
| 627 | + $params=func_get_args(); |
|
| 628 | 628 | $this->_page->registerCachingAction('Page.ClientScript', 'registerBeginScript', $params); |
| 629 | 629 | } |
| 630 | 630 | |
@@ -635,9 +635,9 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | public function registerEndScript($key, $script) |
| 637 | 637 | { |
| 638 | - $this->_endScripts[$key] = $script; |
|
| 638 | + $this->_endScripts[$key]=$script; |
|
| 639 | 639 | |
| 640 | - $params = func_get_args(); |
|
| 640 | + $params=func_get_args(); |
|
| 641 | 641 | $this->_page->registerCachingAction('Page.ClientScript', 'registerEndScript', $params); |
| 642 | 642 | } |
| 643 | 643 | |
@@ -649,9 +649,9 @@ discard block |
||
| 649 | 649 | */ |
| 650 | 650 | public function registerHiddenField($name, $value) |
| 651 | 651 | { |
| 652 | - $this->_hiddenFields[$name] = $value; |
|
| 652 | + $this->_hiddenFields[$name]=$value; |
|
| 653 | 653 | |
| 654 | - $params = func_get_args(); |
|
| 654 | + $params=func_get_args(); |
|
| 655 | 655 | $this->_page->registerCachingAction('Page.ClientScript', 'registerHiddenField', $params); |
| 656 | 656 | } |
| 657 | 657 | |
@@ -748,13 +748,13 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | public function renderStyleSheetFiles($writer) |
| 750 | 750 | { |
| 751 | - $str = ''; |
|
| 751 | + $str=''; |
|
| 752 | 752 | foreach($this->_styleSheetFiles as $url) |
| 753 | 753 | { |
| 754 | 754 | if(is_array($url)) |
| 755 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
| 755 | + $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
| 756 | 756 | else |
| 757 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
| 757 | + $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
| 758 | 758 | } |
| 759 | 759 | $writer->write($str); |
| 760 | 760 | } |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | public function renderStyleSheets($writer) |
| 766 | 766 | { |
| 767 | 767 | if(count($this->_styleSheets)) |
| 768 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
| 768 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n", $this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -796,8 +796,8 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | public function markScriptFileAsRendered($url) |
| 798 | 798 | { |
| 799 | - $this->_renderedScriptFiles[$url] = $url; |
|
| 800 | - $params = func_get_args(); |
|
| 799 | + $this->_renderedScriptFiles[$url]=$url; |
|
| 800 | + $params=func_get_args(); |
|
| 801 | 801 | $this->_page->registerCachingAction('Page.ClientScript', 'markScriptFileAsRendered', $params); |
| 802 | 802 | } |
| 803 | 803 | |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | { |
| 823 | 823 | if(!empty($this->_scriptFiles)) |
| 824 | 824 | { |
| 825 | - $addedScripts = array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
|
| 825 | + $addedScripts=array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
|
| 826 | 826 | $this->renderScriptFiles($writer, $addedScripts); |
| 827 | 827 | } |
| 828 | 828 | } |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | * @param THtmlWriter writer for the rendering purpose |
| 875 | 875 | * @param TControl the control forcing the flush (used only in error messages) |
| 876 | 876 | */ |
| 877 | - public function flushScriptFiles($writer, $control = null) |
|
| 877 | + public function flushScriptFiles($writer, $control=null) |
|
| 878 | 878 | { |
| 879 | 879 | if(!$this->_page->getIsCallback()) |
| 880 | 880 | { |
@@ -893,25 +893,25 @@ discard block |
||
| 893 | 893 | |
| 894 | 894 | protected function renderHiddenFieldsInt($writer, $initial) |
| 895 | 895 | { |
| 896 | - if ($initial) $this->_renderedHiddenFields = []; |
|
| 897 | - $str = ''; |
|
| 896 | + if($initial) $this->_renderedHiddenFields=[]; |
|
| 897 | + $str=''; |
|
| 898 | 898 | foreach($this->_hiddenFields as $name => $value) |
| 899 | 899 | { |
| 900 | - if (in_array($name, $this->_renderedHiddenFields)) continue; |
|
| 901 | - $id = strtr($name, ':', '_'); |
|
| 900 | + if(in_array($name, $this->_renderedHiddenFields)) continue; |
|
| 901 | + $id=strtr($name, ':', '_'); |
|
| 902 | 902 | if(is_array($value)) |
| 903 | 903 | { |
| 904 | 904 | foreach($value as $v) |
| 905 | - $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
| 905 | + $str.='<input type="text" style="display:none" autocomplete="off" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 906 | 906 | } |
| 907 | 907 | else |
| 908 | 908 | { |
| 909 | - $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
| 909 | + $str.='<input type="text" style="display:none" autocomplete="off" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 910 | 910 | } |
| 911 | - $this->_renderedHiddenFields[] = $name; |
|
| 911 | + $this->_renderedHiddenFields[]=$name; |
|
| 912 | 912 | } |
| 913 | - if($str !== '') |
|
| 914 | - $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
| 913 | + if($str!=='') |
|
| 914 | + $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | public function getHiddenFields() |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | */ |
| 925 | 925 | protected function checkIfNotInRender() |
| 926 | 926 | { |
| 927 | - if ($form = $this->_page->InFormRender) |
|
| 927 | + if($form=$this->_page->InFormRender) |
|
| 928 | 928 | throw new \Exception('Operation invalid when page is already rendering'); |
| 929 | 929 | } |
| 930 | 930 | } |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * Template file extension |
| 41 | 41 | */ |
| 42 | - const TEMPLATE_FILE_EXT = '.tpl'; |
|
| 42 | + const TEMPLATE_FILE_EXT='.tpl'; |
|
| 43 | 43 | /** |
| 44 | 44 | * Prefix of the cache variable name for storing parsed templates |
| 45 | 45 | */ |
| 46 | - const TEMPLATE_CACHE_PREFIX = 'prado:template:'; |
|
| 46 | + const TEMPLATE_CACHE_PREFIX='prado:template:'; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Initializes the module. |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getTemplateByClassName($className) |
| 64 | 64 | { |
| 65 | - $class = new \ReflectionClass($className); |
|
| 66 | - $tplFile = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $class->getShortName() . self::TEMPLATE_FILE_EXT; |
|
| 65 | + $class=new \ReflectionClass($className); |
|
| 66 | + $tplFile=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$class->getShortName().self::TEMPLATE_FILE_EXT; |
|
| 67 | 67 | return $this->getTemplateByFileName($tplFile); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -73,38 +73,38 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function getTemplateByFileName($fileName) |
| 75 | 75 | { |
| 76 | - if(($fileName = $this->getLocalizedTemplate($fileName)) !== null) |
|
| 76 | + if(($fileName=$this->getLocalizedTemplate($fileName))!==null) |
|
| 77 | 77 | { |
| 78 | 78 | Prado::trace("Loading template $fileName", '\Prado\Web\UI\TTemplateManager'); |
| 79 | - if(($cache = $this->getApplication()->getCache()) === null) |
|
| 79 | + if(($cache=$this->getApplication()->getCache())===null) |
|
| 80 | 80 | return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
| 81 | 81 | else |
| 82 | 82 | { |
| 83 | - $array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName); |
|
| 83 | + $array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName); |
|
| 84 | 84 | if(is_array($array)) |
| 85 | 85 | { |
| 86 | - list($template, $timestamps) = $array; |
|
| 87 | - if($this->getApplication()->getMode() === TApplicationMode::Performance) |
|
| 86 | + list($template, $timestamps)=$array; |
|
| 87 | + if($this->getApplication()->getMode()===TApplicationMode::Performance) |
|
| 88 | 88 | return $template; |
| 89 | - $cacheValid = true; |
|
| 89 | + $cacheValid=true; |
|
| 90 | 90 | foreach($timestamps as $tplFile => $timestamp) |
| 91 | 91 | { |
| 92 | 92 | if(!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
| 93 | 93 | { |
| 94 | - $cacheValid = false; |
|
| 94 | + $cacheValid=false; |
|
| 95 | 95 | break; |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | if($cacheValid) |
| 99 | 99 | return $template; |
| 100 | 100 | } |
| 101 | - $template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
| 102 | - $includedFiles = $template->getIncludedFiles(); |
|
| 103 | - $timestamps = []; |
|
| 104 | - $timestamps[$fileName] = filemtime($fileName); |
|
| 101 | + $template=new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
| 102 | + $includedFiles=$template->getIncludedFiles(); |
|
| 103 | + $timestamps=[]; |
|
| 104 | + $timestamps[$fileName]=filemtime($fileName); |
|
| 105 | 105 | foreach($includedFiles as $includedFile) |
| 106 | - $timestamps[$includedFile] = filemtime($includedFile); |
|
| 107 | - $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, [$template,$timestamps]); |
|
| 106 | + $timestamps[$includedFile]=filemtime($includedFile); |
|
| 107 | + $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName, [$template, $timestamps]); |
|
| 108 | 108 | return $template; |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | protected function getLocalizedTemplate($filename) |
| 121 | 121 | { |
| 122 | - if(($app = $this->getApplication()->getGlobalization(false)) === null) |
|
| 123 | - return is_file($filename)?$filename:null; |
|
| 122 | + if(($app=$this->getApplication()->getGlobalization(false))===null) |
|
| 123 | + return is_file($filename) ? $filename : null; |
|
| 124 | 124 | foreach($app->getLocalizedResource($filename) as $file) |
| 125 | 125 | { |
| 126 | - if(($file = realpath($file)) !== false && is_file($file)) |
|
| 126 | + if(($file=realpath($file))!==false && is_file($file)) |
|
| 127 | 127 | return $file; |
| 128 | 128 | } |
| 129 | 129 | return null; |