@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | if(!defined('PRADO_DIR')) |
15 | - define('PRADO_DIR',dirname(__FILE__)); |
|
15 | + define('PRADO_DIR', dirname(__FILE__)); |
|
16 | 16 | if(!defined('PRADO_CHMOD')) |
17 | - define('PRADO_CHMOD',0777); |
|
17 | + define('PRADO_CHMOD', 0777); |
|
18 | 18 | class PradoBase |
19 | 19 | { |
20 | 20 | const CLASS_FILE_EXT='.php'; |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | private static $_usings=array(); |
23 | 23 | private static $_application=null; |
24 | 24 | private static $_logger=null; |
25 | - protected static $classExists = array(); |
|
25 | + protected static $classExists=array(); |
|
26 | 26 | public static function getVersion() |
27 | 27 | { |
28 | 28 | return '3.3.2'; |
29 | 29 | } |
30 | 30 | public static function initErrorHandlers() |
31 | 31 | { |
32 | - set_error_handler(array('PradoBase','phpErrorHandler')); |
|
33 | - register_shutdown_function(array('PradoBase','phpFatalErrorHandler')); |
|
34 | - set_exception_handler(array('PradoBase','exceptionHandler')); |
|
32 | + set_error_handler(array('PradoBase', 'phpErrorHandler')); |
|
33 | + register_shutdown_function(array('PradoBase', 'phpFatalErrorHandler')); |
|
34 | + set_exception_handler(array('PradoBase', 'exceptionHandler')); |
|
35 | 35 | ini_set('display_errors', 0); |
36 | 36 | } |
37 | 37 | public static function autoload($className) |
@@ -40,36 +40,36 @@ discard block |
||
40 | 40 | } |
41 | 41 | public static function poweredByPrado($logoType=0) |
42 | 42 | { |
43 | - $logoName=$logoType==1?'powered2':'powered'; |
|
43 | + $logoName=$logoType==1 ? 'powered2' : 'powered'; |
|
44 | 44 | if(self::$_application!==null) |
45 | 45 | { |
46 | 46 | $am=self::$_application->getAssetManager(); |
47 | - $url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif')); |
|
47 | + $url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName, '.gif')); |
|
48 | 48 | } |
49 | 49 | else |
50 | 50 | $url='http://pradosoft.github.io/docs/'.$logoName.'.gif'; |
51 | 51 | return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>'; |
52 | 52 | } |
53 | - public static function phpErrorHandler($errno,$errstr,$errfile,$errline) |
|
53 | + public static function phpErrorHandler($errno, $errstr, $errfile, $errline) |
|
54 | 54 | { |
55 | 55 | if(error_reporting() & $errno) |
56 | - throw new TPhpErrorException($errno,$errstr,$errfile,$errline); |
|
56 | + throw new TPhpErrorException($errno, $errstr, $errfile, $errline); |
|
57 | 57 | } |
58 | 58 | public static function phpFatalErrorHandler() |
59 | 59 | { |
60 | - $error = error_get_last(); |
|
60 | + $error=error_get_last(); |
|
61 | 61 | if($error && |
62 | 62 | TPhpErrorException::isFatalError($error) && |
63 | 63 | error_reporting() & $error['type']) |
64 | 64 | { |
65 | - self::exceptionHandler(new TPhpErrorException($error['type'],$error['message'],$error['file'],$error['line'])); |
|
65 | + self::exceptionHandler(new TPhpErrorException($error['type'], $error['message'], $error['file'], $error['line'])); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | public static function exceptionHandler($exception) |
69 | 69 | { |
70 | 70 | if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null) |
71 | 71 | { |
72 | - $errorHandler->handleError(null,$exception); |
|
72 | + $errorHandler->handleError(null, $exception); |
|
73 | 73 | } |
74 | 74 | else |
75 | 75 | { |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | public static function createComponent($type) |
95 | 95 | { |
96 | 96 | if(!isset(self::$classExists[$type])) |
97 | - self::$classExists[$type] = class_exists($type, false); |
|
98 | - if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
97 | + self::$classExists[$type]=class_exists($type, false); |
|
98 | + if(!isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
99 | 99 | self::using($type); |
100 | - self::$classExists[$type] = class_exists($type, false); |
|
100 | + self::$classExists[$type]=class_exists($type, false); |
|
101 | 101 | } |
102 | - if( ($pos = strrpos($type, '.')) !== false) |
|
103 | - $type = substr($type,$pos+1); |
|
104 | - if(($n=func_num_args())>1) |
|
102 | + if(($pos=strrpos($type, '.'))!==false) |
|
103 | + $type=substr($type, $pos + 1); |
|
104 | + if(($n=func_num_args()) > 1) |
|
105 | 105 | { |
106 | - $args = func_get_args(); |
|
106 | + $args=func_get_args(); |
|
107 | 107 | switch($n) { |
108 | 108 | case 2: |
109 | 109 | return new $type($args[1]); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | break; |
120 | 120 | default: |
121 | 121 | $s='$args[1]'; |
122 | - for($i=2;$i<$n;++$i) |
|
122 | + for($i=2; $i < $n; ++$i) |
|
123 | 123 | $s.=",\$args[$i]"; |
124 | 124 | eval("\$component=new $type($s);"); |
125 | 125 | return $component; |
@@ -129,33 +129,33 @@ discard block |
||
129 | 129 | else |
130 | 130 | return new $type; |
131 | 131 | } |
132 | - public static function using($namespace,$checkClassExistence=true) |
|
132 | + public static function using($namespace, $checkClassExistence=true) |
|
133 | 133 | { |
134 | - if(isset(self::$_usings[$namespace]) || class_exists($namespace,false)) |
|
134 | + if(isset(self::$_usings[$namespace]) || class_exists($namespace, false)) |
|
135 | 135 | return; |
136 | - if(($pos=strrpos($namespace,'.'))===false) { |
|
136 | + if(($pos=strrpos($namespace, '.'))===false) { |
|
137 | 137 | try |
138 | 138 | { |
139 | 139 | include_once($namespace.self::CLASS_FILE_EXT); |
140 | 140 | } |
141 | 141 | catch(Exception $e) |
142 | 142 | { |
143 | - if($checkClassExistence && !class_exists($namespace,false)) |
|
144 | - throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage()); |
|
143 | + if($checkClassExistence && !class_exists($namespace, false)) |
|
144 | + throw new TInvalidOperationException('prado_component_unknown', $namespace, $e->getMessage()); |
|
145 | 145 | else |
146 | 146 | throw $e; |
147 | 147 | } |
148 | 148 | } |
149 | - else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null) |
|
149 | + else if(($path=self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT))!==null) |
|
150 | 150 | { |
151 | - $className=substr($namespace,$pos+1); |
|
152 | - if($className==='*') { |
|
151 | + $className=substr($namespace, $pos + 1); |
|
152 | + if($className==='*') { |
|
153 | 153 | self::$_usings[$namespace]=$path; |
154 | 154 | set_include_path(get_include_path().PATH_SEPARATOR.$path); |
155 | 155 | } |
156 | - else { |
|
156 | + else { |
|
157 | 157 | self::$_usings[$namespace]=$path; |
158 | - if(!$checkClassExistence || !class_exists($className,false)) |
|
158 | + if(!$checkClassExistence || !class_exists($className, false)) |
|
159 | 159 | { |
160 | 160 | try |
161 | 161 | { |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | } |
164 | 164 | catch(Exception $e) |
165 | 165 | { |
166 | - if($checkClassExistence && !class_exists($className,false)) |
|
167 | - throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage()); |
|
166 | + if($checkClassExistence && !class_exists($className, false)) |
|
167 | + throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage()); |
|
168 | 168 | else |
169 | 169 | throw $e; |
170 | 170 | } |
@@ -172,44 +172,44 @@ discard block |
||
172 | 172 | } |
173 | 173 | } |
174 | 174 | else |
175 | - throw new TInvalidDataValueException('prado_using_invalid',$namespace); |
|
175 | + throw new TInvalidDataValueException('prado_using_invalid', $namespace); |
|
176 | 176 | } |
177 | 177 | public static function getPathOfNamespace($namespace, $ext='') |
178 | 178 | { |
179 | - if(self::CLASS_FILE_EXT === $ext || empty($ext)) |
|
179 | + if(self::CLASS_FILE_EXT===$ext || empty($ext)) |
|
180 | 180 | { |
181 | 181 | if(isset(self::$_usings[$namespace])) |
182 | 182 | return self::$_usings[$namespace]; |
183 | 183 | if(isset(self::$_aliases[$namespace])) |
184 | 184 | return self::$_aliases[$namespace]; |
185 | 185 | } |
186 | - $segs = explode('.',$namespace); |
|
187 | - $alias = array_shift($segs); |
|
188 | - if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) |
|
189 | - return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext); |
|
186 | + $segs=explode('.', $namespace); |
|
187 | + $alias=array_shift($segs); |
|
188 | + if(null!==($file=array_pop($segs)) && null!==($root=self::getPathOfAlias($alias))) |
|
189 | + return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $segs), '/\\').(($file==='*') ? '' : DIRECTORY_SEPARATOR.$file.$ext); |
|
190 | 190 | return null; |
191 | 191 | } |
192 | 192 | public static function getPathOfAlias($alias) |
193 | 193 | { |
194 | - return isset(self::$_aliases[$alias])?self::$_aliases[$alias]:null; |
|
194 | + return isset(self::$_aliases[$alias]) ? self::$_aliases[$alias] : null; |
|
195 | 195 | } |
196 | 196 | protected static function getPathAliases() |
197 | 197 | { |
198 | 198 | return self::$_aliases; |
199 | 199 | } |
200 | - public static function setPathOfAlias($alias,$path) |
|
200 | + public static function setPathOfAlias($alias, $path) |
|
201 | 201 | { |
202 | 202 | if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) |
203 | - throw new TInvalidOperationException('prado_alias_redefined',$alias); |
|
203 | + throw new TInvalidOperationException('prado_alias_redefined', $alias); |
|
204 | 204 | else if(($rp=realpath($path))!==false && is_dir($rp)) |
205 | 205 | { |
206 | - if(strpos($alias,'.')===false) |
|
206 | + if(strpos($alias, '.')===false) |
|
207 | 207 | self::$_aliases[$alias]=$rp; |
208 | 208 | else |
209 | - throw new TInvalidDataValueException('prado_aliasname_invalid',$alias); |
|
209 | + throw new TInvalidDataValueException('prado_aliasname_invalid', $alias); |
|
210 | 210 | } |
211 | 211 | else |
212 | - throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path); |
|
212 | + throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path); |
|
213 | 213 | } |
214 | 214 | public static function fatalError($msg) |
215 | 215 | { |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | if($index==0) continue; |
227 | 227 | echo '#'.$index.' '; |
228 | 228 | if(isset($t['file'])) |
229 | - echo basename($t['file']) . ':' . $t['line']; |
|
229 | + echo basename($t['file']).':'.$t['line']; |
|
230 | 230 | else |
231 | 231 | echo '<PHP inner-code>'; |
232 | 232 | echo ' -- '; |
233 | 233 | if(isset($t['class'])) |
234 | - echo $t['class'] . $t['type']; |
|
235 | - echo $t['function'] . '('; |
|
234 | + echo $t['class'].$t['type']; |
|
235 | + echo $t['function'].'('; |
|
236 | 236 | if(isset($t['args']) && sizeof($t['args']) > 0) |
237 | 237 | { |
238 | 238 | $count=0; |
@@ -241,25 +241,25 @@ discard block |
||
241 | 241 | if(is_string($item)) |
242 | 242 | { |
243 | 243 | $str=htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES); |
244 | - if (strlen($item) > 70) |
|
245 | - echo "'". substr($str, 0, 70) . "...'"; |
|
244 | + if(strlen($item) > 70) |
|
245 | + echo "'".substr($str, 0, 70)."...'"; |
|
246 | 246 | else |
247 | - echo "'" . $str . "'"; |
|
247 | + echo "'".$str."'"; |
|
248 | 248 | } |
249 | - else if (is_int($item) || is_float($item)) |
|
249 | + else if(is_int($item) || is_float($item)) |
|
250 | 250 | echo $item; |
251 | - else if (is_object($item)) |
|
251 | + else if(is_object($item)) |
|
252 | 252 | echo get_class($item); |
253 | - else if (is_array($item)) |
|
254 | - echo 'array(' . count($item) . ')'; |
|
255 | - else if (is_bool($item)) |
|
253 | + else if(is_array($item)) |
|
254 | + echo 'array('.count($item).')'; |
|
255 | + else if(is_bool($item)) |
|
256 | 256 | echo $item ? 'true' : 'false'; |
257 | - else if ($item === null) |
|
257 | + else if($item===null) |
|
258 | 258 | echo 'NULL'; |
259 | - else if (is_resource($item)) |
|
259 | + else if(is_resource($item)) |
|
260 | 260 | echo get_resource_type($item); |
261 | 261 | $count++; |
262 | - if (count($t['args']) > $count) |
|
262 | + if(count($t['args']) > $count) |
|
263 | 263 | echo ', '; |
264 | 264 | } |
265 | 265 | } |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | else |
279 | 279 | { |
280 | 280 | $languages=array(); |
281 | - foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
281 | + foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
282 | 282 | { |
283 | - $array=explode(';q=',trim($language)); |
|
284 | - $languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0; |
|
283 | + $array=explode(';q=', trim($language)); |
|
284 | + $languages[trim($array[0])]=isset($array[1]) ? (float) $array[1] : 1.0; |
|
285 | 285 | } |
286 | 286 | arsort($languages); |
287 | 287 | $languages=array_keys($languages); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | if($language===null) |
298 | 298 | { |
299 | 299 | $langs=Prado::getUserLanguages(); |
300 | - $lang=explode('-',$langs[0]); |
|
300 | + $lang=explode('-', $langs[0]); |
|
301 | 301 | if(empty($lang[0]) || !ctype_alpha($lang[0])) |
302 | 302 | $language='en'; |
303 | 303 | else |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | } |
306 | 306 | return $language; |
307 | 307 | } |
308 | - public static function trace($msg,$category='Uncategorized',$ctl=null) |
|
308 | + public static function trace($msg, $category='Uncategorized', $ctl=null) |
|
309 | 309 | { |
310 | 310 | if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance) |
311 | 311 | return; |
@@ -318,13 +318,13 @@ discard block |
||
318 | 318 | } |
319 | 319 | else |
320 | 320 | $level=TLogger::INFO; |
321 | - self::log($msg,$level,$category,$ctl); |
|
321 | + self::log($msg, $level, $category, $ctl); |
|
322 | 322 | } |
323 | - public static function log($msg,$level=TLogger::INFO,$category='Uncategorized',$ctl=null) |
|
323 | + public static function log($msg, $level=TLogger::INFO, $category='Uncategorized', $ctl=null) |
|
324 | 324 | { |
325 | 325 | if(self::$_logger===null) |
326 | 326 | self::$_logger=new TLogger; |
327 | - self::$_logger->log($msg,$level,$category,$ctl); |
|
327 | + self::$_logger->log($msg, $level, $category, $ctl); |
|
328 | 328 | } |
329 | 329 | public static function getLogger() |
330 | 330 | { |
@@ -332,40 +332,40 @@ discard block |
||
332 | 332 | self::$_logger=new TLogger; |
333 | 333 | return self::$_logger; |
334 | 334 | } |
335 | - public static function varDump($var,$depth=10,$highlight=false) |
|
335 | + public static function varDump($var, $depth=10, $highlight=false) |
|
336 | 336 | { |
337 | 337 | Prado::using('System.Util.TVarDumper'); |
338 | - return TVarDumper::dump($var,$depth,$highlight); |
|
338 | + return TVarDumper::dump($var, $depth, $highlight); |
|
339 | 339 | } |
340 | 340 | public static function localize($text, $parameters=array(), $catalogue=null, $charset=null) |
341 | 341 | { |
342 | 342 | Prado::using('System.I18N.Translation'); |
343 | - $app = Prado::getApplication()->getGlobalization(false); |
|
344 | - $params = array(); |
|
343 | + $app=Prado::getApplication()->getGlobalization(false); |
|
344 | + $params=array(); |
|
345 | 345 | foreach($parameters as $key => $value) |
346 | - $params['{'.$key.'}'] = $value; |
|
347 | - if($app===null || ($config = $app->getTranslationConfiguration())===null) |
|
346 | + $params['{'.$key.'}']=$value; |
|
347 | + if($app===null || ($config=$app->getTranslationConfiguration())===null) |
|
348 | 348 | return strtr($text, $params); |
349 | - if ($catalogue===null) |
|
350 | - $catalogue=isset($config['catalogue'])?$config['catalogue']:'messages'; |
|
349 | + if($catalogue===null) |
|
350 | + $catalogue=isset($config['catalogue']) ? $config['catalogue'] : 'messages'; |
|
351 | 351 | Translation::init($catalogue); |
352 | - $appCharset = $app===null ? '' : $app->getCharset(); |
|
353 | - $defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
354 | - if(empty($charset)) $charset = $appCharset; |
|
355 | - if(empty($charset)) $charset = $defaultCharset; |
|
356 | - return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset); |
|
352 | + $appCharset=$app===null ? '' : $app->getCharset(); |
|
353 | + $defaultCharset=($app===null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
354 | + if(empty($charset)) $charset=$appCharset; |
|
355 | + if(empty($charset)) $charset=$defaultCharset; |
|
356 | + return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | PradoBase::using('System.TComponent'); |
360 | 360 | PradoBase::using('System.Exceptions.TException'); |
361 | 361 | PradoBase::using('System.Util.TLogger'); |
362 | -if(!class_exists('Prado',false)) |
|
362 | +if(!class_exists('Prado', false)) |
|
363 | 363 | { |
364 | 364 | class Prado extends PradoBase |
365 | 365 | { |
366 | 366 | } |
367 | 367 | } |
368 | -spl_autoload_register(array('Prado','autoload')); |
|
368 | +spl_autoload_register(array('Prado', 'autoload')); |
|
369 | 369 | Prado::initErrorHandlers(); |
370 | 370 | interface IModule |
371 | 371 | { |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | interface ICache |
408 | 408 | { |
409 | 409 | public function get($id); |
410 | - public function set($id,$value,$expire=0,$dependency=null); |
|
411 | - public function add($id,$value,$expire=0,$dependency=null); |
|
410 | + public function set($id, $value, $expire=0, $dependency=null); |
|
411 | + public function add($id, $value, $expire=0, $dependency=null); |
|
412 | 412 | public function delete($id); |
413 | 413 | public function flush(); |
414 | 414 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | { |
470 | 470 | return Prado::getApplication()->getUser(); |
471 | 471 | } |
472 | - public function publishAsset($assetPath,$className=null) |
|
472 | + public function publishAsset($assetPath, $className=null) |
|
473 | 473 | { |
474 | 474 | if($className===null) |
475 | 475 | $className=get_class($this); |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath)) |
546 | 546 | $this->_templatePath=$templatePath; |
547 | 547 | else |
548 | - throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value); |
|
548 | + throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value); |
|
549 | 549 | } |
550 | - public function handleError($sender,$param) |
|
550 | + public function handleError($sender, $param) |
|
551 | 551 | { |
552 | 552 | static $handling=false; |
553 | 553 | restore_error_handler(); |
@@ -562,56 +562,56 @@ discard block |
||
562 | 562 | if(!headers_sent()) |
563 | 563 | header('Content-Type: text/html; charset=UTF-8'); |
564 | 564 | if($param instanceof THttpException) |
565 | - $this->handleExternalError($param->getStatusCode(),$param); |
|
565 | + $this->handleExternalError($param->getStatusCode(), $param); |
|
566 | 566 | else if($this->getApplication()->getMode()===TApplicationMode::Debug) |
567 | 567 | $this->displayException($param); |
568 | 568 | else |
569 | - $this->handleExternalError(500,$param); |
|
569 | + $this->handleExternalError(500, $param); |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | protected static function hideSecurityRelated($value, $exception=null) |
573 | 573 | { |
574 | - $aRpl = array(); |
|
575 | - if($exception !== null && $exception instanceof Exception) |
|
574 | + $aRpl=array(); |
|
575 | + if($exception!==null && $exception instanceof Exception) |
|
576 | 576 | { |
577 | - $aTrace = $exception->getTrace(); |
|
577 | + $aTrace=$exception->getTrace(); |
|
578 | 578 | foreach($aTrace as $item) |
579 | 579 | { |
580 | 580 | if(isset($item['file'])) |
581 | - $aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR; |
|
581 | + $aRpl[dirname($item['file']).DIRECTORY_SEPARATOR]='<hidden>'.DIRECTORY_SEPARATOR; |
|
582 | 582 | } |
583 | 583 | } |
584 | - $aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}'; |
|
585 | - $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}'; |
|
586 | - $aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR; |
|
584 | + $aRpl[$_SERVER['DOCUMENT_ROOT']]='${DocumentRoot}'; |
|
585 | + $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])]='${DocumentRoot}'; |
|
586 | + $aRpl[PRADO_DIR.DIRECTORY_SEPARATOR]='${PradoFramework}'.DIRECTORY_SEPARATOR; |
|
587 | 587 | if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
588 | - $aRpl = array_reverse($aRpl, true); |
|
588 | + $aRpl=array_reverse($aRpl, true); |
|
589 | 589 | return str_replace(array_keys($aRpl), $aRpl, $value); |
590 | 590 | } |
591 | - protected function handleExternalError($statusCode,$exception) |
|
591 | + protected function handleExternalError($statusCode, $exception) |
|
592 | 592 | { |
593 | 593 | if(!($exception instanceof THttpException)) |
594 | 594 | error_log($exception->__toString()); |
595 | - $content=$this->getErrorTemplate($statusCode,$exception); |
|
596 | - $serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; |
|
597 | - $isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug; |
|
598 | - $errorMessage = $exception->getMessage(); |
|
595 | + $content=$this->getErrorTemplate($statusCode, $exception); |
|
596 | + $serverAdmin=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : ''; |
|
597 | + $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
598 | + $errorMessage=$exception->getMessage(); |
|
599 | 599 | if($isDebug) |
600 | 600 | $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
601 | 601 | else |
602 | 602 | { |
603 | 603 | $version=''; |
604 | - $errorMessage = self::hideSecurityRelated($errorMessage, $exception); |
|
604 | + $errorMessage=self::hideSecurityRelated($errorMessage, $exception); |
|
605 | 605 | } |
606 | 606 | $tokens=array( |
607 | 607 | '%%StatusCode%%' => "$statusCode", |
608 | 608 | '%%ErrorMessage%%' => htmlspecialchars($errorMessage), |
609 | 609 | '%%ServerAdmin%%' => $serverAdmin, |
610 | 610 | '%%Version%%' => $version, |
611 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
611 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
612 | 612 | ); |
613 | 613 | $this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null); |
614 | - echo strtr($content,$tokens); |
|
614 | + echo strtr($content, $tokens); |
|
615 | 615 | } |
616 | 616 | protected function handleRecursiveError($exception) |
617 | 617 | { |
@@ -639,8 +639,8 @@ discard block |
||
639 | 639 | if($exception instanceof TTemplateException) |
640 | 640 | { |
641 | 641 | $fileName=$exception->getTemplateFile(); |
642 | - $lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName); |
|
643 | - $source=$this->getSourceCode($lines,$exception->getLineNumber()); |
|
642 | + $lines=empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName); |
|
643 | + $source=$this->getSourceCode($lines, $exception->getLineNumber()); |
|
644 | 644 | if($fileName==='') |
645 | 645 | $fileName='---embedded template---'; |
646 | 646 | $errorLine=$exception->getLineNumber(); |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | $fileName=$exception->getFile(); |
658 | 658 | $errorLine=$exception->getLine(); |
659 | 659 | } |
660 | - $source=$this->getSourceCode(@file($fileName),$errorLine); |
|
660 | + $source=$this->getSourceCode(@file($fileName), $errorLine); |
|
661 | 661 | } |
662 | 662 | if($this->getApplication()->getMode()===TApplicationMode::Debug) |
663 | 663 | $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
@@ -670,10 +670,10 @@ discard block |
||
670 | 670 | '%%SourceCode%%' => $source, |
671 | 671 | '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()), |
672 | 672 | '%%Version%%' => $version, |
673 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
673 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
674 | 674 | ); |
675 | 675 | $content=$this->getExceptionTemplate($exception); |
676 | - echo strtr($content,$tokens); |
|
676 | + echo strtr($content, $tokens); |
|
677 | 677 | } |
678 | 678 | protected function getExceptionTemplate($exception) |
679 | 679 | { |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | die("Unable to open exception template file '$exceptionFile'."); |
686 | 686 | return $content; |
687 | 687 | } |
688 | - protected function getErrorTemplate($statusCode,$exception) |
|
688 | + protected function getErrorTemplate($statusCode, $exception) |
|
689 | 689 | { |
690 | 690 | $base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME; |
691 | 691 | $lang=Prado::getPreferredLanguage(); |
@@ -714,14 +714,14 @@ discard block |
||
714 | 714 | } |
715 | 715 | else if($exception instanceof TInvalidOperationException) |
716 | 716 | { |
717 | - if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
|
718 | - $result=$this->getPropertyAccessTrace($trace,'__set'); |
|
717 | + if(($result=$this->getPropertyAccessTrace($trace, '__get'))===null) |
|
718 | + $result=$this->getPropertyAccessTrace($trace, '__set'); |
|
719 | 719 | } |
720 | - if($result!==null && strpos($result['file'],': eval()\'d code')!==false) |
|
720 | + if($result!==null && strpos($result['file'], ': eval()\'d code')!==false) |
|
721 | 721 | return null; |
722 | 722 | return $result; |
723 | 723 | } |
724 | - private function getPropertyAccessTrace($trace,$pattern) |
|
724 | + private function getPropertyAccessTrace($trace, $pattern) |
|
725 | 725 | { |
726 | 726 | $result=null; |
727 | 727 | foreach($trace as $t) |
@@ -733,35 +733,35 @@ discard block |
||
733 | 733 | } |
734 | 734 | return $result; |
735 | 735 | } |
736 | - private function getSourceCode($lines,$errorLine) |
|
736 | + private function getSourceCode($lines, $errorLine) |
|
737 | 737 | { |
738 | - $beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0; |
|
739 | - $endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines); |
|
738 | + $beginLine=$errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0; |
|
739 | + $endLine=$errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines); |
|
740 | 740 | $source=''; |
741 | - for($i=$beginLine;$i<$endLine;++$i) |
|
741 | + for($i=$beginLine; $i < $endLine; ++$i) |
|
742 | 742 | { |
743 | - if($i===$errorLine-1) |
|
743 | + if($i===$errorLine - 1) |
|
744 | 744 | { |
745 | - $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
745 | + $line=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
746 | 746 | $source.="<div class=\"error\">".$line."</div>"; |
747 | 747 | } |
748 | 748 | else |
749 | - $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
749 | + $source.=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
750 | 750 | } |
751 | 751 | return $source; |
752 | 752 | } |
753 | 753 | private function addLink($message) |
754 | 754 | { |
755 | 755 | $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
756 | - return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>",$message); |
|
756 | + return preg_replace('/\b(T[A-Z]\w+)\b/', "<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>", $message); |
|
757 | 757 | } |
758 | 758 | } |
759 | -class TList extends TComponent implements IteratorAggregate,ArrayAccess,Countable |
|
759 | +class TList extends TComponent implements IteratorAggregate, ArrayAccess, Countable |
|
760 | 760 | { |
761 | 761 | private $_d=array(); |
762 | 762 | private $_c=0; |
763 | 763 | private $_r=false; |
764 | - public function __construct($data=null,$readOnly=false) |
|
764 | + public function __construct($data=null, $readOnly=false) |
|
765 | 765 | { |
766 | 766 | if($data!==null) |
767 | 767 | $this->copyFrom($data); |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | } |
778 | 778 | public function getIterator() |
779 | 779 | { |
780 | - return new ArrayIterator( $this->_d ); |
|
780 | + return new ArrayIterator($this->_d); |
|
781 | 781 | } |
782 | 782 | public function count() |
783 | 783 | { |
@@ -789,38 +789,38 @@ discard block |
||
789 | 789 | } |
790 | 790 | public function itemAt($index) |
791 | 791 | { |
792 | - if($index>=0 && $index<$this->_c) |
|
792 | + if($index >= 0 && $index < $this->_c) |
|
793 | 793 | return $this->_d[$index]; |
794 | 794 | else |
795 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
795 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
796 | 796 | } |
797 | 797 | public function add($item) |
798 | 798 | { |
799 | - $this->insertAt($this->_c,$item); |
|
800 | - return $this->_c-1; |
|
799 | + $this->insertAt($this->_c, $item); |
|
800 | + return $this->_c - 1; |
|
801 | 801 | } |
802 | - public function insertAt($index,$item) |
|
802 | + public function insertAt($index, $item) |
|
803 | 803 | { |
804 | 804 | if(!$this->_r) |
805 | 805 | { |
806 | 806 | if($index===$this->_c) |
807 | 807 | $this->_d[$this->_c++]=$item; |
808 | - else if($index>=0 && $index<$this->_c) |
|
808 | + else if($index >= 0 && $index < $this->_c) |
|
809 | 809 | { |
810 | - array_splice($this->_d,$index,0,array($item)); |
|
810 | + array_splice($this->_d, $index, 0, array($item)); |
|
811 | 811 | $this->_c++; |
812 | 812 | } |
813 | 813 | else |
814 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
814 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
815 | 815 | } |
816 | 816 | else |
817 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
817 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
818 | 818 | } |
819 | 819 | public function remove($item) |
820 | 820 | { |
821 | 821 | if(!$this->_r) |
822 | 822 | { |
823 | - if(($index=$this->indexOf($item))>=0) |
|
823 | + if(($index=$this->indexOf($item)) >= 0) |
|
824 | 824 | { |
825 | 825 | $this->removeAt($index); |
826 | 826 | return $index; |
@@ -829,13 +829,13 @@ discard block |
||
829 | 829 | throw new TInvalidDataValueException('list_item_inexistent'); |
830 | 830 | } |
831 | 831 | else |
832 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
832 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
833 | 833 | } |
834 | 834 | public function removeAt($index) |
835 | 835 | { |
836 | 836 | if(!$this->_r) |
837 | 837 | { |
838 | - if($index>=0 && $index<$this->_c) |
|
838 | + if($index >= 0 && $index < $this->_c) |
|
839 | 839 | { |
840 | 840 | $this->_c--; |
841 | 841 | if($index===$this->_c) |
@@ -843,28 +843,28 @@ discard block |
||
843 | 843 | else |
844 | 844 | { |
845 | 845 | $item=$this->_d[$index]; |
846 | - array_splice($this->_d,$index,1); |
|
846 | + array_splice($this->_d, $index, 1); |
|
847 | 847 | return $item; |
848 | 848 | } |
849 | 849 | } |
850 | 850 | else |
851 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
851 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
852 | 852 | } |
853 | 853 | else |
854 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
854 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
855 | 855 | } |
856 | 856 | public function clear() |
857 | 857 | { |
858 | - for($i=$this->_c-1;$i>=0;--$i) |
|
858 | + for($i=$this->_c - 1; $i >= 0; --$i) |
|
859 | 859 | $this->removeAt($i); |
860 | 860 | } |
861 | 861 | public function contains($item) |
862 | 862 | { |
863 | - return $this->indexOf($item)>=0; |
|
863 | + return $this->indexOf($item) >= 0; |
|
864 | 864 | } |
865 | 865 | public function indexOf($item) |
866 | 866 | { |
867 | - if(($index=array_search($item,$this->_d,true))===false) |
|
867 | + if(($index=array_search($item, $this->_d, true))===false) |
|
868 | 868 | return -1; |
869 | 869 | else |
870 | 870 | return $index; |
@@ -873,25 +873,25 @@ discard block |
||
873 | 873 | { |
874 | 874 | if(!$this->_r) |
875 | 875 | { |
876 | - if(($index = $this->indexOf($baseitem)) == -1) |
|
876 | + if(($index=$this->indexOf($baseitem))==-1) |
|
877 | 877 | throw new TInvalidDataValueException('list_item_inexistent'); |
878 | 878 | $this->insertAt($index, $item); |
879 | 879 | return $index; |
880 | 880 | } |
881 | 881 | else |
882 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
882 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
883 | 883 | } |
884 | 884 | public function insertAfter($baseitem, $item) |
885 | 885 | { |
886 | 886 | if(!$this->_r) |
887 | 887 | { |
888 | - if(($index = $this->indexOf($baseitem)) == -1) |
|
888 | + if(($index=$this->indexOf($baseitem))==-1) |
|
889 | 889 | throw new TInvalidDataValueException('list_item_inexistent'); |
890 | 890 | $this->insertAt($index + 1, $item); |
891 | 891 | return $index + 1; |
892 | 892 | } |
893 | 893 | else |
894 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
894 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
895 | 895 | } |
896 | 896 | public function toArray() |
897 | 897 | { |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | { |
902 | 902 | if(is_array($data) || ($data instanceof Traversable)) |
903 | 903 | { |
904 | - if($this->_c>0) |
|
904 | + if($this->_c > 0) |
|
905 | 905 | $this->clear(); |
906 | 906 | foreach($data as $item) |
907 | 907 | $this->add($item); |
@@ -921,20 +921,20 @@ discard block |
||
921 | 921 | } |
922 | 922 | public function offsetExists($offset) |
923 | 923 | { |
924 | - return ($offset>=0 && $offset<$this->_c); |
|
924 | + return ($offset >= 0 && $offset < $this->_c); |
|
925 | 925 | } |
926 | 926 | public function offsetGet($offset) |
927 | 927 | { |
928 | 928 | return $this->itemAt($offset); |
929 | 929 | } |
930 | - public function offsetSet($offset,$item) |
|
930 | + public function offsetSet($offset, $item) |
|
931 | 931 | { |
932 | 932 | if($offset===null || $offset===$this->_c) |
933 | - $this->insertAt($this->_c,$item); |
|
933 | + $this->insertAt($this->_c, $item); |
|
934 | 934 | else |
935 | 935 | { |
936 | 936 | $this->removeAt($offset); |
937 | - $this->insertAt($offset,$item); |
|
937 | + $this->insertAt($offset, $item); |
|
938 | 938 | } |
939 | 939 | } |
940 | 940 | public function offsetUnset($offset) |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | if($this->getApplication()->getCache()===null) |
959 | 959 | $this->getApplication()->setCache($this); |
960 | 960 | else |
961 | - throw new TConfigurationException('cache_primary_duplicated',get_class($this)); |
|
961 | + throw new TConfigurationException('cache_primary_duplicated', get_class($this)); |
|
962 | 962 | } |
963 | 963 | } |
964 | 964 | public function getPrimaryCache() |
@@ -992,22 +992,22 @@ discard block |
||
992 | 992 | } |
993 | 993 | return false; |
994 | 994 | } |
995 | - public function set($id,$value,$expire=0,$dependency=null) |
|
995 | + public function set($id, $value, $expire=0, $dependency=null) |
|
996 | 996 | { |
997 | - if(empty($value) && $expire === 0) |
|
997 | + if(empty($value) && $expire===0) |
|
998 | 998 | $this->delete($id); |
999 | 999 | else |
1000 | 1000 | { |
1001 | - $data=array($value,$dependency); |
|
1002 | - return $this->setValue($this->generateUniqueKey($id),$data,$expire); |
|
1001 | + $data=array($value, $dependency); |
|
1002 | + return $this->setValue($this->generateUniqueKey($id), $data, $expire); |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | - public function add($id,$value,$expire=0,$dependency=null) |
|
1005 | + public function add($id, $value, $expire=0, $dependency=null) |
|
1006 | 1006 | { |
1007 | - if(empty($value) && $expire === 0) |
|
1007 | + if(empty($value) && $expire===0) |
|
1008 | 1008 | return false; |
1009 | - $data=array($value,$dependency); |
|
1010 | - return $this->addValue($this->generateUniqueKey($id),$data,$expire); |
|
1009 | + $data=array($value, $dependency); |
|
1010 | + return $this->addValue($this->generateUniqueKey($id), $data, $expire); |
|
1011 | 1011 | } |
1012 | 1012 | public function delete($id) |
1013 | 1013 | { |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | throw new TNotSupportedException('cache_flush_unsupported'); |
1019 | 1019 | } |
1020 | 1020 | abstract protected function getValue($key); |
1021 | - abstract protected function setValue($key,$value,$expire); |
|
1022 | - abstract protected function addValue($key,$value,$expire); |
|
1021 | + abstract protected function setValue($key, $value, $expire); |
|
1022 | + abstract protected function addValue($key, $value, $expire); |
|
1023 | 1023 | abstract protected function deleteValue($key); |
1024 | 1024 | public function offsetExists($id) |
1025 | 1025 | { |
1026 | - return $this->get($id) !== false; |
|
1026 | + return $this->get($id)!==false; |
|
1027 | 1027 | } |
1028 | 1028 | public function offsetGet($id) |
1029 | 1029 | { |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | public function setDirectory($directory) |
1085 | 1085 | { |
1086 | 1086 | if(($path=realpath($directory))===false || !is_dir($path)) |
1087 | - throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory); |
|
1087 | + throw new TInvalidDataValueException('directorycachedependency_directory_invalid', $directory); |
|
1088 | 1088 | $this->_directory=$path; |
1089 | 1089 | $this->_timestamps=$this->generateTimestamps($path); |
1090 | 1090 | } |
@@ -1116,10 +1116,10 @@ discard block |
||
1116 | 1116 | { |
1117 | 1117 | return true; |
1118 | 1118 | } |
1119 | - protected function generateTimestamps($directory,$level=0) |
|
1119 | + protected function generateTimestamps($directory, $level=0) |
|
1120 | 1120 | { |
1121 | 1121 | if(($dir=opendir($directory))===false) |
1122 | - throw new TIOException('directorycachedependency_directory_invalid',$directory); |
|
1122 | + throw new TIOException('directorycachedependency_directory_invalid', $directory); |
|
1123 | 1123 | $timestamps=array(); |
1124 | 1124 | while(($file=readdir($dir))!==false) |
1125 | 1125 | { |
@@ -1128,8 +1128,8 @@ discard block |
||
1128 | 1128 | continue; |
1129 | 1129 | else if(is_dir($path)) |
1130 | 1130 | { |
1131 | - if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) |
|
1132 | - $timestamps=array_merge($this->generateTimestamps($path,$level+1)); |
|
1131 | + if(($this->_recursiveLevel < 0 || $level < $this->_recursiveLevel) && $this->validateDirectory($path)) |
|
1132 | + $timestamps=array_merge($this->generateTimestamps($path, $level + 1)); |
|
1133 | 1133 | } |
1134 | 1134 | else if($this->validateFile($path)) |
1135 | 1135 | $timestamps[$path]=filemtime($path); |
@@ -1189,10 +1189,10 @@ discard block |
||
1189 | 1189 | } |
1190 | 1190 | class TCacheDependencyList extends TList |
1191 | 1191 | { |
1192 | - public function insertAt($index,$item) |
|
1192 | + public function insertAt($index, $item) |
|
1193 | 1193 | { |
1194 | 1194 | if($item instanceof ICacheDependency) |
1195 | - parent::insertAt($index,$item); |
|
1195 | + parent::insertAt($index, $item); |
|
1196 | 1196 | else |
1197 | 1197 | throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required'); |
1198 | 1198 | } |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | private $_c=0; |
1224 | 1224 | private $_dp=10; |
1225 | 1225 | private $_p=8; |
1226 | - public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8) |
|
1226 | + public function __construct($data=null, $readOnly=false, $defaultPriority=10, $precision=8) |
|
1227 | 1227 | { |
1228 | 1228 | parent::__construct(); |
1229 | 1229 | if($data!==null) |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | { |
1245 | 1245 | if($priority===null) |
1246 | 1246 | $priority=$this->getDefaultPriority(); |
1247 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1247 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1248 | 1248 | if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
1249 | 1249 | return false; |
1250 | 1250 | return count($this->_d[$priority]); |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | } |
1256 | 1256 | protected function setDefaultPriority($value) |
1257 | 1257 | { |
1258 | - $this->_dp=(string)round(TPropertyValue::ensureFloat($value),$this->_p); |
|
1258 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
1259 | 1259 | } |
1260 | 1260 | public function getPrecision() |
1261 | 1261 | { |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | } |
1277 | 1277 | protected function sortPriorities() { |
1278 | 1278 | if(!$this->_o) { |
1279 | - ksort($this->_d,SORT_NUMERIC); |
|
1279 | + ksort($this->_d, SORT_NUMERIC); |
|
1280 | 1280 | $this->_o=true; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1286,111 +1286,111 @@ discard block |
||
1286 | 1286 | $this->sortPriorities(); |
1287 | 1287 | $this->_fd=array(); |
1288 | 1288 | foreach($this->_d as $priority => $itemsatpriority) |
1289 | - $this->_fd=array_merge($this->_fd,$itemsatpriority); |
|
1289 | + $this->_fd=array_merge($this->_fd, $itemsatpriority); |
|
1290 | 1290 | return $this->_fd; |
1291 | 1291 | } |
1292 | 1292 | public function itemAt($index) |
1293 | 1293 | { |
1294 | - if($index>=0&&$index<$this->getCount()) { |
|
1294 | + if($index >= 0 && $index < $this->getCount()) { |
|
1295 | 1295 | $arr=$this->flattenPriorities(); |
1296 | 1296 | return $arr[$index]; |
1297 | 1297 | } else |
1298 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
1298 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
1299 | 1299 | } |
1300 | 1300 | public function itemsAtPriority($priority=null) |
1301 | 1301 | { |
1302 | 1302 | if($priority===null) |
1303 | 1303 | $priority=$this->getDefaultPriority(); |
1304 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1305 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
1304 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1305 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
1306 | 1306 | } |
1307 | - public function itemAtIndexInPriority($index,$priority=null) |
|
1307 | + public function itemAtIndexInPriority($index, $priority=null) |
|
1308 | 1308 | { |
1309 | 1309 | if($priority===null) |
1310 | 1310 | $priority=$this->getDefaultPriority(); |
1311 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1312 | - return !isset($this->_d[$priority])?false:( |
|
1313 | - isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false |
|
1311 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1312 | + return !isset($this->_d[$priority]) ? false : ( |
|
1313 | + isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false |
|
1314 | 1314 | ); |
1315 | 1315 | } |
1316 | - public function add($item,$priority=null) |
|
1316 | + public function add($item, $priority=null) |
|
1317 | 1317 | { |
1318 | 1318 | if($this->getReadOnly()) |
1319 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1320 | - return $this->insertAtIndexInPriority($item,false,$priority,true); |
|
1319 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1320 | + return $this->insertAtIndexInPriority($item, false, $priority, true); |
|
1321 | 1321 | } |
1322 | - public function insertAt($index,$item) |
|
1322 | + public function insertAt($index, $item) |
|
1323 | 1323 | { |
1324 | 1324 | if($this->getReadOnly()) |
1325 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1326 | - if(($priority=$this->priorityAt($index,true))!==false) |
|
1327 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
1325 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1326 | + if(($priority=$this->priorityAt($index, true))!==false) |
|
1327 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
1328 | 1328 | else |
1329 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
1329 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
1330 | 1330 | } |
1331 | - public function insertAtIndexInPriority($item,$index=false,$priority=null,$preserveCache=false) |
|
1331 | + public function insertAtIndexInPriority($item, $index=false, $priority=null, $preserveCache=false) |
|
1332 | 1332 | { |
1333 | 1333 | if($this->getReadOnly()) |
1334 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1334 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1335 | 1335 | if($priority===null) |
1336 | 1336 | $priority=$this->getDefaultPriority(); |
1337 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1337 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1338 | 1338 | if($preserveCache) { |
1339 | 1339 | $this->sortPriorities(); |
1340 | 1340 | $cc=0; |
1341 | 1341 | foreach($this->_d as $prioritykey=>$items) |
1342 | - if($prioritykey>=$priority) |
|
1342 | + if($prioritykey >= $priority) |
|
1343 | 1343 | break; |
1344 | 1344 | else |
1345 | 1345 | $cc+=count($items); |
1346 | - if($index===false&&isset($this->_d[$priority])) { |
|
1346 | + if($index===false && isset($this->_d[$priority])) { |
|
1347 | 1347 | $c=count($this->_d[$priority]); |
1348 | 1348 | $c+=$cc; |
1349 | 1349 | $this->_d[$priority][]=$item; |
1350 | 1350 | } else if(isset($this->_d[$priority])) { |
1351 | - $c=$index+$cc; |
|
1352 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
1351 | + $c=$index + $cc; |
|
1352 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
1353 | 1353 | } else { |
1354 | - $c = $cc; |
|
1355 | - $this->_o = false; |
|
1354 | + $c=$cc; |
|
1355 | + $this->_o=false; |
|
1356 | 1356 | $this->_d[$priority]=array($item); |
1357 | 1357 | } |
1358 | - if($this->_fd&&is_array($this->_fd)) array_splice($this->_fd,$c,0,array($item)); |
|
1358 | + if($this->_fd && is_array($this->_fd)) array_splice($this->_fd, $c, 0, array($item)); |
|
1359 | 1359 | } else { |
1360 | 1360 | $c=null; |
1361 | - if($index===false&&isset($this->_d[$priority])) { |
|
1361 | + if($index===false && isset($this->_d[$priority])) { |
|
1362 | 1362 | $cc=count($this->_d[$priority]); |
1363 | 1363 | $this->_d[$priority][]=$item; |
1364 | 1364 | } else if(isset($this->_d[$priority])) { |
1365 | 1365 | $cc=$index; |
1366 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
1366 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
1367 | 1367 | } else { |
1368 | 1368 | $cc=0; |
1369 | 1369 | $this->_o=false; |
1370 | 1370 | $this->_d[$priority]=array($item); |
1371 | 1371 | } |
1372 | - if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1) |
|
1373 | - array_splice($this->_fd,$cc,0,array($item)); |
|
1372 | + if($this->_fd && is_array($this->_fd) && count($this->_d)==1) |
|
1373 | + array_splice($this->_fd, $cc, 0, array($item)); |
|
1374 | 1374 | else |
1375 | 1375 | $this->_fd=null; |
1376 | 1376 | } |
1377 | 1377 | $this->_c++; |
1378 | 1378 | return $c; |
1379 | 1379 | } |
1380 | - public function remove($item,$priority=false) |
|
1380 | + public function remove($item, $priority=false) |
|
1381 | 1381 | { |
1382 | 1382 | if($this->getReadOnly()) |
1383 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1384 | - if(($p=$this->priorityOf($item,true))!==false) |
|
1383 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1384 | + if(($p=$this->priorityOf($item, true))!==false) |
|
1385 | 1385 | { |
1386 | 1386 | if($priority!==false) { |
1387 | 1387 | if($priority===null) |
1388 | 1388 | $priority=$this->getDefaultPriority(); |
1389 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1389 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1390 | 1390 | if($p[0]!=$priority) |
1391 | 1391 | throw new TInvalidDataValueException('list_item_inexistent'); |
1392 | 1392 | } |
1393 | - $this->removeAtIndexInPriority($p[1],$p[0]); |
|
1393 | + $this->removeAtIndexInPriority($p[1], $p[0]); |
|
1394 | 1394 | return $p[2]; |
1395 | 1395 | } |
1396 | 1396 | else |
@@ -1399,21 +1399,21 @@ discard block |
||
1399 | 1399 | public function removeAt($index) |
1400 | 1400 | { |
1401 | 1401 | if($this->getReadOnly()) |
1402 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1402 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1403 | 1403 | if(($priority=$this->priorityAt($index, true))!==false) |
1404 | - return $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
1405 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
1404 | + return $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
1405 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
1406 | 1406 | } |
1407 | 1407 | public function removeAtIndexInPriority($index, $priority=null) |
1408 | 1408 | { |
1409 | 1409 | if($this->getReadOnly()) |
1410 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1410 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1411 | 1411 | if($priority===null) |
1412 | 1412 | $priority=$this->getDefaultPriority(); |
1413 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1414 | - if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority])) |
|
1413 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1414 | + if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) |
|
1415 | 1415 | throw new TInvalidDataValueException('list_item_inexistent'); |
1416 | - $value=array_splice($this->_d[$priority],$index,1); |
|
1416 | + $value=array_splice($this->_d[$priority], $index, 1); |
|
1417 | 1417 | $value=$value[0]; |
1418 | 1418 | if(!count($this->_d[$priority])) |
1419 | 1419 | unset($this->_d[$priority]); |
@@ -1424,71 +1424,71 @@ discard block |
||
1424 | 1424 | public function clear() |
1425 | 1425 | { |
1426 | 1426 | if($this->getReadOnly()) |
1427 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1428 | - $d=array_reverse($this->_d,true); |
|
1427 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1428 | + $d=array_reverse($this->_d, true); |
|
1429 | 1429 | foreach($this->_d as $priority=>$items) { |
1430 | - for($index=count($items)-1;$index>=0;$index--) |
|
1431 | - $this->removeAtIndexInPriority($index,$priority); |
|
1430 | + for($index=count($items) - 1; $index >= 0; $index--) |
|
1431 | + $this->removeAtIndexInPriority($index, $priority); |
|
1432 | 1432 | unset($this->_d[$priority]); |
1433 | 1433 | } |
1434 | 1434 | } |
1435 | 1435 | public function contains($item) |
1436 | 1436 | { |
1437 | - return $this->indexOf($item)>=0; |
|
1437 | + return $this->indexOf($item) >= 0; |
|
1438 | 1438 | } |
1439 | 1439 | public function indexOf($item) |
1440 | 1440 | { |
1441 | - if(($index=array_search($item,$this->flattenPriorities(),true))===false) |
|
1441 | + if(($index=array_search($item, $this->flattenPriorities(), true))===false) |
|
1442 | 1442 | return -1; |
1443 | 1443 | else |
1444 | 1444 | return $index; |
1445 | 1445 | } |
1446 | - public function priorityOf($item,$withindex = false) |
|
1446 | + public function priorityOf($item, $withindex=false) |
|
1447 | 1447 | { |
1448 | 1448 | $this->sortPriorities(); |
1449 | - $absindex = 0; |
|
1449 | + $absindex=0; |
|
1450 | 1450 | foreach($this->_d as $priority=>$items) { |
1451 | - if(($index=array_search($item,$items,true))!==false) { |
|
1451 | + if(($index=array_search($item, $items, true))!==false) { |
|
1452 | 1452 | $absindex+=$index; |
1453 | - return $withindex?array($priority,$index,$absindex, |
|
1454 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
1453 | + return $withindex ? array($priority, $index, $absindex, |
|
1454 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
1455 | 1455 | } else |
1456 | 1456 | $absindex+=count($items); |
1457 | 1457 | } |
1458 | 1458 | return false; |
1459 | 1459 | } |
1460 | - public function priorityAt($index,$withindex = false) |
|
1460 | + public function priorityAt($index, $withindex=false) |
|
1461 | 1461 | { |
1462 | - if($index<0||$index>=$this->getCount()) |
|
1463 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
1462 | + if($index < 0 || $index >= $this->getCount()) |
|
1463 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
1464 | 1464 | $absindex=$index; |
1465 | 1465 | $this->sortPriorities(); |
1466 | 1466 | foreach($this->_d as $priority=>$items) { |
1467 | - if($index>=($c=count($items))) |
|
1467 | + if($index >= ($c=count($items))) |
|
1468 | 1468 | $index-=$c; |
1469 | 1469 | else |
1470 | - return $withindex?array($priority,$index,$absindex, |
|
1471 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
1470 | + return $withindex ? array($priority, $index, $absindex, |
|
1471 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
1472 | 1472 | } |
1473 | 1473 | return false; |
1474 | 1474 | } |
1475 | 1475 | public function insertBefore($indexitem, $item) |
1476 | 1476 | { |
1477 | 1477 | if($this->getReadOnly()) |
1478 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1479 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
1478 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1479 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
1480 | 1480 | throw new TInvalidDataValueException('list_item_inexistent'); |
1481 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
1481 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
1482 | 1482 | return $priority[2]; |
1483 | 1483 | } |
1484 | 1484 | public function insertAfter($indexitem, $item) |
1485 | 1485 | { |
1486 | 1486 | if($this->getReadOnly()) |
1487 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
1488 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
1487 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
1488 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
1489 | 1489 | throw new TInvalidDataValueException('list_item_inexistent'); |
1490 | - $this->insertAtIndexInPriority($item,$priority[1]+1,$priority[0]); |
|
1491 | - return $priority[2]+1; |
|
1490 | + $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]); |
|
1491 | + return $priority[2] + 1; |
|
1492 | 1492 | } |
1493 | 1493 | public function toArray() |
1494 | 1494 | { |
@@ -1499,27 +1499,27 @@ discard block |
||
1499 | 1499 | $this->sortPriorities(); |
1500 | 1500 | return $this->_d; |
1501 | 1501 | } |
1502 | - public function toArrayBelowPriority($priority,$inclusive=false) |
|
1502 | + public function toArrayBelowPriority($priority, $inclusive=false) |
|
1503 | 1503 | { |
1504 | 1504 | $this->sortPriorities(); |
1505 | 1505 | $items=array(); |
1506 | 1506 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
1507 | 1507 | { |
1508 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
1508 | + if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
1509 | 1509 | break; |
1510 | - $items=array_merge($items,$itemsatpriority); |
|
1510 | + $items=array_merge($items, $itemsatpriority); |
|
1511 | 1511 | } |
1512 | 1512 | return $items; |
1513 | 1513 | } |
1514 | - public function toArrayAbovePriority($priority,$inclusive=true) |
|
1514 | + public function toArrayAbovePriority($priority, $inclusive=true) |
|
1515 | 1515 | { |
1516 | 1516 | $this->sortPriorities(); |
1517 | 1517 | $items=array(); |
1518 | 1518 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
1519 | 1519 | { |
1520 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
1520 | + if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
1521 | 1521 | continue; |
1522 | - $items=array_merge($items,$itemsatpriority); |
|
1522 | + $items=array_merge($items, $itemsatpriority); |
|
1523 | 1523 | } |
1524 | 1524 | return $items; |
1525 | 1525 | } |
@@ -1527,15 +1527,15 @@ discard block |
||
1527 | 1527 | { |
1528 | 1528 | if($data instanceof TPriorityList) |
1529 | 1529 | { |
1530 | - if($this->getCount()>0) |
|
1530 | + if($this->getCount() > 0) |
|
1531 | 1531 | $this->clear(); |
1532 | 1532 | foreach($data->getPriorities() as $priority) |
1533 | 1533 | { |
1534 | 1534 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
1535 | - $this->insertAtIndexInPriority($item,$index,$priority); |
|
1535 | + $this->insertAtIndexInPriority($item, $index, $priority); |
|
1536 | 1536 | } |
1537 | - } else if(is_array($data)||$data instanceof Traversable) { |
|
1538 | - if($this->getCount()>0) |
|
1537 | + } else if(is_array($data) || $data instanceof Traversable) { |
|
1538 | + if($this->getCount() > 0) |
|
1539 | 1539 | $this->clear(); |
1540 | 1540 | foreach($data as $key=>$item) |
1541 | 1541 | $this->add($item); |
@@ -1549,10 +1549,10 @@ discard block |
||
1549 | 1549 | foreach($data->getPriorities() as $priority) |
1550 | 1550 | { |
1551 | 1551 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
1552 | - $this->insertAtIndexInPriority($item,false,$priority); |
|
1552 | + $this->insertAtIndexInPriority($item, false, $priority); |
|
1553 | 1553 | } |
1554 | 1554 | } |
1555 | - else if(is_array($data)||$data instanceof Traversable) |
|
1555 | + else if(is_array($data) || $data instanceof Traversable) |
|
1556 | 1556 | { |
1557 | 1557 | foreach($data as $priority=>$item) |
1558 | 1558 | $this->add($item); |
@@ -1562,43 +1562,43 @@ discard block |
||
1562 | 1562 | } |
1563 | 1563 | public function offsetExists($offset) |
1564 | 1564 | { |
1565 | - return ($offset>=0&&$offset<$this->getCount()); |
|
1565 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
1566 | 1566 | } |
1567 | 1567 | public function offsetGet($offset) |
1568 | 1568 | { |
1569 | 1569 | return $this->itemAt($offset); |
1570 | 1570 | } |
1571 | - public function offsetSet($offset,$item) |
|
1571 | + public function offsetSet($offset, $item) |
|
1572 | 1572 | { |
1573 | 1573 | if($offset===null) |
1574 | 1574 | return $this->add($item); |
1575 | 1575 | if($offset===$this->getCount()) { |
1576 | - $priority=$this->priorityAt($offset-1,true); |
|
1576 | + $priority=$this->priorityAt($offset - 1, true); |
|
1577 | 1577 | $priority[1]++; |
1578 | 1578 | } else { |
1579 | - $priority=$this->priorityAt($offset,true); |
|
1580 | - $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
1579 | + $priority=$this->priorityAt($offset, true); |
|
1580 | + $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
1581 | 1581 | } |
1582 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
1582 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
1583 | 1583 | } |
1584 | 1584 | public function offsetUnset($offset) |
1585 | 1585 | { |
1586 | 1586 | $this->removeAt($offset); |
1587 | 1587 | } |
1588 | 1588 | } |
1589 | -class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable |
|
1589 | +class TMap extends TComponent implements IteratorAggregate, ArrayAccess, Countable |
|
1590 | 1590 | { |
1591 | 1591 | private $_d=array(); |
1592 | 1592 | private $_r=false; |
1593 | 1593 | protected function _getZappableSleepProps(&$exprops) |
1594 | 1594 | { |
1595 | 1595 | parent::_getZappableSleepProps($exprops); |
1596 | - if ($this->_d===array()) |
|
1597 | - $exprops[] = "\0TMap\0_d"; |
|
1598 | - if ($this->_r===false) |
|
1599 | - $exprops[] = "\0TMap\0_r"; |
|
1596 | + if($this->_d===array()) |
|
1597 | + $exprops[]="\0TMap\0_d"; |
|
1598 | + if($this->_r===false) |
|
1599 | + $exprops[]="\0TMap\0_r"; |
|
1600 | 1600 | } |
1601 | - public function __construct($data=null,$readOnly=false) |
|
1601 | + public function __construct($data=null, $readOnly=false) |
|
1602 | 1602 | { |
1603 | 1603 | if($data!==null) |
1604 | 1604 | $this->copyFrom($data); |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | } |
1615 | 1615 | public function getIterator() |
1616 | 1616 | { |
1617 | - return new ArrayIterator( $this->_d ); |
|
1617 | + return new ArrayIterator($this->_d); |
|
1618 | 1618 | } |
1619 | 1619 | public function count() |
1620 | 1620 | { |
@@ -1632,18 +1632,18 @@ discard block |
||
1632 | 1632 | { |
1633 | 1633 | return isset($this->_d[$key]) ? $this->_d[$key] : null; |
1634 | 1634 | } |
1635 | - public function add($key,$value) |
|
1635 | + public function add($key, $value) |
|
1636 | 1636 | { |
1637 | 1637 | if(!$this->_r) |
1638 | 1638 | $this->_d[$key]=$value; |
1639 | 1639 | else |
1640 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
1640 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
1641 | 1641 | } |
1642 | 1642 | public function remove($key) |
1643 | 1643 | { |
1644 | 1644 | if(!$this->_r) |
1645 | 1645 | { |
1646 | - if(isset($this->_d[$key]) || array_key_exists($key,$this->_d)) |
|
1646 | + if(isset($this->_d[$key]) || array_key_exists($key, $this->_d)) |
|
1647 | 1647 | { |
1648 | 1648 | $value=$this->_d[$key]; |
1649 | 1649 | unset($this->_d[$key]); |
@@ -1653,7 +1653,7 @@ discard block |
||
1653 | 1653 | return null; |
1654 | 1654 | } |
1655 | 1655 | else |
1656 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
1656 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
1657 | 1657 | } |
1658 | 1658 | public function clear() |
1659 | 1659 | { |
@@ -1662,7 +1662,7 @@ discard block |
||
1662 | 1662 | } |
1663 | 1663 | public function contains($key) |
1664 | 1664 | { |
1665 | - return isset($this->_d[$key]) || array_key_exists($key,$this->_d); |
|
1665 | + return isset($this->_d[$key]) || array_key_exists($key, $this->_d); |
|
1666 | 1666 | } |
1667 | 1667 | public function toArray() |
1668 | 1668 | { |
@@ -1672,10 +1672,10 @@ discard block |
||
1672 | 1672 | { |
1673 | 1673 | if(is_array($data) || $data instanceof Traversable) |
1674 | 1674 | { |
1675 | - if($this->getCount()>0) |
|
1675 | + if($this->getCount() > 0) |
|
1676 | 1676 | $this->clear(); |
1677 | 1677 | foreach($data as $key=>$value) |
1678 | - $this->add($key,$value); |
|
1678 | + $this->add($key, $value); |
|
1679 | 1679 | } |
1680 | 1680 | else if($data!==null) |
1681 | 1681 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -1685,7 +1685,7 @@ discard block |
||
1685 | 1685 | if(is_array($data) || $data instanceof Traversable) |
1686 | 1686 | { |
1687 | 1687 | foreach($data as $key=>$value) |
1688 | - $this->add($key,$value); |
|
1688 | + $this->add($key, $value); |
|
1689 | 1689 | } |
1690 | 1690 | else if($data!==null) |
1691 | 1691 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -1698,9 +1698,9 @@ discard block |
||
1698 | 1698 | { |
1699 | 1699 | return $this->itemAt($offset); |
1700 | 1700 | } |
1701 | - public function offsetSet($offset,$item) |
|
1701 | + public function offsetSet($offset, $item) |
|
1702 | 1702 | { |
1703 | - $this->add($offset,$item); |
|
1703 | + $this->add($offset, $item); |
|
1704 | 1704 | } |
1705 | 1705 | public function offsetUnset($offset) |
1706 | 1706 | { |
@@ -1719,7 +1719,7 @@ discard block |
||
1719 | 1719 | private $_c=0; |
1720 | 1720 | private $_dp=10; |
1721 | 1721 | private $_p=8; |
1722 | - public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8) |
|
1722 | + public function __construct($data=null, $readOnly=false, $defaultPriority=10, $precision=8) |
|
1723 | 1723 | { |
1724 | 1724 | if($data!==null) |
1725 | 1725 | $this->copyFrom($data); |
@@ -1741,7 +1741,7 @@ discard block |
||
1741 | 1741 | } |
1742 | 1742 | protected function setDefaultPriority($value) |
1743 | 1743 | { |
1744 | - $this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p); |
|
1744 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
1745 | 1745 | } |
1746 | 1746 | public function getPrecision() |
1747 | 1747 | { |
@@ -1765,9 +1765,9 @@ discard block |
||
1765 | 1765 | if(is_array($this->_fd)) |
1766 | 1766 | return $this->_fd; |
1767 | 1767 | $this->sortPriorities(); |
1768 | - $this->_fd = array(); |
|
1768 | + $this->_fd=array(); |
|
1769 | 1769 | foreach($this->_d as $priority => $itemsatpriority) |
1770 | - $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
1770 | + $this->_fd=array_merge($this->_fd, $itemsatpriority); |
|
1771 | 1771 | return $this->_fd; |
1772 | 1772 | } |
1773 | 1773 | public function count() |
@@ -1782,8 +1782,8 @@ discard block |
||
1782 | 1782 | { |
1783 | 1783 | if($priority===null) |
1784 | 1784 | $priority=$this->getDefaultPriority(); |
1785 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1786 | - if(!isset($this->_d[$priority])||!is_array($this->_d[$priority])) |
|
1785 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1786 | + if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
|
1787 | 1787 | return false; |
1788 | 1788 | return count($this->_d[$priority]); |
1789 | 1789 | } |
@@ -1796,27 +1796,27 @@ discard block |
||
1796 | 1796 | { |
1797 | 1797 | return array_keys($this->flattenPriorities()); |
1798 | 1798 | } |
1799 | - public function itemAt($key,$priority=false) |
|
1799 | + public function itemAt($key, $priority=false) |
|
1800 | 1800 | { |
1801 | - if($priority===false){ |
|
1801 | + if($priority===false) { |
|
1802 | 1802 | $map=$this->flattenPriorities(); |
1803 | - return isset($map[$key])?$map[$key]:null; |
|
1803 | + return isset($map[$key]) ? $map[$key] : null; |
|
1804 | 1804 | } else { |
1805 | 1805 | if($priority===null) |
1806 | 1806 | $priority=$this->getDefaultPriority(); |
1807 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1808 | - return (isset($this->_d[$priority])&&isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null; |
|
1807 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1808 | + return (isset($this->_d[$priority]) && isset($this->_d[$priority][$key])) ? $this->_d[$priority][$key] : null; |
|
1809 | 1809 | } |
1810 | 1810 | } |
1811 | - public function setPriorityAt($key,$priority=null) |
|
1811 | + public function setPriorityAt($key, $priority=null) |
|
1812 | 1812 | { |
1813 | 1813 | if($priority===null) |
1814 | 1814 | $priority=$this->getDefaultPriority(); |
1815 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1815 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1816 | 1816 | $oldpriority=$this->priorityAt($key); |
1817 | - if($oldpriority!==false&&$oldpriority!=$priority) { |
|
1818 | - $value=$this->remove($key,$oldpriority); |
|
1819 | - $this->add($key,$value,$priority); |
|
1817 | + if($oldpriority!==false && $oldpriority!=$priority) { |
|
1818 | + $value=$this->remove($key, $oldpriority); |
|
1819 | + $this->add($key, $value, $priority); |
|
1820 | 1820 | } |
1821 | 1821 | return $oldpriority; |
1822 | 1822 | } |
@@ -1824,14 +1824,14 @@ discard block |
||
1824 | 1824 | { |
1825 | 1825 | if($priority===null) |
1826 | 1826 | $priority=$this->getDefaultPriority(); |
1827 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1828 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
1827 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1828 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
1829 | 1829 | } |
1830 | 1830 | public function priorityOf($item) |
1831 | 1831 | { |
1832 | 1832 | $this->sortPriorities(); |
1833 | 1833 | foreach($this->_d as $priority=>$items) |
1834 | - if(($index=array_search($item,$items,true))!==false) |
|
1834 | + if(($index=array_search($item, $items, true))!==false) |
|
1835 | 1835 | return $priority; |
1836 | 1836 | return false; |
1837 | 1837 | } |
@@ -1839,19 +1839,19 @@ discard block |
||
1839 | 1839 | { |
1840 | 1840 | $this->sortPriorities(); |
1841 | 1841 | foreach($this->_d as $priority=>$items) |
1842 | - if(array_key_exists($key,$items)) |
|
1842 | + if(array_key_exists($key, $items)) |
|
1843 | 1843 | return $priority; |
1844 | 1844 | return false; |
1845 | 1845 | } |
1846 | - public function add($key,$value,$priority=null) |
|
1846 | + public function add($key, $value, $priority=null) |
|
1847 | 1847 | { |
1848 | 1848 | if($priority===null) |
1849 | 1849 | $priority=$this->getDefaultPriority(); |
1850 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1850 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1851 | 1851 | if(!$this->_r) |
1852 | 1852 | { |
1853 | 1853 | foreach($this->_d as $innerpriority=>$items) |
1854 | - if(array_key_exists($key,$items)) |
|
1854 | + if(array_key_exists($key, $items)) |
|
1855 | 1855 | { |
1856 | 1856 | unset($this->_d[$innerpriority][$key]); |
1857 | 1857 | $this->_c--; |
@@ -1868,10 +1868,10 @@ discard block |
||
1868 | 1868 | $this->_fd=null; |
1869 | 1869 | } |
1870 | 1870 | else |
1871 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
1871 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
1872 | 1872 | return $priority; |
1873 | 1873 | } |
1874 | - public function remove($key,$priority=false) |
|
1874 | + public function remove($key, $priority=false) |
|
1875 | 1875 | { |
1876 | 1876 | if(!$this->_r) |
1877 | 1877 | { |
@@ -1881,7 +1881,7 @@ discard block |
||
1881 | 1881 | { |
1882 | 1882 | $this->sortPriorities(); |
1883 | 1883 | foreach($this->_d as $priority=>$items) |
1884 | - if(array_key_exists($key,$items)) |
|
1884 | + if(array_key_exists($key, $items)) |
|
1885 | 1885 | { |
1886 | 1886 | $value=$this->_d[$priority][$key]; |
1887 | 1887 | unset($this->_d[$priority][$key]); |
@@ -1898,8 +1898,8 @@ discard block |
||
1898 | 1898 | } |
1899 | 1899 | else |
1900 | 1900 | { |
1901 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
1902 | - if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority]))) |
|
1901 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
1902 | + if(isset($this->_d[$priority]) && (isset($this->_d[$priority][$key]) || array_key_exists($key, $this->_d[$priority]))) |
|
1903 | 1903 | { |
1904 | 1904 | $value=$this->_d[$priority][$key]; |
1905 | 1905 | unset($this->_d[$priority][$key]); |
@@ -1916,7 +1916,7 @@ discard block |
||
1916 | 1916 | } |
1917 | 1917 | } |
1918 | 1918 | else |
1919 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
1919 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
1920 | 1920 | } |
1921 | 1921 | public function clear() |
1922 | 1922 | { |
@@ -1927,33 +1927,33 @@ discard block |
||
1927 | 1927 | public function contains($key) |
1928 | 1928 | { |
1929 | 1929 | $map=$this->flattenPriorities(); |
1930 | - return isset($map[$key])||array_key_exists($key,$map); |
|
1930 | + return isset($map[$key]) || array_key_exists($key, $map); |
|
1931 | 1931 | } |
1932 | 1932 | public function toArray() |
1933 | 1933 | { |
1934 | 1934 | return $this->flattenPriorities(); |
1935 | 1935 | } |
1936 | - public function toArrayBelowPriority($priority,$inclusive=false) |
|
1936 | + public function toArrayBelowPriority($priority, $inclusive=false) |
|
1937 | 1937 | { |
1938 | 1938 | $this->sortPriorities(); |
1939 | 1939 | $items=array(); |
1940 | 1940 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
1941 | 1941 | { |
1942 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
1942 | + if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
1943 | 1943 | break; |
1944 | - $items=array_merge($items,$itemsatpriority); |
|
1944 | + $items=array_merge($items, $itemsatpriority); |
|
1945 | 1945 | } |
1946 | 1946 | return $items; |
1947 | 1947 | } |
1948 | - public function toArrayAbovePriority($priority,$inclusive=true) |
|
1948 | + public function toArrayAbovePriority($priority, $inclusive=true) |
|
1949 | 1949 | { |
1950 | 1950 | $this->sortPriorities(); |
1951 | 1951 | $items=array(); |
1952 | 1952 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
1953 | 1953 | { |
1954 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
1954 | + if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
1955 | 1955 | continue; |
1956 | - $items=array_merge($items,$itemsatpriority); |
|
1956 | + $items=array_merge($items, $itemsatpriority); |
|
1957 | 1957 | } |
1958 | 1958 | return $items; |
1959 | 1959 | } |
@@ -1961,20 +1961,20 @@ discard block |
||
1961 | 1961 | { |
1962 | 1962 | if($data instanceof TPriorityMap) |
1963 | 1963 | { |
1964 | - if($this->getCount()>0) |
|
1964 | + if($this->getCount() > 0) |
|
1965 | 1965 | $this->clear(); |
1966 | 1966 | foreach($data->getPriorities() as $priority) { |
1967 | 1967 | foreach($data->itemsAtPriority($priority) as $key => $value) { |
1968 | - $this->add($key,$value,$priority); |
|
1968 | + $this->add($key, $value, $priority); |
|
1969 | 1969 | } |
1970 | 1970 | } |
1971 | 1971 | } |
1972 | - else if(is_array($data)||$data instanceof Traversable) |
|
1972 | + else if(is_array($data) || $data instanceof Traversable) |
|
1973 | 1973 | { |
1974 | - if($this->getCount()>0) |
|
1974 | + if($this->getCount() > 0) |
|
1975 | 1975 | $this->clear(); |
1976 | 1976 | foreach($data as $key=>$value) |
1977 | - $this->add($key,$value); |
|
1977 | + $this->add($key, $value); |
|
1978 | 1978 | } |
1979 | 1979 | else if($data!==null) |
1980 | 1980 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -1986,13 +1986,13 @@ discard block |
||
1986 | 1986 | foreach($data->getPriorities() as $priority) |
1987 | 1987 | { |
1988 | 1988 | foreach($data->itemsAtPriority($priority) as $key => $value) |
1989 | - $this->add($key,$value,$priority); |
|
1989 | + $this->add($key, $value, $priority); |
|
1990 | 1990 | } |
1991 | 1991 | } |
1992 | - else if(is_array($data)||$data instanceof Traversable) |
|
1992 | + else if(is_array($data) || $data instanceof Traversable) |
|
1993 | 1993 | { |
1994 | 1994 | foreach($data as $key=>$value) |
1995 | - $this->add($key,$value); |
|
1995 | + $this->add($key, $value); |
|
1996 | 1996 | } |
1997 | 1997 | else if($data!==null) |
1998 | 1998 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -2005,16 +2005,16 @@ discard block |
||
2005 | 2005 | { |
2006 | 2006 | return $this->itemAt($offset); |
2007 | 2007 | } |
2008 | - public function offsetSet($offset,$item) |
|
2008 | + public function offsetSet($offset, $item) |
|
2009 | 2009 | { |
2010 | - $this->add($offset,$item); |
|
2010 | + $this->add($offset, $item); |
|
2011 | 2011 | } |
2012 | 2012 | public function offsetUnset($offset) |
2013 | 2013 | { |
2014 | 2014 | $this->remove($offset); |
2015 | 2015 | } |
2016 | 2016 | } |
2017 | -class TStack extends TComponent implements IteratorAggregate,Countable |
|
2017 | +class TStack extends TComponent implements IteratorAggregate, Countable |
|
2018 | 2018 | { |
2019 | 2019 | private $_d=array(); |
2020 | 2020 | private $_c=0; |
@@ -2048,14 +2048,14 @@ discard block |
||
2048 | 2048 | } |
2049 | 2049 | public function contains($item) |
2050 | 2050 | { |
2051 | - return array_search($item,$this->_d,true)!==false; |
|
2051 | + return array_search($item, $this->_d, true)!==false; |
|
2052 | 2052 | } |
2053 | 2053 | public function peek() |
2054 | 2054 | { |
2055 | 2055 | if($this->_c===0) |
2056 | 2056 | throw new TInvalidOperationException('stack_empty'); |
2057 | 2057 | else |
2058 | - return $this->_d[$this->_c-1]; |
|
2058 | + return $this->_d[$this->_c - 1]; |
|
2059 | 2059 | } |
2060 | 2060 | public function pop() |
2061 | 2061 | { |
@@ -2070,11 +2070,11 @@ discard block |
||
2070 | 2070 | public function push($item) |
2071 | 2071 | { |
2072 | 2072 | ++$this->_c; |
2073 | - $this->_d[] = $item; |
|
2073 | + $this->_d[]=$item; |
|
2074 | 2074 | } |
2075 | 2075 | public function getIterator() |
2076 | 2076 | { |
2077 | - return new ArrayIterator( $this->_d ); |
|
2077 | + return new ArrayIterator($this->_d); |
|
2078 | 2078 | } |
2079 | 2079 | public function getCount() |
2080 | 2080 | { |
@@ -2114,7 +2114,7 @@ discard block |
||
2114 | 2114 | } |
2115 | 2115 | public function valid() |
2116 | 2116 | { |
2117 | - return $this->_i<$this->_c; |
|
2117 | + return $this->_i < $this->_c; |
|
2118 | 2118 | } |
2119 | 2119 | } |
2120 | 2120 | class TXmlElement extends TComponent |
@@ -2154,11 +2154,11 @@ discard block |
||
2154 | 2154 | } |
2155 | 2155 | public function getHasElement() |
2156 | 2156 | { |
2157 | - return $this->_elements!==null && $this->_elements->getCount()>0; |
|
2157 | + return $this->_elements!==null && $this->_elements->getCount() > 0; |
|
2158 | 2158 | } |
2159 | 2159 | public function getHasAttribute() |
2160 | 2160 | { |
2161 | - return $this->_attributes!==null && $this->_attributes->getCount()>0; |
|
2161 | + return $this->_attributes!==null && $this->_attributes->getCount() > 0; |
|
2162 | 2162 | } |
2163 | 2163 | public function getAttribute($name) |
2164 | 2164 | { |
@@ -2167,9 +2167,9 @@ discard block |
||
2167 | 2167 | else |
2168 | 2168 | return null; |
2169 | 2169 | } |
2170 | - public function setAttribute($name,$value) |
|
2170 | + public function setAttribute($name, $value) |
|
2171 | 2171 | { |
2172 | - $this->getAttributes()->add($name,TPropertyValue::ensureString($value)); |
|
2172 | + $this->getAttributes()->add($name, TPropertyValue::ensureString($value)); |
|
2173 | 2173 | } |
2174 | 2174 | public function getElements() |
2175 | 2175 | { |
@@ -2215,12 +2215,12 @@ discard block |
||
2215 | 2215 | $attr.=" $name=\"$value\""; |
2216 | 2216 | } |
2217 | 2217 | } |
2218 | - $prefix=str_repeat(' ',$indent*4); |
|
2218 | + $prefix=str_repeat(' ', $indent * 4); |
|
2219 | 2219 | if($this->getHasElement()) |
2220 | 2220 | { |
2221 | 2221 | $str=$prefix."<{$this->_tagName}$attr>\n"; |
2222 | 2222 | foreach($this->getElements() as $element) |
2223 | - $str.=$element->toString($indent+1)."\n"; |
|
2223 | + $str.=$element->toString($indent + 1)."\n"; |
|
2224 | 2224 | $str.=$prefix."</{$this->_tagName}>"; |
2225 | 2225 | return $str; |
2226 | 2226 | } |
@@ -2238,7 +2238,7 @@ discard block |
||
2238 | 2238 | } |
2239 | 2239 | private function xmlEncode($str) |
2240 | 2240 | { |
2241 | - return strtr($str,array( |
|
2241 | + return strtr($str, array( |
|
2242 | 2242 | '>'=>'>', |
2243 | 2243 | '<'=>'<', |
2244 | 2244 | '&'=>'&', |
@@ -2252,7 +2252,7 @@ discard block |
||
2252 | 2252 | { |
2253 | 2253 | private $_version; |
2254 | 2254 | private $_encoding; |
2255 | - public function __construct($version='1.0',$encoding='') |
|
2255 | + public function __construct($version='1.0', $encoding='') |
|
2256 | 2256 | { |
2257 | 2257 | parent::__construct(''); |
2258 | 2258 | $this->setVersion($version); |
@@ -2279,7 +2279,7 @@ discard block |
||
2279 | 2279 | if(($str=@file_get_contents($file))!==false) |
2280 | 2280 | return $this->loadFromString($str); |
2281 | 2281 | else |
2282 | - throw new TIOException('xmldocument_file_read_failed',$file); |
|
2282 | + throw new TIOException('xmldocument_file_read_failed', $file); |
|
2283 | 2283 | } |
2284 | 2284 | public function loadFromString($string) |
2285 | 2285 | { |
@@ -2296,23 +2296,23 @@ discard block |
||
2296 | 2296 | $elements->clear(); |
2297 | 2297 | $attributes->clear(); |
2298 | 2298 | static $bSimpleXml; |
2299 | - if($bSimpleXml === null) |
|
2300 | - $bSimpleXml = (boolean)function_exists('simplexml_load_string'); |
|
2299 | + if($bSimpleXml===null) |
|
2300 | + $bSimpleXml=(boolean) function_exists('simplexml_load_string'); |
|
2301 | 2301 | if($bSimpleXml) |
2302 | 2302 | { |
2303 | - $simpleDoc = simplexml_load_string($string); |
|
2304 | - $docNamespaces = $simpleDoc->getDocNamespaces(false); |
|
2305 | - $simpleDoc = null; |
|
2303 | + $simpleDoc=simplexml_load_string($string); |
|
2304 | + $docNamespaces=$simpleDoc->getDocNamespaces(false); |
|
2305 | + $simpleDoc=null; |
|
2306 | 2306 | foreach($docNamespaces as $prefix => $uri) |
2307 | 2307 | { |
2308 | - if($prefix === '') |
|
2308 | + if($prefix==='') |
|
2309 | 2309 | $attributes->add('xmlns', $uri); |
2310 | 2310 | else |
2311 | 2311 | $attributes->add('xmlns:'.$prefix, $uri); |
2312 | 2312 | } |
2313 | 2313 | } |
2314 | 2314 | foreach($element->attributes as $name=>$attr) |
2315 | - $attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value); |
|
2315 | + $attributes->add(($attr->prefix==='' ? '' : $attr->prefix.':').$name, $attr->value); |
|
2316 | 2316 | foreach($element->childNodes as $child) |
2317 | 2317 | { |
2318 | 2318 | if($child instanceof DOMElement) |
@@ -2322,18 +2322,18 @@ discard block |
||
2322 | 2322 | } |
2323 | 2323 | public function saveToFile($file) |
2324 | 2324 | { |
2325 | - if(($fw=fopen($file,'w'))!==false) |
|
2325 | + if(($fw=fopen($file, 'w'))!==false) |
|
2326 | 2326 | { |
2327 | - fwrite($fw,$this->saveToString()); |
|
2327 | + fwrite($fw, $this->saveToString()); |
|
2328 | 2328 | fclose($fw); |
2329 | 2329 | } |
2330 | 2330 | else |
2331 | - throw new TIOException('xmldocument_file_write_failed',$file); |
|
2331 | + throw new TIOException('xmldocument_file_write_failed', $file); |
|
2332 | 2332 | } |
2333 | 2333 | public function saveToString() |
2334 | 2334 | { |
2335 | - $version=empty($this->_version)?' version="1.0"':' version="'.$this->_version.'"'; |
|
2336 | - $encoding=empty($this->_encoding)?'':' encoding="'.$this->_encoding.'"'; |
|
2335 | + $version=empty($this->_version) ? ' version="1.0"' : ' version="'.$this->_version.'"'; |
|
2336 | + $encoding=empty($this->_encoding) ? '' : ' encoding="'.$this->_encoding.'"'; |
|
2337 | 2337 | return "<?xml{$version}{$encoding}?>\n".$this->toString(0); |
2338 | 2338 | } |
2339 | 2339 | public function __toString() |
@@ -2345,7 +2345,7 @@ discard block |
||
2345 | 2345 | $element=new TXmlElement($node->tagName); |
2346 | 2346 | $element->setValue($node->nodeValue); |
2347 | 2347 | foreach($node->attributes as $name=>$attr) |
2348 | - $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value); |
|
2348 | + $element->getAttributes()->add(($attr->prefix==='' ? '' : $attr->prefix.':').$name, $attr->value); |
|
2349 | 2349 | foreach($node->childNodes as $child) |
2350 | 2350 | { |
2351 | 2351 | if($child instanceof DOMElement) |
@@ -2365,11 +2365,11 @@ discard block |
||
2365 | 2365 | { |
2366 | 2366 | return $this->_o; |
2367 | 2367 | } |
2368 | - public function insertAt($index,$item) |
|
2368 | + public function insertAt($index, $item) |
|
2369 | 2369 | { |
2370 | 2370 | if($item instanceof TXmlElement) |
2371 | 2371 | { |
2372 | - parent::insertAt($index,$item); |
|
2372 | + parent::insertAt($index, $item); |
|
2373 | 2373 | if($item->getParent()!==null) |
2374 | 2374 | $item->getParent()->getElements()->remove($item); |
2375 | 2375 | $item->setParent($this->_o); |
@@ -2395,13 +2395,13 @@ discard block |
||
2395 | 2395 | private $_everyone; |
2396 | 2396 | private $_guest; |
2397 | 2397 | private $_authenticated; |
2398 | - public function __construct($action,$users,$roles,$verb='',$ipRules='') |
|
2398 | + public function __construct($action, $users, $roles, $verb='', $ipRules='') |
|
2399 | 2399 | { |
2400 | 2400 | $action=strtolower(trim($action)); |
2401 | 2401 | if($action==='allow' || $action==='deny') |
2402 | 2402 | $this->_action=$action; |
2403 | 2403 | else |
2404 | - throw new TInvalidDataValueException('authorizationrule_action_invalid',$action); |
|
2404 | + throw new TInvalidDataValueException('authorizationrule_action_invalid', $action); |
|
2405 | 2405 | $this->_users=array(); |
2406 | 2406 | $this->_roles=array(); |
2407 | 2407 | $this->_ipRules=array(); |
@@ -2410,7 +2410,7 @@ discard block |
||
2410 | 2410 | $this->_authenticated=false; |
2411 | 2411 | if(trim($users)==='') |
2412 | 2412 | $users='*'; |
2413 | - foreach(explode(',',$users) as $user) |
|
2413 | + foreach(explode(',', $users) as $user) |
|
2414 | 2414 | { |
2415 | 2415 | if(($user=trim(strtolower($user)))!=='') |
2416 | 2416 | { |
@@ -2429,7 +2429,7 @@ discard block |
||
2429 | 2429 | } |
2430 | 2430 | if(trim($roles)==='') |
2431 | 2431 | $roles='*'; |
2432 | - foreach(explode(',',$roles) as $role) |
|
2432 | + foreach(explode(',', $roles) as $role) |
|
2433 | 2433 | { |
2434 | 2434 | if(($role=trim(strtolower($role)))!=='') |
2435 | 2435 | $this->_roles[]=$role; |
@@ -2439,10 +2439,10 @@ discard block |
||
2439 | 2439 | if($verb==='*' || $verb==='get' || $verb==='post') |
2440 | 2440 | $this->_verb=$verb; |
2441 | 2441 | else |
2442 | - throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb); |
|
2442 | + throw new TInvalidDataValueException('authorizationrule_verb_invalid', $verb); |
|
2443 | 2443 | if(trim($ipRules)==='') |
2444 | 2444 | $ipRules='*'; |
2445 | - foreach(explode(',',$ipRules) as $ipRule) |
|
2445 | + foreach(explode(',', $ipRules) as $ipRule) |
|
2446 | 2446 | { |
2447 | 2447 | if(($ipRule=trim($ipRule))!=='') |
2448 | 2448 | $this->_ipRules[]=$ipRule; |
@@ -2480,10 +2480,10 @@ discard block |
||
2480 | 2480 | { |
2481 | 2481 | return $this->_authenticated || $this->_everyone; |
2482 | 2482 | } |
2483 | - public function isUserAllowed(IUser $user,$verb,$ip) |
|
2483 | + public function isUserAllowed(IUser $user, $verb, $ip) |
|
2484 | 2484 | { |
2485 | 2485 | if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) |
2486 | - return ($this->_action==='allow')?1:-1; |
|
2486 | + return ($this->_action==='allow') ? 1 : -1; |
|
2487 | 2487 | else |
2488 | 2488 | return 0; |
2489 | 2489 | } |
@@ -2493,14 +2493,14 @@ discard block |
||
2493 | 2493 | return 1; |
2494 | 2494 | foreach($this->_ipRules as $rule) |
2495 | 2495 | { |
2496 | - if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0)) |
|
2496 | + if($rule==='*' || $rule===$ip || (($pos=strpos($rule, '*'))!==false && strncmp($ip, $rule, $pos)===0)) |
|
2497 | 2497 | return 1; |
2498 | 2498 | } |
2499 | 2499 | return 0; |
2500 | 2500 | } |
2501 | 2501 | private function isUserMatched($user) |
2502 | 2502 | { |
2503 | - return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users)); |
|
2503 | + return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()), $this->_users)); |
|
2504 | 2504 | } |
2505 | 2505 | private function isRoleMatched($user) |
2506 | 2506 | { |
@@ -2513,42 +2513,42 @@ discard block |
||
2513 | 2513 | } |
2514 | 2514 | private function isVerbMatched($verb) |
2515 | 2515 | { |
2516 | - return ($this->_verb==='*' || strcasecmp($verb,$this->_verb)===0); |
|
2516 | + return ($this->_verb==='*' || strcasecmp($verb, $this->_verb)===0); |
|
2517 | 2517 | } |
2518 | 2518 | } |
2519 | 2519 | class TAuthorizationRuleCollection extends TList |
2520 | 2520 | { |
2521 | - public function isUserAllowed($user,$verb,$ip) |
|
2521 | + public function isUserAllowed($user, $verb, $ip) |
|
2522 | 2522 | { |
2523 | 2523 | if($user instanceof IUser) |
2524 | 2524 | { |
2525 | 2525 | $verb=strtolower(trim($verb)); |
2526 | 2526 | foreach($this as $rule) |
2527 | 2527 | { |
2528 | - if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0) |
|
2529 | - return ($decision>0); |
|
2528 | + if(($decision=$rule->isUserAllowed($user, $verb, $ip))!==0) |
|
2529 | + return ($decision > 0); |
|
2530 | 2530 | } |
2531 | 2531 | return true; |
2532 | 2532 | } |
2533 | 2533 | else |
2534 | 2534 | return false; |
2535 | 2535 | } |
2536 | - public function insertAt($index,$item) |
|
2536 | + public function insertAt($index, $item) |
|
2537 | 2537 | { |
2538 | 2538 | if($item instanceof TAuthorizationRule) |
2539 | - parent::insertAt($index,$item); |
|
2539 | + parent::insertAt($index, $item); |
|
2540 | 2540 | else |
2541 | 2541 | throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required'); |
2542 | 2542 | } |
2543 | 2543 | } |
2544 | 2544 | class TSecurityManager extends TModule |
2545 | 2545 | { |
2546 | - const STATE_VALIDATION_KEY = 'prado:securitymanager:validationkey'; |
|
2547 | - const STATE_ENCRYPTION_KEY = 'prado:securitymanager:encryptionkey'; |
|
2548 | - private $_validationKey = null; |
|
2549 | - private $_encryptionKey = null; |
|
2550 | - private $_hashAlgorithm = 'sha1'; |
|
2551 | - private $_cryptAlgorithm = 'rijndael-256'; |
|
2546 | + const STATE_VALIDATION_KEY='prado:securitymanager:validationkey'; |
|
2547 | + const STATE_ENCRYPTION_KEY='prado:securitymanager:encryptionkey'; |
|
2548 | + private $_validationKey=null; |
|
2549 | + private $_encryptionKey=null; |
|
2550 | + private $_hashAlgorithm='sha1'; |
|
2551 | + private $_cryptAlgorithm='rijndael-256'; |
|
2552 | 2552 | private $_mbstring; |
2553 | 2553 | public function init($config) |
2554 | 2554 | { |
@@ -2557,13 +2557,13 @@ discard block |
||
2557 | 2557 | } |
2558 | 2558 | protected function generateRandomKey() |
2559 | 2559 | { |
2560 | - return sprintf('%08x%08x%08x%08x',mt_rand(),mt_rand(),mt_rand(),mt_rand()); |
|
2560 | + return sprintf('%08x%08x%08x%08x', mt_rand(), mt_rand(), mt_rand(), mt_rand()); |
|
2561 | 2561 | } |
2562 | 2562 | public function getValidationKey() |
2563 | 2563 | { |
2564 | - if(null === $this->_validationKey) { |
|
2565 | - if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
2566 | - $this->_validationKey = $this->generateRandomKey(); |
|
2564 | + if(null===$this->_validationKey) { |
|
2565 | + if(null===($this->_validationKey=$this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
2566 | + $this->_validationKey=$this->generateRandomKey(); |
|
2567 | 2567 | $this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true); |
2568 | 2568 | } |
2569 | 2569 | } |
@@ -2571,15 +2571,15 @@ discard block |
||
2571 | 2571 | } |
2572 | 2572 | public function setValidationKey($value) |
2573 | 2573 | { |
2574 | - if('' === $value) |
|
2574 | + if(''===$value) |
|
2575 | 2575 | throw new TInvalidDataValueException('securitymanager_validationkey_invalid'); |
2576 | - $this->_validationKey = $value; |
|
2576 | + $this->_validationKey=$value; |
|
2577 | 2577 | } |
2578 | 2578 | public function getEncryptionKey() |
2579 | 2579 | { |
2580 | - if(null === $this->_encryptionKey) { |
|
2581 | - if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
2582 | - $this->_encryptionKey = $this->generateRandomKey(); |
|
2580 | + if(null===$this->_encryptionKey) { |
|
2581 | + if(null===($this->_encryptionKey=$this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
2582 | + $this->_encryptionKey=$this->generateRandomKey(); |
|
2583 | 2583 | $this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true); |
2584 | 2584 | } |
2585 | 2585 | } |
@@ -2587,9 +2587,9 @@ discard block |
||
2587 | 2587 | } |
2588 | 2588 | public function setEncryptionKey($value) |
2589 | 2589 | { |
2590 | - if('' === $value) |
|
2590 | + if(''===$value) |
|
2591 | 2591 | throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid'); |
2592 | - $this->_encryptionKey = $value; |
|
2592 | + $this->_encryptionKey=$value; |
|
2593 | 2593 | } |
2594 | 2594 | public function getValidation() |
2595 | 2595 | { |
@@ -2601,11 +2601,11 @@ discard block |
||
2601 | 2601 | } |
2602 | 2602 | public function setValidation($value) |
2603 | 2603 | { |
2604 | - $this->_hashAlgorithm = TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode'); |
|
2604 | + $this->_hashAlgorithm=TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode'); |
|
2605 | 2605 | } |
2606 | 2606 | public function setHashAlgorithm($value) |
2607 | 2607 | { |
2608 | - $this->_hashAlgorithm = TPropertyValue::ensureString($value); |
|
2608 | + $this->_hashAlgorithm=TPropertyValue::ensureString($value); |
|
2609 | 2609 | } |
2610 | 2610 | public function getEncryption() |
2611 | 2611 | { |
@@ -2615,7 +2615,7 @@ discard block |
||
2615 | 2615 | } |
2616 | 2616 | public function setEncryption($value) |
2617 | 2617 | { |
2618 | - $this->_cryptAlgorithm = $value; |
|
2618 | + $this->_cryptAlgorithm=$value; |
|
2619 | 2619 | } |
2620 | 2620 | public function getCryptAlgorithm() |
2621 | 2621 | { |
@@ -2623,16 +2623,16 @@ discard block |
||
2623 | 2623 | } |
2624 | 2624 | public function setCryptAlgorithm($value) |
2625 | 2625 | { |
2626 | - $this->_cryptAlgorithm = $value; |
|
2626 | + $this->_cryptAlgorithm=$value; |
|
2627 | 2627 | } |
2628 | 2628 | public function encrypt($data) |
2629 | 2629 | { |
2630 | 2630 | $module=$this->openCryptModule(); |
2631 | - $key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
2631 | + $key=$this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
2632 | 2632 | srand(); |
2633 | - $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND); |
|
2633 | + $iv=mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND); |
|
2634 | 2634 | mcrypt_generic_init($module, $key, $iv); |
2635 | - $encrypted = $iv.mcrypt_generic($module, $data); |
|
2635 | + $encrypted=$iv.mcrypt_generic($module, $data); |
|
2636 | 2636 | mcrypt_generic_deinit($module); |
2637 | 2637 | mcrypt_module_close($module); |
2638 | 2638 | return $encrypted; |
@@ -2640,11 +2640,11 @@ discard block |
||
2640 | 2640 | public function decrypt($data) |
2641 | 2641 | { |
2642 | 2642 | $module=$this->openCryptModule(); |
2643 | - $key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
2644 | - $ivSize = mcrypt_enc_get_iv_size($module); |
|
2645 | - $iv = $this->substr($data, 0, $ivSize); |
|
2643 | + $key=$this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
2644 | + $ivSize=mcrypt_enc_get_iv_size($module); |
|
2645 | + $iv=$this->substr($data, 0, $ivSize); |
|
2646 | 2646 | mcrypt_generic_init($module, $key, $iv); |
2647 | - $decrypted = mdecrypt_generic($module, $this->substr($data, $ivSize, $this->strlen($data))); |
|
2647 | + $decrypted=mdecrypt_generic($module, $this->substr($data, $ivSize, $this->strlen($data))); |
|
2648 | 2648 | mcrypt_generic_deinit($module); |
2649 | 2649 | mcrypt_module_close($module); |
2650 | 2650 | return $decrypted; |
@@ -2654,9 +2654,9 @@ discard block |
||
2654 | 2654 | if(extension_loaded('mcrypt')) |
2655 | 2655 | { |
2656 | 2656 | if(is_array($this->_cryptAlgorithm)) |
2657 | - $module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm); |
|
2657 | + $module=@call_user_func_array('mcrypt_module_open', $this->_cryptAlgorithm); |
|
2658 | 2658 | else |
2659 | - $module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,''); |
|
2659 | + $module=@mcrypt_module_open($this->_cryptAlgorithm, '', MCRYPT_MODE_CBC, ''); |
|
2660 | 2660 | if($module===false) |
2661 | 2661 | throw new TNotSupportedException('securitymanager_mcryptextension_initfailed'); |
2662 | 2662 | return $module; |
@@ -2666,7 +2666,7 @@ discard block |
||
2666 | 2666 | } |
2667 | 2667 | public function hashData($data) |
2668 | 2668 | { |
2669 | - $hmac = $this->computeHMAC($data); |
|
2669 | + $hmac=$this->computeHMAC($data); |
|
2670 | 2670 | return $hmac.$data; |
2671 | 2671 | } |
2672 | 2672 | public function validateData($data) |
@@ -2674,56 +2674,56 @@ discard block |
||
2674 | 2674 | $len=$this->strlen($this->computeHMAC('test')); |
2675 | 2675 | if($this->strlen($data) < $len) |
2676 | 2676 | return false; |
2677 | - $hmac = $this->substr($data, 0, $len); |
|
2677 | + $hmac=$this->substr($data, 0, $len); |
|
2678 | 2678 | $data2=$this->substr($data, $len, $this->strlen($data)); |
2679 | - return $hmac === $this->computeHMAC($data2) ? $data2 : false; |
|
2679 | + return $hmac===$this->computeHMAC($data2) ? $data2 : false; |
|
2680 | 2680 | } |
2681 | 2681 | protected function computeHMAC($data) |
2682 | 2682 | { |
2683 | - $key = $this->getValidationKey(); |
|
2683 | + $key=$this->getValidationKey(); |
|
2684 | 2684 | if(function_exists('hash_hmac')) |
2685 | 2685 | return hash_hmac($this->_hashAlgorithm, $data, $key); |
2686 | - if(!strcasecmp($this->_hashAlgorithm,'sha1')) |
|
2686 | + if(!strcasecmp($this->_hashAlgorithm, 'sha1')) |
|
2687 | 2687 | { |
2688 | - $pack = 'H40'; |
|
2689 | - $func = 'sha1'; |
|
2688 | + $pack='H40'; |
|
2689 | + $func='sha1'; |
|
2690 | 2690 | } else { |
2691 | - $pack = 'H32'; |
|
2692 | - $func = 'md5'; |
|
2691 | + $pack='H32'; |
|
2692 | + $func='md5'; |
|
2693 | 2693 | } |
2694 | - $key = str_pad($func($key), 64, chr(0)); |
|
2695 | - return $func((str_repeat(chr(0x5C), 64) ^ substr($key, 0, 64)) . pack($pack, $func((str_repeat(chr(0x36), 64) ^ substr($key, 0, 64)) . $data))); |
|
2694 | + $key=str_pad($func($key), 64, chr(0)); |
|
2695 | + return $func((str_repeat(chr(0x5C), 64) ^ substr($key, 0, 64)).pack($pack, $func((str_repeat(chr(0x36), 64) ^ substr($key, 0, 64)).$data))); |
|
2696 | 2696 | } |
2697 | 2697 | private function strlen($string) |
2698 | 2698 | { |
2699 | - return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string); |
|
2699 | + return $this->_mbstring ? mb_strlen($string, '8bit') : strlen($string); |
|
2700 | 2700 | } |
2701 | - private function substr($string,$start,$length) |
|
2701 | + private function substr($string, $start, $length) |
|
2702 | 2702 | { |
2703 | - return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length); |
|
2703 | + return $this->_mbstring ? mb_substr($string, $start, $length, '8bit') : substr($string, $start, $length); |
|
2704 | 2704 | } |
2705 | 2705 | } |
2706 | 2706 | class TSecurityManagerValidationMode extends TEnumerable |
2707 | 2707 | { |
2708 | - const MD5 = 'MD5'; |
|
2709 | - const SHA1 = 'SHA1'; |
|
2708 | + const MD5='MD5'; |
|
2709 | + const SHA1='SHA1'; |
|
2710 | 2710 | } |
2711 | 2711 | class THttpUtility |
2712 | 2712 | { |
2713 | - private static $_encodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
2714 | - private static $_decodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
2715 | - private static $_stripTable=array('<'=>'','>'=>'','"'=>''); |
|
2713 | + private static $_encodeTable=array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
2714 | + private static $_decodeTable=array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
2715 | + private static $_stripTable=array('<'=>'', '>'=>'', '"'=>''); |
|
2716 | 2716 | public static function htmlEncode($s) |
2717 | 2717 | { |
2718 | - return strtr($s,self::$_encodeTable); |
|
2718 | + return strtr($s, self::$_encodeTable); |
|
2719 | 2719 | } |
2720 | 2720 | public static function htmlDecode($s) |
2721 | 2721 | { |
2722 | - return strtr($s,self::$_decodeTable); |
|
2722 | + return strtr($s, self::$_decodeTable); |
|
2723 | 2723 | } |
2724 | 2724 | public static function htmlStrip($s) |
2725 | 2725 | { |
2726 | - return strtr($s,self::$_stripTable); |
|
2726 | + return strtr($s, self::$_stripTable); |
|
2727 | 2727 | } |
2728 | 2728 | } |
2729 | 2729 | class TJavaScript |
@@ -2732,7 +2732,7 @@ discard block |
||
2732 | 2732 | { |
2733 | 2733 | $str=''; |
2734 | 2734 | foreach($files as $file) |
2735 | - $str.= self::renderScriptFile($file); |
|
2735 | + $str.=self::renderScriptFile($file); |
|
2736 | 2736 | return $str; |
2737 | 2737 | } |
2738 | 2738 | public static function renderScriptFile($file) |
@@ -2742,14 +2742,14 @@ discard block |
||
2742 | 2742 | public static function renderScriptBlocks($scripts) |
2743 | 2743 | { |
2744 | 2744 | if(count($scripts)) |
2745 | - return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n",$scripts)."\n/*]]>*/\n</script>\n"; |
|
2745 | + return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n", $scripts)."\n/*]]>*/\n</script>\n"; |
|
2746 | 2746 | else |
2747 | 2747 | return ''; |
2748 | 2748 | } |
2749 | 2749 | public static function renderScriptBlocksCallback($scripts) |
2750 | 2750 | { |
2751 | 2751 | if(count($scripts)) |
2752 | - return implode("\n",$scripts)."\n"; |
|
2752 | + return implode("\n", $scripts)."\n"; |
|
2753 | 2753 | else |
2754 | 2754 | return ''; |
2755 | 2755 | } |
@@ -2759,7 +2759,7 @@ discard block |
||
2759 | 2759 | } |
2760 | 2760 | public static function quoteString($js) |
2761 | 2761 | { |
2762 | - return self::jsonEncode($js,JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
2762 | + return self::jsonEncode($js, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
2763 | 2763 | } |
2764 | 2764 | public static function quoteJsLiteral($js) |
2765 | 2765 | { |
@@ -2780,16 +2780,16 @@ discard block |
||
2780 | 2780 | { |
2781 | 2781 | return self::isJsLiteral($js); |
2782 | 2782 | } |
2783 | - public static function encode($value,$toMap=true,$encodeEmptyStrings=false) |
|
2783 | + public static function encode($value, $toMap=true, $encodeEmptyStrings=false) |
|
2784 | 2784 | { |
2785 | 2785 | if(is_string($value)) |
2786 | 2786 | return self::quoteString($value); |
2787 | 2787 | else if(is_bool($value)) |
2788 | - return $value?'true':'false'; |
|
2788 | + return $value ? 'true' : 'false'; |
|
2789 | 2789 | else if(is_array($value)) |
2790 | 2790 | { |
2791 | 2791 | $results=''; |
2792 | - if(($n=count($value))>0 && array_keys($value)!==range(0,$n-1)) |
|
2792 | + if(($n=count($value)) > 0 && array_keys($value)!==range(0, $n - 1)) |
|
2793 | 2793 | { |
2794 | 2794 | foreach($value as $k=>$v) |
2795 | 2795 | { |
@@ -2797,7 +2797,7 @@ discard block |
||
2797 | 2797 | { |
2798 | 2798 | if($results!=='') |
2799 | 2799 | $results.=','; |
2800 | - $results.="'$k':".self::encode($v,$toMap,$encodeEmptyStrings); |
|
2800 | + $results.="'$k':".self::encode($v, $toMap, $encodeEmptyStrings); |
|
2801 | 2801 | } |
2802 | 2802 | } |
2803 | 2803 | return '{'.$results.'}'; |
@@ -2810,7 +2810,7 @@ discard block |
||
2810 | 2810 | { |
2811 | 2811 | if($results!=='') |
2812 | 2812 | $results.=','; |
2813 | - $results.=self::encode($v,$toMap, $encodeEmptyStrings); |
|
2813 | + $results.=self::encode($v, $toMap, $encodeEmptyStrings); |
|
2814 | 2814 | } |
2815 | 2815 | } |
2816 | 2816 | return '['.$results.']'; |
@@ -2838,64 +2838,64 @@ discard block |
||
2838 | 2838 | } |
2839 | 2839 | } |
2840 | 2840 | else if(is_object($value)) |
2841 | - if ($value instanceof TJavaScriptLiteral) |
|
2841 | + if($value instanceof TJavaScriptLiteral) |
|
2842 | 2842 | return $value->toJavaScriptLiteral(); |
2843 | 2843 | else |
2844 | - return self::encode(get_object_vars($value),$toMap); |
|
2844 | + return self::encode(get_object_vars($value), $toMap); |
|
2845 | 2845 | else if($value===null) |
2846 | 2846 | return 'null'; |
2847 | 2847 | else |
2848 | 2848 | return ''; |
2849 | 2849 | } |
2850 | - public static function jsonEncode($value, $options = 0) |
|
2850 | + public static function jsonEncode($value, $options=0) |
|
2851 | 2851 | { |
2852 | - if (($g=Prado::getApplication()->getGlobalization(false))!==null && |
|
2852 | + if(($g=Prado::getApplication()->getGlobalization(false))!==null && |
|
2853 | 2853 | strtoupper($enc=$g->getCharset())!='UTF-8') { |
2854 | 2854 | self::convertToUtf8($value, $enc); |
2855 | 2855 | } |
2856 | - $s = @json_encode($value,$options); |
|
2856 | + $s=@json_encode($value, $options); |
|
2857 | 2857 | self::checkJsonError(); |
2858 | 2858 | return $s; |
2859 | 2859 | } |
2860 | 2860 | private static function convertToUtf8(&$value, $sourceEncoding) { |
2861 | 2861 | if(is_string($value)) |
2862 | 2862 | $value=iconv($sourceEncoding, 'UTF-8', $value); |
2863 | - else if (is_array($value)) |
|
2863 | + else if(is_array($value)) |
|
2864 | 2864 | { |
2865 | 2865 | foreach($value as &$element) |
2866 | 2866 | self::convertToUtf8($element, $sourceEncoding); |
2867 | 2867 | } |
2868 | 2868 | } |
2869 | - public static function jsonDecode($value, $assoc = false, $depth = 512) |
|
2869 | + public static function jsonDecode($value, $assoc=false, $depth=512) |
|
2870 | 2870 | { |
2871 | - $s= @json_decode($value, $assoc, $depth); |
|
2871 | + $s=@json_decode($value, $assoc, $depth); |
|
2872 | 2872 | self::checkJsonError(); |
2873 | 2873 | return $s; |
2874 | 2874 | } |
2875 | 2875 | private static function checkJsonError() |
2876 | 2876 | { |
2877 | - switch ($err = json_last_error()) |
|
2877 | + switch($err=json_last_error()) |
|
2878 | 2878 | { |
2879 | 2879 | case JSON_ERROR_NONE: |
2880 | 2880 | return; |
2881 | 2881 | break; |
2882 | 2882 | case JSON_ERROR_DEPTH: |
2883 | - $msg = 'Maximum stack depth exceeded'; |
|
2883 | + $msg='Maximum stack depth exceeded'; |
|
2884 | 2884 | break; |
2885 | 2885 | case JSON_ERROR_STATE_MISMATCH: |
2886 | - $msg = 'Underflow or the modes mismatch'; |
|
2886 | + $msg='Underflow or the modes mismatch'; |
|
2887 | 2887 | break; |
2888 | 2888 | case JSON_ERROR_CTRL_CHAR: |
2889 | - $msg = 'Unexpected control character found'; |
|
2889 | + $msg='Unexpected control character found'; |
|
2890 | 2890 | break; |
2891 | 2891 | case JSON_ERROR_SYNTAX: |
2892 | - $msg = 'Syntax error, malformed JSON'; |
|
2892 | + $msg='Syntax error, malformed JSON'; |
|
2893 | 2893 | break; |
2894 | 2894 | case JSON_ERROR_UTF8: |
2895 | - $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded'; |
|
2895 | + $msg='Malformed UTF-8 characters, possibly incorrectly encoded'; |
|
2896 | 2896 | break; |
2897 | 2897 | default: |
2898 | - $msg = 'Unknown error'; |
|
2898 | + $msg='Unknown error'; |
|
2899 | 2899 | break; |
2900 | 2900 | } |
2901 | 2901 | throw new Exception("JSON error ($err): $msg"); |
@@ -2908,10 +2908,10 @@ discard block |
||
2908 | 2908 | } |
2909 | 2909 | class TUrlManager extends TModule |
2910 | 2910 | { |
2911 | - public function constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems) |
|
2911 | + public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems) |
|
2912 | 2912 | { |
2913 | 2913 | $url=$serviceID.'='.urlencode($serviceParam); |
2914 | - $amp=$encodeAmpersand?'&':'&'; |
|
2914 | + $amp=$encodeAmpersand ? '&' : '&'; |
|
2915 | 2915 | $request=$this->getRequest(); |
2916 | 2916 | if(is_array($getItems) || $getItems instanceof Traversable) |
2917 | 2917 | { |
@@ -2946,9 +2946,9 @@ discard block |
||
2946 | 2946 | switch($request->getUrlFormat()) |
2947 | 2947 | { |
2948 | 2948 | case THttpRequestUrlFormat::Path: |
2949 | - return $request->getApplicationUrl().'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator())); |
|
2949 | + return $request->getApplicationUrl().'/'.strtr($url, array($amp=>'/', '?'=>'/', '='=>$request->getUrlParamSeparator())); |
|
2950 | 2950 | case THttpRequestUrlFormat::HiddenPath: |
2951 | - return rtrim(dirname($request->getApplicationUrl()), '/').'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator())); |
|
2951 | + return rtrim(dirname($request->getApplicationUrl()), '/').'/'.strtr($url, array($amp=>'/', '?'=>'/', '='=>$request->getUrlParamSeparator())); |
|
2952 | 2952 | default: |
2953 | 2953 | return $request->getApplicationUrl().'?'.$url; |
2954 | 2954 | } |
@@ -2956,24 +2956,24 @@ discard block |
||
2956 | 2956 | public function parseUrl() |
2957 | 2957 | { |
2958 | 2958 | $request=$this->getRequest(); |
2959 | - $pathInfo=trim($request->getPathInfo(),'/'); |
|
2959 | + $pathInfo=trim($request->getPathInfo(), '/'); |
|
2960 | 2960 | if(($request->getUrlFormat()===THttpRequestUrlFormat::Path || |
2961 | 2961 | $request->getUrlFormat()===THttpRequestUrlFormat::HiddenPath) && |
2962 | 2962 | $pathInfo!=='') |
2963 | 2963 | { |
2964 | 2964 | $separator=$request->getUrlParamSeparator(); |
2965 | - $paths=explode('/',$pathInfo); |
|
2965 | + $paths=explode('/', $pathInfo); |
|
2966 | 2966 | $getVariables=array(); |
2967 | 2967 | foreach($paths as $path) |
2968 | 2968 | { |
2969 | 2969 | if(($path=trim($path))!=='') |
2970 | 2970 | { |
2971 | - if(($pos=strpos($path,$separator))!==false) |
|
2971 | + if(($pos=strpos($path, $separator))!==false) |
|
2972 | 2972 | { |
2973 | - $name=substr($path,0,$pos); |
|
2974 | - $value=substr($path,$pos+1); |
|
2975 | - if(($pos=strpos($name,'[]'))!==false) |
|
2976 | - $getVariables[substr($name,0,$pos)][]=$value; |
|
2973 | + $name=substr($path, 0, $pos); |
|
2974 | + $value=substr($path, $pos + 1); |
|
2975 | + if(($pos=strpos($name, '[]'))!==false) |
|
2976 | + $getVariables[substr($name, 0, $pos)][]=$value; |
|
2977 | 2977 | else |
2978 | 2978 | $getVariables[$name]=$value; |
2979 | 2979 | } |
@@ -2987,10 +2987,10 @@ discard block |
||
2987 | 2987 | return array(); |
2988 | 2988 | } |
2989 | 2989 | } |
2990 | -class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
2990 | +class THttpRequest extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
2991 | 2991 | { |
2992 | - const CGIFIX__PATH_INFO = 1; |
|
2993 | - const CGIFIX__SCRIPT_NAME = 2; |
|
2992 | + const CGIFIX__PATH_INFO=1; |
|
2993 | + const CGIFIX__SCRIPT_NAME=2; |
|
2994 | 2994 | private $_urlManager=null; |
2995 | 2995 | private $_urlManagerID=''; |
2996 | 2996 | private $_separator=','; |
@@ -3029,13 +3029,13 @@ discard block |
||
3029 | 3029 | } |
3030 | 3030 | if(isset($_SERVER['REQUEST_URI'])) |
3031 | 3031 | $this->_requestUri=$_SERVER['REQUEST_URI']; |
3032 | - else $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']); |
|
3033 | - if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
3032 | + else $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING']) ? '' : '?'.$_SERVER['QUERY_STRING']); |
|
3033 | + if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
3034 | 3034 | $this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
3035 | 3035 | elseif(isset($_SERVER['PATH_INFO'])) |
3036 | 3036 | $this->_pathInfo=$_SERVER['PATH_INFO']; |
3037 | - else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
3038 | - $this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])); |
|
3037 | + else if(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
3038 | + $this->_pathInfo=substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
3039 | 3039 | else |
3040 | 3040 | $this->_pathInfo=''; |
3041 | 3041 | if(get_magic_quotes_gpc()) |
@@ -3053,14 +3053,14 @@ discard block |
||
3053 | 3053 | } |
3054 | 3054 | public function stripSlashes(&$data) |
3055 | 3055 | { |
3056 | - return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); |
|
3056 | + return is_array($data) ? array_map(array($this, 'stripSlashes'), $data) : stripslashes($data); |
|
3057 | 3057 | } |
3058 | 3058 | public function getUrl() |
3059 | 3059 | { |
3060 | 3060 | if($this->_url===null) |
3061 | 3061 | { |
3062 | 3062 | $secure=$this->getIsSecureConnection(); |
3063 | - $url=$secure?'https://':'http://'; |
|
3063 | + $url=$secure ? 'https://' : 'http://'; |
|
3064 | 3064 | if(empty($_SERVER['HTTP_HOST'])) |
3065 | 3065 | { |
3066 | 3066 | $url.=$_SERVER['SERVER_NAME']; |
@@ -3077,7 +3077,7 @@ discard block |
||
3077 | 3077 | } |
3078 | 3078 | public function setEnableCache($value) |
3079 | 3079 | { |
3080 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
3080 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
3081 | 3081 | } |
3082 | 3082 | public function getEnableCache() |
3083 | 3083 | { |
@@ -3091,15 +3091,15 @@ discard block |
||
3091 | 3091 | { |
3092 | 3092 | if($this->getEnableCache()) |
3093 | 3093 | { |
3094 | - $cache = $this->getApplication()->getCache(); |
|
3095 | - if($cache !== null) |
|
3094 | + $cache=$this->getApplication()->getCache(); |
|
3095 | + if($cache!==null) |
|
3096 | 3096 | { |
3097 | - $dependencies = null; |
|
3098 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
3099 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
3097 | + $dependencies=null; |
|
3098 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
3099 | + if($manager instanceof TUrlMapping && $fn=$manager->getConfigFile()) |
|
3100 | 3100 | { |
3101 | - $fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt()); |
|
3102 | - $dependencies = new TFileCacheDependency($fn); |
|
3101 | + $fn=Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
|
3102 | + $dependencies=new TFileCacheDependency($fn); |
|
3103 | 3103 | } |
3104 | 3104 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
3105 | 3105 | } |
@@ -3110,10 +3110,10 @@ discard block |
||
3110 | 3110 | { |
3111 | 3111 | if($this->getEnableCache()) |
3112 | 3112 | { |
3113 | - $cache = $this->getApplication()->getCache(); |
|
3114 | - if($cache !== null) |
|
3113 | + $cache=$this->getApplication()->getCache(); |
|
3114 | + if($cache!==null) |
|
3115 | 3115 | { |
3116 | - $manager = $cache->get($this->getCacheKey()); |
|
3116 | + $manager=$cache->get($this->getCacheKey()); |
|
3117 | 3117 | if($manager instanceof TUrlManager) |
3118 | 3118 | return $manager; |
3119 | 3119 | } |
@@ -3132,7 +3132,7 @@ discard block |
||
3132 | 3132 | { |
3133 | 3133 | if($this->_urlManager===null) |
3134 | 3134 | { |
3135 | - if(($this->_urlManager = $this->loadCachedUrlManager())===null) |
|
3135 | + if(($this->_urlManager=$this->loadCachedUrlManager())===null) |
|
3136 | 3136 | { |
3137 | 3137 | if(empty($this->_urlManagerID)) |
3138 | 3138 | { |
@@ -3143,9 +3143,9 @@ discard block |
||
3143 | 3143 | { |
3144 | 3144 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
3145 | 3145 | if($this->_urlManager===null) |
3146 | - throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); |
|
3146 | + throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
3147 | 3147 | if(!($this->_urlManager instanceof TUrlManager)) |
3148 | - throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); |
|
3148 | + throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
3149 | 3149 | } |
3150 | 3150 | $this->cacheUrlManager($this->_urlManager); |
3151 | 3151 | } |
@@ -3158,7 +3158,7 @@ discard block |
||
3158 | 3158 | } |
3159 | 3159 | public function setUrlFormat($value) |
3160 | 3160 | { |
3161 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); |
|
3161 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat'); |
|
3162 | 3162 | } |
3163 | 3163 | public function getUrlParamSeparator() |
3164 | 3164 | { |
@@ -3173,19 +3173,19 @@ discard block |
||
3173 | 3173 | } |
3174 | 3174 | public function getRequestType() |
3175 | 3175 | { |
3176 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
3176 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
3177 | 3177 | } |
3178 | - public function getContentType($mimetypeOnly = true) |
|
3178 | + public function getContentType($mimetypeOnly=true) |
|
3179 | 3179 | { |
3180 | 3180 | if(!isset($_SERVER['CONTENT_TYPE'])) |
3181 | 3181 | return null; |
3182 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
3182 | + if($mimetypeOnly===true && ($_pos=strpos(';', $_SERVER['CONTENT_TYPE']))!==false) |
|
3183 | 3183 | return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
3184 | 3184 | return $_SERVER['CONTENT_TYPE']; |
3185 | 3185 | } |
3186 | 3186 | public function getIsSecureConnection() |
3187 | 3187 | { |
3188 | - return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); |
|
3188 | + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off'); |
|
3189 | 3189 | } |
3190 | 3190 | public function getPathInfo() |
3191 | 3191 | { |
@@ -3193,27 +3193,27 @@ discard block |
||
3193 | 3193 | } |
3194 | 3194 | public function getQueryString() |
3195 | 3195 | { |
3196 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
3196 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
3197 | 3197 | } |
3198 | 3198 | public function getHttpProtocolVersion() |
3199 | 3199 | { |
3200 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
3200 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
3201 | 3201 | } |
3202 | 3202 | public function getHeaders($case=null) |
3203 | 3203 | { |
3204 | 3204 | static $result; |
3205 | - if($result === null && function_exists('apache_request_headers')) { |
|
3206 | - $result = apache_request_headers(); |
|
3205 | + if($result===null && function_exists('apache_request_headers')) { |
|
3206 | + $result=apache_request_headers(); |
|
3207 | 3207 | } |
3208 | - elseif($result === null) { |
|
3209 | - $result = array(); |
|
3208 | + elseif($result===null) { |
|
3209 | + $result=array(); |
|
3210 | 3210 | foreach($_SERVER as $key=>$value) { |
3211 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
3212 | - $key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5))))); |
|
3213 | - $result[$key] = $value; |
|
3211 | + if(strncasecmp($key, 'HTTP_', 5)!==0) continue; |
|
3212 | + $key=str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
|
3213 | + $result[$key]=$value; |
|
3214 | 3214 | } |
3215 | 3215 | } |
3216 | - if($case !== null) |
|
3216 | + if($case!==null) |
|
3217 | 3217 | return array_change_key_case($result, $case); |
3218 | 3218 | return $result; |
3219 | 3219 | } |
@@ -3224,40 +3224,40 @@ discard block |
||
3224 | 3224 | public function getBaseUrl($forceSecureConnection=null) |
3225 | 3225 | { |
3226 | 3226 | $url=$this->getUrl(); |
3227 | - $scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
3227 | + $scheme=($forceSecureConnection) ? "https" : (($forceSecureConnection===null) ? $url->getScheme() : 'http'); |
|
3228 | 3228 | $host=$url->getHost(); |
3229 | - if (($port=$url->getPort())) $host.=':'.$port; |
|
3229 | + if(($port=$url->getPort())) $host.=':'.$port; |
|
3230 | 3230 | return $scheme.'://'.$host; |
3231 | 3231 | } |
3232 | 3232 | public function getApplicationUrl() |
3233 | 3233 | { |
3234 | - if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
3234 | + if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
3235 | 3235 | return $_SERVER['ORIG_SCRIPT_NAME']; |
3236 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
3236 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
3237 | 3237 | } |
3238 | 3238 | public function getAbsoluteApplicationUrl($forceSecureConnection=null) |
3239 | 3239 | { |
3240 | - return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); |
|
3240 | + return $this->getBaseUrl($forceSecureConnection).$this->getApplicationUrl(); |
|
3241 | 3241 | } |
3242 | 3242 | public function getApplicationFilePath() |
3243 | 3243 | { |
3244 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
3244 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
3245 | 3245 | } |
3246 | 3246 | public function getServerName() |
3247 | 3247 | { |
3248 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
3248 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
3249 | 3249 | } |
3250 | 3250 | public function getServerSoftware() |
3251 | 3251 | { |
3252 | - return isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:null; |
|
3252 | + return isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null; |
|
3253 | 3253 | } |
3254 | 3254 | public function getServerPort() |
3255 | 3255 | { |
3256 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
3256 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
3257 | 3257 | } |
3258 | 3258 | public function getUrlReferrer() |
3259 | 3259 | { |
3260 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
3260 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
3261 | 3261 | } |
3262 | 3262 | public function getBrowser() |
3263 | 3263 | { |
@@ -3272,19 +3272,19 @@ discard block |
||
3272 | 3272 | } |
3273 | 3273 | public function getUserAgent() |
3274 | 3274 | { |
3275 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
3275 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
3276 | 3276 | } |
3277 | 3277 | public function getUserHostAddress() |
3278 | 3278 | { |
3279 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
3279 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
3280 | 3280 | } |
3281 | 3281 | public function getUserHost() |
3282 | 3282 | { |
3283 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
3283 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
3284 | 3284 | } |
3285 | 3285 | public function getAcceptTypes() |
3286 | 3286 | { |
3287 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
3287 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
3288 | 3288 | } |
3289 | 3289 | public function getUserLanguages() |
3290 | 3290 | { |
@@ -3317,13 +3317,13 @@ discard block |
||
3317 | 3317 | foreach($_COOKIE as $key=>$value) |
3318 | 3318 | { |
3319 | 3319 | if(($value=$sm->validateData($value))!==false) |
3320 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
3320 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
3321 | 3321 | } |
3322 | 3322 | } |
3323 | 3323 | else |
3324 | 3324 | { |
3325 | 3325 | foreach($_COOKIE as $key=>$value) |
3326 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
3326 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
3327 | 3327 | } |
3328 | 3328 | } |
3329 | 3329 | return $this->_cookies; |
@@ -3340,13 +3340,13 @@ discard block |
||
3340 | 3340 | { |
3341 | 3341 | return $_ENV; |
3342 | 3342 | } |
3343 | - public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
3343 | + public function constructUrl($serviceID, $serviceParam, $getItems=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
3344 | 3344 | { |
3345 | - if ($this->_cookieOnly===null) |
|
3346 | - $this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
3347 | - $url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
3348 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
3349 | - return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
3345 | + if($this->_cookieOnly===null) |
|
3346 | + $this->_cookieOnly=(int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
3347 | + $url=$this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
3348 | + if(defined('SID') && SID!='' && !$this->_cookieOnly) |
|
3349 | + return $url.(strpos($url, '?')===false ? '?' : ($encodeAmpersand ? '&' : '&')).SID; |
|
3350 | 3350 | else |
3351 | 3351 | return $url; |
3352 | 3352 | } |
@@ -3359,7 +3359,7 @@ discard block |
||
3359 | 3359 | $getParams=$this->parseUrl(); |
3360 | 3360 | foreach($getParams as $name=>$value) |
3361 | 3361 | $_GET[$name]=$value; |
3362 | - $this->_items=array_merge($_GET,$_POST); |
|
3362 | + $this->_items=array_merge($_GET, $_POST); |
|
3363 | 3363 | $this->_requestResolved=true; |
3364 | 3364 | foreach($serviceIDs as $serviceID) |
3365 | 3365 | { |
@@ -3412,13 +3412,13 @@ discard block |
||
3412 | 3412 | { |
3413 | 3413 | return isset($this->_items[$key]) ? $this->_items[$key] : null; |
3414 | 3414 | } |
3415 | - public function add($key,$value) |
|
3415 | + public function add($key, $value) |
|
3416 | 3416 | { |
3417 | 3417 | $this->_items[$key]=$value; |
3418 | 3418 | } |
3419 | 3419 | public function remove($key) |
3420 | 3420 | { |
3421 | - if(isset($this->_items[$key]) || array_key_exists($key,$this->_items)) |
|
3421 | + if(isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
3422 | 3422 | { |
3423 | 3423 | $value=$this->_items[$key]; |
3424 | 3424 | unset($this->_items[$key]); |
@@ -3434,7 +3434,7 @@ discard block |
||
3434 | 3434 | } |
3435 | 3435 | public function contains($key) |
3436 | 3436 | { |
3437 | - return isset($this->_items[$key]) || array_key_exists($key,$this->_items); |
|
3437 | + return isset($this->_items[$key]) || array_key_exists($key, $this->_items); |
|
3438 | 3438 | } |
3439 | 3439 | public function toArray() |
3440 | 3440 | { |
@@ -3448,9 +3448,9 @@ discard block |
||
3448 | 3448 | { |
3449 | 3449 | return $this->itemAt($offset); |
3450 | 3450 | } |
3451 | - public function offsetSet($offset,$item) |
|
3451 | + public function offsetSet($offset, $item) |
|
3452 | 3452 | { |
3453 | - $this->add($offset,$item); |
|
3453 | + $this->add($offset, $item); |
|
3454 | 3454 | } |
3455 | 3455 | public function offsetUnset($offset) |
3456 | 3456 | { |
@@ -3464,11 +3464,11 @@ discard block |
||
3464 | 3464 | { |
3465 | 3465 | $this->_o=$owner; |
3466 | 3466 | } |
3467 | - public function insertAt($index,$item) |
|
3467 | + public function insertAt($index, $item) |
|
3468 | 3468 | { |
3469 | 3469 | if($item instanceof THttpCookie) |
3470 | 3470 | { |
3471 | - parent::insertAt($index,$item); |
|
3471 | + parent::insertAt($index, $item); |
|
3472 | 3472 | if($this->_o instanceof THttpResponse) |
3473 | 3473 | $this->_o->addCookie($item); |
3474 | 3474 | } |
@@ -3506,7 +3506,7 @@ discard block |
||
3506 | 3506 | private $_path='/'; |
3507 | 3507 | private $_secure=false; |
3508 | 3508 | private $_httpOnly=false; |
3509 | - public function __construct($name,$value) |
|
3509 | + public function __construct($name, $value) |
|
3510 | 3510 | { |
3511 | 3511 | $this->_name=$name; |
3512 | 3512 | $this->_value=$value; |
@@ -3533,7 +3533,7 @@ discard block |
||
3533 | 3533 | } |
3534 | 3534 | public function setHttpOnly($value) |
3535 | 3535 | { |
3536 | - $this->_httpOnly = TPropertyValue::ensureBoolean($value); |
|
3536 | + $this->_httpOnly=TPropertyValue::ensureBoolean($value); |
|
3537 | 3537 | } |
3538 | 3538 | public function getName() |
3539 | 3539 | { |
@@ -3593,19 +3593,19 @@ discard block |
||
3593 | 3593 | { |
3594 | 3594 | if(($ret=@parse_url($uri))!==false) |
3595 | 3595 | { |
3596 | - $this->_scheme=isset($ret['scheme'])?$ret['scheme']:''; |
|
3597 | - $this->_host=isset($ret['host'])?$ret['host']:''; |
|
3598 | - $this->_port=isset($ret['port'])?$ret['port']:''; |
|
3599 | - $this->_user=isset($ret['user'])?$ret['user']:''; |
|
3600 | - $this->_pass=isset($ret['pass'])?$ret['pass']:''; |
|
3601 | - $this->_path=isset($ret['path'])?$ret['path']:''; |
|
3602 | - $this->_query=isset($ret['query'])?$ret['query']:''; |
|
3603 | - $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
|
3596 | + $this->_scheme=isset($ret['scheme']) ? $ret['scheme'] : ''; |
|
3597 | + $this->_host=isset($ret['host']) ? $ret['host'] : ''; |
|
3598 | + $this->_port=isset($ret['port']) ? $ret['port'] : ''; |
|
3599 | + $this->_user=isset($ret['user']) ? $ret['user'] : ''; |
|
3600 | + $this->_pass=isset($ret['pass']) ? $ret['pass'] : ''; |
|
3601 | + $this->_path=isset($ret['path']) ? $ret['path'] : ''; |
|
3602 | + $this->_query=isset($ret['query']) ? $ret['query'] : ''; |
|
3603 | + $this->_fragment=isset($ret['fragment']) ? $ret['fragment'] : ''; |
|
3604 | 3604 | $this->_uri=$uri; |
3605 | 3605 | } |
3606 | 3606 | else |
3607 | 3607 | { |
3608 | - throw new TInvalidDataValueException('uri_format_invalid',$uri); |
|
3608 | + throw new TInvalidDataValueException('uri_format_invalid', $uri); |
|
3609 | 3609 | } |
3610 | 3610 | } |
3611 | 3611 | public function getUri() |
@@ -3672,14 +3672,14 @@ discard block |
||
3672 | 3672 | } |
3673 | 3673 | public function createNewHtmlWriter($type, $writer) |
3674 | 3674 | { |
3675 | - return $this->_response->createNewHtmlWriter($type,$writer); |
|
3675 | + return $this->_response->createNewHtmlWriter($type, $writer); |
|
3676 | 3676 | } |
3677 | 3677 | } |
3678 | 3678 | class THttpResponse extends TModule implements ITextWriter |
3679 | 3679 | { |
3680 | - const DEFAULT_CONTENTTYPE = 'text/html'; |
|
3681 | - const DEFAULT_CHARSET = 'UTF-8'; |
|
3682 | - private static $HTTP_STATUS_CODES = array( |
|
3680 | + const DEFAULT_CONTENTTYPE='text/html'; |
|
3681 | + const DEFAULT_CHARSET='UTF-8'; |
|
3682 | + private static $HTTP_STATUS_CODES=array( |
|
3683 | 3683 | 100 => 'Continue', 101 => 'Switching Protocols', |
3684 | 3684 | 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', |
3685 | 3685 | 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', |
@@ -3733,13 +3733,13 @@ discard block |
||
3733 | 3733 | } |
3734 | 3734 | public function setCacheControl($value) |
3735 | 3735 | { |
3736 | - session_cache_limiter(TPropertyValue::ensureEnum($value,array('none','nocache','private','private_no_expire','public'))); |
|
3736 | + session_cache_limiter(TPropertyValue::ensureEnum($value, array('none', 'nocache', 'private', 'private_no_expire', 'public'))); |
|
3737 | 3737 | } |
3738 | 3738 | public function setContentType($type) |
3739 | 3739 | { |
3740 | - if ($this->_contentTypeHeaderSent) |
|
3740 | + if($this->_contentTypeHeaderSent) |
|
3741 | 3741 | throw new Exception('Unable to alter content-type as it has been already sent'); |
3742 | - $this->_contentType = $type; |
|
3742 | + $this->_contentType=$type; |
|
3743 | 3743 | } |
3744 | 3744 | public function getContentType() |
3745 | 3745 | { |
@@ -3751,7 +3751,7 @@ discard block |
||
3751 | 3751 | } |
3752 | 3752 | public function setCharset($charset) |
3753 | 3753 | { |
3754 | - $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
|
3754 | + $this->_charset=(strToLower($charset)==='false') ? false : (string) $charset; |
|
3755 | 3755 | } |
3756 | 3756 | public function getBufferOutput() |
3757 | 3757 | { |
@@ -3770,12 +3770,12 @@ discard block |
||
3770 | 3770 | } |
3771 | 3771 | public function setStatusCode($status, $reason=null) |
3772 | 3772 | { |
3773 | - if ($this->_httpHeaderSent) |
|
3773 | + if($this->_httpHeaderSent) |
|
3774 | 3774 | throw new Exception('Unable to alter response as HTTP header already sent'); |
3775 | 3775 | $status=TPropertyValue::ensureInteger($status); |
3776 | 3776 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
3777 | 3777 | $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
3778 | - }else{ |
|
3778 | + } else { |
|
3779 | 3779 | if($reason===null || $reason==='') { |
3780 | 3780 | throw new TInvalidDataValueException("response_status_reason_missing"); |
3781 | 3781 | } |
@@ -3798,11 +3798,11 @@ discard block |
||
3798 | 3798 | } |
3799 | 3799 | public function write($str) |
3800 | 3800 | { |
3801 | - if (!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
3801 | + if(!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
3802 | 3802 | $this->ensureHeadersSent(); |
3803 | 3803 | echo $str; |
3804 | 3804 | } |
3805 | - public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$forceDownload=true,$clientFileName=null,$fileSize=null) |
|
3805 | + public function writeFile($fileName, $content=null, $mimeType=null, $headers=null, $forceDownload=true, $clientFileName=null, $fileSize=null) |
|
3806 | 3806 | { |
3807 | 3807 | static $defaultMimeTypes=array( |
3808 | 3808 | 'css'=>'text/css', |
@@ -3821,9 +3821,9 @@ discard block |
||
3821 | 3821 | $mimeType='text/plain'; |
3822 | 3822 | if(function_exists('mime_content_type')) |
3823 | 3823 | $mimeType=mime_content_type($fileName); |
3824 | - else if(($ext=strrchr($fileName,'.'))!==false) |
|
3824 | + else if(($ext=strrchr($fileName, '.'))!==false) |
|
3825 | 3825 | { |
3826 | - $ext=substr($ext,1); |
|
3826 | + $ext=substr($ext, 1); |
|
3827 | 3827 | if(isset($defaultMimeTypes[$ext])) |
3828 | 3828 | $mimeType=$defaultMimeTypes[$ext]; |
3829 | 3829 | } |
@@ -3833,7 +3833,7 @@ discard block |
||
3833 | 3833 | else |
3834 | 3834 | $clientFileName=basename($clientFileName); |
3835 | 3835 | if($fileSize===null || $fileSize < 0) |
3836 | - $fileSize = ($content===null?filesize($fileName):strlen($content)); |
|
3836 | + $fileSize=($content===null ? filesize($fileName) : strlen($content)); |
|
3837 | 3837 | $this->sendHttpHeader(); |
3838 | 3838 | if(is_array($headers)) |
3839 | 3839 | { |
@@ -3846,10 +3846,10 @@ discard block |
||
3846 | 3846 | header('Expires: 0'); |
3847 | 3847 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
3848 | 3848 | header("Content-Type: $mimeType"); |
3849 | - $this->_contentTypeHeaderSent = true; |
|
3849 | + $this->_contentTypeHeaderSent=true; |
|
3850 | 3850 | } |
3851 | 3851 | header('Content-Length: '.$fileSize); |
3852 | - header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\""); |
|
3852 | + header("Content-Disposition: ".($forceDownload ? 'attachment' : 'inline')."; filename=\"$clientFileName\""); |
|
3853 | 3853 | header('Content-Transfer-Encoding: binary'); |
3854 | 3854 | if($content===null) |
3855 | 3855 | readfile($fileName); |
@@ -3866,24 +3866,24 @@ discard block |
||
3866 | 3866 | public function httpRedirect($url) |
3867 | 3867 | { |
3868 | 3868 | $this->ensureHeadersSent(); |
3869 | - $isIIS = (stripos($this->getRequest()->getServerSoftware(), "microsoft-iis") !== false); |
|
3869 | + $isIIS=(stripos($this->getRequest()->getServerSoftware(), "microsoft-iis")!==false); |
|
3870 | 3870 | if($url[0]==='/') |
3871 | 3871 | $url=$this->getRequest()->getBaseUrl().$url; |
3872 | - if ($this->_status >= 300 && $this->_status < 400) |
|
3872 | + if($this->_status >= 300 && $this->_status < 400) |
|
3873 | 3873 | { |
3874 | 3874 | if($isIIS) |
3875 | 3875 | { |
3876 | - header('HTTP/1.1 ' . $this->_status . ' ' . self::$HTTP_STATUS_CODES[ |
|
3876 | + header('HTTP/1.1 '.$this->_status.' '.self::$HTTP_STATUS_CODES[ |
|
3877 | 3877 | array_key_exists($this->_status, self::$HTTP_STATUS_CODES) |
3878 | 3878 | ? $this->_status |
3879 | 3879 | : 302 |
3880 | 3880 | ]); |
3881 | 3881 | } |
3882 | - header('Location: '.str_replace('&','&',$url), true, $this->_status); |
|
3882 | + header('Location: '.str_replace('&', '&', $url), true, $this->_status); |
|
3883 | 3883 | } else { |
3884 | 3884 | if($isIIS) |
3885 | 3885 | header('HTTP/1.1 302 '.self::$HTTP_STATUS_CODES[302]); |
3886 | - header('Location: '.str_replace('&','&',$url)); |
|
3886 | + header('Location: '.str_replace('&', '&', $url)); |
|
3887 | 3887 | } |
3888 | 3888 | if(!$this->getApplication()->getRequestCompleted()) |
3889 | 3889 | $this->getApplication()->onEndRequest(); |
@@ -3893,7 +3893,7 @@ discard block |
||
3893 | 3893 | { |
3894 | 3894 | $this->redirect($this->getRequest()->getRequestUri()); |
3895 | 3895 | } |
3896 | - public function flush($continueBuffering = true) |
|
3896 | + public function flush($continueBuffering=true) |
|
3897 | 3897 | { |
3898 | 3898 | if($this->getHasAdapter()) |
3899 | 3899 | $this->_adapter->flushContent($continueBuffering); |
@@ -3905,16 +3905,16 @@ discard block |
||
3905 | 3905 | $this->ensureHttpHeaderSent(); |
3906 | 3906 | $this->ensureContentTypeHeaderSent(); |
3907 | 3907 | } |
3908 | - public function flushContent($continueBuffering = true) |
|
3908 | + public function flushContent($continueBuffering=true) |
|
3909 | 3909 | { |
3910 | 3910 | $this->ensureHeadersSent(); |
3911 | 3911 | if($this->_bufferOutput) |
3912 | 3912 | { |
3913 | - if (ob_get_length()>0) |
|
3913 | + if(ob_get_length() > 0) |
|
3914 | 3914 | { |
3915 | - if (!$continueBuffering) |
|
3915 | + if(!$continueBuffering) |
|
3916 | 3916 | { |
3917 | - $this->_bufferOutput = false; |
|
3917 | + $this->_bufferOutput=false; |
|
3918 | 3918 | ob_end_flush(); |
3919 | 3919 | } |
3920 | 3920 | else |
@@ -3927,41 +3927,41 @@ discard block |
||
3927 | 3927 | } |
3928 | 3928 | protected function ensureHttpHeaderSent() |
3929 | 3929 | { |
3930 | - if (!$this->_httpHeaderSent) |
|
3930 | + if(!$this->_httpHeaderSent) |
|
3931 | 3931 | $this->sendHttpHeader(); |
3932 | 3932 | } |
3933 | 3933 | protected function sendHttpHeader() |
3934 | 3934 | { |
3935 | 3935 | $protocol=$this->getRequest()->getHttpProtocolVersion(); |
3936 | - if($this->getRequest()->getHttpProtocolVersion() === null) |
|
3936 | + if($this->getRequest()->getHttpProtocolVersion()===null) |
|
3937 | 3937 | $protocol='HTTP/1.1'; |
3938 | - $phpSapiName = substr(php_sapi_name(), 0, 3); |
|
3939 | - $cgi = $phpSapiName == 'cgi' || $phpSapiName == 'fpm'; |
|
3938 | + $phpSapiName=substr(php_sapi_name(), 0, 3); |
|
3939 | + $cgi=$phpSapiName=='cgi' || $phpSapiName=='fpm'; |
|
3940 | 3940 | header(($cgi ? 'Status:' : $protocol).' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
3941 | - $this->_httpHeaderSent = true; |
|
3941 | + $this->_httpHeaderSent=true; |
|
3942 | 3942 | } |
3943 | 3943 | protected function ensureContentTypeHeaderSent() |
3944 | 3944 | { |
3945 | - if (!$this->_contentTypeHeaderSent) |
|
3945 | + if(!$this->_contentTypeHeaderSent) |
|
3946 | 3946 | $this->sendContentTypeHeader(); |
3947 | 3947 | } |
3948 | 3948 | protected function sendContentTypeHeader() |
3949 | 3949 | { |
3950 | - $contentType=$this->_contentType===null?self::DEFAULT_CONTENTTYPE:$this->_contentType; |
|
3950 | + $contentType=$this->_contentType===null ? self::DEFAULT_CONTENTTYPE : $this->_contentType; |
|
3951 | 3951 | $charset=$this->getCharset(); |
3952 | - if($charset === false) { |
|
3952 | + if($charset===false) { |
|
3953 | 3953 | $this->appendHeader('Content-Type: '.$contentType); |
3954 | 3954 | return; |
3955 | 3955 | } |
3956 | 3956 | if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) |
3957 | 3957 | $charset=$globalization->getCharset(); |
3958 | - if($charset==='') $charset = self::DEFAULT_CHARSET; |
|
3958 | + if($charset==='') $charset=self::DEFAULT_CHARSET; |
|
3959 | 3959 | $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); |
3960 | - $this->_contentTypeHeaderSent = true; |
|
3960 | + $this->_contentTypeHeaderSent=true; |
|
3961 | 3961 | } |
3962 | 3962 | public function getContents() |
3963 | 3963 | { |
3964 | - return $this->_bufferOutput?ob_get_contents():''; |
|
3964 | + return $this->_bufferOutput ? ob_get_contents() : ''; |
|
3965 | 3965 | } |
3966 | 3966 | public function clear() |
3967 | 3967 | { |
@@ -3970,18 +3970,18 @@ discard block |
||
3970 | 3970 | } |
3971 | 3971 | public function getHeaders($case=null) |
3972 | 3972 | { |
3973 | - $result = array(); |
|
3974 | - $headers = headers_list(); |
|
3973 | + $result=array(); |
|
3974 | + $headers=headers_list(); |
|
3975 | 3975 | foreach($headers as $header) { |
3976 | - $tmp = explode(':', $header); |
|
3977 | - $key = trim(array_shift($tmp)); |
|
3978 | - $value = trim(implode(':', $tmp)); |
|
3976 | + $tmp=explode(':', $header); |
|
3977 | + $key=trim(array_shift($tmp)); |
|
3978 | + $value=trim(implode(':', $tmp)); |
|
3979 | 3979 | if(isset($result[$key])) |
3980 | - $result[$key] .= ', ' . $value; |
|
3980 | + $result[$key].=', '.$value; |
|
3981 | 3981 | else |
3982 | - $result[$key] = $value; |
|
3982 | + $result[$key]=$value; |
|
3983 | 3983 | } |
3984 | - if($case !== null) |
|
3984 | + if($case!==null) |
|
3985 | 3985 | return array_change_key_case($result, $case); |
3986 | 3986 | return $result; |
3987 | 3987 | } |
@@ -3989,9 +3989,9 @@ discard block |
||
3989 | 3989 | { |
3990 | 3990 | header($value, $replace); |
3991 | 3991 | } |
3992 | - public function appendLog($message,$messageType=0,$destination='',$extraHeaders='') |
|
3992 | + public function appendLog($message, $messageType=0, $destination='', $extraHeaders='') |
|
3993 | 3993 | { |
3994 | - error_log($message,$messageType,$destination,$extraHeaders); |
|
3994 | + error_log($message, $messageType, $destination, $extraHeaders); |
|
3995 | 3995 | } |
3996 | 3996 | public function addCookie($cookie) |
3997 | 3997 | { |
@@ -4055,7 +4055,7 @@ discard block |
||
4055 | 4055 | return Prado::createComponent($type, $writer); |
4056 | 4056 | } |
4057 | 4057 | } |
4058 | -class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
4058 | +class THttpSession extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
4059 | 4059 | { |
4060 | 4060 | private $_initialized=false; |
4061 | 4061 | private $_started=false; |
@@ -4084,9 +4084,9 @@ discard block |
||
4084 | 4084 | if(!$this->_started) |
4085 | 4085 | { |
4086 | 4086 | if($this->_customStorage) |
4087 | - session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc')); |
|
4087 | + session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc')); |
|
4088 | 4088 | if($this->_cookie!==null) |
4089 | - session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly()); |
|
4089 | + session_set_cookie_params($this->_cookie->getExpire(), $this->_cookie->getPath(), $this->_cookie->getDomain(), $this->_cookie->getSecure(), $this->_cookie->getHttpOnly()); |
|
4090 | 4090 | if(ini_get('session.auto_start')!=='1') |
4091 | 4091 | session_start(); |
4092 | 4092 | $this->_started=true; |
@@ -4110,7 +4110,7 @@ discard block |
||
4110 | 4110 | } |
4111 | 4111 | public function regenerate($deleteOld=false) |
4112 | 4112 | { |
4113 | - $old = $this->getSessionID(); |
|
4113 | + $old=$this->getSessionID(); |
|
4114 | 4114 | session_regenerate_id($deleteOld); |
4115 | 4115 | return $old; |
4116 | 4116 | } |
@@ -4140,7 +4140,7 @@ discard block |
||
4140 | 4140 | else if(ctype_alnum($value)) |
4141 | 4141 | session_name($value); |
4142 | 4142 | else |
4143 | - throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value); |
|
4143 | + throw new TInvalidDataValueException('httpsession_sessionname_invalid', $value); |
|
4144 | 4144 | } |
4145 | 4145 | public function getSavePath() |
4146 | 4146 | { |
@@ -4153,7 +4153,7 @@ discard block |
||
4153 | 4153 | else if(is_dir($value)) |
4154 | 4154 | session_save_path($value); |
4155 | 4155 | else |
4156 | - throw new TInvalidDataValueException('httpsession_savepath_invalid',$value); |
|
4156 | + throw new TInvalidDataValueException('httpsession_savepath_invalid', $value); |
|
4157 | 4157 | } |
4158 | 4158 | public function getUseCustomStorage() |
4159 | 4159 | { |
@@ -4166,7 +4166,7 @@ discard block |
||
4166 | 4166 | public function getCookie() |
4167 | 4167 | { |
4168 | 4168 | if($this->_cookie===null) |
4169 | - $this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID()); |
|
4169 | + $this->_cookie=new THttpCookie($this->getSessionName(), $this->getSessionID()); |
|
4170 | 4170 | return $this->_cookie; |
4171 | 4171 | } |
4172 | 4172 | public function getCookieMode() |
@@ -4184,21 +4184,21 @@ discard block |
||
4184 | 4184 | throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); |
4185 | 4185 | else |
4186 | 4186 | { |
4187 | - $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
|
4187 | + $value=TPropertyValue::ensureEnum($value, 'THttpSessionCookieMode'); |
|
4188 | 4188 | if($value===THttpSessionCookieMode::None) |
4189 | 4189 | { |
4190 | - ini_set('session.use_cookies','0'); |
|
4191 | - ini_set('session.use_only_cookies','0'); |
|
4190 | + ini_set('session.use_cookies', '0'); |
|
4191 | + ini_set('session.use_only_cookies', '0'); |
|
4192 | 4192 | } |
4193 | 4193 | else if($value===THttpSessionCookieMode::Allow) |
4194 | 4194 | { |
4195 | - ini_set('session.use_cookies','1'); |
|
4196 | - ini_set('session.use_only_cookies','0'); |
|
4195 | + ini_set('session.use_cookies', '1'); |
|
4196 | + ini_set('session.use_only_cookies', '0'); |
|
4197 | 4197 | } |
4198 | 4198 | else |
4199 | 4199 | { |
4200 | - ini_set('session.use_cookies','1'); |
|
4201 | - ini_set('session.use_only_cookies','1'); |
|
4200 | + ini_set('session.use_cookies', '1'); |
|
4201 | + ini_set('session.use_only_cookies', '1'); |
|
4202 | 4202 | ini_set('session.use_trans_sid', 0); |
4203 | 4203 | } |
4204 | 4204 | } |
@@ -4225,13 +4225,13 @@ discard block |
||
4225 | 4225 | else |
4226 | 4226 | { |
4227 | 4227 | $value=TPropertyValue::ensureInteger($value); |
4228 | - if($value>=0 && $value<=100) |
|
4228 | + if($value >= 0 && $value <= 100) |
|
4229 | 4229 | { |
4230 | - ini_set('session.gc_probability',$value); |
|
4231 | - ini_set('session.gc_divisor','100'); |
|
4230 | + ini_set('session.gc_probability', $value); |
|
4231 | + ini_set('session.gc_divisor', '100'); |
|
4232 | 4232 | } |
4233 | 4233 | else |
4234 | - throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
|
4234 | + throw new TInvalidDataValueException('httpsession_gcprobability_invalid', $value); |
|
4235 | 4235 | } |
4236 | 4236 | } |
4237 | 4237 | public function getUseTransparentSessionID() |
@@ -4245,9 +4245,9 @@ discard block |
||
4245 | 4245 | else |
4246 | 4246 | { |
4247 | 4247 | $value=TPropertyValue::ensureBoolean($value); |
4248 | - if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
4248 | + if($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
4249 | 4249 | throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
4250 | - ini_set('session.use_trans_sid',$value?'1':'0'); |
|
4250 | + ini_set('session.use_trans_sid', $value ? '1' : '0'); |
|
4251 | 4251 | } |
4252 | 4252 | } |
4253 | 4253 | public function getTimeout() |
@@ -4259,9 +4259,9 @@ discard block |
||
4259 | 4259 | if($this->_started) |
4260 | 4260 | throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable'); |
4261 | 4261 | else |
4262 | - ini_set('session.gc_maxlifetime',$value); |
|
4262 | + ini_set('session.gc_maxlifetime', $value); |
|
4263 | 4263 | } |
4264 | - public function _open($savePath,$sessionName) |
|
4264 | + public function _open($savePath, $sessionName) |
|
4265 | 4265 | { |
4266 | 4266 | return true; |
4267 | 4267 | } |
@@ -4273,7 +4273,7 @@ discard block |
||
4273 | 4273 | { |
4274 | 4274 | return ''; |
4275 | 4275 | } |
4276 | - public function _write($id,$data) |
|
4276 | + public function _write($id, $data) |
|
4277 | 4277 | { |
4278 | 4278 | return true; |
4279 | 4279 | } |
@@ -4305,7 +4305,7 @@ discard block |
||
4305 | 4305 | { |
4306 | 4306 | return isset($_SESSION[$key]) ? $_SESSION[$key] : null; |
4307 | 4307 | } |
4308 | - public function add($key,$value) |
|
4308 | + public function add($key, $value) |
|
4309 | 4309 | { |
4310 | 4310 | $_SESSION[$key]=$value; |
4311 | 4311 | } |
@@ -4341,7 +4341,7 @@ discard block |
||
4341 | 4341 | { |
4342 | 4342 | return isset($_SESSION[$offset]) ? $_SESSION[$offset] : null; |
4343 | 4343 | } |
4344 | - public function offsetSet($offset,$item) |
|
4344 | + public function offsetSet($offset, $item) |
|
4345 | 4345 | { |
4346 | 4346 | $_SESSION[$offset]=$item; |
4347 | 4347 | } |
@@ -4368,7 +4368,7 @@ discard block |
||
4368 | 4368 | } |
4369 | 4369 | public function current() |
4370 | 4370 | { |
4371 | - return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null; |
|
4371 | + return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null; |
|
4372 | 4372 | } |
4373 | 4373 | public function next() |
4374 | 4374 | { |
@@ -4396,16 +4396,16 @@ discard block |
||
4396 | 4396 | protected function _getZappableSleepProps(&$exprops) |
4397 | 4397 | { |
4398 | 4398 | parent::_getZappableSleepProps($exprops); |
4399 | - if ($this->_caseSensitive===false) |
|
4400 | - $exprops[] = "\0TAttributeCollection\0_caseSensitive"; |
|
4399 | + if($this->_caseSensitive===false) |
|
4400 | + $exprops[]="\0TAttributeCollection\0_caseSensitive"; |
|
4401 | 4401 | } |
4402 | 4402 | public function __get($name) |
4403 | 4403 | { |
4404 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
4404 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
4405 | 4405 | } |
4406 | - public function __set($name,$value) |
|
4406 | + public function __set($name, $value) |
|
4407 | 4407 | { |
4408 | - $this->add($name,$value); |
|
4408 | + $this->add($name, $value); |
|
4409 | 4409 | } |
4410 | 4410 | public function getCaseSensitive() |
4411 | 4411 | { |
@@ -4417,19 +4417,19 @@ discard block |
||
4417 | 4417 | } |
4418 | 4418 | public function itemAt($key) |
4419 | 4419 | { |
4420 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
4420 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
4421 | 4421 | } |
4422 | - public function add($key,$value) |
|
4422 | + public function add($key, $value) |
|
4423 | 4423 | { |
4424 | - parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
|
4424 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
4425 | 4425 | } |
4426 | 4426 | public function remove($key) |
4427 | 4427 | { |
4428 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
4428 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
4429 | 4429 | } |
4430 | 4430 | public function contains($key) |
4431 | 4431 | { |
4432 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
4432 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
4433 | 4433 | } |
4434 | 4434 | public function hasProperty($name) |
4435 | 4435 | { |
@@ -4457,7 +4457,7 @@ discard block |
||
4457 | 4457 | } |
4458 | 4458 | public function getPage() |
4459 | 4459 | { |
4460 | - return $this->_control?$this->_control->getPage():null; |
|
4460 | + return $this->_control ? $this->_control->getPage() : null; |
|
4461 | 4461 | } |
4462 | 4462 | public function createChildControls() |
4463 | 4463 | { |
@@ -4515,7 +4515,7 @@ discard block |
||
4515 | 4515 | const IS_DISABLE_THEMING=0x10; |
4516 | 4516 | const IS_CHILD_CREATED=0x20; |
4517 | 4517 | const IS_CREATING_CHILD=0x40; |
4518 | - const RF_CONTROLS=0; const RF_CHILD_STATE=1; const RF_NAMED_CONTROLS=2; const RF_NAMED_CONTROLS_ID=3; const RF_SKIN_ID=4; const RF_DATA_BINDINGS=5; const RF_EVENTS=6; const RF_CONTROLSTATE=7; const RF_NAMED_OBJECTS=8; const RF_ADAPTER=9; const RF_AUTO_BINDINGS=10; |
|
4518 | + const RF_CONTROLS=0; const RF_CHILD_STATE=1; const RF_NAMED_CONTROLS=2; const RF_NAMED_CONTROLS_ID=3; const RF_SKIN_ID=4; const RF_DATA_BINDINGS=5; const RF_EVENTS=6; const RF_CONTROLSTATE=7; const RF_NAMED_OBJECTS=8; const RF_ADAPTER=9; const RF_AUTO_BINDINGS=10; |
|
4519 | 4519 | private $_id=''; |
4520 | 4520 | private $_uid; |
4521 | 4521 | private $_parent; |
@@ -4548,7 +4548,7 @@ discard block |
||
4548 | 4548 | } |
4549 | 4549 | public function getAdapter() |
4550 | 4550 | { |
4551 | - return isset($this->_rf[self::RF_ADAPTER])?$this->_rf[self::RF_ADAPTER]:null; |
|
4551 | + return isset($this->_rf[self::RF_ADAPTER]) ? $this->_rf[self::RF_ADAPTER] : null; |
|
4552 | 4552 | } |
4553 | 4553 | public function setAdapter(TControlAdapter $adapter) |
4554 | 4554 | { |
@@ -4621,18 +4621,18 @@ discard block |
||
4621 | 4621 | } |
4622 | 4622 | public function setID($id) |
4623 | 4623 | { |
4624 | - if(!preg_match(self::ID_FORMAT,$id)) |
|
4625 | - throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id); |
|
4624 | + if(!preg_match(self::ID_FORMAT, $id)) |
|
4625 | + throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
|
4626 | 4626 | $this->_id=$id; |
4627 | - $this->_flags |= self::IS_ID_SET; |
|
4627 | + $this->_flags|=self::IS_ID_SET; |
|
4628 | 4628 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
4629 | 4629 | if($this->_namingContainer) |
4630 | 4630 | $this->_namingContainer->clearNameTable(); |
4631 | 4631 | } |
4632 | 4632 | public function getUniqueID() |
4633 | 4633 | { |
4634 | - if($this->_uid==='' || $this->_uid===null) { |
|
4635 | - $this->_uid=''; if($namingContainer=$this->getNamingContainer()) |
|
4634 | + if($this->_uid==='' || $this->_uid===null) { |
|
4635 | + $this->_uid=''; if($namingContainer=$this->getNamingContainer()) |
|
4636 | 4636 | { |
4637 | 4637 | if($this->getPage()===$namingContainer) |
4638 | 4638 | return ($this->_uid=$this->_id); |
@@ -4652,20 +4652,20 @@ discard block |
||
4652 | 4652 | } |
4653 | 4653 | public function getClientID() |
4654 | 4654 | { |
4655 | - return strtr($this->getUniqueID(),self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR); |
|
4655 | + return strtr($this->getUniqueID(), self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR); |
|
4656 | 4656 | } |
4657 | 4657 | public static function convertUniqueIdToClientId($uniqueID) |
4658 | 4658 | { |
4659 | - return strtr($uniqueID,self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR); |
|
4659 | + return strtr($uniqueID, self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR); |
|
4660 | 4660 | } |
4661 | 4661 | public function getSkinID() |
4662 | 4662 | { |
4663 | - return isset($this->_rf[self::RF_SKIN_ID])?$this->_rf[self::RF_SKIN_ID]:''; |
|
4663 | + return isset($this->_rf[self::RF_SKIN_ID]) ? $this->_rf[self::RF_SKIN_ID] : ''; |
|
4664 | 4664 | } |
4665 | 4665 | public function setSkinID($value) |
4666 | 4666 | { |
4667 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED) |
|
4668 | - throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this)); |
|
4667 | + if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
4668 | + throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
|
4669 | 4669 | else |
4670 | 4670 | $this->_rf[self::RF_SKIN_ID]=$value; |
4671 | 4671 | } |
@@ -4678,28 +4678,28 @@ discard block |
||
4678 | 4678 | if($this->_flags & self::IS_DISABLE_THEMING) |
4679 | 4679 | return false; |
4680 | 4680 | else |
4681 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
4681 | + return $this->_parent ? $this->_parent->getEnableTheming() : true; |
|
4682 | 4682 | } |
4683 | 4683 | public function setEnableTheming($value) |
4684 | 4684 | { |
4685 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
4686 | - throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID()); |
|
4685 | + if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
4686 | + throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
|
4687 | 4687 | else if(TPropertyValue::ensureBoolean($value)) |
4688 | - $this->_flags &= ~self::IS_DISABLE_THEMING; |
|
4688 | + $this->_flags&=~self::IS_DISABLE_THEMING; |
|
4689 | 4689 | else |
4690 | - $this->_flags |= self::IS_DISABLE_THEMING; |
|
4690 | + $this->_flags|=self::IS_DISABLE_THEMING; |
|
4691 | 4691 | } |
4692 | 4692 | public function getCustomData() |
4693 | 4693 | { |
4694 | - return $this->getViewState('CustomData',null); |
|
4694 | + return $this->getViewState('CustomData', null); |
|
4695 | 4695 | } |
4696 | 4696 | public function setCustomData($value) |
4697 | 4697 | { |
4698 | - $this->setViewState('CustomData',$value,null); |
|
4698 | + $this->setViewState('CustomData', $value, null); |
|
4699 | 4699 | } |
4700 | 4700 | public function getHasControls() |
4701 | 4701 | { |
4702 | - return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount()>0; |
|
4702 | + return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount() > 0; |
|
4703 | 4703 | } |
4704 | 4704 | public function getControls() |
4705 | 4705 | { |
@@ -4709,79 +4709,79 @@ discard block |
||
4709 | 4709 | } |
4710 | 4710 | protected function createControlCollection() |
4711 | 4711 | { |
4712 | - return $this->getAllowChildControls()?new TControlCollection($this):new TEmptyControlCollection($this); |
|
4712 | + return $this->getAllowChildControls() ? new TControlCollection($this) : new TEmptyControlCollection($this); |
|
4713 | 4713 | } |
4714 | 4714 | public function getVisible($checkParents=true) |
4715 | 4715 | { |
4716 | 4716 | if($checkParents) |
4717 | 4717 | { |
4718 | - for($control=$this;$control;$control=$control->_parent) |
|
4718 | + for($control=$this; $control; $control=$control->_parent) |
|
4719 | 4719 | if(!$control->getVisible(false)) |
4720 | 4720 | return false; |
4721 | 4721 | return true; |
4722 | 4722 | } |
4723 | 4723 | else |
4724 | - return $this->getViewState('Visible',true); |
|
4724 | + return $this->getViewState('Visible', true); |
|
4725 | 4725 | } |
4726 | 4726 | public function setVisible($value) |
4727 | 4727 | { |
4728 | - $this->setViewState('Visible',TPropertyValue::ensureBoolean($value),true); |
|
4728 | + $this->setViewState('Visible', TPropertyValue::ensureBoolean($value), true); |
|
4729 | 4729 | } |
4730 | 4730 | public function getEnabled($checkParents=false) |
4731 | 4731 | { |
4732 | 4732 | if($checkParents) |
4733 | 4733 | { |
4734 | - for($control=$this;$control;$control=$control->_parent) |
|
4735 | - if(!$control->getViewState('Enabled',true)) |
|
4734 | + for($control=$this; $control; $control=$control->_parent) |
|
4735 | + if(!$control->getViewState('Enabled', true)) |
|
4736 | 4736 | return false; |
4737 | 4737 | return true; |
4738 | 4738 | } |
4739 | 4739 | else |
4740 | - return $this->getViewState('Enabled',true); |
|
4740 | + return $this->getViewState('Enabled', true); |
|
4741 | 4741 | } |
4742 | 4742 | public function setEnabled($value) |
4743 | 4743 | { |
4744 | - $this->setViewState('Enabled',TPropertyValue::ensureBoolean($value),true); |
|
4744 | + $this->setViewState('Enabled', TPropertyValue::ensureBoolean($value), true); |
|
4745 | 4745 | } |
4746 | 4746 | public function getHasAttributes() |
4747 | 4747 | { |
4748 | - if($attributes=$this->getViewState('Attributes',null)) |
|
4749 | - return $attributes->getCount()>0; |
|
4748 | + if($attributes=$this->getViewState('Attributes', null)) |
|
4749 | + return $attributes->getCount() > 0; |
|
4750 | 4750 | else |
4751 | 4751 | return false; |
4752 | 4752 | } |
4753 | 4753 | public function getAttributes() |
4754 | 4754 | { |
4755 | - if($attributes=$this->getViewState('Attributes',null)) |
|
4755 | + if($attributes=$this->getViewState('Attributes', null)) |
|
4756 | 4756 | return $attributes; |
4757 | 4757 | else |
4758 | 4758 | { |
4759 | 4759 | $attributes=new TAttributeCollection; |
4760 | - $this->setViewState('Attributes',$attributes,null); |
|
4760 | + $this->setViewState('Attributes', $attributes, null); |
|
4761 | 4761 | return $attributes; |
4762 | 4762 | } |
4763 | 4763 | } |
4764 | 4764 | public function hasAttribute($name) |
4765 | 4765 | { |
4766 | - if($attributes=$this->getViewState('Attributes',null)) |
|
4766 | + if($attributes=$this->getViewState('Attributes', null)) |
|
4767 | 4767 | return $attributes->contains($name); |
4768 | 4768 | else |
4769 | 4769 | return false; |
4770 | 4770 | } |
4771 | 4771 | public function getAttribute($name) |
4772 | 4772 | { |
4773 | - if($attributes=$this->getViewState('Attributes',null)) |
|
4773 | + if($attributes=$this->getViewState('Attributes', null)) |
|
4774 | 4774 | return $attributes->itemAt($name); |
4775 | 4775 | else |
4776 | 4776 | return null; |
4777 | 4777 | } |
4778 | - public function setAttribute($name,$value) |
|
4778 | + public function setAttribute($name, $value) |
|
4779 | 4779 | { |
4780 | - $this->getAttributes()->add($name,$value); |
|
4780 | + $this->getAttributes()->add($name, $value); |
|
4781 | 4781 | } |
4782 | 4782 | public function removeAttribute($name) |
4783 | 4783 | { |
4784 | - if($attributes=$this->getViewState('Attributes',null)) |
|
4784 | + if($attributes=$this->getViewState('Attributes', null)) |
|
4785 | 4785 | return $attributes->remove($name); |
4786 | 4786 | else |
4787 | 4787 | return null; |
@@ -4790,7 +4790,7 @@ discard block |
||
4790 | 4790 | { |
4791 | 4791 | if($checkParents) |
4792 | 4792 | { |
4793 | - for($control=$this;$control!==null;$control=$control->getParent()) |
|
4793 | + for($control=$this; $control!==null; $control=$control->getParent()) |
|
4794 | 4794 | if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
4795 | 4795 | return false; |
4796 | 4796 | return true; |
@@ -4801,15 +4801,15 @@ discard block |
||
4801 | 4801 | public function setEnableViewState($value) |
4802 | 4802 | { |
4803 | 4803 | if(TPropertyValue::ensureBoolean($value)) |
4804 | - $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
|
4804 | + $this->_flags&=~self::IS_DISABLE_VIEWSTATE; |
|
4805 | 4805 | else |
4806 | - $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
|
4806 | + $this->_flags|=self::IS_DISABLE_VIEWSTATE; |
|
4807 | 4807 | } |
4808 | - protected function getControlState($key,$defaultValue=null) |
|
4808 | + protected function getControlState($key, $defaultValue=null) |
|
4809 | 4809 | { |
4810 | - return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue; |
|
4810 | + return isset($this->_rf[self::RF_CONTROLSTATE][$key]) ? $this->_rf[self::RF_CONTROLSTATE][$key] : $defaultValue; |
|
4811 | 4811 | } |
4812 | - protected function setControlState($key,$value,$defaultValue=null) |
|
4812 | + protected function setControlState($key, $value, $defaultValue=null) |
|
4813 | 4813 | { |
4814 | 4814 | if($value===$defaultValue) |
4815 | 4815 | unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
@@ -4824,10 +4824,10 @@ discard block |
||
4824 | 4824 | { |
4825 | 4825 | $this->_trackViewState=TPropertyValue::ensureBoolean($enabled); |
4826 | 4826 | } |
4827 | - public function getViewState($key,$defaultValue=null) |
|
4827 | + public function getViewState($key, $defaultValue=null) |
|
4828 | 4828 | { |
4829 | 4829 | if(isset($this->_viewState[$key])) |
4830 | - return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue; |
|
4830 | + return $this->_viewState[$key]!==null ? $this->_viewState[$key] : $defaultValue; |
|
4831 | 4831 | else if(isset($this->_tempState[$key])) |
4832 | 4832 | { |
4833 | 4833 | if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
@@ -4837,7 +4837,7 @@ discard block |
||
4837 | 4837 | else |
4838 | 4838 | return $defaultValue; |
4839 | 4839 | } |
4840 | - public function setViewState($key,$value,$defaultValue=null) |
|
4840 | + public function setViewState($key, $value, $defaultValue=null) |
|
4841 | 4841 | { |
4842 | 4842 | if($this->_trackViewState) |
4843 | 4843 | { |
@@ -4858,7 +4858,7 @@ discard block |
||
4858 | 4858 | unset($this->_viewState[$key]); |
4859 | 4859 | unset($this->_tempState[$key]); |
4860 | 4860 | } |
4861 | - public function bindProperty($name,$expression) |
|
4861 | + public function bindProperty($name, $expression) |
|
4862 | 4862 | { |
4863 | 4863 | $this->_rf[self::RF_DATA_BINDINGS][$name]=$expression; |
4864 | 4864 | } |
@@ -4866,7 +4866,7 @@ discard block |
||
4866 | 4866 | { |
4867 | 4867 | unset($this->_rf[self::RF_DATA_BINDINGS][$name]); |
4868 | 4868 | } |
4869 | - public function autoBindProperty($name,$expression) |
|
4869 | + public function autoBindProperty($name, $expression) |
|
4870 | 4870 | { |
4871 | 4871 | $this->_rf[self::RF_AUTO_BINDINGS][$name]=$expression; |
4872 | 4872 | } |
@@ -4883,7 +4883,7 @@ discard block |
||
4883 | 4883 | if(($context=$this->getTemplateControl())===null) |
4884 | 4884 | $context=$this; |
4885 | 4885 | foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) |
4886 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
4886 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
4887 | 4887 | } |
4888 | 4888 | } |
4889 | 4889 | protected function autoDataBindProperties() |
@@ -4893,7 +4893,7 @@ discard block |
||
4893 | 4893 | if(($context=$this->getTemplateControl())===null) |
4894 | 4894 | $context=$this; |
4895 | 4895 | foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) |
4896 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
4896 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
4897 | 4897 | } |
4898 | 4898 | } |
4899 | 4899 | protected function dataBindChildren() |
@@ -4912,12 +4912,12 @@ discard block |
||
4912 | 4912 | final protected function setChildControlsCreated($value) |
4913 | 4913 | { |
4914 | 4914 | if($value) |
4915 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
4915 | + $this->_flags|=self::IS_CHILD_CREATED; |
|
4916 | 4916 | else |
4917 | 4917 | { |
4918 | 4918 | if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
4919 | 4919 | $this->getControls()->clear(); |
4920 | - $this->_flags &= ~self::IS_CHILD_CREATED; |
|
4920 | + $this->_flags&=~self::IS_CHILD_CREATED; |
|
4921 | 4921 | } |
4922 | 4922 | } |
4923 | 4923 | public function ensureChildControls() |
@@ -4926,18 +4926,18 @@ discard block |
||
4926 | 4926 | { |
4927 | 4927 | try |
4928 | 4928 | { |
4929 | - $this->_flags |= self::IS_CREATING_CHILD; |
|
4929 | + $this->_flags|=self::IS_CREATING_CHILD; |
|
4930 | 4930 | if(isset($this->_rf[self::RF_ADAPTER])) |
4931 | 4931 | $this->_rf[self::RF_ADAPTER]->createChildControls(); |
4932 | 4932 | else |
4933 | 4933 | $this->createChildControls(); |
4934 | - $this->_flags &= ~self::IS_CREATING_CHILD; |
|
4935 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
4934 | + $this->_flags&=~self::IS_CREATING_CHILD; |
|
4935 | + $this->_flags|=self::IS_CHILD_CREATED; |
|
4936 | 4936 | } |
4937 | 4937 | catch(Exception $e) |
4938 | 4938 | { |
4939 | - $this->_flags &= ~self::IS_CREATING_CHILD; |
|
4940 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
4939 | + $this->_flags&=~self::IS_CREATING_CHILD; |
|
4940 | + $this->_flags|=self::IS_CHILD_CREATED; |
|
4941 | 4941 | throw $e; |
4942 | 4942 | } |
4943 | 4943 | } |
@@ -4947,28 +4947,28 @@ discard block |
||
4947 | 4947 | } |
4948 | 4948 | public function findControl($id) |
4949 | 4949 | { |
4950 | - $id=strtr($id,'.',self::ID_SEPARATOR); |
|
4951 | - $container=($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
|
4950 | + $id=strtr($id, '.', self::ID_SEPARATOR); |
|
4951 | + $container=($this instanceof INamingContainer) ? $this : $this->getNamingContainer(); |
|
4952 | 4952 | if(!$container || !$container->getHasControls()) |
4953 | 4953 | return null; |
4954 | 4954 | if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
4955 | 4955 | { |
4956 | 4956 | $container->_rf[self::RF_NAMED_CONTROLS]=array(); |
4957 | - $container->fillNameTable($container,$container->_rf[self::RF_CONTROLS]); |
|
4957 | + $container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]); |
|
4958 | 4958 | } |
4959 | - if(($pos=strpos($id,self::ID_SEPARATOR))===false) |
|
4960 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
4959 | + if(($pos=strpos($id, self::ID_SEPARATOR))===false) |
|
4960 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id]) ? $container->_rf[self::RF_NAMED_CONTROLS][$id] : null; |
|
4961 | 4961 | else |
4962 | 4962 | { |
4963 | - $cid=substr($id,0,$pos); |
|
4964 | - $sid=substr($id,$pos+1); |
|
4963 | + $cid=substr($id, 0, $pos); |
|
4964 | + $sid=substr($id, $pos + 1); |
|
4965 | 4965 | if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
4966 | 4966 | return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
4967 | 4967 | else |
4968 | 4968 | return null; |
4969 | 4969 | } |
4970 | 4970 | } |
4971 | - public function findControlsByType($type,$strict=true) |
|
4971 | + public function findControlsByType($type, $strict=true) |
|
4972 | 4972 | { |
4973 | 4973 | $controls=array(); |
4974 | 4974 | if($this->getHasControls()) |
@@ -4978,7 +4978,7 @@ discard block |
||
4978 | 4978 | if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type)))) |
4979 | 4979 | $controls[]=$control; |
4980 | 4980 | if(($control instanceof TControl) && $control->getHasControls()) |
4981 | - $controls=array_merge($controls,$control->findControlsByType($type,$strict)); |
|
4981 | + $controls=array_merge($controls, $control->findControlsByType($type, $strict)); |
|
4982 | 4982 | } |
4983 | 4983 | } |
4984 | 4984 | return $controls; |
@@ -4994,7 +4994,7 @@ discard block |
||
4994 | 4994 | { |
4995 | 4995 | if($control->_id===$id) |
4996 | 4996 | $controls[]=$control; |
4997 | - $controls=array_merge($controls,$control->findControlsByID($id)); |
|
4997 | + $controls=array_merge($controls, $control->findControlsByID($id)); |
|
4998 | 4998 | } |
4999 | 4999 | } |
5000 | 5000 | } |
@@ -5005,10 +5005,10 @@ discard block |
||
5005 | 5005 | unset($this->_rf[self::RF_NAMED_CONTROLS_ID]); |
5006 | 5006 | $this->clearNameTable(); |
5007 | 5007 | } |
5008 | - public function registerObject($name,$object) |
|
5008 | + public function registerObject($name, $object) |
|
5009 | 5009 | { |
5010 | 5010 | if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
5011 | - throw new TInvalidOperationException('control_object_reregistered',$name); |
|
5011 | + throw new TInvalidOperationException('control_object_reregistered', $name); |
|
5012 | 5012 | $this->_rf[self::RF_NAMED_OBJECTS][$name]=$object; |
5013 | 5013 | } |
5014 | 5014 | public function unregisterObject($name) |
@@ -5041,7 +5041,7 @@ discard block |
||
5041 | 5041 | } |
5042 | 5042 | public function getRegisteredObject($name) |
5043 | 5043 | { |
5044 | - return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null; |
|
5044 | + return isset($this->_rf[self::RF_NAMED_OBJECTS][$name]) ? $this->_rf[self::RF_NAMED_OBJECTS][$name] : null; |
|
5045 | 5045 | } |
5046 | 5046 | public function getAllowChildControls() |
5047 | 5047 | { |
@@ -5068,7 +5068,7 @@ discard block |
||
5068 | 5068 | $control->_parent->getControls()->remove($control); |
5069 | 5069 | $control->_parent=$this; |
5070 | 5070 | $control->_page=$this->getPage(); |
5071 | - $namingContainer=($this instanceof INamingContainer)?$this:$this->_namingContainer; |
|
5071 | + $namingContainer=($this instanceof INamingContainer) ? $this : $this->_namingContainer; |
|
5072 | 5072 | if($namingContainer) |
5073 | 5073 | { |
5074 | 5074 | $control->_namingContainer=$namingContainer; |
@@ -5078,10 +5078,10 @@ discard block |
||
5078 | 5078 | $namingContainer->clearNameTable(); |
5079 | 5079 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
5080 | 5080 | } |
5081 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
5081 | + if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
5082 | 5082 | { |
5083 | 5083 | $control->initRecursive($namingContainer); |
5084 | - if($this->_stage>=self::CS_STATE_LOADED) |
|
5084 | + if($this->_stage >= self::CS_STATE_LOADED) |
|
5085 | 5085 | { |
5086 | 5086 | if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
5087 | 5087 | { |
@@ -5090,11 +5090,11 @@ discard block |
||
5090 | 5090 | } |
5091 | 5091 | else |
5092 | 5092 | $state=null; |
5093 | - $control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
5094 | - if($this->_stage>=self::CS_LOADED) |
|
5093 | + $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
5094 | + if($this->_stage >= self::CS_LOADED) |
|
5095 | 5095 | { |
5096 | 5096 | $control->loadRecursive(); |
5097 | - if($this->_stage>=self::CS_PRERENDERED) |
|
5097 | + if($this->_stage >= self::CS_PRERENDERED) |
|
5098 | 5098 | $control->preRenderRecursive(); |
5099 | 5099 | } |
5100 | 5100 | } |
@@ -5135,13 +5135,13 @@ discard block |
||
5135 | 5135 | } |
5136 | 5136 | } |
5137 | 5137 | } |
5138 | - if($this->_stage<self::CS_INITIALIZED) |
|
5138 | + if($this->_stage < self::CS_INITIALIZED) |
|
5139 | 5139 | { |
5140 | 5140 | $this->_stage=self::CS_CHILD_INITIALIZED; |
5141 | 5141 | if(($page=$this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
5142 | 5142 | { |
5143 | 5143 | $page->applyControlSkin($this); |
5144 | - $this->_flags |= self::IS_SKIN_APPLIED; |
|
5144 | + $this->_flags|=self::IS_SKIN_APPLIED; |
|
5145 | 5145 | } |
5146 | 5146 | if(isset($this->_rf[self::RF_ADAPTER])) |
5147 | 5147 | $this->_rf[self::RF_ADAPTER]->onInit(null); |
@@ -5152,7 +5152,7 @@ discard block |
||
5152 | 5152 | } |
5153 | 5153 | protected function loadRecursive() |
5154 | 5154 | { |
5155 | - if($this->_stage<self::CS_LOADED) |
|
5155 | + if($this->_stage < self::CS_LOADED) |
|
5156 | 5156 | { |
5157 | 5157 | if(isset($this->_rf[self::RF_ADAPTER])) |
5158 | 5158 | $this->_rf[self::RF_ADAPTER]->onLoad(null); |
@@ -5167,7 +5167,7 @@ discard block |
||
5167 | 5167 | $control->loadRecursive(); |
5168 | 5168 | } |
5169 | 5169 | } |
5170 | - if($this->_stage<self::CS_LOADED) |
|
5170 | + if($this->_stage < self::CS_LOADED) |
|
5171 | 5171 | $this->_stage=self::CS_LOADED; |
5172 | 5172 | } |
5173 | 5173 | protected function preRenderRecursive() |
@@ -5209,73 +5209,73 @@ discard block |
||
5209 | 5209 | } |
5210 | 5210 | public function onInit($param) |
5211 | 5211 | { |
5212 | - $this->raiseEvent('OnInit',$this,$param); |
|
5212 | + $this->raiseEvent('OnInit', $this, $param); |
|
5213 | 5213 | } |
5214 | 5214 | public function onLoad($param) |
5215 | 5215 | { |
5216 | - $this->raiseEvent('OnLoad',$this,$param); |
|
5216 | + $this->raiseEvent('OnLoad', $this, $param); |
|
5217 | 5217 | } |
5218 | 5218 | public function onDataBinding($param) |
5219 | 5219 | { |
5220 | - $this->raiseEvent('OnDataBinding',$this,$param); |
|
5220 | + $this->raiseEvent('OnDataBinding', $this, $param); |
|
5221 | 5221 | } |
5222 | 5222 | public function onUnload($param) |
5223 | 5223 | { |
5224 | - $this->raiseEvent('OnUnload',$this,$param); |
|
5224 | + $this->raiseEvent('OnUnload', $this, $param); |
|
5225 | 5225 | } |
5226 | 5226 | public function onPreRender($param) |
5227 | 5227 | { |
5228 | - $this->raiseEvent('OnPreRender',$this,$param); |
|
5228 | + $this->raiseEvent('OnPreRender', $this, $param); |
|
5229 | 5229 | } |
5230 | - protected function raiseBubbleEvent($sender,$param) |
|
5230 | + protected function raiseBubbleEvent($sender, $param) |
|
5231 | 5231 | { |
5232 | 5232 | $control=$this; |
5233 | 5233 | while($control=$control->_parent) |
5234 | 5234 | { |
5235 | - if($control->bubbleEvent($sender,$param)) |
|
5235 | + if($control->bubbleEvent($sender, $param)) |
|
5236 | 5236 | break; |
5237 | 5237 | } |
5238 | 5238 | } |
5239 | - public function bubbleEvent($sender,$param) |
|
5239 | + public function bubbleEvent($sender, $param) |
|
5240 | 5240 | { |
5241 | 5241 | return false; |
5242 | 5242 | } |
5243 | - public function broadcastEvent($name,$sender,$param) |
|
5243 | + public function broadcastEvent($name, $sender, $param) |
|
5244 | 5244 | { |
5245 | - $rootControl=(($page=$this->getPage())===null)?$this:$page; |
|
5246 | - $rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param)); |
|
5245 | + $rootControl=(($page=$this->getPage())===null) ? $this : $page; |
|
5246 | + $rootControl->broadcastEventInternal($name, $sender, new TBroadcastEventParameter($name, $param)); |
|
5247 | 5247 | } |
5248 | - private function broadcastEventInternal($name,$sender,$param) |
|
5248 | + private function broadcastEventInternal($name, $sender, $param) |
|
5249 | 5249 | { |
5250 | 5250 | if($this->hasEvent($name)) |
5251 | - $this->raiseEvent($name,$sender,$param->getParameter()); |
|
5251 | + $this->raiseEvent($name, $sender, $param->getParameter()); |
|
5252 | 5252 | if($this instanceof IBroadcastEventReceiver) |
5253 | - $this->broadcastEventReceived($sender,$param); |
|
5253 | + $this->broadcastEventReceived($sender, $param); |
|
5254 | 5254 | if($this->getHasControls()) |
5255 | 5255 | { |
5256 | 5256 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
5257 | 5257 | { |
5258 | 5258 | if($control instanceof TControl) |
5259 | - $control->broadcastEventInternal($name,$sender,$param); |
|
5259 | + $control->broadcastEventInternal($name, $sender, $param); |
|
5260 | 5260 | } |
5261 | 5261 | } |
5262 | 5262 | } |
5263 | - protected function traverseChildControls($param,$preCallback=null,$postCallback=null) |
|
5263 | + protected function traverseChildControls($param, $preCallback=null, $postCallback=null) |
|
5264 | 5264 | { |
5265 | 5265 | if($preCallback!==null) |
5266 | - call_user_func($preCallback,$this,$param); |
|
5266 | + call_user_func($preCallback, $this, $param); |
|
5267 | 5267 | if($this->getHasControls()) |
5268 | 5268 | { |
5269 | 5269 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
5270 | 5270 | { |
5271 | 5271 | if($control instanceof TControl) |
5272 | 5272 | { |
5273 | - $control->traverseChildControls($param,$preCallback,$postCallback); |
|
5273 | + $control->traverseChildControls($param, $preCallback, $postCallback); |
|
5274 | 5274 | } |
5275 | 5275 | } |
5276 | 5276 | } |
5277 | 5277 | if($postCallback!==null) |
5278 | - call_user_func($postCallback,$this,$param); |
|
5278 | + call_user_func($postCallback, $this, $param); |
|
5279 | 5279 | } |
5280 | 5280 | public function renderControl($writer) |
5281 | 5281 | { |
@@ -5312,7 +5312,7 @@ discard block |
||
5312 | 5312 | public function loadState() |
5313 | 5313 | { |
5314 | 5314 | } |
5315 | - protected function loadStateRecursive(&$state,$needViewState=true) |
|
5315 | + protected function loadStateRecursive(&$state, $needViewState=true) |
|
5316 | 5316 | { |
5317 | 5317 | if(is_array($state)) |
5318 | 5318 | { |
@@ -5340,7 +5340,7 @@ discard block |
||
5340 | 5340 | { |
5341 | 5341 | if(isset($state[$control->_id])) |
5342 | 5342 | { |
5343 | - $control->loadStateRecursive($state[$control->_id],$needViewState); |
|
5343 | + $control->loadStateRecursive($state[$control->_id], $needViewState); |
|
5344 | 5344 | unset($state[$control->_id]); |
5345 | 5345 | } |
5346 | 5346 | } |
@@ -5369,7 +5369,7 @@ discard block |
||
5369 | 5369 | { |
5370 | 5370 | if($control instanceof TControl) |
5371 | 5371 | { |
5372 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
5372 | + if(count($tmp=&$control->saveStateRecursive($needViewState))) |
|
5373 | 5373 | $state[$control->_id]=$tmp; |
5374 | 5374 | } |
5375 | 5375 | } |
@@ -5385,10 +5385,10 @@ discard block |
||
5385 | 5385 | if($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
5386 | 5386 | { |
5387 | 5387 | $page->applyControlStyleSheet($this); |
5388 | - $this->_flags |= self::IS_STYLESHEET_APPLIED; |
|
5388 | + $this->_flags|=self::IS_STYLESHEET_APPLIED; |
|
5389 | 5389 | } |
5390 | 5390 | else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
5391 | - throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
|
5391 | + throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
|
5392 | 5392 | } |
5393 | 5393 | private function clearCachedUniqueID($recursive) |
5394 | 5394 | { |
@@ -5402,18 +5402,18 @@ discard block |
||
5402 | 5402 | } |
5403 | 5403 | private function generateAutomaticID() |
5404 | 5404 | { |
5405 | - $this->_flags &= ~self::IS_ID_SET; |
|
5405 | + $this->_flags&=~self::IS_ID_SET; |
|
5406 | 5406 | if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
5407 | 5407 | $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0; |
5408 | 5408 | $id=$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
5409 | - $this->_id=self::AUTOMATIC_ID_PREFIX . $id; |
|
5409 | + $this->_id=self::AUTOMATIC_ID_PREFIX.$id; |
|
5410 | 5410 | $this->_namingContainer->clearNameTable(); |
5411 | 5411 | } |
5412 | 5412 | private function clearNameTable() |
5413 | 5413 | { |
5414 | 5414 | unset($this->_rf[self::RF_NAMED_CONTROLS]); |
5415 | 5415 | } |
5416 | - private function fillNameTable($container,$controls) |
|
5416 | + private function fillNameTable($container, $controls) |
|
5417 | 5417 | { |
5418 | 5418 | foreach($controls as $control) |
5419 | 5419 | { |
@@ -5422,12 +5422,12 @@ discard block |
||
5422 | 5422 | if($control->_id!=='') |
5423 | 5423 | { |
5424 | 5424 | if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
5425 | - throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id); |
|
5425 | + throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
|
5426 | 5426 | else |
5427 | 5427 | $container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control; |
5428 | 5428 | } |
5429 | 5429 | if(!($control instanceof INamingContainer) && $control->getHasControls()) |
5430 | - $this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]); |
|
5430 | + $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
|
5431 | 5431 | } |
5432 | 5432 | } |
5433 | 5433 | } |
@@ -5435,24 +5435,24 @@ discard block |
||
5435 | 5435 | class TControlCollection extends TList |
5436 | 5436 | { |
5437 | 5437 | private $_o; |
5438 | - public function __construct(TControl $owner,$readOnly=false) |
|
5438 | + public function __construct(TControl $owner, $readOnly=false) |
|
5439 | 5439 | { |
5440 | 5440 | $this->_o=$owner; |
5441 | - parent::__construct(null,$readOnly); |
|
5441 | + parent::__construct(null, $readOnly); |
|
5442 | 5442 | } |
5443 | 5443 | protected function getOwner() |
5444 | 5444 | { |
5445 | 5445 | return $this->_o; |
5446 | 5446 | } |
5447 | - public function insertAt($index,$item) |
|
5447 | + public function insertAt($index, $item) |
|
5448 | 5448 | { |
5449 | 5449 | if($item instanceof TControl) |
5450 | 5450 | { |
5451 | - parent::insertAt($index,$item); |
|
5451 | + parent::insertAt($index, $item); |
|
5452 | 5452 | $this->_o->addedControl($item); |
5453 | 5453 | } |
5454 | 5454 | else if(is_string($item) || ($item instanceof IRenderable)) |
5455 | - parent::insertAt($index,$item); |
|
5455 | + parent::insertAt($index, $item); |
|
5456 | 5456 | else |
5457 | 5457 | throw new TInvalidDataTypeException('controlcollection_control_required'); |
5458 | 5458 | } |
@@ -5474,11 +5474,11 @@ discard block |
||
5474 | 5474 | { |
5475 | 5475 | public function __construct(TControl $owner) |
5476 | 5476 | { |
5477 | - parent::__construct($owner,true); |
|
5477 | + parent::__construct($owner, true); |
|
5478 | 5478 | } |
5479 | - public function insertAt($index,$item) |
|
5479 | + public function insertAt($index, $item) |
|
5480 | 5480 | { |
5481 | - if(!is_string($item)) parent::insertAt($index,$item); } |
|
5481 | + if(!is_string($item)) parent::insertAt($index, $item); } |
|
5482 | 5482 | } |
5483 | 5483 | interface INamingContainer |
5484 | 5484 | { |
@@ -5489,7 +5489,7 @@ discard block |
||
5489 | 5489 | } |
5490 | 5490 | interface IPostBackDataHandler |
5491 | 5491 | { |
5492 | - public function loadPostData($key,$values); |
|
5492 | + public function loadPostData($key, $values); |
|
5493 | 5493 | public function raisePostDataChangedEvent(); |
5494 | 5494 | public function getDataChanged(); |
5495 | 5495 | } |
@@ -5509,7 +5509,7 @@ discard block |
||
5509 | 5509 | } |
5510 | 5510 | interface IBroadcastEventReceiver |
5511 | 5511 | { |
5512 | - public function broadcastEventReceived($sender,$param); |
|
5512 | + public function broadcastEventReceived($sender, $param); |
|
5513 | 5513 | } |
5514 | 5514 | interface ITheme |
5515 | 5515 | { |
@@ -5545,7 +5545,7 @@ discard block |
||
5545 | 5545 | { |
5546 | 5546 | private $_name; |
5547 | 5547 | private $_param; |
5548 | - public function __construct($name='',$parameter=null) |
|
5548 | + public function __construct($name='', $parameter=null) |
|
5549 | 5549 | { |
5550 | 5550 | $this->_name=$name; |
5551 | 5551 | $this->_param=$parameter; |
@@ -5571,7 +5571,7 @@ discard block |
||
5571 | 5571 | { |
5572 | 5572 | private $_name; |
5573 | 5573 | private $_param; |
5574 | - public function __construct($name='',$parameter='') |
|
5574 | + public function __construct($name='', $parameter='') |
|
5575 | 5575 | { |
5576 | 5576 | $this->_name=$name; |
5577 | 5577 | $this->_param=$parameter; |
@@ -5626,7 +5626,7 @@ discard block |
||
5626 | 5626 | } |
5627 | 5627 | public function evaluateDynamicContent() |
5628 | 5628 | { |
5629 | - $context=$this->_container===null?$this:$this->_container; |
|
5629 | + $context=$this->_container===null ? $this : $this->_container; |
|
5630 | 5630 | foreach($this->_expressions as $id=>$expression) |
5631 | 5631 | $this->_items[$id]=$context->evaluateExpression($expression); |
5632 | 5632 | foreach($this->_statements as $id=>$statement) |
@@ -5634,13 +5634,13 @@ discard block |
||
5634 | 5634 | } |
5635 | 5635 | public function dataBind() |
5636 | 5636 | { |
5637 | - $context=$this->_container===null?$this:$this->_container; |
|
5637 | + $context=$this->_container===null ? $this : $this->_container; |
|
5638 | 5638 | foreach($this->_bindings as $id=>$binding) |
5639 | 5639 | $this->_items[$id]=$context->evaluateExpression($binding); |
5640 | 5640 | } |
5641 | 5641 | public function render($writer) |
5642 | 5642 | { |
5643 | - $writer->write(implode('',$this->_items)); |
|
5643 | + $writer->write(implode('', $this->_items)); |
|
5644 | 5644 | } |
5645 | 5645 | } |
5646 | 5646 | class TFont extends TComponent |
@@ -5663,12 +5663,12 @@ discard block |
||
5663 | 5663 | protected function _getZappableSleepProps(&$exprops) |
5664 | 5664 | { |
5665 | 5665 | parent::_getZappableSleepProps($exprops); |
5666 | - if ($this->_flags===0) |
|
5667 | - $exprops[] = "\0TFont\0_flags"; |
|
5668 | - if ($this->_name==='') |
|
5669 | - $exprops[] = "\0TFont\0_name"; |
|
5670 | - if ($this->_size==='') |
|
5671 | - $exprops[] = "\0TFont\0_size"; |
|
5666 | + if($this->_flags===0) |
|
5667 | + $exprops[]="\0TFont\0_flags"; |
|
5668 | + if($this->_name==='') |
|
5669 | + $exprops[]="\0TFont\0_name"; |
|
5670 | + if($this->_size==='') |
|
5671 | + $exprops[]="\0TFont\0_size"; |
|
5672 | 5672 | } |
5673 | 5673 | public function getBold() |
5674 | 5674 | { |
@@ -5676,11 +5676,11 @@ discard block |
||
5676 | 5676 | } |
5677 | 5677 | public function setBold($value) |
5678 | 5678 | { |
5679 | - $this->_flags |= self::IS_SET_BOLD; |
|
5679 | + $this->_flags|=self::IS_SET_BOLD; |
|
5680 | 5680 | if(TPropertyValue::ensureBoolean($value)) |
5681 | - $this->_flags |= self::IS_BOLD; |
|
5681 | + $this->_flags|=self::IS_BOLD; |
|
5682 | 5682 | else |
5683 | - $this->_flags &= ~self::IS_BOLD; |
|
5683 | + $this->_flags&=~self::IS_BOLD; |
|
5684 | 5684 | } |
5685 | 5685 | public function getItalic() |
5686 | 5686 | { |
@@ -5688,11 +5688,11 @@ discard block |
||
5688 | 5688 | } |
5689 | 5689 | public function setItalic($value) |
5690 | 5690 | { |
5691 | - $this->_flags |= self::IS_SET_ITALIC; |
|
5691 | + $this->_flags|=self::IS_SET_ITALIC; |
|
5692 | 5692 | if(TPropertyValue::ensureBoolean($value)) |
5693 | - $this->_flags |= self::IS_ITALIC; |
|
5693 | + $this->_flags|=self::IS_ITALIC; |
|
5694 | 5694 | else |
5695 | - $this->_flags &= ~self::IS_ITALIC; |
|
5695 | + $this->_flags&=~self::IS_ITALIC; |
|
5696 | 5696 | } |
5697 | 5697 | public function getOverline() |
5698 | 5698 | { |
@@ -5700,11 +5700,11 @@ discard block |
||
5700 | 5700 | } |
5701 | 5701 | public function setOverline($value) |
5702 | 5702 | { |
5703 | - $this->_flags |= self::IS_SET_OVERLINE; |
|
5703 | + $this->_flags|=self::IS_SET_OVERLINE; |
|
5704 | 5704 | if(TPropertyValue::ensureBoolean($value)) |
5705 | - $this->_flags |= self::IS_OVERLINE; |
|
5705 | + $this->_flags|=self::IS_OVERLINE; |
|
5706 | 5706 | else |
5707 | - $this->_flags &= ~self::IS_OVERLINE; |
|
5707 | + $this->_flags&=~self::IS_OVERLINE; |
|
5708 | 5708 | } |
5709 | 5709 | public function getSize() |
5710 | 5710 | { |
@@ -5712,7 +5712,7 @@ discard block |
||
5712 | 5712 | } |
5713 | 5713 | public function setSize($value) |
5714 | 5714 | { |
5715 | - $this->_flags |= self::IS_SET_SIZE; |
|
5715 | + $this->_flags|=self::IS_SET_SIZE; |
|
5716 | 5716 | $this->_size=$value; |
5717 | 5717 | } |
5718 | 5718 | public function getStrikeout() |
@@ -5721,11 +5721,11 @@ discard block |
||
5721 | 5721 | } |
5722 | 5722 | public function setStrikeout($value) |
5723 | 5723 | { |
5724 | - $this->_flags |= self::IS_SET_STRIKEOUT; |
|
5724 | + $this->_flags|=self::IS_SET_STRIKEOUT; |
|
5725 | 5725 | if(TPropertyValue::ensureBoolean($value)) |
5726 | - $this->_flags |= self::IS_STRIKEOUT; |
|
5726 | + $this->_flags|=self::IS_STRIKEOUT; |
|
5727 | 5727 | else |
5728 | - $this->_flags &= ~self::IS_STRIKEOUT; |
|
5728 | + $this->_flags&=~self::IS_STRIKEOUT; |
|
5729 | 5729 | } |
5730 | 5730 | public function getUnderline() |
5731 | 5731 | { |
@@ -5733,11 +5733,11 @@ discard block |
||
5733 | 5733 | } |
5734 | 5734 | public function setUnderline($value) |
5735 | 5735 | { |
5736 | - $this->_flags |= self::IS_SET_UNDERLINE; |
|
5736 | + $this->_flags|=self::IS_SET_UNDERLINE; |
|
5737 | 5737 | if(TPropertyValue::ensureBoolean($value)) |
5738 | - $this->_flags |= self::IS_UNDERLINE; |
|
5738 | + $this->_flags|=self::IS_UNDERLINE; |
|
5739 | 5739 | else |
5740 | - $this->_flags &= ~self::IS_UNDERLINE; |
|
5740 | + $this->_flags&=~self::IS_UNDERLINE; |
|
5741 | 5741 | } |
5742 | 5742 | public function getName() |
5743 | 5743 | { |
@@ -5745,7 +5745,7 @@ discard block |
||
5745 | 5745 | } |
5746 | 5746 | public function setName($value) |
5747 | 5747 | { |
5748 | - $this->_flags |= self::IS_SET_NAME; |
|
5748 | + $this->_flags|=self::IS_SET_NAME; |
|
5749 | 5749 | $this->_name=$value; |
5750 | 5750 | } |
5751 | 5751 | public function getIsEmpty() |
@@ -5802,9 +5802,9 @@ discard block |
||
5802 | 5802 | return ''; |
5803 | 5803 | $str=''; |
5804 | 5804 | if($this->_flags & self::IS_SET_BOLD) |
5805 | - $str.='font-weight:'.(($this->_flags & self::IS_BOLD)?'bold;':'normal;'); |
|
5805 | + $str.='font-weight:'.(($this->_flags & self::IS_BOLD) ? 'bold;' : 'normal;'); |
|
5806 | 5806 | if($this->_flags & self::IS_SET_ITALIC) |
5807 | - $str.='font-style:'.(($this->_flags & self::IS_ITALIC)?'italic;':'normal;'); |
|
5807 | + $str.='font-style:'.(($this->_flags & self::IS_ITALIC) ? 'italic;' : 'normal;'); |
|
5808 | 5808 | $textDec=''; |
5809 | 5809 | if($this->_flags & self::IS_UNDERLINE) |
5810 | 5810 | $textDec.='underline'; |
@@ -5826,9 +5826,9 @@ discard block |
||
5826 | 5826 | if($this->_flags===0) |
5827 | 5827 | return; |
5828 | 5828 | if($this->_flags & self::IS_SET_BOLD) |
5829 | - $writer->addStyleAttribute('font-weight',(($this->_flags & self::IS_BOLD)?'bold':'normal')); |
|
5829 | + $writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD) ? 'bold' : 'normal')); |
|
5830 | 5830 | if($this->_flags & self::IS_SET_ITALIC) |
5831 | - $writer->addStyleAttribute('font-style',(($this->_flags & self::IS_ITALIC)?'italic':'normal')); |
|
5831 | + $writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC) ? 'italic' : 'normal')); |
|
5832 | 5832 | $textDec=''; |
5833 | 5833 | if($this->_flags & self::IS_UNDERLINE) |
5834 | 5834 | $textDec.='underline'; |
@@ -5838,11 +5838,11 @@ discard block |
||
5838 | 5838 | $textDec.=' line-through'; |
5839 | 5839 | $textDec=ltrim($textDec); |
5840 | 5840 | if($textDec!=='') |
5841 | - $writer->addStyleAttribute('text-decoration',$textDec); |
|
5841 | + $writer->addStyleAttribute('text-decoration', $textDec); |
|
5842 | 5842 | if($this->_size!=='') |
5843 | - $writer->addStyleAttribute('font-size',$this->_size); |
|
5843 | + $writer->addStyleAttribute('font-size', $this->_size); |
|
5844 | 5844 | if($this->_name!=='') |
5845 | - $writer->addStyleAttribute('font-family',$this->_name); |
|
5845 | + $writer->addStyleAttribute('font-family', $this->_name); |
|
5846 | 5846 | } |
5847 | 5847 | } |
5848 | 5848 | class TStyle extends TComponent |
@@ -5855,16 +5855,16 @@ discard block |
||
5855 | 5855 | protected function _getZappableSleepProps(&$exprops) |
5856 | 5856 | { |
5857 | 5857 | parent::_getZappableSleepProps($exprops); |
5858 | - if ($this->_fields===array()) |
|
5859 | - $exprops[] = "\0TStyle\0_fields"; |
|
5858 | + if($this->_fields===array()) |
|
5859 | + $exprops[]="\0TStyle\0_fields"; |
|
5860 | 5860 | if($this->_font===null) |
5861 | - $exprops[] = "\0TStyle\0_font"; |
|
5861 | + $exprops[]="\0TStyle\0_font"; |
|
5862 | 5862 | if($this->_class===null) |
5863 | - $exprops[] = "\0TStyle\0_class"; |
|
5864 | - if ($this->_customStyle===null) |
|
5865 | - $exprops[] = "\0TStyle\0_customStyle"; |
|
5866 | - if ($this->_displayStyle==='Fixed') |
|
5867 | - $exprops[] = "\0TStyle\0_displayStyle"; |
|
5863 | + $exprops[]="\0TStyle\0_class"; |
|
5864 | + if($this->_customStyle===null) |
|
5865 | + $exprops[]="\0TStyle\0_customStyle"; |
|
5866 | + if($this->_displayStyle==='Fixed') |
|
5867 | + $exprops[]="\0TStyle\0_displayStyle"; |
|
5868 | 5868 | } |
5869 | 5869 | public function __construct($style=null) |
5870 | 5870 | { |
@@ -5875,11 +5875,11 @@ discard block |
||
5875 | 5875 | public function __clone() |
5876 | 5876 | { |
5877 | 5877 | if($this->_font!==null) |
5878 | - $this->_font = clone($this->_font); |
|
5878 | + $this->_font=clone($this->_font); |
|
5879 | 5879 | } |
5880 | 5880 | public function getBackColor() |
5881 | 5881 | { |
5882 | - return isset($this->_fields['background-color'])?$this->_fields['background-color']:''; |
|
5882 | + return isset($this->_fields['background-color']) ? $this->_fields['background-color'] : ''; |
|
5883 | 5883 | } |
5884 | 5884 | public function setBackColor($value) |
5885 | 5885 | { |
@@ -5890,7 +5890,7 @@ discard block |
||
5890 | 5890 | } |
5891 | 5891 | public function getBorderColor() |
5892 | 5892 | { |
5893 | - return isset($this->_fields['border-color'])?$this->_fields['border-color']:''; |
|
5893 | + return isset($this->_fields['border-color']) ? $this->_fields['border-color'] : ''; |
|
5894 | 5894 | } |
5895 | 5895 | public function setBorderColor($value) |
5896 | 5896 | { |
@@ -5901,7 +5901,7 @@ discard block |
||
5901 | 5901 | } |
5902 | 5902 | public function getBorderStyle() |
5903 | 5903 | { |
5904 | - return isset($this->_fields['border-style'])?$this->_fields['border-style']:''; |
|
5904 | + return isset($this->_fields['border-style']) ? $this->_fields['border-style'] : ''; |
|
5905 | 5905 | } |
5906 | 5906 | public function setBorderStyle($value) |
5907 | 5907 | { |
@@ -5912,7 +5912,7 @@ discard block |
||
5912 | 5912 | } |
5913 | 5913 | public function getBorderWidth() |
5914 | 5914 | { |
5915 | - return isset($this->_fields['border-width'])?$this->_fields['border-width']:''; |
|
5915 | + return isset($this->_fields['border-width']) ? $this->_fields['border-width'] : ''; |
|
5916 | 5916 | } |
5917 | 5917 | public function setBorderWidth($value) |
5918 | 5918 | { |
@@ -5923,7 +5923,7 @@ discard block |
||
5923 | 5923 | } |
5924 | 5924 | public function getCssClass() |
5925 | 5925 | { |
5926 | - return $this->_class===null?'':$this->_class; |
|
5926 | + return $this->_class===null ? '' : $this->_class; |
|
5927 | 5927 | } |
5928 | 5928 | public function hasCssClass() |
5929 | 5929 | { |
@@ -5941,23 +5941,23 @@ discard block |
||
5941 | 5941 | } |
5942 | 5942 | public function hasFont() |
5943 | 5943 | { |
5944 | - return $this->_font !== null; |
|
5944 | + return $this->_font!==null; |
|
5945 | 5945 | } |
5946 | 5946 | public function setDisplayStyle($value) |
5947 | 5947 | { |
5948 | - $this->_displayStyle = TPropertyValue::ensureEnum($value, 'TDisplayStyle'); |
|
5948 | + $this->_displayStyle=TPropertyValue::ensureEnum($value, 'TDisplayStyle'); |
|
5949 | 5949 | switch($this->_displayStyle) |
5950 | 5950 | { |
5951 | 5951 | case TDisplayStyle::None: |
5952 | - $this->_fields['display'] = 'none'; |
|
5952 | + $this->_fields['display']='none'; |
|
5953 | 5953 | break; |
5954 | 5954 | case TDisplayStyle::Dynamic: |
5955 | - $this->_fields['display'] = ''; break; |
|
5955 | + $this->_fields['display']=''; break; |
|
5956 | 5956 | case TDisplayStyle::Fixed: |
5957 | - $this->_fields['visibility'] = 'visible'; |
|
5957 | + $this->_fields['visibility']='visible'; |
|
5958 | 5958 | break; |
5959 | 5959 | case TDisplayStyle::Hidden: |
5960 | - $this->_fields['visibility'] = 'hidden'; |
|
5960 | + $this->_fields['visibility']='hidden'; |
|
5961 | 5961 | break; |
5962 | 5962 | } |
5963 | 5963 | } |
@@ -5967,7 +5967,7 @@ discard block |
||
5967 | 5967 | } |
5968 | 5968 | public function getForeColor() |
5969 | 5969 | { |
5970 | - return isset($this->_fields['color'])?$this->_fields['color']:''; |
|
5970 | + return isset($this->_fields['color']) ? $this->_fields['color'] : ''; |
|
5971 | 5971 | } |
5972 | 5972 | public function setForeColor($value) |
5973 | 5973 | { |
@@ -5978,7 +5978,7 @@ discard block |
||
5978 | 5978 | } |
5979 | 5979 | public function getHeight() |
5980 | 5980 | { |
5981 | - return isset($this->_fields['height'])?$this->_fields['height']:''; |
|
5981 | + return isset($this->_fields['height']) ? $this->_fields['height'] : ''; |
|
5982 | 5982 | } |
5983 | 5983 | public function setHeight($value) |
5984 | 5984 | { |
@@ -5989,7 +5989,7 @@ discard block |
||
5989 | 5989 | } |
5990 | 5990 | public function getCustomStyle() |
5991 | 5991 | { |
5992 | - return $this->_customStyle===null?'':$this->_customStyle; |
|
5992 | + return $this->_customStyle===null ? '' : $this->_customStyle; |
|
5993 | 5993 | } |
5994 | 5994 | public function setCustomStyle($value) |
5995 | 5995 | { |
@@ -5997,9 +5997,9 @@ discard block |
||
5997 | 5997 | } |
5998 | 5998 | public function getStyleField($name) |
5999 | 5999 | { |
6000 | - return isset($this->_fields[$name])?$this->_fields[$name]:''; |
|
6000 | + return isset($this->_fields[$name]) ? $this->_fields[$name] : ''; |
|
6001 | 6001 | } |
6002 | - public function setStyleField($name,$value) |
|
6002 | + public function setStyleField($name, $value) |
|
6003 | 6003 | { |
6004 | 6004 | $this->_fields[$name]=$value; |
6005 | 6005 | } |
@@ -6013,7 +6013,7 @@ discard block |
||
6013 | 6013 | } |
6014 | 6014 | public function getWidth() |
6015 | 6015 | { |
6016 | - return isset($this->_fields['width'])?$this->_fields['width']:''; |
|
6016 | + return isset($this->_fields['width']) ? $this->_fields['width'] : ''; |
|
6017 | 6017 | } |
6018 | 6018 | public function setWidth($value) |
6019 | 6019 | { |
@@ -6030,7 +6030,7 @@ discard block |
||
6030 | 6030 | { |
6031 | 6031 | if($style instanceof TStyle) |
6032 | 6032 | { |
6033 | - $this->_fields=array_merge($this->_fields,$style->_fields); |
|
6033 | + $this->_fields=array_merge($this->_fields, $style->_fields); |
|
6034 | 6034 | if($style->_class!==null) |
6035 | 6035 | $this->_class=$style->_class; |
6036 | 6036 | if($style->_customStyle!==null) |
@@ -6043,7 +6043,7 @@ discard block |
||
6043 | 6043 | { |
6044 | 6044 | if($style instanceof TStyle) |
6045 | 6045 | { |
6046 | - $this->_fields=array_merge($style->_fields,$this->_fields); |
|
6046 | + $this->_fields=array_merge($style->_fields, $this->_fields); |
|
6047 | 6047 | if($this->_class===null) |
6048 | 6048 | $this->_class=$style->_class; |
6049 | 6049 | if($this->_customStyle===null) |
@@ -6056,18 +6056,18 @@ discard block |
||
6056 | 6056 | { |
6057 | 6057 | if($this->_customStyle!==null) |
6058 | 6058 | { |
6059 | - foreach(explode(';',$this->_customStyle) as $style) |
|
6059 | + foreach(explode(';', $this->_customStyle) as $style) |
|
6060 | 6060 | { |
6061 | - $arr=explode(':',$style,2); |
|
6061 | + $arr=explode(':', $style, 2); |
|
6062 | 6062 | if(isset($arr[1]) && trim($arr[0])!=='') |
6063 | - $writer->addStyleAttribute(trim($arr[0]),trim($arr[1])); |
|
6063 | + $writer->addStyleAttribute(trim($arr[0]), trim($arr[1])); |
|
6064 | 6064 | } |
6065 | 6065 | } |
6066 | 6066 | $writer->addStyleAttributes($this->_fields); |
6067 | 6067 | if($this->_font!==null) |
6068 | 6068 | $this->_font->addAttributesToRender($writer); |
6069 | 6069 | if($this->_class!==null) |
6070 | - $writer->addAttribute('class',$this->_class); |
|
6070 | + $writer->addAttribute('class', $this->_class); |
|
6071 | 6071 | } |
6072 | 6072 | public function getStyleFields() |
6073 | 6073 | { |
@@ -6092,18 +6092,18 @@ discard block |
||
6092 | 6092 | protected function _getZappableSleepProps(&$exprops) |
6093 | 6093 | { |
6094 | 6094 | parent::_getZappableSleepProps($exprops); |
6095 | - if ($this->_backImageUrl===null) |
|
6096 | - $exprops[] = "\0TTableStyle\0_backImageUrl"; |
|
6097 | - if ($this->_horizontalAlign===null) |
|
6098 | - $exprops[] = "\0TTableStyle\0_horizontalAlign"; |
|
6099 | - if ($this->_cellPadding===null) |
|
6100 | - $exprops[] = "\0TTableStyle\0_cellPadding"; |
|
6101 | - if ($this->_cellSpacing===null) |
|
6102 | - $exprops[] = "\0TTableStyle\0_cellSpacing"; |
|
6103 | - if ($this->_gridLines===null) |
|
6104 | - $exprops[] = "\0TTableStyle\0_gridLines"; |
|
6105 | - if ($this->_borderCollapse===null) |
|
6106 | - $exprops[] = "\0TTableStyle\0_borderCollapse"; |
|
6095 | + if($this->_backImageUrl===null) |
|
6096 | + $exprops[]="\0TTableStyle\0_backImageUrl"; |
|
6097 | + if($this->_horizontalAlign===null) |
|
6098 | + $exprops[]="\0TTableStyle\0_horizontalAlign"; |
|
6099 | + if($this->_cellPadding===null) |
|
6100 | + $exprops[]="\0TTableStyle\0_cellPadding"; |
|
6101 | + if($this->_cellSpacing===null) |
|
6102 | + $exprops[]="\0TTableStyle\0_cellSpacing"; |
|
6103 | + if($this->_gridLines===null) |
|
6104 | + $exprops[]="\0TTableStyle\0_gridLines"; |
|
6105 | + if($this->_borderCollapse===null) |
|
6106 | + $exprops[]="\0TTableStyle\0_borderCollapse"; |
|
6107 | 6107 | } |
6108 | 6108 | public function reset() |
6109 | 6109 | { |
@@ -6155,26 +6155,26 @@ discard block |
||
6155 | 6155 | public function addAttributesToRender($writer) |
6156 | 6156 | { |
6157 | 6157 | if(($url=trim($this->getBackImageUrl()))!=='') |
6158 | - $writer->addStyleAttribute('background-image','url('.$url.')'); |
|
6158 | + $writer->addStyleAttribute('background-image', 'url('.$url.')'); |
|
6159 | 6159 | if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) |
6160 | - $writer->addStyleAttribute('text-align',strtolower($horizontalAlign)); |
|
6161 | - if(($cellPadding=$this->getCellPadding())>=0) |
|
6162 | - $writer->addAttribute('cellpadding',"$cellPadding"); |
|
6163 | - if(($cellSpacing=$this->getCellSpacing())>=0) |
|
6164 | - $writer->addAttribute('cellspacing',"$cellSpacing"); |
|
6160 | + $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
|
6161 | + if(($cellPadding=$this->getCellPadding()) >= 0) |
|
6162 | + $writer->addAttribute('cellpadding', "$cellPadding"); |
|
6163 | + if(($cellSpacing=$this->getCellSpacing()) >= 0) |
|
6164 | + $writer->addAttribute('cellspacing', "$cellSpacing"); |
|
6165 | 6165 | if($this->getBorderCollapse()) |
6166 | - $writer->addStyleAttribute('border-collapse','collapse'); |
|
6166 | + $writer->addStyleAttribute('border-collapse', 'collapse'); |
|
6167 | 6167 | switch($this->getGridLines()) |
6168 | 6168 | { |
6169 | - case TTableGridLines::Horizontal : $writer->addAttribute('rules','rows'); break; |
|
6170 | - case TTableGridLines::Vertical : $writer->addAttribute('rules','cols'); break; |
|
6171 | - case TTableGridLines::Both : $writer->addAttribute('rules','all'); break; |
|
6169 | + case TTableGridLines::Horizontal : $writer->addAttribute('rules', 'rows'); break; |
|
6170 | + case TTableGridLines::Vertical : $writer->addAttribute('rules', 'cols'); break; |
|
6171 | + case TTableGridLines::Both : $writer->addAttribute('rules', 'all'); break; |
|
6172 | 6172 | } |
6173 | 6173 | parent::addAttributesToRender($writer); |
6174 | 6174 | } |
6175 | 6175 | public function getBackImageUrl() |
6176 | 6176 | { |
6177 | - return $this->_backImageUrl===null?'':$this->_backImageUrl; |
|
6177 | + return $this->_backImageUrl===null ? '' : $this->_backImageUrl; |
|
6178 | 6178 | } |
6179 | 6179 | public function setBackImageUrl($value) |
6180 | 6180 | { |
@@ -6182,41 +6182,41 @@ discard block |
||
6182 | 6182 | } |
6183 | 6183 | public function getHorizontalAlign() |
6184 | 6184 | { |
6185 | - return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
6185 | + return $this->_horizontalAlign===null ? THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
6186 | 6186 | } |
6187 | 6187 | public function setHorizontalAlign($value) |
6188 | 6188 | { |
6189 | - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); |
|
6189 | + $this->_horizontalAlign=TPropertyValue::ensureEnum($value, 'THorizontalAlign'); |
|
6190 | 6190 | } |
6191 | 6191 | public function getCellPadding() |
6192 | 6192 | { |
6193 | - return $this->_cellPadding===null?-1:$this->_cellPadding; |
|
6193 | + return $this->_cellPadding===null ?-1 : $this->_cellPadding; |
|
6194 | 6194 | } |
6195 | 6195 | public function setCellPadding($value) |
6196 | 6196 | { |
6197 | - if(($this->_cellPadding=TPropertyValue::ensureInteger($value))<-1) |
|
6197 | + if(($this->_cellPadding=TPropertyValue::ensureInteger($value)) < -1) |
|
6198 | 6198 | throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
6199 | 6199 | } |
6200 | 6200 | public function getCellSpacing() |
6201 | 6201 | { |
6202 | - return $this->_cellSpacing===null?-1:$this->_cellSpacing; |
|
6202 | + return $this->_cellSpacing===null ?-1 : $this->_cellSpacing; |
|
6203 | 6203 | } |
6204 | 6204 | public function setCellSpacing($value) |
6205 | 6205 | { |
6206 | - if(($this->_cellSpacing=TPropertyValue::ensureInteger($value))<-1) |
|
6206 | + if(($this->_cellSpacing=TPropertyValue::ensureInteger($value)) < -1) |
|
6207 | 6207 | throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
6208 | 6208 | } |
6209 | 6209 | public function getGridLines() |
6210 | 6210 | { |
6211 | - return $this->_gridLines===null?TTableGridLines::None:$this->_gridLines; |
|
6211 | + return $this->_gridLines===null ? TTableGridLines::None : $this->_gridLines; |
|
6212 | 6212 | } |
6213 | 6213 | public function setGridLines($value) |
6214 | 6214 | { |
6215 | - $this->_gridLines=TPropertyValue::ensureEnum($value,'TTableGridLines'); |
|
6215 | + $this->_gridLines=TPropertyValue::ensureEnum($value, 'TTableGridLines'); |
|
6216 | 6216 | } |
6217 | 6217 | public function getBorderCollapse() |
6218 | 6218 | { |
6219 | - return $this->_borderCollapse===null?false:$this->_borderCollapse; |
|
6219 | + return $this->_borderCollapse===null ? false : $this->_borderCollapse; |
|
6220 | 6220 | } |
6221 | 6221 | public function setBorderCollapse($value) |
6222 | 6222 | { |
@@ -6231,12 +6231,12 @@ discard block |
||
6231 | 6231 | protected function _getZappableSleepProps(&$exprops) |
6232 | 6232 | { |
6233 | 6233 | parent::_getZappableSleepProps($exprops); |
6234 | - if ($this->_horizontalAlign===null) |
|
6235 | - $exprops[] = "\0TTableItemStyle\0_horizontalAlign"; |
|
6236 | - if ($this->_verticalAlign===null) |
|
6237 | - $exprops[] = "\0TTableItemStyle\0_verticalAlign"; |
|
6238 | - if ($this->_wrap===null) |
|
6239 | - $exprops[] = "\0TTableItemStyle\0_wrap"; |
|
6234 | + if($this->_horizontalAlign===null) |
|
6235 | + $exprops[]="\0TTableItemStyle\0_horizontalAlign"; |
|
6236 | + if($this->_verticalAlign===null) |
|
6237 | + $exprops[]="\0TTableItemStyle\0_verticalAlign"; |
|
6238 | + if($this->_wrap===null) |
|
6239 | + $exprops[]="\0TTableItemStyle\0_wrap"; |
|
6240 | 6240 | } |
6241 | 6241 | public function reset() |
6242 | 6242 | { |
@@ -6274,32 +6274,32 @@ discard block |
||
6274 | 6274 | public function addAttributesToRender($writer) |
6275 | 6275 | { |
6276 | 6276 | if(!$this->getWrap()) |
6277 | - $writer->addStyleAttribute('white-space','nowrap'); |
|
6277 | + $writer->addStyleAttribute('white-space', 'nowrap'); |
|
6278 | 6278 | if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) |
6279 | - $writer->addAttribute('align',strtolower($horizontalAlign)); |
|
6279 | + $writer->addAttribute('align', strtolower($horizontalAlign)); |
|
6280 | 6280 | if(($verticalAlign=$this->getVerticalAlign())!==TVerticalAlign::NotSet) |
6281 | - $writer->addAttribute('valign',strtolower($verticalAlign)); |
|
6281 | + $writer->addAttribute('valign', strtolower($verticalAlign)); |
|
6282 | 6282 | parent::addAttributesToRender($writer); |
6283 | 6283 | } |
6284 | 6284 | public function getHorizontalAlign() |
6285 | 6285 | { |
6286 | - return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
6286 | + return $this->_horizontalAlign===null ? THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
6287 | 6287 | } |
6288 | 6288 | public function setHorizontalAlign($value) |
6289 | 6289 | { |
6290 | - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); |
|
6290 | + $this->_horizontalAlign=TPropertyValue::ensureEnum($value, 'THorizontalAlign'); |
|
6291 | 6291 | } |
6292 | 6292 | public function getVerticalAlign() |
6293 | 6293 | { |
6294 | - return $this->_verticalAlign===null?TVerticalAlign::NotSet:$this->_verticalAlign; |
|
6294 | + return $this->_verticalAlign===null ? TVerticalAlign::NotSet : $this->_verticalAlign; |
|
6295 | 6295 | } |
6296 | 6296 | public function setVerticalAlign($value) |
6297 | 6297 | { |
6298 | - $this->_verticalAlign=TPropertyValue::ensureEnum($value,'TVerticalAlign'); |
|
6298 | + $this->_verticalAlign=TPropertyValue::ensureEnum($value, 'TVerticalAlign'); |
|
6299 | 6299 | } |
6300 | 6300 | public function getWrap() |
6301 | 6301 | { |
6302 | - return $this->_wrap===null?true:$this->_wrap; |
|
6302 | + return $this->_wrap===null ? true : $this->_wrap; |
|
6303 | 6303 | } |
6304 | 6304 | public function setWrap($value) |
6305 | 6305 | { |
@@ -6351,21 +6351,21 @@ discard block |
||
6351 | 6351 | } |
6352 | 6352 | class TWebControlDecorator extends TComponent { |
6353 | 6353 | private $_internalonly; |
6354 | - private $_usestate = false; |
|
6354 | + private $_usestate=false; |
|
6355 | 6355 | private $_control; |
6356 | 6356 | private $_outercontrol; |
6357 | 6357 | private $_addedTemplateDecoration=false; |
6358 | - private $_pretagtext = ''; |
|
6359 | - private $_precontentstext = ''; |
|
6360 | - private $_postcontentstext = ''; |
|
6361 | - private $_posttagtext = ''; |
|
6358 | + private $_pretagtext=''; |
|
6359 | + private $_precontentstext=''; |
|
6360 | + private $_postcontentstext=''; |
|
6361 | + private $_posttagtext=''; |
|
6362 | 6362 | private $_pretagtemplate; |
6363 | 6363 | private $_precontentstemplate; |
6364 | 6364 | private $_postcontentstemplate; |
6365 | 6365 | private $_posttagtemplate; |
6366 | - public function __construct($control, $onlyinternal = false) { |
|
6367 | - $this->_control = $control; |
|
6368 | - $this->_internalonly = $onlyinternal; |
|
6366 | + public function __construct($control, $onlyinternal=false) { |
|
6367 | + $this->_control=$control; |
|
6368 | + $this->_internalonly=$onlyinternal; |
|
6369 | 6369 | } |
6370 | 6370 | public function getUseState() |
6371 | 6371 | { |
@@ -6373,91 +6373,91 @@ discard block |
||
6373 | 6373 | } |
6374 | 6374 | public function setUseState($value) |
6375 | 6375 | { |
6376 | - $this->_usestate = TPropertyValue::ensureBoolean($value); |
|
6376 | + $this->_usestate=TPropertyValue::ensureBoolean($value); |
|
6377 | 6377 | } |
6378 | 6378 | public function getPreTagText() { |
6379 | 6379 | return $this->_pretagtext; |
6380 | 6380 | } |
6381 | 6381 | public function setPreTagText($value) { |
6382 | 6382 | if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
6383 | - $this->_pretagtext = TPropertyValue::ensureString($value); |
|
6383 | + $this->_pretagtext=TPropertyValue::ensureString($value); |
|
6384 | 6384 | } |
6385 | 6385 | public function getPreContentsText() { |
6386 | 6386 | return $this->_precontentstext; |
6387 | 6387 | } |
6388 | 6388 | public function setPreContentsText($value) { |
6389 | 6389 | if(!$this->_control->getIsSkinApplied()) |
6390 | - $this->_precontentstext = TPropertyValue::ensureString($value); |
|
6390 | + $this->_precontentstext=TPropertyValue::ensureString($value); |
|
6391 | 6391 | } |
6392 | 6392 | public function getPostContentsText() { |
6393 | 6393 | return $this->_postcontentstext; |
6394 | 6394 | } |
6395 | 6395 | public function setPostContentsText($value) { |
6396 | 6396 | if(!$this->_control->getIsSkinApplied()) |
6397 | - $this->_postcontentstext = TPropertyValue::ensureString($value); |
|
6397 | + $this->_postcontentstext=TPropertyValue::ensureString($value); |
|
6398 | 6398 | } |
6399 | 6399 | public function getPostTagText() { |
6400 | 6400 | return $this->_posttagtext; |
6401 | 6401 | } |
6402 | 6402 | public function setPostTagText($value) { |
6403 | 6403 | if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
6404 | - $this->_posttagtext = TPropertyValue::ensureString($value); |
|
6404 | + $this->_posttagtext=TPropertyValue::ensureString($value); |
|
6405 | 6405 | } |
6406 | 6406 | public function getPreTagTemplate() { |
6407 | 6407 | return $this->_pretagtemplate; |
6408 | 6408 | } |
6409 | 6409 | public function setPreTagTemplate($value) { |
6410 | 6410 | if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
6411 | - $this->_pretagtemplate = $value; |
|
6411 | + $this->_pretagtemplate=$value; |
|
6412 | 6412 | } |
6413 | 6413 | public function getPreContentsTemplate() { |
6414 | 6414 | return $this->_precontentstemplate; |
6415 | 6415 | } |
6416 | 6416 | public function setPreContentsTemplate($value) { |
6417 | 6417 | if(!$this->_control->getIsSkinApplied()) |
6418 | - $this->_precontentstemplate = $value; |
|
6418 | + $this->_precontentstemplate=$value; |
|
6419 | 6419 | } |
6420 | 6420 | public function getPostContentsTemplate() { |
6421 | 6421 | return $this->_postcontentstemplate; |
6422 | 6422 | } |
6423 | 6423 | public function setPostContentsTemplate($value) { |
6424 | 6424 | if(!$this->_control->getIsSkinApplied()) |
6425 | - $this->_postcontentstemplate = $value; |
|
6425 | + $this->_postcontentstemplate=$value; |
|
6426 | 6426 | } |
6427 | 6427 | public function getPostTagTemplate() { |
6428 | 6428 | return $this->_posttagtemplate; |
6429 | 6429 | } |
6430 | 6430 | public function setPostTagTemplate($value) { |
6431 | 6431 | if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) |
6432 | - $this->_posttagtemplate = $value; |
|
6432 | + $this->_posttagtemplate=$value; |
|
6433 | 6433 | } |
6434 | - public function instantiate($outercontrol = null) { |
|
6434 | + public function instantiate($outercontrol=null) { |
|
6435 | 6435 | if($this->getPreTagTemplate() || $this->getPreContentsTemplate() || |
6436 | 6436 | $this->getPostContentsTemplate() || $this->getPostTagTemplate()) { |
6437 | - $this->_outercontrol = $outercontrol; |
|
6437 | + $this->_outercontrol=$outercontrol; |
|
6438 | 6438 | if($this->getUseState()) |
6439 | 6439 | $this->ensureTemplateDecoration(); |
6440 | 6440 | else |
6441 | - $this->_control->getPage()->onSaveStateComplete[] = array($this, 'ensureTemplateDecoration'); |
|
6441 | + $this->_control->getPage()->onSaveStateComplete[]=array($this, 'ensureTemplateDecoration'); |
|
6442 | 6442 | } |
6443 | 6443 | } |
6444 | 6444 | public function ensureTemplateDecoration($sender=null, $param=null) { |
6445 | - $control = $this->_control; |
|
6446 | - $outercontrol = $this->_outercontrol; |
|
6447 | - if($outercontrol === null) |
|
6448 | - $outercontrol = $control; |
|
6445 | + $control=$this->_control; |
|
6446 | + $outercontrol=$this->_outercontrol; |
|
6447 | + if($outercontrol===null) |
|
6448 | + $outercontrol=$control; |
|
6449 | 6449 | if($this->_addedTemplateDecoration) |
6450 | 6450 | return $this->_addedTemplateDecoration; |
6451 | - $this->_addedTemplateDecoration = true; |
|
6451 | + $this->_addedTemplateDecoration=true; |
|
6452 | 6452 | if($this->getPreContentsTemplate()) |
6453 | 6453 | { |
6454 | - $precontents = Prado::createComponent('TCompositeControl'); |
|
6454 | + $precontents=Prado::createComponent('TCompositeControl'); |
|
6455 | 6455 | $this->getPreContentsTemplate()->instantiateIn($precontents); |
6456 | 6456 | $control->getControls()->insertAt(0, $precontents); |
6457 | 6457 | } |
6458 | 6458 | if($this->getPostContentsTemplate()) |
6459 | 6459 | { |
6460 | - $postcontents = Prado::createComponent('TCompositeControl'); |
|
6460 | + $postcontents=Prado::createComponent('TCompositeControl'); |
|
6461 | 6461 | $this->getPostContentsTemplate()->instantiateIn($postcontents); |
6462 | 6462 | $control->getControls()->add($postcontents); |
6463 | 6463 | } |
@@ -6465,13 +6465,13 @@ discard block |
||
6465 | 6465 | return $this->_addedTemplateDecoration; |
6466 | 6466 | if($this->getPreTagTemplate()) |
6467 | 6467 | { |
6468 | - $pretag = Prado::createComponent('TCompositeControl'); |
|
6468 | + $pretag=Prado::createComponent('TCompositeControl'); |
|
6469 | 6469 | $this->getPreTagTemplate()->instantiateIn($pretag); |
6470 | 6470 | $outercontrol->getParent()->getControls()->insertBefore($outercontrol, $pretag); |
6471 | 6471 | } |
6472 | 6472 | if($this->getPostTagTemplate()) |
6473 | 6473 | { |
6474 | - $posttag = Prado::createComponent('TCompositeControl'); |
|
6474 | + $posttag=Prado::createComponent('TCompositeControl'); |
|
6475 | 6475 | $this->getPostTagTemplate()->instantiateIn($posttag); |
6476 | 6476 | $outercontrol->getParent()->getControls()->insertAfter($outercontrol, $posttag); |
6477 | 6477 | } |
@@ -6496,7 +6496,7 @@ discard block |
||
6496 | 6496 | protected $_decorator; |
6497 | 6497 | public function setEnsureId($value) |
6498 | 6498 | { |
6499 | - $this->_ensureid |= TPropertyValue::ensureBoolean($value); |
|
6499 | + $this->_ensureid|=TPropertyValue::ensureBoolean($value); |
|
6500 | 6500 | } |
6501 | 6501 | public function getEnsureId() |
6502 | 6502 | { |
@@ -6505,7 +6505,7 @@ discard block |
||
6505 | 6505 | public function getDecorator($create=true) |
6506 | 6506 | { |
6507 | 6507 | if($create && !$this->_decorator) |
6508 | - $this->_decorator = Prado::createComponent('TWebControlDecorator', $this); |
|
6508 | + $this->_decorator=Prado::createComponent('TWebControlDecorator', $this); |
|
6509 | 6509 | return $this->_decorator; |
6510 | 6510 | } |
6511 | 6511 | public function copyBaseAttributes(TWebControl $control) |
@@ -6520,17 +6520,17 @@ discard block |
||
6520 | 6520 | } |
6521 | 6521 | public function getAccessKey() |
6522 | 6522 | { |
6523 | - return $this->getViewState('AccessKey',''); |
|
6523 | + return $this->getViewState('AccessKey', ''); |
|
6524 | 6524 | } |
6525 | 6525 | public function setAccessKey($value) |
6526 | 6526 | { |
6527 | - if(strlen($value)>1) |
|
6528 | - throw new TInvalidDataValueException('webcontrol_accesskey_invalid',get_class($this),$value); |
|
6529 | - $this->setViewState('AccessKey',$value,''); |
|
6527 | + if(strlen($value) > 1) |
|
6528 | + throw new TInvalidDataValueException('webcontrol_accesskey_invalid', get_class($this), $value); |
|
6529 | + $this->setViewState('AccessKey', $value, ''); |
|
6530 | 6530 | } |
6531 | 6531 | public function getBackColor() |
6532 | 6532 | { |
6533 | - if($style=$this->getViewState('Style',null)) |
|
6533 | + if($style=$this->getViewState('Style', null)) |
|
6534 | 6534 | return $style->getBackColor(); |
6535 | 6535 | else |
6536 | 6536 | return ''; |
@@ -6541,7 +6541,7 @@ discard block |
||
6541 | 6541 | } |
6542 | 6542 | public function getBorderColor() |
6543 | 6543 | { |
6544 | - if($style=$this->getViewState('Style',null)) |
|
6544 | + if($style=$this->getViewState('Style', null)) |
|
6545 | 6545 | return $style->getBorderColor(); |
6546 | 6546 | else |
6547 | 6547 | return ''; |
@@ -6552,7 +6552,7 @@ discard block |
||
6552 | 6552 | } |
6553 | 6553 | public function getBorderStyle() |
6554 | 6554 | { |
6555 | - if($style=$this->getViewState('Style',null)) |
|
6555 | + if($style=$this->getViewState('Style', null)) |
|
6556 | 6556 | return $style->getBorderStyle(); |
6557 | 6557 | else |
6558 | 6558 | return ''; |
@@ -6563,7 +6563,7 @@ discard block |
||
6563 | 6563 | } |
6564 | 6564 | public function getBorderWidth() |
6565 | 6565 | { |
6566 | - if($style=$this->getViewState('Style',null)) |
|
6566 | + if($style=$this->getViewState('Style', null)) |
|
6567 | 6567 | return $style->getBorderWidth(); |
6568 | 6568 | else |
6569 | 6569 | return ''; |
@@ -6578,7 +6578,7 @@ discard block |
||
6578 | 6578 | } |
6579 | 6579 | public function getForeColor() |
6580 | 6580 | { |
6581 | - if($style=$this->getViewState('Style',null)) |
|
6581 | + if($style=$this->getViewState('Style', null)) |
|
6582 | 6582 | return $style->getForeColor(); |
6583 | 6583 | else |
6584 | 6584 | return ''; |
@@ -6589,7 +6589,7 @@ discard block |
||
6589 | 6589 | } |
6590 | 6590 | public function getHeight() |
6591 | 6591 | { |
6592 | - if($style=$this->getViewState('Style',null)) |
|
6592 | + if($style=$this->getViewState('Style', null)) |
|
6593 | 6593 | return $style->getHeight(); |
6594 | 6594 | else |
6595 | 6595 | return ''; |
@@ -6608,7 +6608,7 @@ discard block |
||
6608 | 6608 | } |
6609 | 6609 | public function getCssClass() |
6610 | 6610 | { |
6611 | - if($style=$this->getViewState('Style',null)) |
|
6611 | + if($style=$this->getViewState('Style', null)) |
|
6612 | 6612 | return $style->getCssClass(); |
6613 | 6613 | else |
6614 | 6614 | return ''; |
@@ -6619,7 +6619,7 @@ discard block |
||
6619 | 6619 | } |
6620 | 6620 | public function getHasStyle() |
6621 | 6621 | { |
6622 | - return $this->getViewState('Style',null)!==null; |
|
6622 | + return $this->getViewState('Style', null)!==null; |
|
6623 | 6623 | } |
6624 | 6624 | protected function createStyle() |
6625 | 6625 | { |
@@ -6627,12 +6627,12 @@ discard block |
||
6627 | 6627 | } |
6628 | 6628 | public function getStyle() |
6629 | 6629 | { |
6630 | - if($style=$this->getViewState('Style',null)) |
|
6630 | + if($style=$this->getViewState('Style', null)) |
|
6631 | 6631 | return $style; |
6632 | 6632 | else |
6633 | 6633 | { |
6634 | 6634 | $style=$this->createStyle(); |
6635 | - $this->setViewState('Style',$style,null); |
|
6635 | + $this->setViewState('Style', $style, null); |
|
6636 | 6636 | return $style; |
6637 | 6637 | } |
6638 | 6638 | } |
@@ -6641,7 +6641,7 @@ discard block |
||
6641 | 6641 | if(is_string($value)) |
6642 | 6642 | $this->getStyle()->setCustomStyle($value); |
6643 | 6643 | else |
6644 | - throw new TInvalidDataValueException('webcontrol_style_invalid',get_class($this)); |
|
6644 | + throw new TInvalidDataValueException('webcontrol_style_invalid', get_class($this)); |
|
6645 | 6645 | } |
6646 | 6646 | public function clearStyle() |
6647 | 6647 | { |
@@ -6649,11 +6649,11 @@ discard block |
||
6649 | 6649 | } |
6650 | 6650 | public function getTabIndex() |
6651 | 6651 | { |
6652 | - return $this->getViewState('TabIndex',0); |
|
6652 | + return $this->getViewState('TabIndex', 0); |
|
6653 | 6653 | } |
6654 | 6654 | public function setTabIndex($value) |
6655 | 6655 | { |
6656 | - $this->setViewState('TabIndex',TPropertyValue::ensureInteger($value),0); |
|
6656 | + $this->setViewState('TabIndex', TPropertyValue::ensureInteger($value), 0); |
|
6657 | 6657 | } |
6658 | 6658 | protected function getTagName() |
6659 | 6659 | { |
@@ -6661,15 +6661,15 @@ discard block |
||
6661 | 6661 | } |
6662 | 6662 | public function getToolTip() |
6663 | 6663 | { |
6664 | - return $this->getViewState('ToolTip',''); |
|
6664 | + return $this->getViewState('ToolTip', ''); |
|
6665 | 6665 | } |
6666 | 6666 | public function setToolTip($value) |
6667 | 6667 | { |
6668 | - $this->setViewState('ToolTip',$value,''); |
|
6668 | + $this->setViewState('ToolTip', $value, ''); |
|
6669 | 6669 | } |
6670 | 6670 | public function getWidth() |
6671 | 6671 | { |
6672 | - if($style=$this->getViewState('Style',null)) |
|
6672 | + if($style=$this->getViewState('Style', null)) |
|
6673 | 6673 | return $style->getWidth(); |
6674 | 6674 | else |
6675 | 6675 | return ''; |
@@ -6679,28 +6679,28 @@ discard block |
||
6679 | 6679 | $this->getStyle()->setWidth($value); |
6680 | 6680 | } |
6681 | 6681 | public function onPreRender($param) { |
6682 | - if($decorator = $this->getDecorator(false)) |
|
6682 | + if($decorator=$this->getDecorator(false)) |
|
6683 | 6683 | $decorator->instantiate(); |
6684 | 6684 | parent::onPreRender($param); |
6685 | 6685 | } |
6686 | 6686 | protected function addAttributesToRender($writer) |
6687 | 6687 | { |
6688 | 6688 | if($this->getID()!=='' || $this->getEnsureId()) |
6689 | - $writer->addAttribute('id',$this->getClientID()); |
|
6689 | + $writer->addAttribute('id', $this->getClientID()); |
|
6690 | 6690 | if(($accessKey=$this->getAccessKey())!=='') |
6691 | - $writer->addAttribute('accesskey',$accessKey); |
|
6691 | + $writer->addAttribute('accesskey', $accessKey); |
|
6692 | 6692 | if(!$this->getEnabled()) |
6693 | - $writer->addAttribute('disabled','disabled'); |
|
6694 | - if(($tabIndex=$this->getTabIndex())>0) |
|
6695 | - $writer->addAttribute('tabindex',"$tabIndex"); |
|
6693 | + $writer->addAttribute('disabled', 'disabled'); |
|
6694 | + if(($tabIndex=$this->getTabIndex()) > 0) |
|
6695 | + $writer->addAttribute('tabindex', "$tabIndex"); |
|
6696 | 6696 | if(($toolTip=$this->getToolTip())!=='') |
6697 | - $writer->addAttribute('title',$toolTip); |
|
6698 | - if($style=$this->getViewState('Style',null)) |
|
6697 | + $writer->addAttribute('title', $toolTip); |
|
6698 | + if($style=$this->getViewState('Style', null)) |
|
6699 | 6699 | $style->addAttributesToRender($writer); |
6700 | 6700 | if($this->getHasAttributes()) |
6701 | 6701 | { |
6702 | 6702 | foreach($this->getAttributes() as $name=>$value) |
6703 | - $writer->addAttribute($name,$value); |
|
6703 | + $writer->addAttribute($name, $value); |
|
6704 | 6704 | } |
6705 | 6705 | } |
6706 | 6706 | public function render($writer) |
@@ -6711,7 +6711,7 @@ discard block |
||
6711 | 6711 | } |
6712 | 6712 | public function renderBeginTag($writer) |
6713 | 6713 | { |
6714 | - if($decorator = $this->getDecorator(false)) { |
|
6714 | + if($decorator=$this->getDecorator(false)) { |
|
6715 | 6715 | $decorator->renderPreTagText($writer); |
6716 | 6716 | $this->addAttributesToRender($writer); |
6717 | 6717 | $writer->renderBeginTag($this->getTagName()); |
@@ -6727,7 +6727,7 @@ discard block |
||
6727 | 6727 | } |
6728 | 6728 | public function renderEndTag($writer) |
6729 | 6729 | { |
6730 | - if($decorator = $this->getDecorator(false)) { |
|
6730 | + if($decorator=$this->getDecorator(false)) { |
|
6731 | 6731 | $decorator->renderPostContentsText($writer); |
6732 | 6732 | $writer->renderEndTag(); |
6733 | 6733 | $decorator->renderPostTagText($writer); |
@@ -6794,24 +6794,24 @@ discard block |
||
6794 | 6794 | foreach($tpl->getDirective() as $name=>$value) |
6795 | 6795 | { |
6796 | 6796 | if(is_string($value)) |
6797 | - $this->setSubProperty($name,$value); |
|
6797 | + $this->setSubProperty($name, $value); |
|
6798 | 6798 | else |
6799 | - throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name); |
|
6799 | + throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name); |
|
6800 | 6800 | } |
6801 | 6801 | $tpl->instantiateIn($this); |
6802 | 6802 | } |
6803 | 6803 | } |
6804 | - public function registerContent($id,TContent $object) |
|
6804 | + public function registerContent($id, TContent $object) |
|
6805 | 6805 | { |
6806 | 6806 | if(isset($this->_contents[$id])) |
6807 | - throw new TConfigurationException('templatecontrol_contentid_duplicated',$id); |
|
6807 | + throw new TConfigurationException('templatecontrol_contentid_duplicated', $id); |
|
6808 | 6808 | else |
6809 | 6809 | $this->_contents[$id]=$object; |
6810 | 6810 | } |
6811 | - public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
|
6811 | + public function registerContentPlaceHolder($id, TContentPlaceHolder $object) |
|
6812 | 6812 | { |
6813 | 6813 | if(isset($this->_placeholders[$id])) |
6814 | - throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id); |
|
6814 | + throw new TConfigurationException('templatecontrol_placeholderid_duplicated', $id); |
|
6815 | 6815 | else |
6816 | 6816 | $this->_placeholders[$id]=$object; |
6817 | 6817 | } |
@@ -6827,17 +6827,17 @@ discard block |
||
6827 | 6827 | { |
6828 | 6828 | return $this->_master; |
6829 | 6829 | } |
6830 | - public function injectContent($id,$content) |
|
6830 | + public function injectContent($id, $content) |
|
6831 | 6831 | { |
6832 | 6832 | if(isset($this->_placeholders[$id])) |
6833 | 6833 | { |
6834 | 6834 | $placeholder=$this->_placeholders[$id]; |
6835 | 6835 | $controls=$placeholder->getParent()->getControls(); |
6836 | 6836 | $loc=$controls->remove($placeholder); |
6837 | - $controls->insertAt($loc,$content); |
|
6837 | + $controls->insertAt($loc, $content); |
|
6838 | 6838 | } |
6839 | 6839 | else |
6840 | - throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
|
6840 | + throw new TConfigurationException('templatecontrol_placeholder_inexistent', $id); |
|
6841 | 6841 | } |
6842 | 6842 | protected function initRecursive($namingContainer=null) |
6843 | 6843 | { |
@@ -6852,44 +6852,44 @@ discard block |
||
6852 | 6852 | $this->getControls()->add($master); |
6853 | 6853 | $master->ensureChildControls(); |
6854 | 6854 | foreach($this->_contents as $id=>$content) |
6855 | - $master->injectContent($id,$content); |
|
6855 | + $master->injectContent($id, $content); |
|
6856 | 6856 | } |
6857 | 6857 | else if(!empty($this->_contents)) |
6858 | - throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
|
6858 | + throw new TConfigurationException('templatecontrol_mastercontrol_required', get_class($this)); |
|
6859 | 6859 | parent::initRecursive($namingContainer); |
6860 | 6860 | } |
6861 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
6861 | + public function tryToUpdateView($arObj, $throwExceptions=false) |
|
6862 | 6862 | { |
6863 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
6864 | - foreach (array_keys($objAttrs) as $key) |
|
6863 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
6864 | + foreach(array_keys($objAttrs) as $key) |
|
6865 | 6865 | { |
6866 | 6866 | try |
6867 | 6867 | { |
6868 | - if ($key != "RELATIONS") |
|
6868 | + if($key!="RELATIONS") |
|
6869 | 6869 | { |
6870 | - $control = $this->{$key}; |
|
6871 | - if ($control instanceof TTextBox) |
|
6872 | - $control->Text = $arObj->{$key}; |
|
6873 | - elseif ($control instanceof TCheckBox) |
|
6874 | - $control->Checked = (boolean) $arObj->{$key}; |
|
6875 | - elseif ($control instanceof TDatePicker) |
|
6876 | - $control->Date = $arObj->{$key}; |
|
6870 | + $control=$this->{$key}; |
|
6871 | + if($control instanceof TTextBox) |
|
6872 | + $control->Text=$arObj->{$key}; |
|
6873 | + elseif($control instanceof TCheckBox) |
|
6874 | + $control->Checked=(boolean) $arObj->{$key}; |
|
6875 | + elseif($control instanceof TDatePicker) |
|
6876 | + $control->Date=$arObj->{$key}; |
|
6877 | 6877 | } |
6878 | 6878 | else |
6879 | 6879 | { |
6880 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
6880 | + foreach($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
6881 | 6881 | { |
6882 | - $relControl = $this->{$relKey}; |
|
6883 | - switch ($relValues[0]) |
|
6882 | + $relControl=$this->{$relKey}; |
|
6883 | + switch($relValues[0]) |
|
6884 | 6884 | { |
6885 | 6885 | case TActiveRecord::BELONGS_TO: |
6886 | 6886 | case TActiveRecord::HAS_ONE: |
6887 | - $relControl->Text = $arObj->{$relKey}; |
|
6887 | + $relControl->Text=$arObj->{$relKey}; |
|
6888 | 6888 | break; |
6889 | 6889 | case TActiveRecord::HAS_MANY: |
6890 | - if ($relControl instanceof TListControl) |
|
6890 | + if($relControl instanceof TListControl) |
|
6891 | 6891 | { |
6892 | - $relControl->DataSource = $arObj->{$relKey}; |
|
6892 | + $relControl->DataSource=$arObj->{$relKey}; |
|
6893 | 6893 | $relControl->dataBind(); |
6894 | 6894 | } |
6895 | 6895 | break; |
@@ -6898,33 +6898,33 @@ discard block |
||
6898 | 6898 | break; |
6899 | 6899 | } |
6900 | 6900 | } |
6901 | - catch (Exception $ex) |
|
6901 | + catch(Exception $ex) |
|
6902 | 6902 | { |
6903 | - if ($throwExceptions) |
|
6903 | + if($throwExceptions) |
|
6904 | 6904 | throw $ex; |
6905 | 6905 | } |
6906 | 6906 | } |
6907 | 6907 | } |
6908 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
6908 | + public function tryToUpdateAR($arObj, $throwExceptions=false) |
|
6909 | 6909 | { |
6910 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
6911 | - foreach (array_keys($objAttrs) as $key) |
|
6910 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
6911 | + foreach(array_keys($objAttrs) as $key) |
|
6912 | 6912 | { |
6913 | 6913 | try |
6914 | 6914 | { |
6915 | - if ($key == "RELATIONS") |
|
6915 | + if($key=="RELATIONS") |
|
6916 | 6916 | break; |
6917 | - $control = $this->{$key}; |
|
6918 | - if ($control instanceof TTextBox) |
|
6919 | - $arObj->{$key} = $control->Text; |
|
6920 | - elseif ($control instanceof TCheckBox) |
|
6921 | - $arObj->{$key} = $control->Checked; |
|
6922 | - elseif ($control instanceof TDatePicker) |
|
6923 | - $arObj->{$key} = $control->Date; |
|
6917 | + $control=$this->{$key}; |
|
6918 | + if($control instanceof TTextBox) |
|
6919 | + $arObj->{$key}=$control->Text; |
|
6920 | + elseif($control instanceof TCheckBox) |
|
6921 | + $arObj->{$key}=$control->Checked; |
|
6922 | + elseif($control instanceof TDatePicker) |
|
6923 | + $arObj->{$key}=$control->Date; |
|
6924 | 6924 | } |
6925 | - catch (Exception $ex) |
|
6925 | + catch(Exception $ex) |
|
6926 | 6926 | { |
6927 | - if ($throwExceptions) |
|
6927 | + if($throwExceptions) |
|
6928 | 6928 | throw $ex; |
6929 | 6929 | } |
6930 | 6930 | } |
@@ -6939,12 +6939,12 @@ discard block |
||
6939 | 6939 | } |
6940 | 6940 | protected function addAttributesToRender($writer) |
6941 | 6941 | { |
6942 | - $writer->addAttribute('id',$this->getClientID()); |
|
6943 | - $writer->addAttribute('method',$this->getMethod()); |
|
6942 | + $writer->addAttribute('id', $this->getClientID()); |
|
6943 | + $writer->addAttribute('method', $this->getMethod()); |
|
6944 | 6944 | $uri=$this->getRequest()->getRequestURI(); |
6945 | - $writer->addAttribute('action',str_replace('&','&',str_replace('&','&',$uri))); |
|
6945 | + $writer->addAttribute('action', str_replace('&', '&', str_replace('&', '&', $uri))); |
|
6946 | 6946 | if(($enctype=$this->getEnctype())!=='') |
6947 | - $writer->addAttribute('enctype',$enctype); |
|
6947 | + $writer->addAttribute('enctype', $enctype); |
|
6948 | 6948 | $attributes=$this->getAttributes(); |
6949 | 6949 | $attributes->remove('action'); |
6950 | 6950 | $writer->addAttributes($attributes); |
@@ -6953,7 +6953,7 @@ discard block |
||
6953 | 6953 | if(($button=$this->findControl($butt))!==null) |
6954 | 6954 | $this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
6955 | 6955 | else |
6956 | - throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt); |
|
6956 | + throw new TInvalidDataValueException('form_defaultbutton_invalid', $butt); |
|
6957 | 6957 | } |
6958 | 6958 | } |
6959 | 6959 | public function render($writer) |
@@ -6986,27 +6986,27 @@ discard block |
||
6986 | 6986 | } |
6987 | 6987 | public function getDefaultButton() |
6988 | 6988 | { |
6989 | - return $this->getViewState('DefaultButton',''); |
|
6989 | + return $this->getViewState('DefaultButton', ''); |
|
6990 | 6990 | } |
6991 | 6991 | public function setDefaultButton($value) |
6992 | 6992 | { |
6993 | - $this->setViewState('DefaultButton',$value,''); |
|
6993 | + $this->setViewState('DefaultButton', $value, ''); |
|
6994 | 6994 | } |
6995 | 6995 | public function getMethod() |
6996 | 6996 | { |
6997 | - return $this->getViewState('Method','post'); |
|
6997 | + return $this->getViewState('Method', 'post'); |
|
6998 | 6998 | } |
6999 | 6999 | public function setMethod($value) |
7000 | 7000 | { |
7001 | - $this->setViewState('Method',TPropertyValue::ensureEnum($value,'post','get'),'post'); |
|
7001 | + $this->setViewState('Method', TPropertyValue::ensureEnum($value, 'post', 'get'), 'post'); |
|
7002 | 7002 | } |
7003 | 7003 | public function getEnctype() |
7004 | 7004 | { |
7005 | - return $this->getViewState('Enctype',''); |
|
7005 | + return $this->getViewState('Enctype', ''); |
|
7006 | 7006 | } |
7007 | 7007 | public function setEnctype($value) |
7008 | 7008 | { |
7009 | - $this->setViewState('Enctype',$value,''); |
|
7009 | + $this->setViewState('Enctype', $value, ''); |
|
7010 | 7010 | } |
7011 | 7011 | public function getName() |
7012 | 7012 | { |
@@ -7058,43 +7058,43 @@ discard block |
||
7058 | 7058 | { |
7059 | 7059 | $this->registerPradoScriptInternal($name); |
7060 | 7060 | $params=func_get_args(); |
7061 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoScript',$params); |
|
7061 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoScript', $params); |
|
7062 | 7062 | } |
7063 | 7063 | protected function registerPradoScriptInternal($name) |
7064 | 7064 | { |
7065 | 7065 | if(!isset($this->_registeredPradoScripts[$name])) |
7066 | 7066 | { |
7067 | - if(self::$_pradoScripts === null) |
|
7067 | + if(self::$_pradoScripts===null) |
|
7068 | 7068 | { |
7069 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
7070 | - list($packages,$deps)= include($packageFile); |
|
7071 | - self::$_pradoScripts = $deps; |
|
7072 | - self::$_pradoPackages = $packages; |
|
7069 | + $packageFile=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
7070 | + list($packages, $deps)=include($packageFile); |
|
7071 | + self::$_pradoScripts=$deps; |
|
7072 | + self::$_pradoPackages=$packages; |
|
7073 | 7073 | } |
7074 | - if (isset(self::$_pradoScripts[$name])) |
|
7074 | + if(isset(self::$_pradoScripts[$name])) |
|
7075 | 7075 | $this->_registeredPradoScripts[$name]=true; |
7076 | 7076 | else |
7077 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
7077 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
7078 | 7078 | if(($packages=array_keys($this->_registeredPradoScripts))!==array()) |
7079 | 7079 | { |
7080 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
7081 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
7080 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
7081 | + list($path, $baseUrl)=$this->getPackagePathUrl($base); |
|
7082 | 7082 | $packagesUrl=array(); |
7083 | 7083 | $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
7084 | - foreach ($packages as $p) |
|
7084 | + foreach($packages as $p) |
|
7085 | 7085 | { |
7086 | - foreach (self::$_pradoScripts[$p] as $dep) |
|
7086 | + foreach(self::$_pradoScripts[$p] as $dep) |
|
7087 | 7087 | { |
7088 | - foreach (self::$_pradoPackages[$dep] as $script) |
|
7089 | - if (!isset($this->_expandedPradoScripts[$script])) |
|
7088 | + foreach(self::$_pradoPackages[$dep] as $script) |
|
7089 | + if(!isset($this->_expandedPradoScripts[$script])) |
|
7090 | 7090 | { |
7091 | - $this->_expandedPradoScripts[$script] = true; |
|
7091 | + $this->_expandedPradoScripts[$script]=true; |
|
7092 | 7092 | if($isDebug) |
7093 | 7093 | { |
7094 | - if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
|
7094 | + if(!in_array($url=$baseUrl.'/'.$script, $packagesUrl)) |
|
7095 | 7095 | $packagesUrl[]=$url; |
7096 | 7096 | } else { |
7097 | - if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl)) |
|
7097 | + if(!in_array($url=$baseUrl.'/min/'.$script, $packagesUrl)) |
|
7098 | 7098 | { |
7099 | 7099 | if(!is_file($filePath=$path.'/min/'.$script)) |
7100 | 7100 | { |
@@ -7111,47 +7111,47 @@ discard block |
||
7111 | 7111 | } |
7112 | 7112 | } |
7113 | 7113 | foreach($packagesUrl as $url) |
7114 | - $this->registerScriptFile($url,$url); |
|
7114 | + $this->registerScriptFile($url, $url); |
|
7115 | 7115 | } |
7116 | 7116 | } |
7117 | 7117 | } |
7118 | 7118 | public function getPradoScriptAssetUrl() |
7119 | 7119 | { |
7120 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
7121 | - $assets = Prado::getApplication()->getAssetManager(); |
|
7120 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
7121 | + $assets=Prado::getApplication()->getAssetManager(); |
|
7122 | 7122 | return $assets->getPublishedUrl($base); |
7123 | 7123 | } |
7124 | 7124 | public function getScriptUrls() |
7125 | 7125 | { |
7126 | - $scripts = array_values($this->_headScriptFiles); |
|
7127 | - $scripts = array_merge($scripts, array_values($this->_scriptFiles)); |
|
7128 | - $scripts = array_unique($scripts); |
|
7126 | + $scripts=array_values($this->_headScriptFiles); |
|
7127 | + $scripts=array_merge($scripts, array_values($this->_scriptFiles)); |
|
7128 | + $scripts=array_unique($scripts); |
|
7129 | 7129 | return $scripts; |
7130 | 7130 | } |
7131 | 7131 | protected function getPackagePathUrl($base) |
7132 | 7132 | { |
7133 | - $assets = Prado::getApplication()->getAssetManager(); |
|
7133 | + $assets=Prado::getApplication()->getAssetManager(); |
|
7134 | 7134 | if(strpos($base, $assets->getBaseUrl())===false) |
7135 | 7135 | { |
7136 | - if(($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
7137 | - $base = $dir; |
|
7136 | + if(($dir=Prado::getPathOfNameSpace($base))!==null) { |
|
7137 | + $base=$dir; |
|
7138 | 7138 | } |
7139 | 7139 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
7140 | 7140 | } |
7141 | 7141 | else |
7142 | 7142 | { |
7143 | - return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
|
7143 | + return array($assets->getBasePath().str_replace($assets->getBaseUrl(), '', $base), $base); |
|
7144 | 7144 | } |
7145 | 7145 | } |
7146 | 7146 | public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null) |
7147 | 7147 | { |
7148 | - $options = !is_array($options) ? array() : $options; |
|
7149 | - $class = new ReflectionClass($callbackHandler); |
|
7150 | - $clientSide = $callbackHandler->getActiveControl()->getClientSide(); |
|
7151 | - $options = array_merge($options, $clientSide->getOptions()->toArray()); |
|
7152 | - $optionString = TJavaScript::encode($options); |
|
7148 | + $options=!is_array($options) ? array() : $options; |
|
7149 | + $class=new ReflectionClass($callbackHandler); |
|
7150 | + $clientSide=$callbackHandler->getActiveControl()->getClientSide(); |
|
7151 | + $options=array_merge($options, $clientSide->getOptions()->toArray()); |
|
7152 | + $optionString=TJavaScript::encode($options); |
|
7153 | 7153 | $this->registerPradoScriptInternal('ajax'); |
7154 | - $id = $callbackHandler->getUniqueID(); |
|
7154 | + $id=$callbackHandler->getUniqueID(); |
|
7155 | 7155 | return "new Prado.CallbackRequest('{$id}',{$optionString})"; |
7156 | 7156 | } |
7157 | 7157 | public function registerCallbackControl($class, $options) |
@@ -7161,11 +7161,11 @@ discard block |
||
7161 | 7161 | $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
7162 | 7162 | $this->registerPradoScriptInternal('ajax'); |
7163 | 7163 | $params=func_get_args(); |
7164 | - $this->_page->registerCachingAction('Page.ClientScript','registerCallbackControl',$params); |
|
7164 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerCallbackControl', $params); |
|
7165 | 7165 | } |
7166 | - public function registerPostBackControl($class,$options) |
|
7166 | + public function registerPostBackControl($class, $options) |
|
7167 | 7167 | { |
7168 | - if($class === null) { |
|
7168 | + if($class===null) { |
|
7169 | 7169 | return; |
7170 | 7170 | } |
7171 | 7171 | if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
@@ -7175,11 +7175,11 @@ discard block |
||
7175 | 7175 | $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
7176 | 7176 | $this->registerPradoScriptInternal('prado'); |
7177 | 7177 | $params=func_get_args(); |
7178 | - $this->_page->registerCachingAction('Page.ClientScript','registerPostBackControl',$params); |
|
7178 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPostBackControl', $params); |
|
7179 | 7179 | } |
7180 | 7180 | public function registerDefaultButton($panel, $button) |
7181 | 7181 | { |
7182 | - $panelID=is_string($panel)?$panel:$panel->getUniqueID(); |
|
7182 | + $panelID=is_string($panel) ? $panel : $panel->getUniqueID(); |
|
7183 | 7183 | if(is_string($button)) |
7184 | 7184 | $buttonID=$button; |
7185 | 7185 | else |
@@ -7187,20 +7187,20 @@ discard block |
||
7187 | 7187 | $button->setIsDefaultButton(true); |
7188 | 7188 | $buttonID=$button->getUniqueID(); |
7189 | 7189 | } |
7190 | - $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
|
7191 | - $code = "new Prado.WebUI.DefaultButton($options);"; |
|
7190 | + $options=TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
|
7191 | + $code="new Prado.WebUI.DefaultButton($options);"; |
|
7192 | 7192 | $this->_endScripts['prado:'.$panelID]=$code; |
7193 | 7193 | $this->registerPradoScriptInternal('prado'); |
7194 | - $params=array($panelID,$buttonID); |
|
7195 | - $this->_page->registerCachingAction('Page.ClientScript','registerDefaultButton',$params); |
|
7194 | + $params=array($panelID, $buttonID); |
|
7195 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
|
7196 | 7196 | } |
7197 | 7197 | protected function getDefaultButtonOptions($panelID, $buttonID) |
7198 | 7198 | { |
7199 | - $options['ID'] = TControl::convertUniqueIdToClientId($panelID); |
|
7200 | - $options['Panel'] = TControl::convertUniqueIdToClientId($panelID); |
|
7201 | - $options['Target'] = TControl::convertUniqueIdToClientId($buttonID); |
|
7202 | - $options['EventTarget'] = $buttonID; |
|
7203 | - $options['Event'] = 'click'; |
|
7199 | + $options['ID']=TControl::convertUniqueIdToClientId($panelID); |
|
7200 | + $options['Panel']=TControl::convertUniqueIdToClientId($panelID); |
|
7201 | + $options['Target']=TControl::convertUniqueIdToClientId($buttonID); |
|
7202 | + $options['EventTarget']=$buttonID; |
|
7203 | + $options['Event']='click'; |
|
7204 | 7204 | return $options; |
7205 | 7205 | } |
7206 | 7206 | public function registerFocusControl($target) |
@@ -7208,126 +7208,126 @@ discard block |
||
7208 | 7208 | $this->registerPradoScriptInternal('jquery'); |
7209 | 7209 | if($target instanceof TControl) |
7210 | 7210 | $target=$target->getClientID(); |
7211 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
|
7211 | + $this->_endScripts['prado:focus']='jQuery(\'#'.$target.'\').focus();'; |
|
7212 | 7212 | $params=func_get_args(); |
7213 | - $this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params); |
|
7213 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
|
7214 | 7214 | } |
7215 | 7215 | public function registerPradoStyle($name) |
7216 | 7216 | { |
7217 | 7217 | $this->registerPradoStyleInternal($name); |
7218 | 7218 | $params=func_get_args(); |
7219 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoStyle',$params); |
|
7219 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoStyle', $params); |
|
7220 | 7220 | } |
7221 | 7221 | protected function registerPradoStyleInternal($name) |
7222 | 7222 | { |
7223 | 7223 | if(!isset($this->_registeredPradoStyles[$name])) |
7224 | 7224 | { |
7225 | - $base = $this->getPradoScriptAssetUrl(); |
|
7226 | - if(self::$_pradoStyles === null) |
|
7225 | + $base=$this->getPradoScriptAssetUrl(); |
|
7226 | + if(self::$_pradoStyles===null) |
|
7227 | 7227 | { |
7228 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
7229 | - list($packages,$deps)= include($packageFile); |
|
7230 | - self::$_pradoStyles = $deps; |
|
7231 | - self::$_pradoStylePackages = $packages; |
|
7228 | + $packageFile=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
7229 | + list($packages, $deps)=include($packageFile); |
|
7230 | + self::$_pradoStyles=$deps; |
|
7231 | + self::$_pradoStylePackages=$packages; |
|
7232 | 7232 | } |
7233 | - if (isset(self::$_pradoStyles[$name])) |
|
7233 | + if(isset(self::$_pradoStyles[$name])) |
|
7234 | 7234 | $this->_registeredPradoStyles[$name]=true; |
7235 | 7235 | else |
7236 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid',$name); |
|
7236 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
|
7237 | 7237 | if(($packages=array_keys($this->_registeredPradoStyles))!==array()) |
7238 | 7238 | { |
7239 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
7240 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
7239 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
7240 | + list($path, $baseUrl)=$this->getPackagePathUrl($base); |
|
7241 | 7241 | $packagesUrl=array(); |
7242 | 7242 | $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
7243 | - foreach ($packages as $p) |
|
7243 | + foreach($packages as $p) |
|
7244 | 7244 | { |
7245 | - foreach (self::$_pradoStyles[$p] as $dep) |
|
7245 | + foreach(self::$_pradoStyles[$p] as $dep) |
|
7246 | 7246 | { |
7247 | - foreach (self::$_pradoStylePackages[$dep] as $style) |
|
7248 | - if (!isset($this->_expandedPradoStyles[$style])) |
|
7247 | + foreach(self::$_pradoStylePackages[$dep] as $style) |
|
7248 | + if(!isset($this->_expandedPradoStyles[$style])) |
|
7249 | 7249 | { |
7250 | - $this->_expandedPradoStyles[$style] = true; |
|
7251 | - if (!in_array($url=$baseUrl.'/'.$style,$packagesUrl)) |
|
7250 | + $this->_expandedPradoStyles[$style]=true; |
|
7251 | + if(!in_array($url=$baseUrl.'/'.$style, $packagesUrl)) |
|
7252 | 7252 | $packagesUrl[]=$url; |
7253 | 7253 | } |
7254 | 7254 | } |
7255 | 7255 | } |
7256 | 7256 | foreach($packagesUrl as $url) |
7257 | - $this->registerStyleSheetFile($url,$url); |
|
7257 | + $this->registerStyleSheetFile($url, $url); |
|
7258 | 7258 | } |
7259 | 7259 | } |
7260 | 7260 | } |
7261 | - public function registerStyleSheetFile($key,$url,$media='') |
|
7261 | + public function registerStyleSheetFile($key, $url, $media='') |
|
7262 | 7262 | { |
7263 | 7263 | if($media==='') |
7264 | 7264 | $this->_styleSheetFiles[$key]=$url; |
7265 | 7265 | else |
7266 | - $this->_styleSheetFiles[$key]=array($url,$media); |
|
7266 | + $this->_styleSheetFiles[$key]=array($url, $media); |
|
7267 | 7267 | $params=func_get_args(); |
7268 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); |
|
7268 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
|
7269 | 7269 | } |
7270 | - public function registerStyleSheet($key,$css,$media='') |
|
7270 | + public function registerStyleSheet($key, $css, $media='') |
|
7271 | 7271 | { |
7272 | 7272 | $this->_styleSheets[$key]=$css; |
7273 | 7273 | $params=func_get_args(); |
7274 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheet',$params); |
|
7274 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheet', $params); |
|
7275 | 7275 | } |
7276 | 7276 | public function getStyleSheetUrls() |
7277 | 7277 | { |
7278 | - $stylesheets = array_values( |
|
7278 | + $stylesheets=array_values( |
|
7279 | 7279 | array_map(function($e) { |
7280 | 7280 | return is_array($e) ? $e[0] : $e; |
7281 | 7281 | }, $this->_styleSheetFiles) |
7282 | 7282 | ); |
7283 | 7283 | foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
7284 | - if (substr($url,strlen($url)-4)=='.css') |
|
7285 | - $stylesheets[] = $url; |
|
7286 | - $stylesheets = array_unique($stylesheets); |
|
7284 | + if(substr($url, strlen($url) - 4)=='.css') |
|
7285 | + $stylesheets[]=$url; |
|
7286 | + $stylesheets=array_unique($stylesheets); |
|
7287 | 7287 | return $stylesheets; |
7288 | 7288 | } |
7289 | 7289 | public function getStyleSheetCodes() |
7290 | 7290 | { |
7291 | 7291 | return array_unique(array_values($this->_styleSheets)); |
7292 | 7292 | } |
7293 | - public function registerHeadScriptFile($key,$url) |
|
7293 | + public function registerHeadScriptFile($key, $url) |
|
7294 | 7294 | { |
7295 | 7295 | $this->checkIfNotInRender(); |
7296 | 7296 | $this->_headScriptFiles[$key]=$url; |
7297 | 7297 | $params=func_get_args(); |
7298 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScriptFile',$params); |
|
7298 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScriptFile', $params); |
|
7299 | 7299 | } |
7300 | - public function registerHeadScript($key,$script) |
|
7300 | + public function registerHeadScript($key, $script) |
|
7301 | 7301 | { |
7302 | 7302 | $this->checkIfNotInRender(); |
7303 | 7303 | $this->_headScripts[$key]=$script; |
7304 | 7304 | $params=func_get_args(); |
7305 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScript',$params); |
|
7305 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScript', $params); |
|
7306 | 7306 | } |
7307 | 7307 | public function registerScriptFile($key, $url) |
7308 | 7308 | { |
7309 | 7309 | $this->_scriptFiles[$key]=$url; |
7310 | 7310 | $params=func_get_args(); |
7311 | - $this->_page->registerCachingAction('Page.ClientScript','registerScriptFile',$params); |
|
7311 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerScriptFile', $params); |
|
7312 | 7312 | } |
7313 | - public function registerBeginScript($key,$script) |
|
7313 | + public function registerBeginScript($key, $script) |
|
7314 | 7314 | { |
7315 | 7315 | $this->checkIfNotInRender(); |
7316 | 7316 | $this->_beginScripts[$key]=$script; |
7317 | 7317 | $params=func_get_args(); |
7318 | - $this->_page->registerCachingAction('Page.ClientScript','registerBeginScript',$params); |
|
7318 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerBeginScript', $params); |
|
7319 | 7319 | } |
7320 | - public function registerEndScript($key,$script) |
|
7320 | + public function registerEndScript($key, $script) |
|
7321 | 7321 | { |
7322 | 7322 | $this->_endScripts[$key]=$script; |
7323 | 7323 | $params=func_get_args(); |
7324 | - $this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params); |
|
7324 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerEndScript', $params); |
|
7325 | 7325 | } |
7326 | - public function registerHiddenField($name,$value) |
|
7326 | + public function registerHiddenField($name, $value) |
|
7327 | 7327 | { |
7328 | 7328 | $this->_hiddenFields[$name]=$value; |
7329 | 7329 | $params=func_get_args(); |
7330 | - $this->_page->registerCachingAction('Page.ClientScript','registerHiddenField',$params); |
|
7330 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHiddenField', $params); |
|
7331 | 7331 | } |
7332 | 7332 | public function isStyleSheetFileRegistered($key) |
7333 | 7333 | { |
@@ -7384,11 +7384,11 @@ discard block |
||
7384 | 7384 | public function renderStyleSheets($writer) |
7385 | 7385 | { |
7386 | 7386 | if(count($this->_styleSheets)) |
7387 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
7387 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n", $this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
7388 | 7388 | } |
7389 | 7389 | public function renderHeadScriptFiles($writer) |
7390 | 7390 | { |
7391 | - $this->renderScriptFiles($writer,$this->_headScriptFiles); |
|
7391 | + $this->renderScriptFiles($writer, $this->_headScriptFiles); |
|
7392 | 7392 | } |
7393 | 7393 | public function renderHeadScripts($writer) |
7394 | 7394 | { |
@@ -7404,9 +7404,9 @@ discard block |
||
7404 | 7404 | } |
7405 | 7405 | public function markScriptFileAsRendered($url) |
7406 | 7406 | { |
7407 | - $this->_renderedScriptFiles[$url] = $url; |
|
7407 | + $this->_renderedScriptFiles[$url]=$url; |
|
7408 | 7408 | $params=func_get_args(); |
7409 | - $this->_page->registerCachingAction('Page.ClientScript','markScriptFileAsRendered',$params); |
|
7409 | + $this->_page->registerCachingAction('Page.ClientScript', 'markScriptFileAsRendered', $params); |
|
7410 | 7410 | } |
7411 | 7411 | protected function renderScriptFiles($writer, Array $scripts) |
7412 | 7412 | { |
@@ -7424,8 +7424,8 @@ discard block |
||
7424 | 7424 | { |
7425 | 7425 | if(!empty($this->_scriptFiles)) |
7426 | 7426 | { |
7427 | - $addedScripts = array_diff($this->_scriptFiles,$this->getRenderedScriptFiles()); |
|
7428 | - $this->renderScriptFiles($writer,$addedScripts); |
|
7427 | + $addedScripts=array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
|
7428 | + $this->renderScriptFiles($writer, $addedScripts); |
|
7429 | 7429 | } |
7430 | 7430 | } |
7431 | 7431 | public function renderBeginScripts($writer) |
@@ -7446,11 +7446,11 @@ discard block |
||
7446 | 7446 | } |
7447 | 7447 | public function renderHiddenFieldsBegin($writer) |
7448 | 7448 | { |
7449 | - $this->renderHiddenFieldsInt($writer,true); |
|
7449 | + $this->renderHiddenFieldsInt($writer, true); |
|
7450 | 7450 | } |
7451 | 7451 | public function renderHiddenFieldsEnd($writer) |
7452 | 7452 | { |
7453 | - $this->renderHiddenFieldsInt($writer,false); |
|
7453 | + $this->renderHiddenFieldsInt($writer, false); |
|
7454 | 7454 | } |
7455 | 7455 | public function flushScriptFiles($writer, $control=null) |
7456 | 7456 | { |
@@ -7462,12 +7462,12 @@ discard block |
||
7462 | 7462 | } |
7463 | 7463 | protected function renderHiddenFieldsInt($writer, $initial) |
7464 | 7464 | { |
7465 | - if ($initial) $this->_renderedHiddenFields = array(); |
|
7465 | + if($initial) $this->_renderedHiddenFields=array(); |
|
7466 | 7466 | $str=''; |
7467 | 7467 | foreach($this->_hiddenFields as $name=>$value) |
7468 | 7468 | { |
7469 | - if (in_array($name,$this->_renderedHiddenFields)) continue; |
|
7470 | - $id=strtr($name,':','_'); |
|
7469 | + if(in_array($name, $this->_renderedHiddenFields)) continue; |
|
7470 | + $id=strtr($name, ':', '_'); |
|
7471 | 7471 | if(is_array($value)) |
7472 | 7472 | { |
7473 | 7473 | foreach($value as $v) |
@@ -7477,7 +7477,7 @@ discard block |
||
7477 | 7477 | { |
7478 | 7478 | $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
7479 | 7479 | } |
7480 | - $this->_renderedHiddenFields[] = $name; |
|
7480 | + $this->_renderedHiddenFields[]=$name; |
|
7481 | 7481 | } |
7482 | 7482 | if($str!=='') |
7483 | 7483 | $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
@@ -7488,7 +7488,7 @@ discard block |
||
7488 | 7488 | } |
7489 | 7489 | protected function checkIfNotInRender() |
7490 | 7490 | { |
7491 | - if ($form = $this->_page->InFormRender) |
|
7491 | + if($form=$this->_page->InFormRender) |
|
7492 | 7492 | throw new Exception('Operation invalid when page is already rendering'); |
7493 | 7493 | } |
7494 | 7494 | } |
@@ -7498,12 +7498,12 @@ discard block |
||
7498 | 7498 | protected function setFunction($name, $code) |
7499 | 7499 | { |
7500 | 7500 | if(!TJavaScript::isJsLiteral($code)) |
7501 | - $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
7501 | + $code=TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
7502 | 7502 | $this->setOption($name, $code); |
7503 | 7503 | } |
7504 | 7504 | protected function getOption($name) |
7505 | 7505 | { |
7506 | - if ($this->_options) |
|
7506 | + if($this->_options) |
|
7507 | 7507 | return $this->_options->itemAt($name); |
7508 | 7508 | else |
7509 | 7509 | return null; |
@@ -7514,8 +7514,8 @@ discard block |
||
7514 | 7514 | } |
7515 | 7515 | public function getOptions() |
7516 | 7516 | { |
7517 | - if (!$this->_options) |
|
7518 | - $this->_options = Prado::createComponent('System.Collections.TMap'); |
|
7517 | + if(!$this->_options) |
|
7518 | + $this->_options=Prado::createComponent('System.Collections.TMap'); |
|
7519 | 7519 | return $this->_options; |
7520 | 7520 | } |
7521 | 7521 | protected function ensureFunction($javascript) |
@@ -7574,7 +7574,7 @@ discard block |
||
7574 | 7574 | } |
7575 | 7575 | public function run($writer) |
7576 | 7576 | { |
7577 | - $this->_writer = $writer; |
|
7577 | + $this->_writer=$writer; |
|
7578 | 7578 | $this->determinePostBackMode(); |
7579 | 7579 | if($this->getIsPostBack()) |
7580 | 7580 | { |
@@ -7585,7 +7585,7 @@ discard block |
||
7585 | 7585 | } |
7586 | 7586 | else |
7587 | 7587 | $this->processNormalRequest($writer); |
7588 | - $this->_writer = null; |
|
7588 | + $this->_writer=null; |
|
7589 | 7589 | } |
7590 | 7590 | protected function processNormalRequest($writer) |
7591 | 7591 | { |
@@ -7609,10 +7609,10 @@ discard block |
||
7609 | 7609 | $this->onInitComplete(null); |
7610 | 7610 | $this->_restPostData=new TMap; |
7611 | 7611 | $this->loadPageState(); |
7612 | - $this->processPostData($this->_postData,true); |
|
7612 | + $this->processPostData($this->_postData, true); |
|
7613 | 7613 | $this->onPreLoad(null); |
7614 | 7614 | $this->loadRecursive(); |
7615 | - $this->processPostData($this->_restPostData,false); |
|
7615 | + $this->processPostData($this->_restPostData, false); |
|
7616 | 7616 | $this->raiseChangedEvents(); |
7617 | 7617 | $this->raisePostBackEvent(); |
7618 | 7618 | $this->onLoadComplete(null); |
@@ -7631,7 +7631,7 @@ discard block |
||
7631 | 7631 | $data[$k]=self::decodeUTF8($v, $enc); |
7632 | 7632 | return $data; |
7633 | 7633 | } elseif(is_string($data)) { |
7634 | - return iconv('UTF-8',$enc.'//IGNORE',$data); |
|
7634 | + return iconv('UTF-8', $enc.'//IGNORE', $data); |
|
7635 | 7635 | } else { |
7636 | 7636 | return $data; |
7637 | 7637 | } |
@@ -7641,22 +7641,22 @@ discard block |
||
7641 | 7641 | Prado::using('System.Web.UI.ActiveControls.TActivePageAdapter'); |
7642 | 7642 | Prado::using('System.Web.UI.JuiControls.TJuiControlOptions'); |
7643 | 7643 | $this->setAdapter(new TActivePageAdapter($this)); |
7644 | - $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
7644 | + $callbackEventParameter=$this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
7645 | 7645 | if(strlen($callbackEventParameter) > 0) |
7646 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
7647 | - if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
7646 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string) $callbackEventParameter); |
|
7647 | + if(($g=$this->getApplication()->getGlobalization(false))!==null && |
|
7648 | 7648 | strtoupper($enc=$g->getCharset())!='UTF-8') |
7649 | - foreach ($this->_postData as $k=>$v) |
|
7649 | + foreach($this->_postData as $k=>$v) |
|
7650 | 7650 | $this->_postData[$k]=self::decodeUTF8($v, $enc); |
7651 | 7651 | $this->onPreInit(null); |
7652 | 7652 | $this->initRecursive(); |
7653 | 7653 | $this->onInitComplete(null); |
7654 | 7654 | $this->_restPostData=new TMap; |
7655 | 7655 | $this->loadPageState(); |
7656 | - $this->processPostData($this->_postData,true); |
|
7656 | + $this->processPostData($this->_postData, true); |
|
7657 | 7657 | $this->onPreLoad(null); |
7658 | 7658 | $this->loadRecursive(); |
7659 | - $this->processPostData($this->_restPostData,false); |
|
7659 | + $this->processPostData($this->_restPostData, false); |
|
7660 | 7660 | $this->raiseChangedEvents(); |
7661 | 7661 | $this->getAdapter()->processCallbackEvent($writer); |
7662 | 7662 | $this->onLoadComplete(null); |
@@ -7669,7 +7669,7 @@ discard block |
||
7669 | 7669 | } |
7670 | 7670 | public function getCallbackClient() |
7671 | 7671 | { |
7672 | - if($this->getAdapter() !== null) |
|
7672 | + if($this->getAdapter()!==null) |
|
7673 | 7673 | return $this->getAdapter()->getCallbackClientHandler(); |
7674 | 7674 | else |
7675 | 7675 | return new TCallbackClientScript(); |
@@ -7709,7 +7709,7 @@ discard block |
||
7709 | 7709 | { |
7710 | 7710 | if(!$this->_validators) |
7711 | 7711 | $this->_validators=new TList; |
7712 | - if(empty($validationGroup) === true) |
|
7712 | + if(empty($validationGroup)===true) |
|
7713 | 7713 | return $this->_validators; |
7714 | 7714 | else |
7715 | 7715 | { |
@@ -7763,7 +7763,7 @@ discard block |
||
7763 | 7763 | } |
7764 | 7764 | public function setTheme($value) |
7765 | 7765 | { |
7766 | - $this->_theme=empty($value)?null:$value; |
|
7766 | + $this->_theme=empty($value) ? null : $value; |
|
7767 | 7767 | } |
7768 | 7768 | public function getStyleSheetTheme() |
7769 | 7769 | { |
@@ -7773,7 +7773,7 @@ discard block |
||
7773 | 7773 | } |
7774 | 7774 | public function setStyleSheetTheme($value) |
7775 | 7775 | { |
7776 | - $this->_styleSheet=empty($value)?null:$value; |
|
7776 | + $this->_styleSheet=empty($value) ? null : $value; |
|
7777 | 7777 | } |
7778 | 7778 | public function applyControlSkin($control) |
7779 | 7779 | { |
@@ -7788,66 +7788,66 @@ discard block |
||
7788 | 7788 | public function getClientScript() |
7789 | 7789 | { |
7790 | 7790 | if(!$this->_clientScript) { |
7791 | - $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
|
7791 | + $className=$classPath=$this->getService()->getClientScriptManagerClass(); |
|
7792 | 7792 | Prado::using($className); |
7793 | - if(($pos=strrpos($className,'.'))!==false) |
|
7794 | - $className=substr($className,$pos+1); |
|
7795 | - if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager'))) |
|
7796 | - throw new THttpException(404,'page_csmanagerclass_invalid',$classPath); |
|
7793 | + if(($pos=strrpos($className, '.'))!==false) |
|
7794 | + $className=substr($className, $pos + 1); |
|
7795 | + if(!class_exists($className, false) || ($className!=='TClientScriptManager' && !is_subclass_of($className, 'TClientScriptManager'))) |
|
7796 | + throw new THttpException(404, 'page_csmanagerclass_invalid', $classPath); |
|
7797 | 7797 | $this->_clientScript=new $className($this); |
7798 | 7798 | } |
7799 | 7799 | return $this->_clientScript; |
7800 | 7800 | } |
7801 | 7801 | public function onPreInit($param) |
7802 | 7802 | { |
7803 | - $this->raiseEvent('OnPreInit',$this,$param); |
|
7803 | + $this->raiseEvent('OnPreInit', $this, $param); |
|
7804 | 7804 | } |
7805 | 7805 | public function onInitComplete($param) |
7806 | 7806 | { |
7807 | - $this->raiseEvent('OnInitComplete',$this,$param); |
|
7807 | + $this->raiseEvent('OnInitComplete', $this, $param); |
|
7808 | 7808 | } |
7809 | 7809 | public function onPreLoad($param) |
7810 | 7810 | { |
7811 | - $this->raiseEvent('OnPreLoad',$this,$param); |
|
7811 | + $this->raiseEvent('OnPreLoad', $this, $param); |
|
7812 | 7812 | } |
7813 | 7813 | public function onLoadComplete($param) |
7814 | 7814 | { |
7815 | - $this->raiseEvent('OnLoadComplete',$this,$param); |
|
7815 | + $this->raiseEvent('OnLoadComplete', $this, $param); |
|
7816 | 7816 | } |
7817 | 7817 | public function onPreRenderComplete($param) |
7818 | 7818 | { |
7819 | - $this->raiseEvent('OnPreRenderComplete',$this,$param); |
|
7819 | + $this->raiseEvent('OnPreRenderComplete', $this, $param); |
|
7820 | 7820 | $cs=$this->getClientScript(); |
7821 | 7821 | $theme=$this->getTheme(); |
7822 | 7822 | if($theme instanceof ITheme) |
7823 | 7823 | { |
7824 | 7824 | foreach($theme->getStyleSheetFiles() as $url) |
7825 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
7825 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
7826 | 7826 | foreach($theme->getJavaScriptFiles() as $url) |
7827 | - $cs->registerHeadScriptFile($url,$url); |
|
7827 | + $cs->registerHeadScriptFile($url, $url); |
|
7828 | 7828 | } |
7829 | 7829 | $styleSheet=$this->getStyleSheetTheme(); |
7830 | 7830 | if($styleSheet instanceof ITheme) |
7831 | 7831 | { |
7832 | 7832 | foreach($styleSheet->getStyleSheetFiles() as $url) |
7833 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
7833 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
7834 | 7834 | foreach($styleSheet->getJavaScriptFiles() as $url) |
7835 | - $cs->registerHeadScriptFile($url,$url); |
|
7835 | + $cs->registerHeadScriptFile($url, $url); |
|
7836 | 7836 | } |
7837 | 7837 | if($cs->getRequiresHead() && $this->getHead()===null) |
7838 | 7838 | throw new TConfigurationException('page_head_required'); |
7839 | 7839 | } |
7840 | 7840 | private function getCssMediaType($url) |
7841 | 7841 | { |
7842 | - $segs=explode('.',basename($url)); |
|
7842 | + $segs=explode('.', basename($url)); |
|
7843 | 7843 | if(isset($segs[2])) |
7844 | - return $segs[count($segs)-2]; |
|
7844 | + return $segs[count($segs) - 2]; |
|
7845 | 7845 | else |
7846 | 7846 | return ''; |
7847 | 7847 | } |
7848 | 7848 | public function onSaveStateComplete($param) |
7849 | 7849 | { |
7850 | - $this->raiseEvent('OnSaveStateComplete',$this,$param); |
|
7850 | + $this->raiseEvent('OnSaveStateComplete', $this, $param); |
|
7851 | 7851 | } |
7852 | 7852 | private function determinePostBackMode() |
7853 | 7853 | { |
@@ -7866,17 +7866,17 @@ discard block |
||
7866 | 7866 | public function saveState() |
7867 | 7867 | { |
7868 | 7868 | parent::saveState(); |
7869 | - $this->setViewState('ControlsRequiringPostBack',$this->_controlsRegisteredForPostData,array()); |
|
7869 | + $this->setViewState('ControlsRequiringPostBack', $this->_controlsRegisteredForPostData, array()); |
|
7870 | 7870 | } |
7871 | 7871 | public function loadState() |
7872 | 7872 | { |
7873 | 7873 | parent::loadState(); |
7874 | - $this->_controlsRequiringPostData=$this->getViewState('ControlsRequiringPostBack',array()); |
|
7874 | + $this->_controlsRequiringPostData=$this->getViewState('ControlsRequiringPostBack', array()); |
|
7875 | 7875 | } |
7876 | 7876 | protected function loadPageState() |
7877 | 7877 | { |
7878 | 7878 | $state=$this->getStatePersister()->load(); |
7879 | - $this->loadStateRecursive($state,$this->getEnableViewState()); |
|
7879 | + $this->loadStateRecursive($state, $this->getEnableViewState()); |
|
7880 | 7880 | } |
7881 | 7881 | protected function savePageState() |
7882 | 7882 | { |
@@ -7889,11 +7889,11 @@ discard block |
||
7889 | 7889 | } |
7890 | 7890 | public function registerRequiresPostData($control) |
7891 | 7891 | { |
7892 | - $id=is_string($control)?$control:$control->getUniqueID(); |
|
7892 | + $id=is_string($control) ? $control : $control->getUniqueID(); |
|
7893 | 7893 | $this->_controlsRegisteredForPostData[$id]=true; |
7894 | 7894 | $params=func_get_args(); |
7895 | 7895 | foreach($this->getCachingStack() as $item) |
7896 | - $item->registerAction('Page','registerRequiresPostData',array($id)); |
|
7896 | + $item->registerAction('Page', 'registerRequiresPostData', array($id)); |
|
7897 | 7897 | } |
7898 | 7898 | public function getPostBackEventTarget() |
7899 | 7899 | { |
@@ -7922,7 +7922,7 @@ discard block |
||
7922 | 7922 | { |
7923 | 7923 | $this->_postBackEventParameter=$value; |
7924 | 7924 | } |
7925 | - protected function processPostData($postData,$beforeLoad) |
|
7925 | + protected function processPostData($postData, $beforeLoad) |
|
7926 | 7926 | { |
7927 | 7927 | $this->_isLoadingPostData=true; |
7928 | 7928 | if($beforeLoad) |
@@ -7935,17 +7935,17 @@ discard block |
||
7935 | 7935 | { |
7936 | 7936 | if($control instanceof IPostBackDataHandler) |
7937 | 7937 | { |
7938 | - if($control->loadPostData($key,$postData)) |
|
7938 | + if($control->loadPostData($key, $postData)) |
|
7939 | 7939 | $this->_controlsPostDataChanged[]=$control; |
7940 | 7940 | } |
7941 | 7941 | else if($control instanceof IPostBackEventHandler && |
7942 | 7942 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
7943 | 7943 | { |
7944 | - $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); } |
|
7944 | + $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); } |
|
7945 | 7945 | unset($this->_controlsRequiringPostData[$key]); |
7946 | 7946 | } |
7947 | 7947 | else if($beforeLoad) |
7948 | - $this->_restPostData->add($key,$value); |
|
7948 | + $this->_restPostData->add($key, $value); |
|
7949 | 7949 | } |
7950 | 7950 | foreach($this->_controlsRequiringPostData as $key=>$value) |
7951 | 7951 | { |
@@ -7953,11 +7953,11 @@ discard block |
||
7953 | 7953 | { |
7954 | 7954 | if($control instanceof IPostBackDataHandler) |
7955 | 7955 | { |
7956 | - if($control->loadPostData($key,$this->_postData)) |
|
7956 | + if($control->loadPostData($key, $this->_postData)) |
|
7957 | 7957 | $this->_controlsPostDataChanged[]=$control; |
7958 | 7958 | } |
7959 | 7959 | else |
7960 | - throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key); |
|
7960 | + throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
|
7961 | 7961 | unset($this->_controlsRequiringPostData[$key]); |
7962 | 7962 | } |
7963 | 7963 | } |
@@ -7986,14 +7986,14 @@ discard block |
||
7986 | 7986 | public function ensureRenderInForm($control) |
7987 | 7987 | { |
7988 | 7988 | if(!$this->getIsCallback() && !$this->_inFormRender) |
7989 | - throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null); |
|
7989 | + throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
|
7990 | 7990 | } |
7991 | 7991 | public function beginFormRender($writer) |
7992 | 7992 | { |
7993 | 7993 | if($this->_formRendered) |
7994 | 7994 | throw new TConfigurationException('page_form_duplicated'); |
7995 | 7995 | $this->_formRendered=true; |
7996 | - $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE,$this->getClientState()); |
|
7996 | + $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState()); |
|
7997 | 7997 | $this->_inFormRender=true; |
7998 | 7998 | } |
7999 | 7999 | public function endFormRender($writer) |
@@ -8114,12 +8114,12 @@ discard block |
||
8114 | 8114 | { |
8115 | 8115 | $this->_pagePath=$value; |
8116 | 8116 | } |
8117 | - public function registerCachingAction($context,$funcName,$funcParams) |
|
8117 | + public function registerCachingAction($context, $funcName, $funcParams) |
|
8118 | 8118 | { |
8119 | 8119 | if($this->_cachingStack) |
8120 | 8120 | { |
8121 | 8121 | foreach($this->_cachingStack as $cache) |
8122 | - $cache->registerAction($context,$funcName,$funcParams); |
|
8122 | + $cache->registerAction($context, $funcName, $funcParams); |
|
8123 | 8123 | } |
8124 | 8124 | } |
8125 | 8125 | public function getCachingStack() |
@@ -8130,7 +8130,7 @@ discard block |
||
8130 | 8130 | } |
8131 | 8131 | public function flushWriter() |
8132 | 8132 | { |
8133 | - if ($this->_writer) |
|
8133 | + if($this->_writer) |
|
8134 | 8134 | $this->Response->write($this->_writer->flush()); |
8135 | 8135 | } |
8136 | 8136 | } |
@@ -8143,7 +8143,7 @@ discard block |
||
8143 | 8143 | } |
8144 | 8144 | class TPageStateFormatter |
8145 | 8145 | { |
8146 | - public static function serialize($page,$data) |
|
8146 | + public static function serialize($page, $data) |
|
8147 | 8147 | { |
8148 | 8148 | $sm=$page->getApplication()->getSecurityManager(); |
8149 | 8149 | if($page->getEnableStateValidation()) |
@@ -8156,7 +8156,7 @@ discard block |
||
8156 | 8156 | $str=$sm->encrypt($str); |
8157 | 8157 | return base64_encode($str); |
8158 | 8158 | } |
8159 | - public static function unserialize($page,$data) |
|
8159 | + public static function unserialize($page, $data) |
|
8160 | 8160 | { |
8161 | 8161 | $str=base64_decode($data); |
8162 | 8162 | if($str==='') |
@@ -8207,13 +8207,13 @@ discard block |
||
8207 | 8207 | if(!$this->_cacheChecked) |
8208 | 8208 | { |
8209 | 8209 | $this->_cacheChecked=true; |
8210 | - if($this->_duration>0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) |
|
8210 | + if($this->_duration > 0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) |
|
8211 | 8211 | { |
8212 | 8212 | if($this->_cacheModuleID!=='') |
8213 | 8213 | { |
8214 | 8214 | $this->_cache=$this->getApplication()->getModule($this->_cacheModuleID); |
8215 | 8215 | if(!($this->_cache instanceof ICache)) |
8216 | - throw new TConfigurationException('outputcache_cachemoduleid_invalid',$this->_cacheModuleID); |
|
8216 | + throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID); |
|
8217 | 8217 | } |
8218 | 8218 | else |
8219 | 8219 | $this->_cache=$this->getApplication()->getCache(); |
@@ -8224,14 +8224,14 @@ discard block |
||
8224 | 8224 | if(is_array($data)) |
8225 | 8225 | { |
8226 | 8226 | $param=new TOutputCacheCheckDependencyEventParameter; |
8227 | - $param->setCacheTime(isset($data[3])?$data[3]:0); |
|
8227 | + $param->setCacheTime(isset($data[3]) ? $data[3] : 0); |
|
8228 | 8228 | $this->onCheckDependency($param); |
8229 | 8229 | $this->_dataCached=$param->getIsValid(); |
8230 | 8230 | } |
8231 | 8231 | else |
8232 | 8232 | $this->_dataCached=false; |
8233 | 8233 | if($this->_dataCached) |
8234 | - list($this->_contents,$this->_state,$this->_actions,$this->_cacheTime)=$data; |
|
8234 | + list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime)=$data; |
|
8235 | 8235 | } |
8236 | 8236 | } |
8237 | 8237 | } |
@@ -8271,11 +8271,11 @@ discard block |
||
8271 | 8271 | foreach($this->_actions as $action) |
8272 | 8272 | { |
8273 | 8273 | if($action[0]==='Page.ClientScript') |
8274 | - call_user_func_array(array($cs,$action[1]),$action[2]); |
|
8274 | + call_user_func_array(array($cs, $action[1]), $action[2]); |
|
8275 | 8275 | else if($action[0]==='Page') |
8276 | - call_user_func_array(array($page,$action[1]),$action[2]); |
|
8276 | + call_user_func_array(array($page, $action[1]), $action[2]); |
|
8277 | 8277 | else |
8278 | - call_user_func_array(array($this->getSubProperty($action[0]),$action[1]),$action[2]); |
|
8278 | + call_user_func_array(array($this->getSubProperty($action[0]), $action[1]), $action[2]); |
|
8279 | 8279 | } |
8280 | 8280 | } |
8281 | 8281 | protected function preRenderRecursive() |
@@ -8290,10 +8290,10 @@ discard block |
||
8290 | 8290 | else |
8291 | 8291 | parent::preRenderRecursive(); |
8292 | 8292 | } |
8293 | - protected function loadStateRecursive(&$state,$needViewState=true) |
|
8293 | + protected function loadStateRecursive(&$state, $needViewState=true) |
|
8294 | 8294 | { |
8295 | 8295 | $st=unserialize($state); |
8296 | - parent::loadStateRecursive($st,$needViewState); |
|
8296 | + parent::loadStateRecursive($st, $needViewState); |
|
8297 | 8297 | } |
8298 | 8298 | protected function &saveStateRecursive($needViewState=true) |
8299 | 8299 | { |
@@ -8306,9 +8306,9 @@ discard block |
||
8306 | 8306 | return $this->_state; |
8307 | 8307 | } |
8308 | 8308 | } |
8309 | - public function registerAction($context,$funcName,$funcParams) |
|
8309 | + public function registerAction($context, $funcName, $funcParams) |
|
8310 | 8310 | { |
8311 | - $this->_actions[]=array($context,$funcName,$funcParams); |
|
8311 | + $this->_actions[]=array($context, $funcName, $funcParams); |
|
8312 | 8312 | } |
8313 | 8313 | public function getCacheKey() |
8314 | 8314 | { |
@@ -8325,7 +8325,7 @@ discard block |
||
8325 | 8325 | { |
8326 | 8326 | $params=array(); |
8327 | 8327 | $request=$this->getRequest(); |
8328 | - foreach(explode(',',$this->_varyByParam) as $name) |
|
8328 | + foreach(explode(',', $this->_varyByParam) as $name) |
|
8329 | 8329 | { |
8330 | 8330 | $name=trim($name); |
8331 | 8331 | $params[$name]=$request->itemAt($name); |
@@ -8371,8 +8371,8 @@ discard block |
||
8371 | 8371 | } |
8372 | 8372 | public function setDuration($value) |
8373 | 8373 | { |
8374 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
8375 | - throw new TInvalidDataValueException('outputcache_duration_invalid',get_class($this)); |
|
8374 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
8375 | + throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this)); |
|
8376 | 8376 | $this->_duration=$value; |
8377 | 8377 | } |
8378 | 8378 | public function getVaryByParam() |
@@ -8401,11 +8401,11 @@ discard block |
||
8401 | 8401 | } |
8402 | 8402 | public function onCheckDependency($param) |
8403 | 8403 | { |
8404 | - $this->raiseEvent('OnCheckDependency',$this,$param); |
|
8404 | + $this->raiseEvent('OnCheckDependency', $this, $param); |
|
8405 | 8405 | } |
8406 | 8406 | public function onCalculateKey($param) |
8407 | 8407 | { |
8408 | - $this->raiseEvent('OnCalculateKey',$this,$param); |
|
8408 | + $this->raiseEvent('OnCalculateKey', $this, $param); |
|
8409 | 8409 | } |
8410 | 8410 | public function render($writer) |
8411 | 8411 | { |
@@ -8413,16 +8413,16 @@ discard block |
||
8413 | 8413 | $writer->write($this->_contents); |
8414 | 8414 | else if($this->_cacheAvailable) |
8415 | 8415 | { |
8416 | - $textwriter = new TTextWriter(); |
|
8417 | - $multiwriter = new TOutputCacheTextWriterMulti(array($writer->getWriter(),$textwriter)); |
|
8418 | - $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $multiwriter); |
|
8416 | + $textwriter=new TTextWriter(); |
|
8417 | + $multiwriter=new TOutputCacheTextWriterMulti(array($writer->getWriter(), $textwriter)); |
|
8418 | + $htmlWriter=Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $multiwriter); |
|
8419 | 8419 | $stack=$this->getPage()->getCachingStack(); |
8420 | 8420 | $stack->push($this); |
8421 | 8421 | parent::render($htmlWriter); |
8422 | 8422 | $stack->pop(); |
8423 | 8423 | $content=$textwriter->flush(); |
8424 | - $data=array($content,$this->_state,$this->_actions,time()); |
|
8425 | - $this->_cache->set($this->getCacheKey(),$data,$this->getDuration(),$this->getCacheDependency()); |
|
8424 | + $data=array($content, $this->_state, $this->_actions, time()); |
|
8425 | + $this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency()); |
|
8426 | 8426 | } |
8427 | 8427 | else |
8428 | 8428 | parent::render($writer); |
@@ -8466,7 +8466,7 @@ discard block |
||
8466 | 8466 | protected $_writers; |
8467 | 8467 | public function __construct(Array $writers) |
8468 | 8468 | { |
8469 | - $this->_writers = $writers; |
|
8469 | + $this->_writers=$writers; |
|
8470 | 8470 | } |
8471 | 8471 | public function write($s) |
8472 | 8472 | { |
@@ -8476,7 +8476,7 @@ discard block |
||
8476 | 8476 | public function flush() |
8477 | 8477 | { |
8478 | 8478 | foreach($this->_writers as $writer) |
8479 | - $s = $writer->flush(); |
|
8479 | + $s=$writer->flush(); |
|
8480 | 8480 | return $s; |
8481 | 8481 | } |
8482 | 8482 | } |
@@ -8499,19 +8499,19 @@ discard block |
||
8499 | 8499 | if(($fileName=$this->getLocalizedTemplate($fileName))!==null) |
8500 | 8500 | { |
8501 | 8501 | if(($cache=$this->getApplication()->getCache())===null) |
8502 | - return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName); |
|
8502 | + return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
8503 | 8503 | else |
8504 | 8504 | { |
8505 | 8505 | $array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName); |
8506 | 8506 | if(is_array($array)) |
8507 | 8507 | { |
8508 | - list($template,$timestamps)=$array; |
|
8508 | + list($template, $timestamps)=$array; |
|
8509 | 8509 | if($this->getApplication()->getMode()===TApplicationMode::Performance) |
8510 | 8510 | return $template; |
8511 | 8511 | $cacheValid=true; |
8512 | 8512 | foreach($timestamps as $tplFile=>$timestamp) |
8513 | 8513 | { |
8514 | - if(!is_file($tplFile) || filemtime($tplFile)>$timestamp) |
|
8514 | + if(!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
|
8515 | 8515 | { |
8516 | 8516 | $cacheValid=false; |
8517 | 8517 | break; |
@@ -8520,13 +8520,13 @@ discard block |
||
8520 | 8520 | if($cacheValid) |
8521 | 8521 | return $template; |
8522 | 8522 | } |
8523 | - $template=new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName); |
|
8523 | + $template=new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
8524 | 8524 | $includedFiles=$template->getIncludedFiles(); |
8525 | 8525 | $timestamps=array(); |
8526 | 8526 | $timestamps[$fileName]=filemtime($fileName); |
8527 | 8527 | foreach($includedFiles as $includedFile) |
8528 | 8528 | $timestamps[$includedFile]=filemtime($includedFile); |
8529 | - $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps)); |
|
8529 | + $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName, array($template, $timestamps)); |
|
8530 | 8530 | return $template; |
8531 | 8531 | } |
8532 | 8532 | } |
@@ -8536,7 +8536,7 @@ discard block |
||
8536 | 8536 | protected function getLocalizedTemplate($filename) |
8537 | 8537 | { |
8538 | 8538 | if(($app=$this->getApplication()->getGlobalization(false))===null) |
8539 | - return is_file($filename)?$filename:null; |
|
8539 | + return is_file($filename) ? $filename : null; |
|
8540 | 8540 | foreach($app->getLocalizedResource($filename) as $file) |
8541 | 8541 | { |
8542 | 8542 | if(($file=realpath($file))!==false && is_file($file)) |
@@ -8566,7 +8566,7 @@ discard block |
||
8566 | 8566 | private $_includedFiles=array(); |
8567 | 8567 | private $_includeAtLine=array(); |
8568 | 8568 | private $_includeLines=array(); |
8569 | - public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true) |
|
8569 | + public function __construct($template, $contextPath, $tplFile=null, $startingLine=0, $sourceTemplate=true) |
|
8570 | 8570 | { |
8571 | 8571 | $this->_sourceTemplate=$sourceTemplate; |
8572 | 8572 | $this->_contextPath=$contextPath; |
@@ -8575,7 +8575,7 @@ discard block |
||
8575 | 8575 | $this->_content=$template; |
8576 | 8576 | $this->_hashCode=md5($template); |
8577 | 8577 | $this->parse($template); |
8578 | - $this->_content=null; } |
|
8578 | + $this->_content=null; } |
|
8579 | 8579 | public function getTemplateFile() |
8580 | 8580 | { |
8581 | 8581 | return $this->_tplFile; |
@@ -8600,7 +8600,7 @@ discard block |
||
8600 | 8600 | { |
8601 | 8601 | return $this->_tpl; |
8602 | 8602 | } |
8603 | - public function instantiateIn($tplControl,$parentControl=null) |
|
8603 | + public function instantiateIn($tplControl, $parentControl=null) |
|
8604 | 8604 | { |
8605 | 8605 | $this->_tplControl=$tplControl; |
8606 | 8606 | if($parentControl===null) |
@@ -8617,7 +8617,7 @@ discard block |
||
8617 | 8617 | $parent=$controls[$object[0]]; |
8618 | 8618 | else |
8619 | 8619 | continue; |
8620 | - if(isset($object[2])) { |
|
8620 | + if(isset($object[2])) { |
|
8621 | 8621 | $component=Prado::createComponent($object[1]); |
8622 | 8622 | $properties=&$object[2]; |
8623 | 8623 | if($component instanceof TControl) |
@@ -8629,7 +8629,7 @@ discard block |
||
8629 | 8629 | { |
8630 | 8630 | if(is_array($properties['id'])) |
8631 | 8631 | $properties['id']=$component->evaluateExpression($properties['id'][1]); |
8632 | - $tplControl->registerObject($properties['id'],$component); |
|
8632 | + $tplControl->registerObject($properties['id'], $component); |
|
8633 | 8633 | } |
8634 | 8634 | if(isset($properties['skinid'])) |
8635 | 8635 | { |
@@ -8642,7 +8642,7 @@ discard block |
||
8642 | 8642 | $component->trackViewState(false); |
8643 | 8643 | $component->applyStyleSheetSkin($page); |
8644 | 8644 | foreach($properties as $name=>$value) |
8645 | - $this->configureControl($component,$name,$value); |
|
8645 | + $this->configureControl($component, $name, $value); |
|
8646 | 8646 | $component->trackViewState(true); |
8647 | 8647 | if($parent===$parentControl) |
8648 | 8648 | $directChildren[]=$component; |
@@ -8658,12 +8658,12 @@ discard block |
||
8658 | 8658 | { |
8659 | 8659 | if(is_array($properties['id'])) |
8660 | 8660 | $properties['id']=$component->evaluateExpression($properties['id'][1]); |
8661 | - $tplControl->registerObject($properties['id'],$component); |
|
8661 | + $tplControl->registerObject($properties['id'], $component); |
|
8662 | 8662 | if(!$component->hasProperty('id')) |
8663 | 8663 | unset($properties['id']); |
8664 | 8664 | } |
8665 | 8665 | foreach($properties as $name=>$value) |
8666 | - $this->configureComponent($component,$name,$value); |
|
8666 | + $this->configureComponent($component, $name, $value); |
|
8667 | 8667 | if($parent===$parentControl) |
8668 | 8668 | $directChildren[]=$component; |
8669 | 8669 | else |
@@ -8698,36 +8698,36 @@ discard block |
||
8698 | 8698 | $parentControl->addParsedObject($control); |
8699 | 8699 | } |
8700 | 8700 | } |
8701 | - protected function configureControl($control,$name,$value) |
|
8701 | + protected function configureControl($control, $name, $value) |
|
8702 | 8702 | { |
8703 | - if(strncasecmp($name,'on',2)===0) $this->configureEvent($control,$name,$value,$control); |
|
8704 | - else if(($pos=strrpos($name,'.'))===false) $this->configureProperty($control,$name,$value); |
|
8705 | - else $this->configureSubProperty($control,$name,$value); |
|
8703 | + if(strncasecmp($name, 'on', 2)===0) $this->configureEvent($control, $name, $value, $control); |
|
8704 | + else if(($pos=strrpos($name, '.'))===false) $this->configureProperty($control, $name, $value); |
|
8705 | + else $this->configureSubProperty($control, $name, $value); |
|
8706 | 8706 | } |
8707 | - protected function configureComponent($component,$name,$value) |
|
8707 | + protected function configureComponent($component, $name, $value) |
|
8708 | 8708 | { |
8709 | - if(strpos($name,'.')===false) $this->configureProperty($component,$name,$value); |
|
8710 | - else $this->configureSubProperty($component,$name,$value); |
|
8709 | + if(strpos($name, '.')===false) $this->configureProperty($component, $name, $value); |
|
8710 | + else $this->configureSubProperty($component, $name, $value); |
|
8711 | 8711 | } |
8712 | - protected function configureEvent($control,$name,$value,$contextControl) |
|
8712 | + protected function configureEvent($control, $name, $value, $contextControl) |
|
8713 | 8713 | { |
8714 | - if(strpos($value,'.')===false) |
|
8715 | - $control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value)); |
|
8714 | + if(strpos($value, '.')===false) |
|
8715 | + $control->attachEventHandler($name, array($contextControl, 'TemplateControl.'.$value)); |
|
8716 | 8716 | else |
8717 | - $control->attachEventHandler($name,array($contextControl,$value)); |
|
8717 | + $control->attachEventHandler($name, array($contextControl, $value)); |
|
8718 | 8718 | } |
8719 | - protected function configureProperty($component,$name,$value) |
|
8719 | + protected function configureProperty($component, $name, $value) |
|
8720 | 8720 | { |
8721 | 8721 | if(is_array($value)) |
8722 | 8722 | { |
8723 | 8723 | switch($value[0]) |
8724 | 8724 | { |
8725 | 8725 | case self::CONFIG_DATABIND: |
8726 | - $component->bindProperty($name,$value[1]); |
|
8726 | + $component->bindProperty($name, $value[1]); |
|
8727 | 8727 | break; |
8728 | 8728 | case self::CONFIG_EXPRESSION: |
8729 | 8729 | if($component instanceof TControl) |
8730 | - $component->autoBindProperty($name,$value[1]); |
|
8730 | + $component->autoBindProperty($name, $value[1]); |
|
8731 | 8731 | else |
8732 | 8732 | { |
8733 | 8733 | $setter='set'.$name; |
@@ -8749,55 +8749,55 @@ discard block |
||
8749 | 8749 | $setter='set'.$name; |
8750 | 8750 | $component->$setter(Prado::localize($value[1])); |
8751 | 8751 | break; |
8752 | - default: throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
8752 | + default: throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
8753 | 8753 | break; |
8754 | 8754 | } |
8755 | 8755 | } |
8756 | 8756 | else |
8757 | 8757 | { |
8758 | - if (substr($name,0,2)=='js') |
|
8759 | - if ($value and !($value instanceof TJavaScriptLiteral)) |
|
8760 | - $value = new TJavaScriptLiteral($value); |
|
8758 | + if(substr($name, 0, 2)=='js') |
|
8759 | + if($value and !($value instanceof TJavaScriptLiteral)) |
|
8760 | + $value=new TJavaScriptLiteral($value); |
|
8761 | 8761 | $setter='set'.$name; |
8762 | 8762 | $component->$setter($value); |
8763 | 8763 | } |
8764 | 8764 | } |
8765 | - protected function configureSubProperty($component,$name,$value) |
|
8765 | + protected function configureSubProperty($component, $name, $value) |
|
8766 | 8766 | { |
8767 | 8767 | if(is_array($value)) |
8768 | 8768 | { |
8769 | 8769 | switch($value[0]) |
8770 | 8770 | { |
8771 | - case self::CONFIG_DATABIND: $component->bindProperty($name,$value[1]); |
|
8771 | + case self::CONFIG_DATABIND: $component->bindProperty($name, $value[1]); |
|
8772 | 8772 | break; |
8773 | 8773 | case self::CONFIG_EXPRESSION: if($component instanceof TControl) |
8774 | - $component->autoBindProperty($name,$value[1]); |
|
8774 | + $component->autoBindProperty($name, $value[1]); |
|
8775 | 8775 | else |
8776 | - $component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1])); |
|
8776 | + $component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1])); |
|
8777 | 8777 | break; |
8778 | 8778 | case self::CONFIG_TEMPLATE: |
8779 | - $component->setSubProperty($name,$value[1]); |
|
8779 | + $component->setSubProperty($name, $value[1]); |
|
8780 | 8780 | break; |
8781 | 8781 | case self::CONFIG_ASSET: $url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]); |
8782 | - $component->setSubProperty($name,$url); |
|
8782 | + $component->setSubProperty($name, $url); |
|
8783 | 8783 | break; |
8784 | - case self::CONFIG_PARAMETER: $component->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1])); |
|
8784 | + case self::CONFIG_PARAMETER: $component->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1])); |
|
8785 | 8785 | break; |
8786 | 8786 | case self::CONFIG_LOCALIZATION: |
8787 | - $component->setSubProperty($name,Prado::localize($value[1])); |
|
8787 | + $component->setSubProperty($name, Prado::localize($value[1])); |
|
8788 | 8788 | break; |
8789 | - default: throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
8789 | + default: throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
8790 | 8790 | break; |
8791 | 8791 | } |
8792 | 8792 | } |
8793 | 8793 | else |
8794 | - $component->setSubProperty($name,$value); |
|
8794 | + $component->setSubProperty($name, $value); |
|
8795 | 8795 | } |
8796 | 8796 | protected function parse($input) |
8797 | 8797 | { |
8798 | 8798 | $input=$this->preprocess($input); |
8799 | 8799 | $tpl=&$this->_tpl; |
8800 | - $n=preg_match_all(self::REGEX_RULES,$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
8800 | + $n=preg_match_all(self::REGEX_RULES, $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
8801 | 8801 | $expectPropEnd=false; |
8802 | 8802 | $textStart=0; |
8803 | 8803 | $stack=array(); |
@@ -8807,171 +8807,171 @@ discard block |
||
8807 | 8807 | $this->_directive=null; |
8808 | 8808 | try |
8809 | 8809 | { |
8810 | - for($i=0;$i<$n;++$i) |
|
8810 | + for($i=0; $i < $n; ++$i) |
|
8811 | 8811 | { |
8812 | 8812 | $match=&$matches[$i]; |
8813 | 8813 | $str=$match[0][0]; |
8814 | 8814 | $matchStart=$match[0][1]; |
8815 | - $matchEnd=$matchStart+strlen($str)-1; |
|
8816 | - if(strpos($str,'<com:')===0) { |
|
8815 | + $matchEnd=$matchStart + strlen($str) - 1; |
|
8816 | + if(strpos($str, '<com:')===0) { |
|
8817 | 8817 | if($expectPropEnd) |
8818 | 8818 | continue; |
8819 | - if($matchStart>$textStart) |
|
8820 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
8821 | - $textStart=$matchEnd+1; |
|
8819 | + if($matchStart > $textStart) |
|
8820 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
8821 | + $textStart=$matchEnd + 1; |
|
8822 | 8822 | $type=$match[1][0]; |
8823 | - $attributes=$this->parseAttributes($match[2][0],$match[2][1]); |
|
8824 | - $this->validateAttributes($type,$attributes); |
|
8825 | - $tpl[$c++]=array($container,$type,$attributes); |
|
8826 | - if($str[strlen($str)-2]!=='/') { |
|
8827 | - $stack[] = $type; |
|
8828 | - $container=$c-1; |
|
8823 | + $attributes=$this->parseAttributes($match[2][0], $match[2][1]); |
|
8824 | + $this->validateAttributes($type, $attributes); |
|
8825 | + $tpl[$c++]=array($container, $type, $attributes); |
|
8826 | + if($str[strlen($str) - 2]!=='/') { |
|
8827 | + $stack[]=$type; |
|
8828 | + $container=$c - 1; |
|
8829 | 8829 | } |
8830 | 8830 | } |
8831 | - else if(strpos($str,'</com:')===0) { |
|
8831 | + else if(strpos($str, '</com:')===0) { |
|
8832 | 8832 | if($expectPropEnd) |
8833 | 8833 | continue; |
8834 | - if($matchStart>$textStart) |
|
8835 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
8836 | - $textStart=$matchEnd+1; |
|
8834 | + if($matchStart > $textStart) |
|
8835 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
8836 | + $textStart=$matchEnd + 1; |
|
8837 | 8837 | $type=$match[1][0]; |
8838 | 8838 | if(empty($stack)) |
8839 | - throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>"); |
|
8839 | + throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>"); |
|
8840 | 8840 | $name=array_pop($stack); |
8841 | 8841 | if($name!==$type) |
8842 | 8842 | { |
8843 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
8844 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
8843 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
8844 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
8845 | 8845 | } |
8846 | 8846 | $container=$tpl[$container][0]; |
8847 | 8847 | } |
8848 | - else if(strpos($str,'<%@')===0) { |
|
8848 | + else if(strpos($str, '<%@')===0) { |
|
8849 | 8849 | if($expectPropEnd) |
8850 | 8850 | continue; |
8851 | - if($matchStart>$textStart) |
|
8852 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
8853 | - $textStart=$matchEnd+1; |
|
8851 | + if($matchStart > $textStart) |
|
8852 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
8853 | + $textStart=$matchEnd + 1; |
|
8854 | 8854 | if(isset($tpl[0]) || $this->_directive!==null) |
8855 | 8855 | throw new TConfigurationException('template_directive_nonunique'); |
8856 | - $this->_directive=$this->parseAttributes($match[4][0],$match[4][1]); |
|
8856 | + $this->_directive=$this->parseAttributes($match[4][0], $match[4][1]); |
|
8857 | 8857 | } |
8858 | - else if(strpos($str,'<%')===0) { |
|
8858 | + else if(strpos($str, '<%')===0) { |
|
8859 | 8859 | if($expectPropEnd) |
8860 | 8860 | continue; |
8861 | - if($matchStart>$textStart) |
|
8862 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
8863 | - $textStart=$matchEnd+1; |
|
8861 | + if($matchStart > $textStart) |
|
8862 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
8863 | + $textStart=$matchEnd + 1; |
|
8864 | 8864 | $literal=trim($match[5][0]); |
8865 | - if($str[2]==='=') $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal)); |
|
8866 | - else if($str[2]==='%') $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal)); |
|
8865 | + if($str[2]==='=') $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, $literal)); |
|
8866 | + else if($str[2]==='%') $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_STATEMENTS, $literal)); |
|
8867 | 8867 | else if($str[2]==='#') |
8868 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal)); |
|
8868 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_DATABINDING, $literal)); |
|
8869 | 8869 | else if($str[2]==='$') |
8870 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
8870 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
8871 | 8871 | else if($str[2]==='~') |
8872 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
8872 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
8873 | 8873 | else if($str[2]==='/') |
8874 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); |
|
8874 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); |
|
8875 | 8875 | else if($str[2]==='[') |
8876 | 8876 | { |
8877 | - $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); |
|
8878 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')")); |
|
8877 | + $literal=strtr(trim(substr($literal, 0, strlen($literal) - 1)), array("'"=>"\'", "\\"=>"\\\\")); |
|
8878 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')")); |
|
8879 | 8879 | } |
8880 | 8880 | } |
8881 | - else if(strpos($str,'<prop:')===0) { |
|
8882 | - if(strrpos($str,'/>')===strlen($str)-2) { |
|
8881 | + else if(strpos($str, '<prop:')===0) { |
|
8882 | + if(strrpos($str, '/>')===strlen($str) - 2) { |
|
8883 | 8883 | if($expectPropEnd) |
8884 | 8884 | continue; |
8885 | - if($matchStart>$textStart) |
|
8886 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
8887 | - $textStart=$matchEnd+1; |
|
8885 | + if($matchStart > $textStart) |
|
8886 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
8887 | + $textStart=$matchEnd + 1; |
|
8888 | 8888 | $prop=strtolower($match[6][0]); |
8889 | - $attrs=$this->parseAttributes($match[7][0],$match[7][1]); |
|
8889 | + $attrs=$this->parseAttributes($match[7][0], $match[7][1]); |
|
8890 | 8890 | $attributes=array(); |
8891 | 8891 | foreach($attrs as $name=>$value) |
8892 | 8892 | $attributes[$prop.'.'.$name]=$value; |
8893 | 8893 | $type=$tpl[$container][1]; |
8894 | - $this->validateAttributes($type,$attributes); |
|
8894 | + $this->validateAttributes($type, $attributes); |
|
8895 | 8895 | foreach($attributes as $name=>$value) |
8896 | 8896 | { |
8897 | 8897 | if(isset($tpl[$container][2][$name])) |
8898 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
8898 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
8899 | 8899 | $tpl[$container][2][$name]=$value; |
8900 | 8900 | } |
8901 | 8901 | } |
8902 | - else { |
|
8902 | + else { |
|
8903 | 8903 | $prop=strtolower($match[3][0]); |
8904 | - $stack[] = '@'.$prop; |
|
8904 | + $stack[]='@'.$prop; |
|
8905 | 8905 | if(!$expectPropEnd) |
8906 | 8906 | { |
8907 | - if($matchStart>$textStart) |
|
8908 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
8909 | - $textStart=$matchEnd+1; |
|
8907 | + if($matchStart > $textStart) |
|
8908 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
8909 | + $textStart=$matchEnd + 1; |
|
8910 | 8910 | $expectPropEnd=true; |
8911 | 8911 | } |
8912 | 8912 | } |
8913 | 8913 | } |
8914 | - else if(strpos($str,'</prop:')===0) { |
|
8914 | + else if(strpos($str, '</prop:')===0) { |
|
8915 | 8915 | $prop=strtolower($match[3][0]); |
8916 | 8916 | if(empty($stack)) |
8917 | - throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>"); |
|
8917 | + throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>"); |
|
8918 | 8918 | $name=array_pop($stack); |
8919 | 8919 | if($name!=='@'.$prop) |
8920 | 8920 | { |
8921 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
8922 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
8921 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
8922 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
8923 | 8923 | } |
8924 | - if(($last=count($stack))<1 || $stack[$last-1][0]!=='@') |
|
8924 | + if(($last=count($stack)) < 1 || $stack[$last - 1][0]!=='@') |
|
8925 | 8925 | { |
8926 | - if($matchStart>$textStart) |
|
8926 | + if($matchStart > $textStart) |
|
8927 | 8927 | { |
8928 | - $value=substr($input,$textStart,$matchStart-$textStart); |
|
8929 | - if(substr($prop,-8,8)==='template') |
|
8930 | - $value=$this->parseTemplateProperty($value,$textStart); |
|
8928 | + $value=substr($input, $textStart, $matchStart - $textStart); |
|
8929 | + if(substr($prop, -8, 8)==='template') |
|
8930 | + $value=$this->parseTemplateProperty($value, $textStart); |
|
8931 | 8931 | else |
8932 | 8932 | $value=$this->parseAttribute($value); |
8933 | - if($container>=0) |
|
8933 | + if($container >= 0) |
|
8934 | 8934 | { |
8935 | 8935 | $type=$tpl[$container][1]; |
8936 | - $this->validateAttributes($type,array($prop=>$value)); |
|
8936 | + $this->validateAttributes($type, array($prop=>$value)); |
|
8937 | 8937 | if(isset($tpl[$container][2][$prop])) |
8938 | - throw new TConfigurationException('template_property_duplicated',$prop); |
|
8938 | + throw new TConfigurationException('template_property_duplicated', $prop); |
|
8939 | 8939 | $tpl[$container][2][$prop]=$value; |
8940 | 8940 | } |
8941 | 8941 | else $this->_directive[$prop]=$value; |
8942 | - $textStart=$matchEnd+1; |
|
8942 | + $textStart=$matchEnd + 1; |
|
8943 | 8943 | } |
8944 | 8944 | $expectPropEnd=false; |
8945 | 8945 | } |
8946 | 8946 | } |
8947 | - else if(strpos($str,'<!--')===0) { |
|
8947 | + else if(strpos($str, '<!--')===0) { |
|
8948 | 8948 | if($expectPropEnd) |
8949 | 8949 | throw new TConfigurationException('template_comments_forbidden'); |
8950 | - if($matchStart>$textStart) |
|
8951 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
8952 | - $textStart=$matchEnd+1; |
|
8950 | + if($matchStart > $textStart) |
|
8951 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
8952 | + $textStart=$matchEnd + 1; |
|
8953 | 8953 | } |
8954 | 8954 | else |
8955 | - throw new TConfigurationException('template_matching_unexpected',$match); |
|
8955 | + throw new TConfigurationException('template_matching_unexpected', $match); |
|
8956 | 8956 | } |
8957 | 8957 | if(!empty($stack)) |
8958 | 8958 | { |
8959 | 8959 | $name=array_pop($stack); |
8960 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
8961 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
8960 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
8961 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
8962 | 8962 | } |
8963 | - if($textStart<strlen($input)) |
|
8964 | - $tpl[$c++]=array($container,substr($input,$textStart)); |
|
8963 | + if($textStart < strlen($input)) |
|
8964 | + $tpl[$c++]=array($container, substr($input, $textStart)); |
|
8965 | 8965 | } |
8966 | 8966 | catch(Exception $e) |
8967 | 8967 | { |
8968 | 8968 | if(($e instanceof TException) && ($e instanceof TTemplateException)) |
8969 | 8969 | throw $e; |
8970 | 8970 | if($matchEnd===0) |
8971 | - $line=$this->_startingLine+1; |
|
8971 | + $line=$this->_startingLine + 1; |
|
8972 | 8972 | else |
8973 | - $line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1))); |
|
8974 | - $this->handleException($e,$line,$input); |
|
8973 | + $line=$this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1))); |
|
8974 | + $this->handleException($e, $line, $input); |
|
8975 | 8975 | } |
8976 | 8976 | if($this->_directive===null) |
8977 | 8977 | $this->_directive=array(); |
@@ -8985,9 +8985,9 @@ discard block |
||
8985 | 8985 | if($parent!==null) |
8986 | 8986 | { |
8987 | 8987 | if(count($merged[1])===1 && is_string($merged[1][0])) |
8988 | - $objects[$id-1]=array($merged[0],$merged[1][0]); |
|
8988 | + $objects[$id - 1]=array($merged[0], $merged[1][0]); |
|
8989 | 8989 | else |
8990 | - $objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
8990 | + $objects[$id - 1]=array($merged[0], new TCompositeLiteral($merged[1])); |
|
8991 | 8991 | } |
8992 | 8992 | if(isset($object[2])) |
8993 | 8993 | { |
@@ -8997,7 +8997,7 @@ discard block |
||
8997 | 8997 | else |
8998 | 8998 | { |
8999 | 8999 | $parent=$object[0]; |
9000 | - $merged=array($parent,array($object[1])); |
|
9000 | + $merged=array($parent, array($object[1])); |
|
9001 | 9001 | } |
9002 | 9002 | } |
9003 | 9003 | else |
@@ -9006,57 +9006,57 @@ discard block |
||
9006 | 9006 | if($parent!==null) |
9007 | 9007 | { |
9008 | 9008 | if(count($merged[1])===1 && is_string($merged[1][0])) |
9009 | - $objects[$id]=array($merged[0],$merged[1][0]); |
|
9009 | + $objects[$id]=array($merged[0], $merged[1][0]); |
|
9010 | 9010 | else |
9011 | - $objects[$id]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
9011 | + $objects[$id]=array($merged[0], new TCompositeLiteral($merged[1])); |
|
9012 | 9012 | } |
9013 | 9013 | $tpl=$objects; |
9014 | 9014 | return $objects; |
9015 | 9015 | } |
9016 | - protected function parseAttributes($str,$offset) |
|
9016 | + protected function parseAttributes($str, $offset) |
|
9017 | 9017 | { |
9018 | 9018 | if($str==='') |
9019 | 9019 | return array(); |
9020 | 9020 | $pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS'; |
9021 | 9021 | $attributes=array(); |
9022 | - $n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
9023 | - for($i=0;$i<$n;++$i) |
|
9022 | + $n=preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
9023 | + for($i=0; $i < $n; ++$i) |
|
9024 | 9024 | { |
9025 | 9025 | $match=&$matches[$i]; |
9026 | 9026 | $name=strtolower($match[1][0]); |
9027 | 9027 | if(isset($attributes[$name])) |
9028 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
9028 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
9029 | 9029 | $value=$match[2][0]; |
9030 | - if(substr($name,-8,8)==='template') |
|
9030 | + if(substr($name, -8, 8)==='template') |
|
9031 | 9031 | { |
9032 | 9032 | if($value[0]==='\'' || $value[0]==='"') |
9033 | - $attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1); |
|
9033 | + $attributes[$name]=$this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1); |
|
9034 | 9034 | else |
9035 | - $attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]); |
|
9035 | + $attributes[$name]=$this->parseTemplateProperty($value, $match[2][1]); |
|
9036 | 9036 | } |
9037 | 9037 | else |
9038 | 9038 | { |
9039 | 9039 | if($value[0]==='\'' || $value[0]==='"') |
9040 | - $attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2)); |
|
9040 | + $attributes[$name]=$this->parseAttribute(substr($value, 1, strlen($value) - 2)); |
|
9041 | 9041 | else |
9042 | 9042 | $attributes[$name]=$this->parseAttribute($value); |
9043 | 9043 | } |
9044 | 9044 | } |
9045 | 9045 | return $attributes; |
9046 | 9046 | } |
9047 | - protected function parseTemplateProperty($content,$offset) |
|
9047 | + protected function parseTemplateProperty($content, $offset) |
|
9048 | 9048 | { |
9049 | - $line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1; |
|
9050 | - return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false)); |
|
9049 | + $line=$this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1; |
|
9050 | + return array(self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)); |
|
9051 | 9051 | } |
9052 | 9052 | protected function parseAttribute($value) |
9053 | 9053 | { |
9054 | - if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0) |
|
9054 | + if(($n=preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0) |
|
9055 | 9055 | { |
9056 | 9056 | $isDataBind=false; |
9057 | 9057 | $textStart=0; |
9058 | 9058 | $expr=''; |
9059 | - for($i=0;$i<$n;++$i) |
|
9059 | + for($i=0; $i < $n; ++$i) |
|
9060 | 9060 | { |
9061 | 9061 | $match=$matches[0][$i]; |
9062 | 9062 | $token=$match[0]; |
@@ -9064,133 +9064,133 @@ discard block |
||
9064 | 9064 | $length=strlen($token); |
9065 | 9065 | if($token[2]==='#') |
9066 | 9066 | $isDataBind=true; |
9067 | - if($offset>$textStart) |
|
9068 | - $expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
9069 | - $expr.='.('.substr($token,3,$length-5).')'; |
|
9070 | - $textStart=$offset+$length; |
|
9067 | + if($offset > $textStart) |
|
9068 | + $expr.=".'".strtr(substr($value, $textStart, $offset - $textStart), array("'"=>"\\'", "\\"=>"\\\\"))."'"; |
|
9069 | + $expr.='.('.substr($token, 3, $length - 5).')'; |
|
9070 | + $textStart=$offset + $length; |
|
9071 | 9071 | } |
9072 | 9072 | $length=strlen($value); |
9073 | - if($length>$textStart) |
|
9074 | - $expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
9073 | + if($length > $textStart) |
|
9074 | + $expr.=".'".strtr(substr($value, $textStart, $length - $textStart), array("'"=>"\\'", "\\"=>"\\\\"))."'"; |
|
9075 | 9075 | if($isDataBind) |
9076 | - return array(self::CONFIG_DATABIND,ltrim($expr,'.')); |
|
9076 | + return array(self::CONFIG_DATABIND, ltrim($expr, '.')); |
|
9077 | 9077 | else |
9078 | - return array(self::CONFIG_EXPRESSION,ltrim($expr,'.')); |
|
9078 | + return array(self::CONFIG_EXPRESSION, ltrim($expr, '.')); |
|
9079 | 9079 | } |
9080 | - else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
9080 | + else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0]===$value) |
|
9081 | 9081 | { |
9082 | 9082 | $value=$matches[1]; |
9083 | 9083 | if($value[2]==='~') |
9084 | - return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5))); |
|
9084 | + return array(self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5))); |
|
9085 | 9085 | elseif($value[2]==='[') |
9086 | - return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6))); |
|
9086 | + return array(self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6))); |
|
9087 | 9087 | elseif($value[2]==='$') |
9088 | - return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5))); |
|
9088 | + return array(self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5))); |
|
9089 | 9089 | elseif($value[2]==='/') { |
9090 | - $literal = trim(substr($value,3,strlen($value)-5)); |
|
9091 | - return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
|
9090 | + $literal=trim(substr($value, 3, strlen($value) - 5)); |
|
9091 | + return array(self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
|
9092 | 9092 | } |
9093 | 9093 | } |
9094 | 9094 | else |
9095 | 9095 | return $value; |
9096 | 9096 | } |
9097 | - protected function validateAttributes($type,$attributes) |
|
9097 | + protected function validateAttributes($type, $attributes) |
|
9098 | 9098 | { |
9099 | 9099 | Prado::using($type); |
9100 | - if(($pos=strrpos($type,'.'))!==false) |
|
9101 | - $className=substr($type,$pos+1); |
|
9100 | + if(($pos=strrpos($type, '.'))!==false) |
|
9101 | + $className=substr($type, $pos + 1); |
|
9102 | 9102 | else |
9103 | 9103 | $className=$type; |
9104 | 9104 | $class=new ReflectionClass($className); |
9105 | - if(is_subclass_of($className,'TControl') || $className==='TControl') |
|
9105 | + if(is_subclass_of($className, 'TControl') || $className==='TControl') |
|
9106 | 9106 | { |
9107 | 9107 | foreach($attributes as $name=>$att) |
9108 | 9108 | { |
9109 | - if(($pos=strpos($name,'.'))!==false) |
|
9109 | + if(($pos=strpos($name, '.'))!==false) |
|
9110 | 9110 | { |
9111 | - $subname=substr($name,0,$pos); |
|
9111 | + $subname=substr($name, 0, $pos); |
|
9112 | 9112 | if(!$class->hasMethod('get'.$subname)) |
9113 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
9113 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
9114 | 9114 | } |
9115 | - else if(strncasecmp($name,'on',2)===0) |
|
9115 | + else if(strncasecmp($name, 'on', 2)===0) |
|
9116 | 9116 | { |
9117 | 9117 | if(!$class->hasMethod($name)) |
9118 | - throw new TConfigurationException('template_event_unknown',$type,$name); |
|
9118 | + throw new TConfigurationException('template_event_unknown', $type, $name); |
|
9119 | 9119 | else if(!is_string($att)) |
9120 | - throw new TConfigurationException('template_eventhandler_invalid',$type,$name); |
|
9120 | + throw new TConfigurationException('template_eventhandler_invalid', $type, $name); |
|
9121 | 9121 | } |
9122 | 9122 | else |
9123 | 9123 | { |
9124 | - if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) ) |
|
9124 | + if(!($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name))) |
|
9125 | 9125 | { |
9126 | - if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
9127 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
9126 | + if($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
9127 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
9128 | 9128 | else |
9129 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
9129 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
9130 | 9130 | } |
9131 | 9131 | else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
9132 | 9132 | { |
9133 | - if(strcasecmp($name,'id')===0) |
|
9134 | - throw new TConfigurationException('template_controlid_invalid',$type); |
|
9135 | - else if(strcasecmp($name,'skinid')===0) |
|
9136 | - throw new TConfigurationException('template_controlskinid_invalid',$type); |
|
9133 | + if(strcasecmp($name, 'id')===0) |
|
9134 | + throw new TConfigurationException('template_controlid_invalid', $type); |
|
9135 | + else if(strcasecmp($name, 'skinid')===0) |
|
9136 | + throw new TConfigurationException('template_controlskinid_invalid', $type); |
|
9137 | 9137 | } |
9138 | 9138 | } |
9139 | 9139 | } |
9140 | 9140 | } |
9141 | - else if(is_subclass_of($className,'TComponent') || $className==='TComponent') |
|
9141 | + else if(is_subclass_of($className, 'TComponent') || $className==='TComponent') |
|
9142 | 9142 | { |
9143 | 9143 | foreach($attributes as $name=>$att) |
9144 | 9144 | { |
9145 | 9145 | if(is_array($att) && ($att[0]===self::CONFIG_DATABIND)) |
9146 | - throw new TConfigurationException('template_databind_forbidden',$type,$name); |
|
9147 | - if(($pos=strpos($name,'.'))!==false) |
|
9146 | + throw new TConfigurationException('template_databind_forbidden', $type, $name); |
|
9147 | + if(($pos=strpos($name, '.'))!==false) |
|
9148 | 9148 | { |
9149 | - $subname=substr($name,0,$pos); |
|
9149 | + $subname=substr($name, 0, $pos); |
|
9150 | 9150 | if(!$class->hasMethod('get'.$subname)) |
9151 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
9151 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
9152 | 9152 | } |
9153 | - else if(strncasecmp($name,'on',2)===0) |
|
9154 | - throw new TConfigurationException('template_event_forbidden',$type,$name); |
|
9153 | + else if(strncasecmp($name, 'on', 2)===0) |
|
9154 | + throw new TConfigurationException('template_event_forbidden', $type, $name); |
|
9155 | 9155 | else |
9156 | 9156 | { |
9157 | - if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name))) |
|
9157 | + if(strcasecmp($name, 'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name))) |
|
9158 | 9158 | { |
9159 | 9159 | if($class->hasMethod('get'.$name)) |
9160 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
9160 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
9161 | 9161 | else |
9162 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
9162 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
9163 | 9163 | } |
9164 | 9164 | } |
9165 | 9165 | } |
9166 | 9166 | } |
9167 | 9167 | else |
9168 | - throw new TConfigurationException('template_component_required',$type); |
|
9168 | + throw new TConfigurationException('template_component_required', $type); |
|
9169 | 9169 | } |
9170 | 9170 | public function getIncludedFiles() |
9171 | 9171 | { |
9172 | 9172 | return $this->_includedFiles; |
9173 | 9173 | } |
9174 | - protected function handleException($e,$line,$input=null) |
|
9174 | + protected function handleException($e, $line, $input=null) |
|
9175 | 9175 | { |
9176 | 9176 | $srcFile=$this->_tplFile; |
9177 | - if(($n=count($this->_includedFiles))>0) { |
|
9178 | - for($i=$n-1;$i>=0;--$i) |
|
9177 | + if(($n=count($this->_includedFiles)) > 0) { |
|
9178 | + for($i=$n - 1; $i >= 0; --$i) |
|
9179 | 9179 | { |
9180 | - if($this->_includeAtLine[$i]<=$line) |
|
9180 | + if($this->_includeAtLine[$i] <= $line) |
|
9181 | 9181 | { |
9182 | - if($line<$this->_includeAtLine[$i]+$this->_includeLines[$i]) |
|
9182 | + if($line < $this->_includeAtLine[$i] + $this->_includeLines[$i]) |
|
9183 | 9183 | { |
9184 | - $line=$line-$this->_includeAtLine[$i]+1; |
|
9184 | + $line=$line - $this->_includeAtLine[$i] + 1; |
|
9185 | 9185 | $srcFile=$this->_includedFiles[$i]; |
9186 | 9186 | break; |
9187 | 9187 | } |
9188 | 9188 | else |
9189 | - $line=$line-$this->_includeLines[$i]+1; |
|
9189 | + $line=$line - $this->_includeLines[$i] + 1; |
|
9190 | 9190 | } |
9191 | 9191 | } |
9192 | 9192 | } |
9193 | - $exception=new TTemplateException('template_format_invalid',$e->getMessage()); |
|
9193 | + $exception=new TTemplateException('template_format_invalid', $e->getMessage()); |
|
9194 | 9194 | $exception->setLineNumber($line); |
9195 | 9195 | if(!empty($srcFile)) |
9196 | 9196 | $exception->setTemplateFile($srcFile); |
@@ -9200,34 +9200,34 @@ discard block |
||
9200 | 9200 | } |
9201 | 9201 | protected function preprocess($input) |
9202 | 9202 | { |
9203 | - if($n=preg_match_all('/<%include(.*?)%>/',$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) |
|
9203 | + if($n=preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
|
9204 | 9204 | { |
9205 | - for($i=0;$i<$n;++$i) |
|
9205 | + for($i=0; $i < $n; ++$i) |
|
9206 | 9206 | { |
9207 | - $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT); |
|
9207 | + $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT); |
|
9208 | 9208 | if($filePath!==null && is_file($filePath)) |
9209 | 9209 | $this->_includedFiles[]=$filePath; |
9210 | 9210 | else |
9211 | 9211 | { |
9212 | - $errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1))); |
|
9213 | - $this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input); |
|
9212 | + $errorLine=count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1))); |
|
9213 | + $this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input); |
|
9214 | 9214 | } |
9215 | 9215 | } |
9216 | 9216 | $base=0; |
9217 | - for($i=0;$i<$n;++$i) |
|
9217 | + for($i=0; $i < $n; ++$i) |
|
9218 | 9218 | { |
9219 | 9219 | $ext=file_get_contents($this->_includedFiles[$i]); |
9220 | 9220 | $length=strlen($matches[$i][0][0]); |
9221 | - $offset=$base+$matches[$i][0][1]; |
|
9222 | - $this->_includeAtLine[$i]=count(explode("\n",substr($input,0,$offset))); |
|
9223 | - $this->_includeLines[$i]=count(explode("\n",$ext)); |
|
9224 | - $input=substr_replace($input,$ext,$offset,$length); |
|
9225 | - $base+=strlen($ext)-$length; |
|
9221 | + $offset=$base + $matches[$i][0][1]; |
|
9222 | + $this->_includeAtLine[$i]=count(explode("\n", substr($input, 0, $offset))); |
|
9223 | + $this->_includeLines[$i]=count(explode("\n", $ext)); |
|
9224 | + $input=substr_replace($input, $ext, $offset, $length); |
|
9225 | + $base+=strlen($ext) - $length; |
|
9226 | 9226 | } |
9227 | 9227 | } |
9228 | 9228 | return $input; |
9229 | 9229 | } |
9230 | - protected function isClassBehaviorMethod(ReflectionClass $class,$method) |
|
9230 | + protected function isClassBehaviorMethod(ReflectionClass $class, $method) |
|
9231 | 9231 | { |
9232 | 9232 | $component=new ReflectionClass('TComponent'); |
9233 | 9233 | $behaviors=$component->getStaticProperties(); |
@@ -9238,7 +9238,7 @@ discard block |
||
9238 | 9238 | if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
9239 | 9239 | foreach($list as $param) |
9240 | 9240 | { |
9241 | - if(method_exists($param->getBehavior(),$method)) |
|
9241 | + if(method_exists($param->getBehavior(), $method)) |
|
9242 | 9242 | return true; |
9243 | 9243 | } |
9244 | 9244 | } |
@@ -9248,7 +9248,7 @@ discard block |
||
9248 | 9248 | class TThemeManager extends TModule |
9249 | 9249 | { |
9250 | 9250 | const DEFAULT_BASEPATH='themes'; |
9251 | - const DEFAULT_THEMECLASS = 'TTheme'; |
|
9251 | + const DEFAULT_THEMECLASS='TTheme'; |
|
9252 | 9252 | private $_themeClass=self::DEFAULT_THEMECLASS; |
9253 | 9253 | private $_initialized=false; |
9254 | 9254 | private $_basePath=null; |
@@ -9265,11 +9265,11 @@ discard block |
||
9265 | 9265 | public function getTheme($name) |
9266 | 9266 | { |
9267 | 9267 | $themePath=$this->getBasePath().DIRECTORY_SEPARATOR.$name; |
9268 | - $themeUrl=rtrim($this->getBaseUrl(),'/').'/'.$name; |
|
9268 | + $themeUrl=rtrim($this->getBaseUrl(), '/').'/'.$name; |
|
9269 | 9269 | return Prado::createComponent($this->getThemeClass(), $themePath, $themeUrl); |
9270 | 9270 | } |
9271 | 9271 | public function setThemeClass($class) { |
9272 | - $this->_themeClass = $class===null ? self::DEFAULT_THEMECLASS : (string)$class; |
|
9272 | + $this->_themeClass=$class===null ? self::DEFAULT_THEMECLASS : (string) $class; |
|
9273 | 9273 | } |
9274 | 9274 | public function getThemeClass() { |
9275 | 9275 | return $this->_themeClass; |
@@ -9293,7 +9293,7 @@ discard block |
||
9293 | 9293 | { |
9294 | 9294 | $this->_basePath=dirname($this->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
9295 | 9295 | if(($basePath=realpath($this->_basePath))===false || !is_dir($basePath)) |
9296 | - throw new TConfigurationException('thememanager_basepath_invalid2',$this->_basePath); |
|
9296 | + throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
|
9297 | 9297 | $this->_basePath=$basePath; |
9298 | 9298 | } |
9299 | 9299 | return $this->_basePath; |
@@ -9306,7 +9306,7 @@ discard block |
||
9306 | 9306 | { |
9307 | 9307 | $this->_basePath=Prado::getPathOfNamespace($value); |
9308 | 9308 | if($this->_basePath===null || !is_dir($this->_basePath)) |
9309 | - throw new TInvalidDataValueException('thememanager_basepath_invalid',$value); |
|
9309 | + throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
|
9310 | 9310 | } |
9311 | 9311 | } |
9312 | 9312 | public function getBaseUrl() |
@@ -9315,16 +9315,16 @@ discard block |
||
9315 | 9315 | { |
9316 | 9316 | $appPath=dirname($this->getRequest()->getApplicationFilePath()); |
9317 | 9317 | $basePath=$this->getBasePath(); |
9318 | - if(strpos($basePath,$appPath)===false) |
|
9318 | + if(strpos($basePath, $appPath)===false) |
|
9319 | 9319 | throw new TConfigurationException('thememanager_baseurl_required'); |
9320 | - $appUrl=rtrim(dirname($this->getRequest()->getApplicationUrl()),'/\\'); |
|
9321 | - $this->_baseUrl=$appUrl.strtr(substr($basePath,strlen($appPath)),'\\','/'); |
|
9320 | + $appUrl=rtrim(dirname($this->getRequest()->getApplicationUrl()), '/\\'); |
|
9321 | + $this->_baseUrl=$appUrl.strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
|
9322 | 9322 | } |
9323 | 9323 | return $this->_baseUrl; |
9324 | 9324 | } |
9325 | 9325 | public function setBaseUrl($value) |
9326 | 9326 | { |
9327 | - $this->_baseUrl=rtrim($value,'/'); |
|
9327 | + $this->_baseUrl=rtrim($value, '/'); |
|
9328 | 9328 | } |
9329 | 9329 | } |
9330 | 9330 | class TTheme extends TApplicationComponent implements ITheme |
@@ -9337,7 +9337,7 @@ discard block |
||
9337 | 9337 | private $_name=''; |
9338 | 9338 | private $_cssFiles=array(); |
9339 | 9339 | private $_jsFiles=array(); |
9340 | - public function __construct($themePath,$themeUrl) |
|
9340 | + public function __construct($themePath, $themeUrl) |
|
9341 | 9341 | { |
9342 | 9342 | $this->_themeUrl=$themeUrl; |
9343 | 9343 | $this->_themePath=realpath($themePath); |
@@ -9348,21 +9348,21 @@ discard block |
||
9348 | 9348 | $array=$cache->get(self::THEME_CACHE_PREFIX.$themePath); |
9349 | 9349 | if(is_array($array)) |
9350 | 9350 | { |
9351 | - list($skins,$cssFiles,$jsFiles,$timestamp)=$array; |
|
9351 | + list($skins, $cssFiles, $jsFiles, $timestamp)=$array; |
|
9352 | 9352 | if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
9353 | 9353 | { |
9354 | 9354 | if(($dir=opendir($themePath))===false) |
9355 | - throw new TIOException('theme_path_inexistent',$themePath); |
|
9355 | + throw new TIOException('theme_path_inexistent', $themePath); |
|
9356 | 9356 | $cacheValid=true; |
9357 | 9357 | while(($file=readdir($dir))!==false) |
9358 | 9358 | { |
9359 | 9359 | if($file==='.' || $file==='..') |
9360 | 9360 | continue; |
9361 | - else if(basename($file,'.css')!==$file) |
|
9361 | + else if(basename($file, '.css')!==$file) |
|
9362 | 9362 | $this->_cssFiles[]=$themeUrl.'/'.$file; |
9363 | - else if(basename($file,'.js')!==$file) |
|
9363 | + else if(basename($file, '.js')!==$file) |
|
9364 | 9364 | $this->_jsFiles[]=$themeUrl.'/'.$file; |
9365 | - else if(basename($file,self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file)>$timestamp) |
|
9365 | + else if(basename($file, self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file) > $timestamp) |
|
9366 | 9366 | { |
9367 | 9367 | $cacheValid=false; |
9368 | 9368 | break; |
@@ -9387,28 +9387,28 @@ discard block |
||
9387 | 9387 | $this->_jsFiles=array(); |
9388 | 9388 | $this->_skins=array(); |
9389 | 9389 | if(($dir=opendir($themePath))===false) |
9390 | - throw new TIOException('theme_path_inexistent',$themePath); |
|
9390 | + throw new TIOException('theme_path_inexistent', $themePath); |
|
9391 | 9391 | while(($file=readdir($dir))!==false) |
9392 | 9392 | { |
9393 | 9393 | if($file==='.' || $file==='..') |
9394 | 9394 | continue; |
9395 | - else if(basename($file,'.css')!==$file) |
|
9395 | + else if(basename($file, '.css')!==$file) |
|
9396 | 9396 | $this->_cssFiles[]=$themeUrl.'/'.$file; |
9397 | - else if(basename($file,'.js')!==$file) |
|
9397 | + else if(basename($file, '.js')!==$file) |
|
9398 | 9398 | $this->_jsFiles[]=$themeUrl.'/'.$file; |
9399 | - else if(basename($file,self::SKIN_FILE_EXT)!==$file) |
|
9399 | + else if(basename($file, self::SKIN_FILE_EXT)!==$file) |
|
9400 | 9400 | { |
9401 | - $template=new TTemplate(file_get_contents($themePath.'/'.$file),$themePath,$themePath.'/'.$file); |
|
9401 | + $template=new TTemplate(file_get_contents($themePath.'/'.$file), $themePath, $themePath.'/'.$file); |
|
9402 | 9402 | foreach($template->getItems() as $skin) |
9403 | 9403 | { |
9404 | 9404 | if(!isset($skin[2])) continue; |
9405 | 9405 | else if($skin[0]!==-1) |
9406 | - throw new TConfigurationException('theme_control_nested',$skin[1],dirname($themePath)); |
|
9406 | + throw new TConfigurationException('theme_control_nested', $skin[1], dirname($themePath)); |
|
9407 | 9407 | $type=$skin[1]; |
9408 | - $id=isset($skin[2]['skinid'])?$skin[2]['skinid']:0; |
|
9408 | + $id=isset($skin[2]['skinid']) ? $skin[2]['skinid'] : 0; |
|
9409 | 9409 | unset($skin[2]['skinid']); |
9410 | 9410 | if(isset($this->_skins[$type][$id])) |
9411 | - throw new TConfigurationException('theme_skinid_duplicated',$type,$id,dirname($themePath)); |
|
9411 | + throw new TConfigurationException('theme_skinid_duplicated', $type, $id, dirname($themePath)); |
|
9412 | 9412 | $this->_skins[$type][$id]=$skin[2]; |
9413 | 9413 | } |
9414 | 9414 | } |
@@ -9417,7 +9417,7 @@ discard block |
||
9417 | 9417 | sort($this->_cssFiles); |
9418 | 9418 | sort($this->_jsFiles); |
9419 | 9419 | if($cache!==null) |
9420 | - $cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,$this->_jsFiles,time())); |
|
9420 | + $cache->set(self::THEME_CACHE_PREFIX.$themePath, array($this->_skins, $this->_cssFiles, $this->_jsFiles, time())); |
|
9421 | 9421 | } |
9422 | 9422 | } |
9423 | 9423 | public function getName() |
@@ -9426,7 +9426,7 @@ discard block |
||
9426 | 9426 | } |
9427 | 9427 | protected function setName($value) |
9428 | 9428 | { |
9429 | - $this->_name = $value; |
|
9429 | + $this->_name=$value; |
|
9430 | 9430 | } |
9431 | 9431 | public function getBaseUrl() |
9432 | 9432 | { |
@@ -9434,7 +9434,7 @@ discard block |
||
9434 | 9434 | } |
9435 | 9435 | protected function setBaseUrl($value) |
9436 | 9436 | { |
9437 | - $this->_themeUrl=rtrim($value,'/'); |
|
9437 | + $this->_themeUrl=rtrim($value, '/'); |
|
9438 | 9438 | } |
9439 | 9439 | public function getBasePath() |
9440 | 9440 | { |
@@ -9450,7 +9450,7 @@ discard block |
||
9450 | 9450 | } |
9451 | 9451 | protected function setSkins($value) |
9452 | 9452 | { |
9453 | - $this->_skins = $value; |
|
9453 | + $this->_skins=$value; |
|
9454 | 9454 | } |
9455 | 9455 | public function applySkin($control) |
9456 | 9456 | { |
@@ -9469,28 +9469,28 @@ discard block |
||
9469 | 9469 | $value=$this->evaluateExpression($value[1]); |
9470 | 9470 | break; |
9471 | 9471 | case TTemplate::CONFIG_ASSET: |
9472 | - $value=$this->_themeUrl.'/'.ltrim($value[1],'/'); |
|
9472 | + $value=$this->_themeUrl.'/'.ltrim($value[1], '/'); |
|
9473 | 9473 | break; |
9474 | 9474 | case TTemplate::CONFIG_DATABIND: |
9475 | - $control->bindProperty($name,$value[1]); |
|
9475 | + $control->bindProperty($name, $value[1]); |
|
9476 | 9476 | break; |
9477 | 9477 | case TTemplate::CONFIG_PARAMETER: |
9478 | - $control->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1])); |
|
9478 | + $control->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1])); |
|
9479 | 9479 | break; |
9480 | 9480 | case TTemplate::CONFIG_TEMPLATE: |
9481 | - $control->setSubProperty($name,$value[1]); |
|
9481 | + $control->setSubProperty($name, $value[1]); |
|
9482 | 9482 | break; |
9483 | 9483 | case TTemplate::CONFIG_LOCALIZATION: |
9484 | - $control->setSubProperty($name,Prado::localize($value[1])); |
|
9484 | + $control->setSubProperty($name, Prado::localize($value[1])); |
|
9485 | 9485 | break; |
9486 | 9486 | default: |
9487 | - throw new TConfigurationException('theme_tag_unexpected',$name,$value[0]); |
|
9487 | + throw new TConfigurationException('theme_tag_unexpected', $name, $value[0]); |
|
9488 | 9488 | break; |
9489 | 9489 | } |
9490 | 9490 | } |
9491 | 9491 | if(!is_array($value)) |
9492 | 9492 | { |
9493 | - if(strpos($name,'.')===false) { |
|
9493 | + if(strpos($name, '.')===false) { |
|
9494 | 9494 | if($control->hasProperty($name)) |
9495 | 9495 | { |
9496 | 9496 | if($control->canSetProperty($name)) |
@@ -9499,12 +9499,12 @@ discard block |
||
9499 | 9499 | $control->$setter($value); |
9500 | 9500 | } |
9501 | 9501 | else |
9502 | - throw new TConfigurationException('theme_property_readonly',$type,$name); |
|
9502 | + throw new TConfigurationException('theme_property_readonly', $type, $name); |
|
9503 | 9503 | } |
9504 | 9504 | else |
9505 | - throw new TConfigurationException('theme_property_undefined',$type,$name); |
|
9505 | + throw new TConfigurationException('theme_property_undefined', $type, $name); |
|
9506 | 9506 | } |
9507 | - else $control->setSubProperty($name,$value); |
|
9507 | + else $control->setSubProperty($name, $value); |
|
9508 | 9508 | } |
9509 | 9509 | } |
9510 | 9510 | return true; |
@@ -9567,15 +9567,15 @@ discard block |
||
9567 | 9567 | $pagePath=$this->getRequestedPagePath(); |
9568 | 9568 | foreach($config->getExternalConfigurations() as $filePath=>$params) |
9569 | 9569 | { |
9570 | - list($configPagePath,$condition)=$params; |
|
9570 | + list($configPagePath, $condition)=$params; |
|
9571 | 9571 | if($condition!==true) |
9572 | 9572 | $condition=$this->evaluateExpression($condition); |
9573 | 9573 | if($condition) |
9574 | 9574 | { |
9575 | - if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
9576 | - throw new TConfigurationException('pageservice_includefile_invalid',$filePath); |
|
9575 | + if(($path=Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
9576 | + throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
|
9577 | 9577 | $c=new TPageConfiguration($pagePath); |
9578 | - $c->loadFromFile($path,$configPagePath); |
|
9578 | + $c->loadFromFile($path, $configPagePath); |
|
9579 | 9579 | $this->applyConfiguration($c); |
9580 | 9580 | } |
9581 | 9581 | } |
@@ -9597,9 +9597,9 @@ discard block |
||
9597 | 9597 | if($config!==null) |
9598 | 9598 | { |
9599 | 9599 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
9600 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
9600 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
9601 | 9601 | else |
9602 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
9602 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
9603 | 9603 | } |
9604 | 9604 | $pageConfig->loadFromFiles($this->getBasePath()); |
9605 | 9605 | } |
@@ -9610,21 +9610,21 @@ discard block |
||
9610 | 9610 | $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
9611 | 9611 | if(is_array($arr)) |
9612 | 9612 | { |
9613 | - list($pageConfig,$timestamps)=$arr; |
|
9613 | + list($pageConfig, $timestamps)=$arr; |
|
9614 | 9614 | if($application->getMode()!==TApplicationMode::Performance) |
9615 | 9615 | { |
9616 | 9616 | foreach($timestamps as $fileName=>$timestamp) |
9617 | 9617 | { |
9618 | - if($fileName===0) { |
|
9618 | + if($fileName===0) { |
|
9619 | 9619 | $appConfigFile=$application->getConfigurationFile(); |
9620 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
9621 | - if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
|
9620 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
9621 | + if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
|
9622 | 9622 | $configCached=false; |
9623 | 9623 | } |
9624 | 9624 | else |
9625 | 9625 | { |
9626 | 9626 | $currentTimestamp[$fileName]=@filemtime($fileName); |
9627 | - if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
|
9627 | + if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
|
9628 | 9628 | $configCached=false; |
9629 | 9629 | } |
9630 | 9630 | } |
@@ -9633,9 +9633,9 @@ discard block |
||
9633 | 9633 | else |
9634 | 9634 | { |
9635 | 9635 | $configCached=false; |
9636 | - $paths=explode('.',$pagePath); |
|
9636 | + $paths=explode('.', $pagePath); |
|
9637 | 9637 | $configPath=$this->getBasePath(); |
9638 | - $fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
9638 | + $fileName=$this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
9639 | 9639 | ? self::CONFIG_FILE_PHP |
9640 | 9640 | : self::CONFIG_FILE_XML; |
9641 | 9641 | foreach($paths as $path) |
@@ -9645,7 +9645,7 @@ discard block |
||
9645 | 9645 | $configPath.=DIRECTORY_SEPARATOR.$path; |
9646 | 9646 | } |
9647 | 9647 | $appConfigFile=$application->getConfigurationFile(); |
9648 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
9648 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
9649 | 9649 | } |
9650 | 9650 | if(!$configCached) |
9651 | 9651 | { |
@@ -9653,12 +9653,12 @@ discard block |
||
9653 | 9653 | if($config!==null) |
9654 | 9654 | { |
9655 | 9655 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
9656 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
9656 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
9657 | 9657 | else |
9658 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
9658 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
9659 | 9659 | } |
9660 | 9660 | $pageConfig->loadFromFiles($this->getBasePath()); |
9661 | - $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp)); |
|
9661 | + $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, array($pageConfig, $currentTimestamp)); |
|
9662 | 9662 | } |
9663 | 9663 | } |
9664 | 9664 | return $pageConfig; |
@@ -9693,9 +9693,9 @@ discard block |
||
9693 | 9693 | { |
9694 | 9694 | if($this->_pagePath===null) |
9695 | 9695 | { |
9696 | - $this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..'); |
|
9696 | + $this->_pagePath=strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
9697 | 9697 | if(empty($this->_pagePath)) |
9698 | - throw new THttpException(404,'pageservice_page_required'); |
|
9698 | + throw new THttpException(404, 'pageservice_page_required'); |
|
9699 | 9699 | } |
9700 | 9700 | return $this->_pagePath; |
9701 | 9701 | } |
@@ -9727,7 +9727,7 @@ discard block |
||
9727 | 9727 | { |
9728 | 9728 | $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
9729 | 9729 | if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
9730 | - throw new TConfigurationException('pageservice_basepath_invalid',$basePath); |
|
9730 | + throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
|
9731 | 9731 | } |
9732 | 9732 | } |
9733 | 9733 | return $this->_basePath; |
@@ -9737,7 +9737,7 @@ discard block |
||
9737 | 9737 | if($this->_initialized) |
9738 | 9738 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
9739 | 9739 | else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
9740 | - throw new TConfigurationException('pageservice_basepath_invalid',$value); |
|
9740 | + throw new TConfigurationException('pageservice_basepath_invalid', $value); |
|
9741 | 9741 | $this->_basePath=realpath($path); |
9742 | 9742 | } |
9743 | 9743 | public function setBasePageClass($value) |
@@ -9759,45 +9759,45 @@ discard block |
||
9759 | 9759 | public function run() |
9760 | 9760 | { |
9761 | 9761 | $this->_page=$this->createPage($this->getRequestedPagePath()); |
9762 | - $this->runPage($this->_page,$this->_properties); |
|
9762 | + $this->runPage($this->_page, $this->_properties); |
|
9763 | 9763 | } |
9764 | 9764 | protected function createPage($pagePath) |
9765 | 9765 | { |
9766 | - $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR); |
|
9766 | + $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
9767 | 9767 | $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
9768 | 9768 | $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
9769 | 9769 | if(!$hasTemplateFile && !$hasClassFile) |
9770 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
9770 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
9771 | 9771 | if($hasClassFile) |
9772 | 9772 | { |
9773 | 9773 | $className=basename($path); |
9774 | - if(!class_exists($className,false)) |
|
9774 | + if(!class_exists($className, false)) |
|
9775 | 9775 | include_once($path.Prado::CLASS_FILE_EXT); |
9776 | 9776 | } |
9777 | 9777 | else |
9778 | 9778 | { |
9779 | 9779 | $className=$this->getBasePageClass(); |
9780 | 9780 | Prado::using($className); |
9781 | - if(($pos=strrpos($className,'.'))!==false) |
|
9782 | - $className=substr($className,$pos+1); |
|
9781 | + if(($pos=strrpos($className, '.'))!==false) |
|
9782 | + $className=substr($className, $pos + 1); |
|
9783 | 9783 | } |
9784 | - if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage'))) |
|
9785 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
9784 | + if(!class_exists($className, false) || ($className!=='TPage' && !is_subclass_of($className, 'TPage'))) |
|
9785 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
9786 | 9786 | $page=Prado::createComponent($className); |
9787 | 9787 | $page->setPagePath($pagePath); |
9788 | 9788 | if($hasTemplateFile) |
9789 | 9789 | $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT)); |
9790 | 9790 | return $page; |
9791 | 9791 | } |
9792 | - protected function runPage($page,$properties) |
|
9792 | + protected function runPage($page, $properties) |
|
9793 | 9793 | { |
9794 | 9794 | foreach($properties as $name=>$value) |
9795 | - $page->setSubProperty($name,$value); |
|
9795 | + $page->setSubProperty($name, $value); |
|
9796 | 9796 | $page->run($this->getResponse()->createHtmlWriter()); |
9797 | 9797 | } |
9798 | - public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
9798 | + public function constructUrl($pagePath, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
9799 | 9799 | { |
9800 | - return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); |
|
9800 | + return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
|
9801 | 9801 | } |
9802 | 9802 | } |
9803 | 9803 | class TPageConfiguration extends TComponent |
@@ -9829,89 +9829,89 @@ discard block |
||
9829 | 9829 | } |
9830 | 9830 | public function loadFromFiles($basePath) |
9831 | 9831 | { |
9832 | - $paths=explode('.',$this->_pagePath); |
|
9832 | + $paths=explode('.', $this->_pagePath); |
|
9833 | 9833 | $page=array_pop($paths); |
9834 | 9834 | $path=$basePath; |
9835 | 9835 | $configPagePath=''; |
9836 | - $fileName = Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
9836 | + $fileName=Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
9837 | 9837 | ? TPageService::CONFIG_FILE_PHP |
9838 | 9838 | : TPageService::CONFIG_FILE_XML; |
9839 | 9839 | foreach($paths as $p) |
9840 | 9840 | { |
9841 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
9841 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
9842 | 9842 | $path.=DIRECTORY_SEPARATOR.$p; |
9843 | 9843 | if($configPagePath==='') |
9844 | 9844 | $configPagePath=$p; |
9845 | 9845 | else |
9846 | 9846 | $configPagePath.='.'.$p; |
9847 | 9847 | } |
9848 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
9848 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
9849 | 9849 | $this->_rules=new TAuthorizationRuleCollection($this->_rules); |
9850 | 9850 | } |
9851 | - public function loadFromFile($fname,$configPagePath) |
|
9851 | + public function loadFromFile($fname, $configPagePath) |
|
9852 | 9852 | { |
9853 | 9853 | if(empty($fname) || !is_file($fname)) |
9854 | 9854 | return; |
9855 | 9855 | if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
9856 | 9856 | { |
9857 | - $fcontent = include $fname; |
|
9858 | - $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
|
9857 | + $fcontent=include $fname; |
|
9858 | + $this->loadFromPhp($fcontent, dirname($fname), $configPagePath); |
|
9859 | 9859 | } |
9860 | 9860 | else |
9861 | 9861 | { |
9862 | 9862 | $dom=new TXmlDocument; |
9863 | 9863 | if($dom->loadFromFile($fname)) |
9864 | - $this->loadFromXml($dom,dirname($fname),$configPagePath); |
|
9864 | + $this->loadFromXml($dom, dirname($fname), $configPagePath); |
|
9865 | 9865 | else |
9866 | - throw new TConfigurationException('pageserviceconf_file_invalid',$fname); |
|
9866 | + throw new TConfigurationException('pageserviceconf_file_invalid', $fname); |
|
9867 | 9867 | } |
9868 | 9868 | } |
9869 | - public function loadFromPhp($config,$configPath,$configPagePath) |
|
9869 | + public function loadFromPhp($config, $configPath, $configPagePath) |
|
9870 | 9870 | { |
9871 | - $this->loadApplicationConfigurationFromPhp($config,$configPath); |
|
9872 | - $this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath); |
|
9871 | + $this->loadApplicationConfigurationFromPhp($config, $configPath); |
|
9872 | + $this->loadPageConfigurationFromPhp($config, $configPath, $configPagePath); |
|
9873 | 9873 | } |
9874 | - public function loadFromXml($dom,$configPath,$configPagePath) |
|
9874 | + public function loadFromXml($dom, $configPath, $configPagePath) |
|
9875 | 9875 | { |
9876 | - $this->loadApplicationConfigurationFromXml($dom,$configPath); |
|
9877 | - $this->loadPageConfigurationFromXml($dom,$configPath,$configPagePath); |
|
9876 | + $this->loadApplicationConfigurationFromXml($dom, $configPath); |
|
9877 | + $this->loadPageConfigurationFromXml($dom, $configPath, $configPagePath); |
|
9878 | 9878 | } |
9879 | - public function loadApplicationConfigurationFromPhp($config,$configPath) |
|
9879 | + public function loadApplicationConfigurationFromPhp($config, $configPath) |
|
9880 | 9880 | { |
9881 | 9881 | $appConfig=new TApplicationConfiguration; |
9882 | - $appConfig->loadFromPhp($config,$configPath); |
|
9882 | + $appConfig->loadFromPhp($config, $configPath); |
|
9883 | 9883 | $this->_appConfigs[]=$appConfig; |
9884 | 9884 | } |
9885 | - public function loadApplicationConfigurationFromXml($dom,$configPath) |
|
9885 | + public function loadApplicationConfigurationFromXml($dom, $configPath) |
|
9886 | 9886 | { |
9887 | 9887 | $appConfig=new TApplicationConfiguration; |
9888 | - $appConfig->loadFromXml($dom,$configPath); |
|
9888 | + $appConfig->loadFromXml($dom, $configPath); |
|
9889 | 9889 | $this->_appConfigs[]=$appConfig; |
9890 | 9890 | } |
9891 | 9891 | public function loadPageConfigurationFromPhp($config, $configPath, $configPagePath) |
9892 | 9892 | { |
9893 | 9893 | if(isset($config['authorization']) && is_array($config['authorization'])) |
9894 | 9894 | { |
9895 | - $rules = array(); |
|
9895 | + $rules=array(); |
|
9896 | 9896 | foreach($config['authorization'] as $authorization) |
9897 | 9897 | { |
9898 | - $patterns=isset($authorization['pages'])?$authorization['pages']:''; |
|
9898 | + $patterns=isset($authorization['pages']) ? $authorization['pages'] : ''; |
|
9899 | 9899 | $ruleApplies=false; |
9900 | 9900 | if(empty($patterns) || trim($patterns)==='*') $ruleApplies=true; |
9901 | 9901 | else |
9902 | 9902 | { |
9903 | - foreach(explode(',',$patterns) as $pattern) |
|
9903 | + foreach(explode(',', $patterns) as $pattern) |
|
9904 | 9904 | { |
9905 | 9905 | if(($pattern=trim($pattern))!=='') |
9906 | 9906 | { |
9907 | 9907 | if($configPagePath!=='') $pattern=$configPagePath.'.'.$pattern; |
9908 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
9908 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
9909 | 9909 | { |
9910 | 9910 | $ruleApplies=true; |
9911 | 9911 | break; |
9912 | 9912 | } |
9913 | - if($pattern[strlen($pattern)-1]==='*') { |
|
9914 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
9913 | + if($pattern[strlen($pattern) - 1]==='*') { |
|
9914 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
9915 | 9915 | { |
9916 | 9916 | $ruleApplies=true; |
9917 | 9917 | break; |
@@ -9922,56 +9922,56 @@ discard block |
||
9922 | 9922 | } |
9923 | 9923 | if($ruleApplies) |
9924 | 9924 | { |
9925 | - $action = isset($authorization['action'])?$authorization['action']:''; |
|
9926 | - $users = isset($authorization['users'])?$authorization['users']:''; |
|
9927 | - $roles = isset($authorization['roles'])?$authorization['roles']:''; |
|
9928 | - $verb = isset($authorization['verb'])?$authorization['verb']:''; |
|
9929 | - $ips = isset($authorization['ips'])?$authorization['ips']:''; |
|
9930 | - $rules[]=new TAuthorizationRule($action,$users,$roles,$verb,$ips); |
|
9925 | + $action=isset($authorization['action']) ? $authorization['action'] : ''; |
|
9926 | + $users=isset($authorization['users']) ? $authorization['users'] : ''; |
|
9927 | + $roles=isset($authorization['roles']) ? $authorization['roles'] : ''; |
|
9928 | + $verb=isset($authorization['verb']) ? $authorization['verb'] : ''; |
|
9929 | + $ips=isset($authorization['ips']) ? $authorization['ips'] : ''; |
|
9930 | + $rules[]=new TAuthorizationRule($action, $users, $roles, $verb, $ips); |
|
9931 | 9931 | } |
9932 | 9932 | } |
9933 | - $this->_rules=array_merge($rules,$this->_rules); |
|
9933 | + $this->_rules=array_merge($rules, $this->_rules); |
|
9934 | 9934 | } |
9935 | 9935 | if(isset($config['pages']) && is_array($config['pages'])) |
9936 | 9936 | { |
9937 | 9937 | if(isset($config['pages']['properties'])) |
9938 | 9938 | { |
9939 | - $this->_properties = array_merge($this->_properties, $config['pages']['properties']); |
|
9939 | + $this->_properties=array_merge($this->_properties, $config['pages']['properties']); |
|
9940 | 9940 | unset($config['pages']['properties']); |
9941 | 9941 | } |
9942 | 9942 | foreach($config['pages'] as $id => $page) |
9943 | 9943 | { |
9944 | - $properties = array(); |
|
9944 | + $properties=array(); |
|
9945 | 9945 | if(isset($page['properties'])) |
9946 | 9946 | { |
9947 | 9947 | $properties=$page['properties']; |
9948 | 9948 | unset($page['properties']); |
9949 | 9949 | } |
9950 | 9950 | $matching=false; |
9951 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
9952 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
9951 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
9952 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
9953 | 9953 | $matching=true; |
9954 | - else if($id[strlen($id)-1]==='*') $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
9954 | + else if($id[strlen($id) - 1]==='*') $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
9955 | 9955 | if($matching) |
9956 | - $this->_properties=array_merge($this->_properties,$properties); |
|
9956 | + $this->_properties=array_merge($this->_properties, $properties); |
|
9957 | 9957 | } |
9958 | 9958 | } |
9959 | 9959 | if(isset($config['includes']) && is_array($config['includes'])) |
9960 | 9960 | { |
9961 | 9961 | foreach($config['includes'] as $include) |
9962 | 9962 | { |
9963 | - $when = isset($include['when'])?true:false; |
|
9963 | + $when=isset($include['when']) ? true : false; |
|
9964 | 9964 | if(!isset($include['file'])) |
9965 | 9965 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
9966 | - $filePath = $include['file']; |
|
9966 | + $filePath=$include['file']; |
|
9967 | 9967 | if(isset($this->_includes[$filePath])) |
9968 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
9968 | + $this->_includes[$filePath]=array($configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
9969 | 9969 | else |
9970 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
9970 | + $this->_includes[$filePath]=array($configPagePath, $when); |
|
9971 | 9971 | } |
9972 | 9972 | } |
9973 | 9973 | } |
9974 | - public function loadPageConfigurationFromXml($dom,$configPath,$configPagePath) |
|
9974 | + public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath) |
|
9975 | 9975 | { |
9976 | 9976 | if(($authorizationNode=$dom->getElementByTagName('authorization'))!==null) |
9977 | 9977 | { |
@@ -9983,18 +9983,18 @@ discard block |
||
9983 | 9983 | if(empty($patterns) || trim($patterns)==='*') $ruleApplies=true; |
9984 | 9984 | else |
9985 | 9985 | { |
9986 | - foreach(explode(',',$patterns) as $pattern) |
|
9986 | + foreach(explode(',', $patterns) as $pattern) |
|
9987 | 9987 | { |
9988 | 9988 | if(($pattern=trim($pattern))!=='') |
9989 | 9989 | { |
9990 | 9990 | if($configPagePath!=='') $pattern=$configPagePath.'.'.$pattern; |
9991 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
9991 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
9992 | 9992 | { |
9993 | 9993 | $ruleApplies=true; |
9994 | 9994 | break; |
9995 | 9995 | } |
9996 | - if($pattern[strlen($pattern)-1]==='*') { |
|
9997 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
9996 | + if($pattern[strlen($pattern) - 1]==='*') { |
|
9997 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
9998 | 9998 | { |
9999 | 9999 | $ruleApplies=true; |
10000 | 10000 | break; |
@@ -10004,26 +10004,26 @@ discard block |
||
10004 | 10004 | } |
10005 | 10005 | } |
10006 | 10006 | if($ruleApplies) |
10007 | - $rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips')); |
|
10007 | + $rules[]=new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips')); |
|
10008 | 10008 | } |
10009 | - $this->_rules=array_merge($rules,$this->_rules); |
|
10009 | + $this->_rules=array_merge($rules, $this->_rules); |
|
10010 | 10010 | } |
10011 | 10011 | if(($pagesNode=$dom->getElementByTagName('pages'))!==null) |
10012 | 10012 | { |
10013 | - $this->_properties=array_merge($this->_properties,$pagesNode->getAttributes()->toArray()); |
|
10013 | + $this->_properties=array_merge($this->_properties, $pagesNode->getAttributes()->toArray()); |
|
10014 | 10014 | foreach($pagesNode->getElementsByTagName('page') as $node) |
10015 | 10015 | { |
10016 | 10016 | $properties=$node->getAttributes(); |
10017 | 10017 | $id=$properties->remove('id'); |
10018 | 10018 | if(empty($id)) |
10019 | - throw new TConfigurationException('pageserviceconf_page_invalid',$configPath); |
|
10019 | + throw new TConfigurationException('pageserviceconf_page_invalid', $configPath); |
|
10020 | 10020 | $matching=false; |
10021 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
10022 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
10021 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
10022 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
10023 | 10023 | $matching=true; |
10024 | - else if($id[strlen($id)-1]==='*') $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
10024 | + else if($id[strlen($id) - 1]==='*') $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
10025 | 10025 | if($matching) |
10026 | - $this->_properties=array_merge($this->_properties,$properties->toArray()); |
|
10026 | + $this->_properties=array_merge($this->_properties, $properties->toArray()); |
|
10027 | 10027 | } |
10028 | 10028 | } |
10029 | 10029 | foreach($dom->getElementsByTagName('include') as $node) |
@@ -10033,9 +10033,9 @@ discard block |
||
10033 | 10033 | if(($filePath=$node->getAttribute('file'))===null) |
10034 | 10034 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
10035 | 10035 | if(isset($this->_includes[$filePath])) |
10036 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
10036 | + $this->_includes[$filePath]=array($configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
10037 | 10037 | else |
10038 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
10038 | + $this->_includes[$filePath]=array($configPagePath, $when); |
|
10039 | 10039 | } |
10040 | 10040 | } |
10041 | 10041 | } |
@@ -10054,9 +10054,9 @@ discard block |
||
10054 | 10054 | if($this->_basePath===null) |
10055 | 10055 | $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
10056 | 10056 | if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
10057 | - throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath); |
|
10057 | + throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
|
10058 | 10058 | if($this->_baseUrl===null) |
10059 | - $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH; |
|
10059 | + $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\').'/'.self::DEFAULT_BASEPATH; |
|
10060 | 10060 | $application->setAssetManager($this); |
10061 | 10061 | $this->_initialized=true; |
10062 | 10062 | } |
@@ -10072,7 +10072,7 @@ discard block |
||
10072 | 10072 | { |
10073 | 10073 | $this->_basePath=Prado::getPathOfNamespace($value); |
10074 | 10074 | if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
10075 | - throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value); |
|
10075 | + throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
|
10076 | 10076 | } |
10077 | 10077 | } |
10078 | 10078 | public function getBaseUrl() |
@@ -10084,21 +10084,21 @@ discard block |
||
10084 | 10084 | if($this->_initialized) |
10085 | 10085 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
10086 | 10086 | else |
10087 | - $this->_baseUrl=rtrim($value,'/'); |
|
10087 | + $this->_baseUrl=rtrim($value, '/'); |
|
10088 | 10088 | } |
10089 | - public function publishFilePath($path,$checkTimestamp=false) |
|
10089 | + public function publishFilePath($path, $checkTimestamp=false) |
|
10090 | 10090 | { |
10091 | 10091 | if(isset($this->_published[$path])) |
10092 | 10092 | return $this->_published[$path]; |
10093 | 10093 | else if(empty($path) || ($fullpath=realpath($path))===false) |
10094 | - throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path); |
|
10094 | + throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
|
10095 | 10095 | else if(is_file($fullpath)) |
10096 | 10096 | { |
10097 | 10097 | $dir=$this->hash(dirname($fullpath)); |
10098 | 10098 | $fileName=basename($fullpath); |
10099 | 10099 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
10100 | 10100 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
10101 | - $this->copyFile($fullpath,$dst); |
|
10101 | + $this->copyFile($fullpath, $dst); |
|
10102 | 10102 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
10103 | 10103 | } |
10104 | 10104 | else |
@@ -10106,7 +10106,7 @@ discard block |
||
10106 | 10106 | $dir=$this->hash($fullpath); |
10107 | 10107 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
10108 | 10108 | { |
10109 | - $this->copyDirectory($fullpath,$this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
10109 | + $this->copyDirectory($fullpath, $this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
10110 | 10110 | } |
10111 | 10111 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
10112 | 10112 | } |
@@ -10117,7 +10117,7 @@ discard block |
||
10117 | 10117 | } |
10118 | 10118 | protected function setPublished($values=array()) |
10119 | 10119 | { |
10120 | - $this->_published = $values; |
|
10120 | + $this->_published=$values; |
|
10121 | 10121 | } |
10122 | 10122 | public function getPublishedPath($path) |
10123 | 10123 | { |
@@ -10137,9 +10137,9 @@ discard block |
||
10137 | 10137 | } |
10138 | 10138 | protected function hash($dir) |
10139 | 10139 | { |
10140 | - return sprintf('%x',crc32($dir.Prado::getVersion())); |
|
10140 | + return sprintf('%x', crc32($dir.Prado::getVersion())); |
|
10141 | 10141 | } |
10142 | - protected function copyFile($src,$dst) |
|
10142 | + protected function copyFile($src, $dst) |
|
10143 | 10143 | { |
10144 | 10144 | if(!is_dir($dst)) |
10145 | 10145 | { |
@@ -10147,12 +10147,12 @@ discard block |
||
10147 | 10147 | @chmod($dst, PRADO_CHMOD); |
10148 | 10148 | } |
10149 | 10149 | $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
10150 | - if(@filemtime($dstFile)<@filemtime($src)) |
|
10150 | + if(@filemtime($dstFile) < @filemtime($src)) |
|
10151 | 10151 | { |
10152 | - @copy($src,$dstFile); |
|
10152 | + @copy($src, $dstFile); |
|
10153 | 10153 | } |
10154 | 10154 | } |
10155 | - public function copyDirectory($src,$dst) |
|
10155 | + public function copyDirectory($src, $dst) |
|
10156 | 10156 | { |
10157 | 10157 | if(!is_dir($dst)) |
10158 | 10158 | { |
@@ -10167,14 +10167,14 @@ discard block |
||
10167 | 10167 | continue; |
10168 | 10168 | else if(is_file($src.DIRECTORY_SEPARATOR.$file)) |
10169 | 10169 | { |
10170 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
10170 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$file) < @filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
10171 | 10171 | { |
10172 | - @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
10172 | + @copy($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
10173 | 10173 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
10174 | 10174 | } |
10175 | 10175 | } |
10176 | 10176 | else |
10177 | - $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
10177 | + $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
10178 | 10178 | } |
10179 | 10179 | closedir($folder); |
10180 | 10180 | } else { |
@@ -10186,7 +10186,7 @@ discard block |
||
10186 | 10186 | if(isset($this->_published[$md5sum])) |
10187 | 10187 | return $this->_published[$md5sum]; |
10188 | 10188 | else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
10189 | - throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum); |
|
10189 | + throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
|
10190 | 10190 | else |
10191 | 10191 | { |
10192 | 10192 | $dir=$this->hash(dirname($fullpath)); |
@@ -10194,31 +10194,31 @@ discard block |
||
10194 | 10194 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
10195 | 10195 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
10196 | 10196 | { |
10197 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName)<@filemtime($fullpath)) |
|
10197 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName) < @filemtime($fullpath)) |
|
10198 | 10198 | { |
10199 | - $this->copyFile($fullpath,$dst); |
|
10200 | - $this->deployTarFile($tarfile,$dst); |
|
10199 | + $this->copyFile($fullpath, $dst); |
|
10200 | + $this->deployTarFile($tarfile, $dst); |
|
10201 | 10201 | } |
10202 | 10202 | } |
10203 | 10203 | return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
10204 | 10204 | } |
10205 | 10205 | } |
10206 | - protected function deployTarFile($path,$destination) |
|
10206 | + protected function deployTarFile($path, $destination) |
|
10207 | 10207 | { |
10208 | 10208 | if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
10209 | - throw new TIOException('assetmanager_tarfile_invalid',$path); |
|
10209 | + throw new TIOException('assetmanager_tarfile_invalid', $path); |
|
10210 | 10210 | else |
10211 | 10211 | { |
10212 | 10212 | Prado::using('System.IO.TTarFileExtractor'); |
10213 | - $tar = new TTarFileExtractor($fullpath); |
|
10213 | + $tar=new TTarFileExtractor($fullpath); |
|
10214 | 10214 | return $tar->extract($destination); |
10215 | 10215 | } |
10216 | 10216 | } |
10217 | 10217 | } |
10218 | 10218 | class TGlobalization extends TModule |
10219 | 10219 | { |
10220 | - private $_defaultCharset = 'UTF-8'; |
|
10221 | - private $_defaultCulture = 'en'; |
|
10220 | + private $_defaultCharset='UTF-8'; |
|
10221 | + private $_defaultCulture='en'; |
|
10222 | 10222 | private $_charset=null; |
10223 | 10223 | private $_culture=null; |
10224 | 10224 | private $_translation; |
@@ -10232,11 +10232,11 @@ discard block |
||
10232 | 10232 | if($config!==null) |
10233 | 10233 | { |
10234 | 10234 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
10235 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
10235 | + $translation=isset($config['translate']) ? $config['translate'] : null; |
|
10236 | 10236 | else |
10237 | 10237 | { |
10238 | - $t = $config->getElementByTagName('translation'); |
|
10239 | - $translation = ($t)?$t->getAttributes():null; |
|
10238 | + $t=$config->getElementByTagName('translation'); |
|
10239 | + $translation=($t) ? $t->getAttributes() : null; |
|
10240 | 10240 | } |
10241 | 10241 | if($translation) |
10242 | 10242 | $this->setTranslationConfiguration($translation); |
@@ -10249,7 +10249,7 @@ discard block |
||
10249 | 10249 | } |
10250 | 10250 | public function setTranslateDefaultCulture($value) |
10251 | 10251 | { |
10252 | - $this->_translateDefaultCulture = TPropertyValue::ensureBoolean($value); |
|
10252 | + $this->_translateDefaultCulture=TPropertyValue::ensureBoolean($value); |
|
10253 | 10253 | } |
10254 | 10254 | public function getDefaultCulture() |
10255 | 10255 | { |
@@ -10257,7 +10257,7 @@ discard block |
||
10257 | 10257 | } |
10258 | 10258 | public function setDefaultCulture($culture) |
10259 | 10259 | { |
10260 | - $this->_defaultCulture = str_replace('-','_',$culture); |
|
10260 | + $this->_defaultCulture=str_replace('-', '_', $culture); |
|
10261 | 10261 | } |
10262 | 10262 | public function getDefaultCharset() |
10263 | 10263 | { |
@@ -10265,7 +10265,7 @@ discard block |
||
10265 | 10265 | } |
10266 | 10266 | public function setDefaultCharset($charset) |
10267 | 10267 | { |
10268 | - $this->_defaultCharset = $charset; |
|
10268 | + $this->_defaultCharset=$charset; |
|
10269 | 10269 | } |
10270 | 10270 | public function getCulture() |
10271 | 10271 | { |
@@ -10273,7 +10273,7 @@ discard block |
||
10273 | 10273 | } |
10274 | 10274 | public function setCulture($culture) |
10275 | 10275 | { |
10276 | - $this->_culture = str_replace('-','_',$culture); |
|
10276 | + $this->_culture=str_replace('-', '_', $culture); |
|
10277 | 10277 | } |
10278 | 10278 | public function getCharset() |
10279 | 10279 | { |
@@ -10281,27 +10281,27 @@ discard block |
||
10281 | 10281 | } |
10282 | 10282 | public function setCharset($charset) |
10283 | 10283 | { |
10284 | - $this->_charset = $charset; |
|
10284 | + $this->_charset=$charset; |
|
10285 | 10285 | } |
10286 | 10286 | public function getTranslationConfiguration() |
10287 | 10287 | { |
10288 | - return (!$this->_translateDefaultCulture && ($this->getDefaultCulture() == $this->getCulture())) |
|
10288 | + return (!$this->_translateDefaultCulture && ($this->getDefaultCulture()==$this->getCulture())) |
|
10289 | 10289 | ? null |
10290 | 10290 | : $this->_translation; |
10291 | 10291 | } |
10292 | 10292 | protected function setTranslationConfiguration($config) |
10293 | 10293 | { |
10294 | - if($config['type'] == 'XLIFF' || $config['type'] == 'gettext') |
|
10294 | + if($config['type']=='XLIFF' || $config['type']=='gettext') |
|
10295 | 10295 | { |
10296 | 10296 | if($config['source']) |
10297 | 10297 | { |
10298 | - $config['source'] = Prado::getPathOfNamespace($config['source']); |
|
10298 | + $config['source']=Prado::getPathOfNamespace($config['source']); |
|
10299 | 10299 | if(!is_dir($config['source'])) |
10300 | 10300 | { |
10301 | 10301 | if(@mkdir($config['source'])===false) |
10302 | 10302 | throw new TConfigurationException('globalization_source_path_failed', |
10303 | 10303 | $config['source']); |
10304 | - chmod($config['source'], PRADO_CHMOD); } |
|
10304 | + chmod($config['source'], PRADO_CHMOD); } |
|
10305 | 10305 | } |
10306 | 10306 | else |
10307 | 10307 | { |
@@ -10310,19 +10310,19 @@ discard block |
||
10310 | 10310 | } |
10311 | 10311 | if(isset($config['cache']) && TPropertyValue::ensureBoolean($config['cache'])) |
10312 | 10312 | { |
10313 | - $config['cache'] = $this->getApplication()->getRunTimePath().'/i18n'; |
|
10313 | + $config['cache']=$this->getApplication()->getRunTimePath().'/i18n'; |
|
10314 | 10314 | if(!is_dir($config['cache'])) |
10315 | 10315 | { |
10316 | 10316 | if(@mkdir($config['cache'])===false) |
10317 | 10317 | throw new TConfigurationException('globalization_cache_path_failed', |
10318 | 10318 | $config['cache']); |
10319 | - chmod($config['cache'], PRADO_CHMOD); } |
|
10319 | + chmod($config['cache'], PRADO_CHMOD); } |
|
10320 | 10320 | } |
10321 | 10321 | else |
10322 | 10322 | { |
10323 | 10323 | unset($config['cache']); |
10324 | 10324 | } |
10325 | - $this->_translation = $config; |
|
10325 | + $this->_translation=$config; |
|
10326 | 10326 | } |
10327 | 10327 | public function getTranslationCatalogue() |
10328 | 10328 | { |
@@ -10330,28 +10330,28 @@ discard block |
||
10330 | 10330 | } |
10331 | 10331 | public function setTranslationCatalogue($value) |
10332 | 10332 | { |
10333 | - $this->_translation['catalogue'] = $value; |
|
10333 | + $this->_translation['catalogue']=$value; |
|
10334 | 10334 | } |
10335 | 10335 | public function getCultureVariants($culture=null) |
10336 | 10336 | { |
10337 | - if($culture===null) $culture = $this->getCulture(); |
|
10338 | - $variants = explode('_', $culture); |
|
10339 | - $result = array(); |
|
10337 | + if($culture===null) $culture=$this->getCulture(); |
|
10338 | + $variants=explode('_', $culture); |
|
10339 | + $result=array(); |
|
10340 | 10340 | for(; count($variants) > 0; array_pop($variants)) |
10341 | - $result[] = implode('_', $variants); |
|
10341 | + $result[]=implode('_', $variants); |
|
10342 | 10342 | return $result; |
10343 | 10343 | } |
10344 | - public function getLocalizedResource($file,$culture=null) |
|
10344 | + public function getLocalizedResource($file, $culture=null) |
|
10345 | 10345 | { |
10346 | - $files = array(); |
|
10347 | - $variants = $this->getCultureVariants($culture); |
|
10348 | - $path = pathinfo($file); |
|
10346 | + $files=array(); |
|
10347 | + $variants=$this->getCultureVariants($culture); |
|
10348 | + $path=pathinfo($file); |
|
10349 | 10349 | foreach($variants as $variant) |
10350 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
10351 | - $filename = substr($path['basename'],0,strrpos($path['basename'],'.')); |
|
10350 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
10351 | + $filename=substr($path['basename'], 0, strrpos($path['basename'], '.')); |
|
10352 | 10352 | foreach($variants as $variant) |
10353 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
10354 | - $files[] = $file; |
|
10353 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
10354 | + $files[]=$file; |
|
10355 | 10355 | return $files; |
10356 | 10356 | } |
10357 | 10357 | } |
@@ -10364,10 +10364,10 @@ discard block |
||
10364 | 10364 | const PAGE_SERVICE_ID='page'; |
10365 | 10365 | const CONFIG_FILE_XML='application.xml'; |
10366 | 10366 | const CONFIG_FILE_EXT_XML='.xml'; |
10367 | - const CONFIG_TYPE_XML = 'xml'; |
|
10367 | + const CONFIG_TYPE_XML='xml'; |
|
10368 | 10368 | const CONFIG_FILE_PHP='application.php'; |
10369 | 10369 | const CONFIG_FILE_EXT_PHP='.php'; |
10370 | - const CONFIG_TYPE_PHP = 'php'; |
|
10370 | + const CONFIG_TYPE_PHP='php'; |
|
10371 | 10371 | const RUNTIME_PATH='runtime'; |
10372 | 10372 | const CONFIGCACHE_FILE='config.cache'; |
10373 | 10373 | const GLOBAL_FILE='global.cache'; |
@@ -10415,8 +10415,8 @@ discard block |
||
10415 | 10415 | private $_assetManager; |
10416 | 10416 | private $_authRules; |
10417 | 10417 | private $_mode=TApplicationMode::Debug; |
10418 | - private $_pageServiceID = self::PAGE_SERVICE_ID; |
|
10419 | - public function __construct($basePath='protected',$cacheConfig=true, $configType=self::CONFIG_TYPE_XML) |
|
10418 | + private $_pageServiceID=self::PAGE_SERVICE_ID; |
|
10419 | + public function __construct($basePath='protected', $cacheConfig=true, $configType=self::CONFIG_TYPE_XML) |
|
10420 | 10420 | { |
10421 | 10421 | Prado::setApplication($this); |
10422 | 10422 | $this->setConfigurationType($configType); |
@@ -10425,13 +10425,13 @@ discard block |
||
10425 | 10425 | $this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE; |
10426 | 10426 | $this->_uniqueID=md5($this->_runtimePath); |
10427 | 10427 | $this->_parameters=new TMap; |
10428 | - $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
|
10429 | - Prado::setPathOfAlias('Application',$this->_basePath); |
|
10428 | + $this->_services=array($this->getPageServiceID()=>array('TPageService', array(), null)); |
|
10429 | + Prado::setPathOfAlias('Application', $this->_basePath); |
|
10430 | 10430 | } |
10431 | 10431 | protected function resolvePaths($basePath) |
10432 | 10432 | { |
10433 | 10433 | if(empty($basePath) || ($basePath=realpath($basePath))===false) |
10434 | - throw new TConfigurationException('application_basepath_invalid',$basePath); |
|
10434 | + throw new TConfigurationException('application_basepath_invalid', $basePath); |
|
10435 | 10435 | if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName())) |
10436 | 10436 | $configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName(); |
10437 | 10437 | else if(is_file($basePath)) |
@@ -10450,15 +10450,15 @@ discard block |
||
10450 | 10450 | if(!is_dir($runtimePath)) |
10451 | 10451 | { |
10452 | 10452 | if(@mkdir($runtimePath)===false) |
10453 | - throw new TConfigurationException('application_runtimepath_failed',$runtimePath); |
|
10454 | - @chmod($runtimePath, PRADO_CHMOD); } |
|
10453 | + throw new TConfigurationException('application_runtimepath_failed', $runtimePath); |
|
10454 | + @chmod($runtimePath, PRADO_CHMOD); } |
|
10455 | 10455 | $this->setConfigurationFile($configFile); |
10456 | 10456 | } |
10457 | 10457 | $this->setBasePath($basePath); |
10458 | 10458 | $this->setRuntimePath($runtimePath); |
10459 | 10459 | } |
10460 | 10460 | else |
10461 | - throw new TConfigurationException('application_runtimepath_invalid',$runtimePath); |
|
10461 | + throw new TConfigurationException('application_runtimepath_invalid', $runtimePath); |
|
10462 | 10462 | } |
10463 | 10463 | public function run() |
10464 | 10464 | { |
@@ -10468,10 +10468,10 @@ discard block |
||
10468 | 10468 | $n=count(self::$_steps); |
10469 | 10469 | $this->_step=0; |
10470 | 10470 | $this->_requestCompleted=false; |
10471 | - while($this->_step<$n) |
|
10471 | + while($this->_step < $n) |
|
10472 | 10472 | { |
10473 | 10473 | if($this->_mode===self::STATE_OFF) |
10474 | - throw new THttpException(503,'application_unavailable'); |
|
10474 | + throw new THttpException(503, 'application_unavailable'); |
|
10475 | 10475 | if($this->_requestCompleted) |
10476 | 10476 | break; |
10477 | 10477 | $method=self::$_steps[$this->_step]; |
@@ -10493,11 +10493,11 @@ discard block |
||
10493 | 10493 | { |
10494 | 10494 | return $this->_requestCompleted; |
10495 | 10495 | } |
10496 | - public function getGlobalState($key,$defaultValue=null) |
|
10496 | + public function getGlobalState($key, $defaultValue=null) |
|
10497 | 10497 | { |
10498 | - return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue; |
|
10498 | + return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue; |
|
10499 | 10499 | } |
10500 | - public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false) |
|
10500 | + public function setGlobalState($key, $value, $defaultValue=null, $forceSave=false) |
|
10501 | 10501 | { |
10502 | 10502 | $this->_stateChanged=true; |
10503 | 10503 | if($value===$defaultValue) |
@@ -10550,7 +10550,7 @@ discard block |
||
10550 | 10550 | } |
10551 | 10551 | public function setMode($value) |
10552 | 10552 | { |
10553 | - $this->_mode=TPropertyValue::ensureEnum($value,'TApplicationMode'); |
|
10553 | + $this->_mode=TPropertyValue::ensureEnum($value, 'TApplicationMode'); |
|
10554 | 10554 | } |
10555 | 10555 | public function getBasePath() |
10556 | 10556 | { |
@@ -10574,7 +10574,7 @@ discard block |
||
10574 | 10574 | } |
10575 | 10575 | public function setConfigurationType($value) |
10576 | 10576 | { |
10577 | - $this->_configType = $value; |
|
10577 | + $this->_configType=$value; |
|
10578 | 10578 | } |
10579 | 10579 | public function getConfigurationFileExt() |
10580 | 10580 | { |
@@ -10583,10 +10583,10 @@ discard block |
||
10583 | 10583 | switch($this->_configType) |
10584 | 10584 | { |
10585 | 10585 | case TApplication::CONFIG_TYPE_PHP: |
10586 | - $this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP; |
|
10586 | + $this->_configFileExt=TApplication::CONFIG_FILE_EXT_PHP; |
|
10587 | 10587 | break; |
10588 | 10588 | default: |
10589 | - $this->_configFileExt = TApplication::CONFIG_FILE_EXT_XML; |
|
10589 | + $this->_configFileExt=TApplication::CONFIG_FILE_EXT_XML; |
|
10590 | 10590 | } |
10591 | 10591 | } |
10592 | 10592 | return $this->_configFileExt; |
@@ -10594,15 +10594,15 @@ discard block |
||
10594 | 10594 | public function getConfigurationFileName() |
10595 | 10595 | { |
10596 | 10596 | static $fileName; |
10597 | - if($fileName == null) |
|
10597 | + if($fileName==null) |
|
10598 | 10598 | { |
10599 | 10599 | switch($this->_configType) |
10600 | 10600 | { |
10601 | 10601 | case TApplication::CONFIG_TYPE_PHP: |
10602 | - $fileName = TApplication::CONFIG_FILE_PHP; |
|
10602 | + $fileName=TApplication::CONFIG_FILE_PHP; |
|
10603 | 10603 | break; |
10604 | 10604 | default: |
10605 | - $fileName = TApplication::CONFIG_FILE_XML; |
|
10605 | + $fileName=TApplication::CONFIG_FILE_XML; |
|
10606 | 10606 | } |
10607 | 10607 | } |
10608 | 10608 | return $fileName; |
@@ -10626,10 +10626,10 @@ discard block |
||
10626 | 10626 | { |
10627 | 10627 | $this->_service=$value; |
10628 | 10628 | } |
10629 | - public function setModule($id,IModule $module=null) |
|
10629 | + public function setModule($id, IModule $module=null) |
|
10630 | 10630 | { |
10631 | 10631 | if(isset($this->_modules[$id])) |
10632 | - throw new TConfigurationException('application_moduleid_duplicated',$id); |
|
10632 | + throw new TConfigurationException('application_moduleid_duplicated', $id); |
|
10633 | 10633 | else |
10634 | 10634 | $this->_modules[$id]=$module; |
10635 | 10635 | } |
@@ -10639,7 +10639,7 @@ discard block |
||
10639 | 10639 | return null; |
10640 | 10640 | if($this->_modules[$id]===null) |
10641 | 10641 | { |
10642 | - $module = $this->internalLoadModule($id, true); |
|
10642 | + $module=$this->internalLoadModule($id, true); |
|
10643 | 10643 | $module[0]->init($module[1]); |
10644 | 10644 | } |
10645 | 10645 | return $this->_modules[$id]; |
@@ -10794,38 +10794,38 @@ discard block |
||
10794 | 10794 | foreach($initProperties as $name=>$value) |
10795 | 10795 | { |
10796 | 10796 | if($name==='lazy') continue; |
10797 | - $module->setSubProperty($name,$value); |
|
10797 | + $module->setSubProperty($name, $value); |
|
10798 | 10798 | } |
10799 | - $this->setModule($id,$module); |
|
10799 | + $this->setModule($id, $module); |
|
10800 | 10800 | $this->_lazyModules[$id]=null; |
10801 | - return array($module,$configElement); |
|
10801 | + return array($module, $configElement); |
|
10802 | 10802 | } |
10803 | - public function applyConfiguration($config,$withinService=false) |
|
10803 | + public function applyConfiguration($config, $withinService=false) |
|
10804 | 10804 | { |
10805 | 10805 | if($config->getIsEmpty()) |
10806 | 10806 | return; |
10807 | 10807 | foreach($config->getAliases() as $alias=>$path) |
10808 | - Prado::setPathOfAlias($alias,$path); |
|
10808 | + Prado::setPathOfAlias($alias, $path); |
|
10809 | 10809 | foreach($config->getUsings() as $using) |
10810 | 10810 | Prado::using($using); |
10811 | 10811 | if(!$withinService) |
10812 | 10812 | { |
10813 | 10813 | foreach($config->getProperties() as $name=>$value) |
10814 | - $this->setSubProperty($name,$value); |
|
10814 | + $this->setSubProperty($name, $value); |
|
10815 | 10815 | } |
10816 | 10816 | if(empty($this->_services)) |
10817 | - $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
|
10817 | + $this->_services=array($this->getPageServiceID()=>array('TPageService', array(), null)); |
|
10818 | 10818 | foreach($config->getParameters() as $id=>$parameter) |
10819 | 10819 | { |
10820 | 10820 | if(is_array($parameter)) |
10821 | 10821 | { |
10822 | 10822 | $component=Prado::createComponent($parameter[0]); |
10823 | 10823 | foreach($parameter[1] as $name=>$value) |
10824 | - $component->setSubProperty($name,$value); |
|
10825 | - $this->_parameters->add($id,$component); |
|
10824 | + $component->setSubProperty($name, $value); |
|
10825 | + $this->_parameters->add($id, $component); |
|
10826 | 10826 | } |
10827 | 10827 | else |
10828 | - $this->_parameters->add($id,$parameter); |
|
10828 | + $this->_parameters->add($id, $parameter); |
|
10829 | 10829 | } |
10830 | 10830 | $modules=array(); |
10831 | 10831 | foreach($config->getModules() as $id=>$moduleConfig) |
@@ -10833,7 +10833,7 @@ discard block |
||
10833 | 10833 | if(!is_string($id)) |
10834 | 10834 | $id='_module'.count($this->_lazyModules); |
10835 | 10835 | $this->_lazyModules[$id]=$moduleConfig; |
10836 | - if($module = $this->internalLoadModule($id)) |
|
10836 | + if($module=$this->internalLoadModule($id)) |
|
10837 | 10837 | $modules[]=$module; |
10838 | 10838 | } |
10839 | 10839 | foreach($modules as $module) |
@@ -10846,12 +10846,12 @@ discard block |
||
10846 | 10846 | $condition=$this->evaluateExpression($condition); |
10847 | 10847 | if($condition) |
10848 | 10848 | { |
10849 | - if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path)) |
|
10850 | - throw new TConfigurationException('application_includefile_invalid',$filePath); |
|
10849 | + if(($path=Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt()))===null || !is_file($path)) |
|
10850 | + throw new TConfigurationException('application_includefile_invalid', $filePath); |
|
10851 | 10851 | $cn=$this->getApplicationConfigurationClass(); |
10852 | 10852 | $c=new $cn; |
10853 | 10853 | $c->loadFromFile($path); |
10854 | - $this->applyConfiguration($c,$withinService); |
|
10854 | + $this->applyConfiguration($c, $withinService); |
|
10855 | 10855 | } |
10856 | 10856 | } |
10857 | 10857 | } |
@@ -10859,16 +10859,16 @@ discard block |
||
10859 | 10859 | { |
10860 | 10860 | if($this->_configFile!==null) |
10861 | 10861 | { |
10862 | - if($this->_cacheFile===null || @filemtime($this->_cacheFile)<filemtime($this->_configFile)) |
|
10862 | + if($this->_cacheFile===null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) |
|
10863 | 10863 | { |
10864 | 10864 | $config=new TApplicationConfiguration; |
10865 | 10865 | $config->loadFromFile($this->_configFile); |
10866 | 10866 | if($this->_cacheFile!==null) |
10867 | - file_put_contents($this->_cacheFile,serialize($config),LOCK_EX); |
|
10867 | + file_put_contents($this->_cacheFile, serialize($config), LOCK_EX); |
|
10868 | 10868 | } |
10869 | 10869 | else |
10870 | 10870 | $config=unserialize(file_get_contents($this->_cacheFile)); |
10871 | - $this->applyConfiguration($config,false); |
|
10871 | + $this->applyConfiguration($config, false); |
|
10872 | 10872 | } |
10873 | 10873 | if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null) |
10874 | 10874 | $serviceID=$this->getPageServiceID(); |
@@ -10878,68 +10878,68 @@ discard block |
||
10878 | 10878 | { |
10879 | 10879 | if(isset($this->_services[$serviceID])) |
10880 | 10880 | { |
10881 | - list($serviceClass,$initProperties,$configElement)=$this->_services[$serviceID]; |
|
10881 | + list($serviceClass, $initProperties, $configElement)=$this->_services[$serviceID]; |
|
10882 | 10882 | $service=Prado::createComponent($serviceClass); |
10883 | 10883 | if(!($service instanceof IService)) |
10884 | - throw new THttpException(500,'application_service_invalid',$serviceClass); |
|
10884 | + throw new THttpException(500, 'application_service_invalid', $serviceClass); |
|
10885 | 10885 | if(!$service->getEnabled()) |
10886 | - throw new THttpException(500,'application_service_unavailable',$serviceClass); |
|
10886 | + throw new THttpException(500, 'application_service_unavailable', $serviceClass); |
|
10887 | 10887 | $service->setID($serviceID); |
10888 | 10888 | $this->setService($service); |
10889 | 10889 | foreach($initProperties as $name=>$value) |
10890 | - $service->setSubProperty($name,$value); |
|
10890 | + $service->setSubProperty($name, $value); |
|
10891 | 10891 | if($configElement!==null) |
10892 | 10892 | { |
10893 | 10893 | $config=new TApplicationConfiguration; |
10894 | 10894 | if($this->getConfigurationType()==self::CONFIG_TYPE_PHP) |
10895 | - $config->loadFromPhp($configElement,$this->getBasePath()); |
|
10895 | + $config->loadFromPhp($configElement, $this->getBasePath()); |
|
10896 | 10896 | else |
10897 | - $config->loadFromXml($configElement,$this->getBasePath()); |
|
10898 | - $this->applyConfiguration($config,true); |
|
10897 | + $config->loadFromXml($configElement, $this->getBasePath()); |
|
10898 | + $this->applyConfiguration($config, true); |
|
10899 | 10899 | } |
10900 | 10900 | $service->init($configElement); |
10901 | 10901 | } |
10902 | 10902 | else |
10903 | - throw new THttpException(500,'application_service_unknown',$serviceID); |
|
10903 | + throw new THttpException(500, 'application_service_unknown', $serviceID); |
|
10904 | 10904 | } |
10905 | 10905 | public function onError($param) |
10906 | 10906 | { |
10907 | - Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication'); |
|
10908 | - $this->raiseEvent('OnError',$this,$param); |
|
10909 | - $this->getErrorHandler()->handleError($this,$param); |
|
10907 | + Prado::log($param->getMessage(), TLogger::ERROR, 'System.TApplication'); |
|
10908 | + $this->raiseEvent('OnError', $this, $param); |
|
10909 | + $this->getErrorHandler()->handleError($this, $param); |
|
10910 | 10910 | } |
10911 | 10911 | public function onBeginRequest() |
10912 | 10912 | { |
10913 | - $this->raiseEvent('OnBeginRequest',$this,null); |
|
10913 | + $this->raiseEvent('OnBeginRequest', $this, null); |
|
10914 | 10914 | } |
10915 | 10915 | public function onAuthentication() |
10916 | 10916 | { |
10917 | - $this->raiseEvent('OnAuthentication',$this,null); |
|
10917 | + $this->raiseEvent('OnAuthentication', $this, null); |
|
10918 | 10918 | } |
10919 | 10919 | public function onAuthenticationComplete() |
10920 | 10920 | { |
10921 | - $this->raiseEvent('OnAuthenticationComplete',$this,null); |
|
10921 | + $this->raiseEvent('OnAuthenticationComplete', $this, null); |
|
10922 | 10922 | } |
10923 | 10923 | public function onAuthorization() |
10924 | 10924 | { |
10925 | - $this->raiseEvent('OnAuthorization',$this,null); |
|
10925 | + $this->raiseEvent('OnAuthorization', $this, null); |
|
10926 | 10926 | } |
10927 | 10927 | public function onAuthorizationComplete() |
10928 | 10928 | { |
10929 | - $this->raiseEvent('OnAuthorizationComplete',$this,null); |
|
10929 | + $this->raiseEvent('OnAuthorizationComplete', $this, null); |
|
10930 | 10930 | } |
10931 | 10931 | public function onLoadState() |
10932 | 10932 | { |
10933 | 10933 | $this->loadGlobals(); |
10934 | - $this->raiseEvent('OnLoadState',$this,null); |
|
10934 | + $this->raiseEvent('OnLoadState', $this, null); |
|
10935 | 10935 | } |
10936 | 10936 | public function onLoadStateComplete() |
10937 | 10937 | { |
10938 | - $this->raiseEvent('OnLoadStateComplete',$this,null); |
|
10938 | + $this->raiseEvent('OnLoadStateComplete', $this, null); |
|
10939 | 10939 | } |
10940 | 10940 | public function onPreRunService() |
10941 | 10941 | { |
10942 | - $this->raiseEvent('OnPreRunService',$this,null); |
|
10942 | + $this->raiseEvent('OnPreRunService', $this, null); |
|
10943 | 10943 | } |
10944 | 10944 | public function runService() |
10945 | 10945 | { |
@@ -10948,24 +10948,24 @@ discard block |
||
10948 | 10948 | } |
10949 | 10949 | public function onSaveState() |
10950 | 10950 | { |
10951 | - $this->raiseEvent('OnSaveState',$this,null); |
|
10951 | + $this->raiseEvent('OnSaveState', $this, null); |
|
10952 | 10952 | $this->saveGlobals(); |
10953 | 10953 | } |
10954 | 10954 | public function onSaveStateComplete() |
10955 | 10955 | { |
10956 | - $this->raiseEvent('OnSaveStateComplete',$this,null); |
|
10956 | + $this->raiseEvent('OnSaveStateComplete', $this, null); |
|
10957 | 10957 | } |
10958 | 10958 | public function onPreFlushOutput() |
10959 | 10959 | { |
10960 | - $this->raiseEvent('OnPreFlushOutput',$this,null); |
|
10960 | + $this->raiseEvent('OnPreFlushOutput', $this, null); |
|
10961 | 10961 | } |
10962 | - public function flushOutput($continueBuffering = true) |
|
10962 | + public function flushOutput($continueBuffering=true) |
|
10963 | 10963 | { |
10964 | 10964 | $this->getResponse()->flush($continueBuffering); |
10965 | 10965 | } |
10966 | 10966 | public function onEndRequest() |
10967 | 10967 | { |
10968 | - $this->flushOutput(false); $this->saveGlobals(); $this->raiseEvent('OnEndRequest',$this,null); |
|
10968 | + $this->flushOutput(false); $this->saveGlobals(); $this->raiseEvent('OnEndRequest', $this, null); |
|
10969 | 10969 | } |
10970 | 10970 | } |
10971 | 10971 | class TApplicationMode extends TEnumerable |
@@ -10989,14 +10989,14 @@ discard block |
||
10989 | 10989 | { |
10990 | 10990 | if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
10991 | 10991 | { |
10992 | - $fcontent = include $fname; |
|
10993 | - $this->loadFromPhp($fcontent,dirname($fname)); |
|
10992 | + $fcontent=include $fname; |
|
10993 | + $this->loadFromPhp($fcontent, dirname($fname)); |
|
10994 | 10994 | } |
10995 | 10995 | else |
10996 | 10996 | { |
10997 | 10997 | $dom=new TXmlDocument; |
10998 | 10998 | $dom->loadFromFile($fname); |
10999 | - $this->loadFromXml($dom,dirname($fname)); |
|
10999 | + $this->loadFromXml($dom, dirname($fname)); |
|
11000 | 11000 | } |
11001 | 11001 | } |
11002 | 11002 | public function getIsEmpty() |
@@ -11011,20 +11011,20 @@ discard block |
||
11011 | 11011 | { |
11012 | 11012 | $this->_properties[$name]=$value; |
11013 | 11013 | } |
11014 | - $this->_empty = false; |
|
11014 | + $this->_empty=false; |
|
11015 | 11015 | } |
11016 | 11016 | if(isset($config['paths']) && is_array($config['paths'])) |
11017 | - $this->loadPathsPhp($config['paths'],$configPath); |
|
11017 | + $this->loadPathsPhp($config['paths'], $configPath); |
|
11018 | 11018 | if(isset($config['modules']) && is_array($config['modules'])) |
11019 | - $this->loadModulesPhp($config['modules'],$configPath); |
|
11019 | + $this->loadModulesPhp($config['modules'], $configPath); |
|
11020 | 11020 | if(isset($config['services']) && is_array($config['services'])) |
11021 | - $this->loadServicesPhp($config['services'],$configPath); |
|
11021 | + $this->loadServicesPhp($config['services'], $configPath); |
|
11022 | 11022 | if(isset($config['parameters']) && is_array($config['parameters'])) |
11023 | 11023 | $this->loadParametersPhp($config['parameters'], $configPath); |
11024 | 11024 | if(isset($config['includes']) && is_array($config['includes'])) |
11025 | - $this->loadExternalXml($config['includes'],$configPath); |
|
11025 | + $this->loadExternalXml($config['includes'], $configPath); |
|
11026 | 11026 | } |
11027 | - public function loadFromXml($dom,$configPath) |
|
11027 | + public function loadFromXml($dom, $configPath) |
|
11028 | 11028 | { |
11029 | 11029 | foreach($dom->getAttributes() as $name=>$value) |
11030 | 11030 | { |
@@ -11036,19 +11036,19 @@ discard block |
||
11036 | 11036 | switch($element->getTagName()) |
11037 | 11037 | { |
11038 | 11038 | case 'paths': |
11039 | - $this->loadPathsXml($element,$configPath); |
|
11039 | + $this->loadPathsXml($element, $configPath); |
|
11040 | 11040 | break; |
11041 | 11041 | case 'modules': |
11042 | - $this->loadModulesXml($element,$configPath); |
|
11042 | + $this->loadModulesXml($element, $configPath); |
|
11043 | 11043 | break; |
11044 | 11044 | case 'services': |
11045 | - $this->loadServicesXml($element,$configPath); |
|
11045 | + $this->loadServicesXml($element, $configPath); |
|
11046 | 11046 | break; |
11047 | 11047 | case 'parameters': |
11048 | - $this->loadParametersXml($element,$configPath); |
|
11048 | + $this->loadParametersXml($element, $configPath); |
|
11049 | 11049 | break; |
11050 | 11050 | case 'include': |
11051 | - $this->loadExternalXml($element,$configPath); |
|
11051 | + $this->loadExternalXml($element, $configPath); |
|
11052 | 11052 | break; |
11053 | 11053 | default: |
11054 | 11054 | break; |
@@ -11061,14 +11061,14 @@ discard block |
||
11061 | 11061 | { |
11062 | 11062 | foreach($pathsNode['aliases'] as $id=>$path) |
11063 | 11063 | { |
11064 | - $path=str_replace('\\','/',$path); |
|
11065 | - if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) $p=realpath($path); |
|
11064 | + $path=str_replace('\\', '/', $path); |
|
11065 | + if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) $p=realpath($path); |
|
11066 | 11066 | else |
11067 | 11067 | $p=realpath($configPath.DIRECTORY_SEPARATOR.$path); |
11068 | 11068 | if($p===false || !is_dir($p)) |
11069 | - throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path); |
|
11069 | + throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
11070 | 11070 | if(isset($this->_aliases[$id])) |
11071 | - throw new TConfigurationException('appconfig_alias_redefined',$id); |
|
11071 | + throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
11072 | 11072 | $this->_aliases[$id]=$p; |
11073 | 11073 | } |
11074 | 11074 | } |
@@ -11076,11 +11076,11 @@ discard block |
||
11076 | 11076 | { |
11077 | 11077 | foreach($pathsNode['using'] as $namespace) |
11078 | 11078 | { |
11079 | - $this->_usings[] = $namespace; |
|
11079 | + $this->_usings[]=$namespace; |
|
11080 | 11080 | } |
11081 | 11081 | } |
11082 | 11082 | } |
11083 | - protected function loadPathsXml($pathsNode,$configPath) |
|
11083 | + protected function loadPathsXml($pathsNode, $configPath) |
|
11084 | 11084 | { |
11085 | 11085 | foreach($pathsNode->getElements() as $element) |
11086 | 11086 | { |
@@ -11090,14 +11090,14 @@ discard block |
||
11090 | 11090 | { |
11091 | 11091 | if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null) |
11092 | 11092 | { |
11093 | - $path=str_replace('\\','/',$path); |
|
11094 | - if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) $p=realpath($path); |
|
11093 | + $path=str_replace('\\', '/', $path); |
|
11094 | + if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) $p=realpath($path); |
|
11095 | 11095 | else |
11096 | 11096 | $p=realpath($configPath.DIRECTORY_SEPARATOR.$path); |
11097 | 11097 | if($p===false || !is_dir($p)) |
11098 | - throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path); |
|
11098 | + throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
11099 | 11099 | if(isset($this->_aliases[$id])) |
11100 | - throw new TConfigurationException('appconfig_alias_redefined',$id); |
|
11100 | + throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
11101 | 11101 | $this->_aliases[$id]=$p; |
11102 | 11102 | } |
11103 | 11103 | else |
@@ -11115,7 +11115,7 @@ discard block |
||
11115 | 11115 | break; |
11116 | 11116 | } |
11117 | 11117 | default: |
11118 | - throw new TConfigurationException('appconfig_paths_invalid',$element->getTagName()); |
|
11118 | + throw new TConfigurationException('appconfig_paths_invalid', $element->getTagName()); |
|
11119 | 11119 | } |
11120 | 11120 | } |
11121 | 11121 | } |
@@ -11124,21 +11124,21 @@ discard block |
||
11124 | 11124 | foreach($modulesNode as $id=>$module) |
11125 | 11125 | { |
11126 | 11126 | if(!isset($module['class'])) |
11127 | - throw new TConfigurationException('appconfig_moduletype_required',$id); |
|
11128 | - $type = $module['class']; |
|
11127 | + throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
11128 | + $type=$module['class']; |
|
11129 | 11129 | unset($module['class']); |
11130 | - $properties = array(); |
|
11130 | + $properties=array(); |
|
11131 | 11131 | if(isset($module['properties'])) |
11132 | 11132 | { |
11133 | - $properties = $module['properties']; |
|
11133 | + $properties=$module['properties']; |
|
11134 | 11134 | unset($module['properties']); |
11135 | 11135 | } |
11136 | - $properties['id'] = $id; |
|
11137 | - $this->_modules[$id]=array($type,$properties,$module); |
|
11136 | + $properties['id']=$id; |
|
11137 | + $this->_modules[$id]=array($type, $properties, $module); |
|
11138 | 11138 | $this->_empty=false; |
11139 | 11139 | } |
11140 | 11140 | } |
11141 | - protected function loadModulesXml($modulesNode,$configPath) |
|
11141 | + protected function loadModulesXml($modulesNode, $configPath) |
|
11142 | 11142 | { |
11143 | 11143 | foreach($modulesNode->getElements() as $element) |
11144 | 11144 | { |
@@ -11148,33 +11148,33 @@ discard block |
||
11148 | 11148 | $id=$properties->itemAt('id'); |
11149 | 11149 | $type=$properties->remove('class'); |
11150 | 11150 | if($type===null) |
11151 | - throw new TConfigurationException('appconfig_moduletype_required',$id); |
|
11151 | + throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
11152 | 11152 | $element->setParent(null); |
11153 | 11153 | if($id===null) |
11154 | - $this->_modules[]=array($type,$properties->toArray(),$element); |
|
11154 | + $this->_modules[]=array($type, $properties->toArray(), $element); |
|
11155 | 11155 | else |
11156 | - $this->_modules[$id]=array($type,$properties->toArray(),$element); |
|
11156 | + $this->_modules[$id]=array($type, $properties->toArray(), $element); |
|
11157 | 11157 | $this->_empty=false; |
11158 | 11158 | } |
11159 | 11159 | else |
11160 | - throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName()); |
|
11160 | + throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName()); |
|
11161 | 11161 | } |
11162 | 11162 | } |
11163 | - protected function loadServicesPhp($servicesNode,$configPath) |
|
11163 | + protected function loadServicesPhp($servicesNode, $configPath) |
|
11164 | 11164 | { |
11165 | 11165 | foreach($servicesNode as $id => $service) |
11166 | 11166 | { |
11167 | 11167 | if(!isset($service['class'])) |
11168 | 11168 | throw new TConfigurationException('appconfig_servicetype_required'); |
11169 | - $type = $service['class']; |
|
11170 | - $properties = isset($service['properties']) ? $service['properties'] : array(); |
|
11169 | + $type=$service['class']; |
|
11170 | + $properties=isset($service['properties']) ? $service['properties'] : array(); |
|
11171 | 11171 | unset($service['properties']); |
11172 | - $properties['id'] = $id; |
|
11173 | - $this->_services[$id] = array($type,$properties,$service); |
|
11174 | - $this->_empty = false; |
|
11172 | + $properties['id']=$id; |
|
11173 | + $this->_services[$id]=array($type, $properties, $service); |
|
11174 | + $this->_empty=false; |
|
11175 | 11175 | } |
11176 | 11176 | } |
11177 | - protected function loadServicesXml($servicesNode,$configPath) |
|
11177 | + protected function loadServicesXml($servicesNode, $configPath) |
|
11178 | 11178 | { |
11179 | 11179 | foreach($servicesNode->getElements() as $element) |
11180 | 11180 | { |
@@ -11184,16 +11184,16 @@ discard block |
||
11184 | 11184 | if(($id=$properties->itemAt('id'))===null) |
11185 | 11185 | throw new TConfigurationException('appconfig_serviceid_required'); |
11186 | 11186 | if(($type=$properties->remove('class'))===null) |
11187 | - throw new TConfigurationException('appconfig_servicetype_required',$id); |
|
11187 | + throw new TConfigurationException('appconfig_servicetype_required', $id); |
|
11188 | 11188 | $element->setParent(null); |
11189 | - $this->_services[$id]=array($type,$properties->toArray(),$element); |
|
11189 | + $this->_services[$id]=array($type, $properties->toArray(), $element); |
|
11190 | 11190 | $this->_empty=false; |
11191 | 11191 | } |
11192 | 11192 | else |
11193 | - throw new TConfigurationException('appconfig_services_invalid',$element->getTagName()); |
|
11193 | + throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
|
11194 | 11194 | } |
11195 | 11195 | } |
11196 | - protected function loadParametersPhp($parametersNode,$configPath) |
|
11196 | + protected function loadParametersPhp($parametersNode, $configPath) |
|
11197 | 11197 | { |
11198 | 11198 | foreach($parametersNode as $id => $parameter) |
11199 | 11199 | { |
@@ -11201,20 +11201,20 @@ discard block |
||
11201 | 11201 | { |
11202 | 11202 | if(isset($parameter['class'])) |
11203 | 11203 | { |
11204 | - $type = $parameter['class']; |
|
11204 | + $type=$parameter['class']; |
|
11205 | 11205 | unset($parameter['class']); |
11206 | - $properties = isset($service['properties']) ? $service['properties'] : array(); |
|
11207 | - $properties['id'] = $id; |
|
11208 | - $this->_parameters[$id] = array($type,$properties); |
|
11206 | + $properties=isset($service['properties']) ? $service['properties'] : array(); |
|
11207 | + $properties['id']=$id; |
|
11208 | + $this->_parameters[$id]=array($type, $properties); |
|
11209 | 11209 | } |
11210 | 11210 | } |
11211 | 11211 | else |
11212 | 11212 | { |
11213 | - $this->_parameters[$id] = $parameter; |
|
11213 | + $this->_parameters[$id]=$parameter; |
|
11214 | 11214 | } |
11215 | 11215 | } |
11216 | 11216 | } |
11217 | - protected function loadParametersXml($parametersNode,$configPath) |
|
11217 | + protected function loadParametersXml($parametersNode, $configPath) |
|
11218 | 11218 | { |
11219 | 11219 | foreach($parametersNode->getElements() as $element) |
11220 | 11220 | { |
@@ -11231,21 +11231,21 @@ discard block |
||
11231 | 11231 | $this->_parameters[$id]=$value; |
11232 | 11232 | } |
11233 | 11233 | else |
11234 | - $this->_parameters[$id]=array($type,$properties->toArray()); |
|
11234 | + $this->_parameters[$id]=array($type, $properties->toArray()); |
|
11235 | 11235 | $this->_empty=false; |
11236 | 11236 | } |
11237 | 11237 | else |
11238 | - throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName()); |
|
11238 | + throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName()); |
|
11239 | 11239 | } |
11240 | 11240 | } |
11241 | - protected function loadExternalPhp($includeNode,$configPath) |
|
11241 | + protected function loadExternalPhp($includeNode, $configPath) |
|
11242 | 11242 | { |
11243 | 11243 | foreach($includeNode as $include) |
11244 | 11244 | { |
11245 | - $when = isset($include['when'])?true:false; |
|
11245 | + $when=isset($include['when']) ? true : false; |
|
11246 | 11246 | if(!isset($include['file'])) |
11247 | 11247 | throw new TConfigurationException('appconfig_includefile_required'); |
11248 | - $filePath = $include['file']; |
|
11248 | + $filePath=$include['file']; |
|
11249 | 11249 | if(isset($this->_includes[$filePath])) |
11250 | 11250 | $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')'; |
11251 | 11251 | else |
@@ -11253,7 +11253,7 @@ discard block |
||
11253 | 11253 | $this->_empty=false; |
11254 | 11254 | } |
11255 | 11255 | } |
11256 | - protected function loadExternalXml($includeNode,$configPath) |
|
11256 | + protected function loadExternalXml($includeNode, $configPath) |
|
11257 | 11257 | { |
11258 | 11258 | if(($when=$includeNode->getAttribute('when'))===null) |
11259 | 11259 | $when=true; |
@@ -11326,12 +11326,12 @@ discard block |
||
11326 | 11326 | if($cache->get(self::CACHE_NAME)===$content) |
11327 | 11327 | $saveFile=false; |
11328 | 11328 | else |
11329 | - $cache->set(self::CACHE_NAME,$content); |
|
11329 | + $cache->set(self::CACHE_NAME, $content); |
|
11330 | 11330 | } |
11331 | 11331 | if($saveFile) |
11332 | 11332 | { |
11333 | 11333 | $fileName=$this->getStateFilePath(); |
11334 | - file_put_contents($fileName,$content,LOCK_EX); |
|
11334 | + file_put_contents($fileName, $content, LOCK_EX); |
|
11335 | 11335 | } |
11336 | 11336 | } |
11337 | 11337 | } |