@@ -107,33 +107,33 @@ discard block |
||
107 | 107 | |
108 | 108 | private function determineCacheability() |
109 | 109 | { |
110 | - if(!$this->_cacheChecked) |
|
110 | + if (!$this->_cacheChecked) |
|
111 | 111 | { |
112 | 112 | $this->_cacheChecked = true; |
113 | - if($this->_duration > 0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) |
|
113 | + if ($this->_duration > 0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) |
|
114 | 114 | { |
115 | - if($this->_cacheModuleID !== '') |
|
115 | + if ($this->_cacheModuleID !== '') |
|
116 | 116 | { |
117 | 117 | $this->_cache = $this->getApplication()->getModule($this->_cacheModuleID); |
118 | - if(!($this->_cache instanceof ICache)) |
|
118 | + if (!($this->_cache instanceof ICache)) |
|
119 | 119 | throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID); |
120 | 120 | } |
121 | 121 | else |
122 | 122 | $this->_cache = $this->getApplication()->getCache(); |
123 | - if($this->_cache !== null) |
|
123 | + if ($this->_cache !== null) |
|
124 | 124 | { |
125 | 125 | $this->_cacheAvailable = true; |
126 | 126 | $data = $this->_cache->get($this->getCacheKey()); |
127 | - if(is_array($data)) |
|
127 | + if (is_array($data)) |
|
128 | 128 | { |
129 | 129 | $param = new TOutputCacheCheckDependencyEventParameter; |
130 | - $param->setCacheTime(isset($data[3])?$data[3]:0); |
|
130 | + $param->setCacheTime(isset($data[3]) ? $data[3] : 0); |
|
131 | 131 | $this->onCheckDependency($param); |
132 | 132 | $this->_dataCached = $param->getIsValid(); |
133 | 133 | } |
134 | 134 | else |
135 | 135 | $this->_dataCached = false; |
136 | - if($this->_dataCached) |
|
136 | + if ($this->_dataCached) |
|
137 | 137 | list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime) = $data; |
138 | 138 | } |
139 | 139 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function initRecursive($namingContainer = null) |
151 | 151 | { |
152 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
152 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
153 | 153 | { |
154 | 154 | $stack = $this->getPage()->getCachingStack(); |
155 | 155 | $stack->push($this); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function loadRecursive() |
172 | 172 | { |
173 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
173 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
174 | 174 | { |
175 | 175 | $stack = $this->getPage()->getCachingStack(); |
176 | 176 | $stack->push($this); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | else |
181 | 181 | { |
182 | - if($this->_dataCached) |
|
182 | + if ($this->_dataCached) |
|
183 | 183 | $this->performActions(); |
184 | 184 | parent::loadRecursive(); |
185 | 185 | } |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | { |
190 | 190 | $page = $this->getPage(); |
191 | 191 | $cs = $page->getClientScript(); |
192 | - foreach($this->_actions as $action) |
|
192 | + foreach ($this->_actions as $action) |
|
193 | 193 | { |
194 | - if($action[0] === 'Page.ClientScript') |
|
195 | - call_user_func_array([$cs,$action[1]], $action[2]); |
|
196 | - elseif($action[0] === 'Page') |
|
197 | - call_user_func_array([$page,$action[1]], $action[2]); |
|
194 | + if ($action[0] === 'Page.ClientScript') |
|
195 | + call_user_func_array([$cs, $action[1]], $action[2]); |
|
196 | + elseif ($action[0] === 'Page') |
|
197 | + call_user_func_array([$page, $action[1]], $action[2]); |
|
198 | 198 | else |
199 | - call_user_func_array([$this->getSubProperty($action[0]),$action[1]], $action[2]); |
|
199 | + call_user_func_array([$this->getSubProperty($action[0]), $action[1]], $action[2]); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function preRenderRecursive() |
211 | 211 | { |
212 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
212 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
213 | 213 | { |
214 | 214 | $stack = $this->getPage()->getCachingStack(); |
215 | 215 | $stack->push($this); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | protected function &saveStateRecursive($needViewState = true) |
246 | 246 | { |
247 | - if($this->_dataCached) |
|
247 | + if ($this->_dataCached) |
|
248 | 248 | return $this->_state; |
249 | 249 | else |
250 | 250 | { |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function registerAction($context, $funcName, $funcParams) |
268 | 268 | { |
269 | - $this->_actions[] = [$context,$funcName,$funcParams]; |
|
269 | + $this->_actions[] = [$context, $funcName, $funcParams]; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | public function getCacheKey() |
273 | 273 | { |
274 | - if($this->_cacheKey === null) |
|
274 | + if ($this->_cacheKey === null) |
|
275 | 275 | $this->_cacheKey = $this->calculateCacheKey(); |
276 | 276 | return $this->_cacheKey; |
277 | 277 | } |
@@ -289,13 +289,13 @@ discard block |
||
289 | 289 | protected function calculateCacheKey() |
290 | 290 | { |
291 | 291 | $key = $this->getBaseCacheKey(); |
292 | - if($this->_varyBySession) |
|
292 | + if ($this->_varyBySession) |
|
293 | 293 | $key .= $this->getSession()->getSessionID(); |
294 | - if($this->_varyByParam !== '') |
|
294 | + if ($this->_varyByParam !== '') |
|
295 | 295 | { |
296 | 296 | $params = []; |
297 | 297 | $request = $this->getRequest(); |
298 | - foreach(explode(',', $this->_varyByParam) as $name) |
|
298 | + foreach (explode(',', $this->_varyByParam) as $name) |
|
299 | 299 | { |
300 | 300 | $name = trim($name); |
301 | 301 | $params[$name] = $request->itemAt($name); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | protected function getBaseCacheKey() |
315 | 315 | { |
316 | - return self::CACHE_ID_PREFIX . $this->_keyPrefix . $this->getPage()->getPagePath() . $this->getUniqueID(); |
|
316 | + return self::CACHE_ID_PREFIX.$this->_keyPrefix.$this->getPage()->getPagePath().$this->getUniqueID(); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function setDuration($value) |
389 | 389 | { |
390 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
390 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
391 | 391 | throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this)); |
392 | 392 | $this->_duration = $value; |
393 | 393 | } |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | */ |
482 | 482 | public function render($writer) |
483 | 483 | { |
484 | - if($this->_dataCached) |
|
484 | + if ($this->_dataCached) |
|
485 | 485 | $writer->write($this->_contents); |
486 | - elseif($this->_cacheAvailable) |
|
486 | + elseif ($this->_cacheAvailable) |
|
487 | 487 | { |
488 | 488 | $textwriter = new TTextWriter(); |
489 | - $multiwriter = new TOutputCacheTextWriterMulti([$writer->getWriter(),$textwriter]); |
|
489 | + $multiwriter = new TOutputCacheTextWriterMulti([$writer->getWriter(), $textwriter]); |
|
490 | 490 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $multiwriter); |
491 | 491 | |
492 | 492 | $stack = $this->getPage()->getCachingStack(); |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $stack->pop(); |
496 | 496 | |
497 | 497 | $content = $textwriter->flush(); |
498 | - $data = [$content,$this->_state,$this->_actions,time()]; |
|
498 | + $data = [$content, $this->_state, $this->_actions, time()]; |
|
499 | 499 | $this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency()); |
500 | 500 | } |
501 | 501 | else |
@@ -115,11 +115,12 @@ discard block |
||
115 | 115 | if($this->_cacheModuleID !== '') |
116 | 116 | { |
117 | 117 | $this->_cache = $this->getApplication()->getModule($this->_cacheModuleID); |
118 | - if(!($this->_cache instanceof ICache)) |
|
119 | - throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID); |
|
118 | + if(!($this->_cache instanceof ICache)) { |
|
119 | + throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID); |
|
120 | + } |
|
121 | + } else { |
|
122 | + $this->_cache = $this->getApplication()->getCache(); |
|
120 | 123 | } |
121 | - else |
|
122 | - $this->_cache = $this->getApplication()->getCache(); |
|
123 | 124 | if($this->_cache !== null) |
124 | 125 | { |
125 | 126 | $this->_cacheAvailable = true; |
@@ -130,11 +131,12 @@ discard block |
||
130 | 131 | $param->setCacheTime(isset($data[3])?$data[3]:0); |
131 | 132 | $this->onCheckDependency($param); |
132 | 133 | $this->_dataCached = $param->getIsValid(); |
134 | + } else { |
|
135 | + $this->_dataCached = false; |
|
136 | + } |
|
137 | + if($this->_dataCached) { |
|
138 | + list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime) = $data; |
|
133 | 139 | } |
134 | - else |
|
135 | - $this->_dataCached = false; |
|
136 | - if($this->_dataCached) |
|
137 | - list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime) = $data; |
|
138 | 140 | } |
139 | 141 | } |
140 | 142 | } |
@@ -155,9 +157,9 @@ discard block |
||
155 | 157 | $stack->push($this); |
156 | 158 | parent::initRecursive($namingContainer); |
157 | 159 | $stack->pop(); |
160 | + } else { |
|
161 | + parent::initRecursive($namingContainer); |
|
158 | 162 | } |
159 | - else |
|
160 | - parent::initRecursive($namingContainer); |
|
161 | 163 | } |
162 | 164 | |
163 | 165 | /** |
@@ -176,11 +178,11 @@ discard block |
||
176 | 178 | $stack->push($this); |
177 | 179 | parent::loadRecursive(); |
178 | 180 | $stack->pop(); |
179 | - } |
|
180 | - else |
|
181 | + } else |
|
181 | 182 | { |
182 | - if($this->_dataCached) |
|
183 | - $this->performActions(); |
|
183 | + if($this->_dataCached) { |
|
184 | + $this->performActions(); |
|
185 | + } |
|
184 | 186 | parent::loadRecursive(); |
185 | 187 | } |
186 | 188 | } |
@@ -191,12 +193,13 @@ discard block |
||
191 | 193 | $cs = $page->getClientScript(); |
192 | 194 | foreach($this->_actions as $action) |
193 | 195 | { |
194 | - if($action[0] === 'Page.ClientScript') |
|
195 | - call_user_func_array([$cs,$action[1]], $action[2]); |
|
196 | - elseif($action[0] === 'Page') |
|
197 | - call_user_func_array([$page,$action[1]], $action[2]); |
|
198 | - else |
|
199 | - call_user_func_array([$this->getSubProperty($action[0]),$action[1]], $action[2]); |
|
196 | + if($action[0] === 'Page.ClientScript') { |
|
197 | + call_user_func_array([$cs,$action[1]], $action[2]); |
|
198 | + } elseif($action[0] === 'Page') { |
|
199 | + call_user_func_array([$page,$action[1]], $action[2]); |
|
200 | + } else { |
|
201 | + call_user_func_array([$this->getSubProperty($action[0]),$action[1]], $action[2]); |
|
202 | + } |
|
200 | 203 | } |
201 | 204 | } |
202 | 205 | |
@@ -215,9 +218,9 @@ discard block |
||
215 | 218 | $stack->push($this); |
216 | 219 | parent::preRenderRecursive(); |
217 | 220 | $stack->pop(); |
221 | + } else { |
|
222 | + parent::preRenderRecursive(); |
|
218 | 223 | } |
219 | - else |
|
220 | - parent::preRenderRecursive(); |
|
221 | 224 | } |
222 | 225 | |
223 | 226 | /** |
@@ -244,9 +247,9 @@ discard block |
||
244 | 247 | */ |
245 | 248 | protected function &saveStateRecursive($needViewState = true) |
246 | 249 | { |
247 | - if($this->_dataCached) |
|
248 | - return $this->_state; |
|
249 | - else |
|
250 | + if($this->_dataCached) { |
|
251 | + return $this->_state; |
|
252 | + } else |
|
250 | 253 | { |
251 | 254 | $st = parent::saveStateRecursive($needViewState); |
252 | 255 | // serialization is needed to avoid undefined classes when loading state |
@@ -271,8 +274,9 @@ discard block |
||
271 | 274 | |
272 | 275 | public function getCacheKey() |
273 | 276 | { |
274 | - if($this->_cacheKey === null) |
|
275 | - $this->_cacheKey = $this->calculateCacheKey(); |
|
277 | + if($this->_cacheKey === null) { |
|
278 | + $this->_cacheKey = $this->calculateCacheKey(); |
|
279 | + } |
|
276 | 280 | return $this->_cacheKey; |
277 | 281 | } |
278 | 282 | |
@@ -289,8 +293,9 @@ discard block |
||
289 | 293 | protected function calculateCacheKey() |
290 | 294 | { |
291 | 295 | $key = $this->getBaseCacheKey(); |
292 | - if($this->_varyBySession) |
|
293 | - $key .= $this->getSession()->getSessionID(); |
|
296 | + if($this->_varyBySession) { |
|
297 | + $key .= $this->getSession()->getSessionID(); |
|
298 | + } |
|
294 | 299 | if($this->_varyByParam !== '') |
295 | 300 | { |
296 | 301 | $params = []; |
@@ -387,8 +392,9 @@ discard block |
||
387 | 392 | */ |
388 | 393 | public function setDuration($value) |
389 | 394 | { |
390 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
391 | - throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this)); |
|
395 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
396 | + throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this)); |
|
397 | + } |
|
392 | 398 | $this->_duration = $value; |
393 | 399 | } |
394 | 400 | |
@@ -481,9 +487,9 @@ discard block |
||
481 | 487 | */ |
482 | 488 | public function render($writer) |
483 | 489 | { |
484 | - if($this->_dataCached) |
|
485 | - $writer->write($this->_contents); |
|
486 | - elseif($this->_cacheAvailable) |
|
490 | + if($this->_dataCached) { |
|
491 | + $writer->write($this->_contents); |
|
492 | + } elseif($this->_cacheAvailable) |
|
487 | 493 | { |
488 | 494 | $textwriter = new TTextWriter(); |
489 | 495 | $multiwriter = new TOutputCacheTextWriterMulti([$writer->getWriter(),$textwriter]); |
@@ -497,8 +503,8 @@ discard block |
||
497 | 503 | $content = $textwriter->flush(); |
498 | 504 | $data = [$content,$this->_state,$this->_actions,time()]; |
499 | 505 | $this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency()); |
506 | + } else { |
|
507 | + parent::render($writer); |
|
500 | 508 | } |
501 | - else |
|
502 | - parent::render($writer); |
|
503 | 509 | } |
504 | 510 | } |
505 | 511 | \ No newline at end of file |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function getTemplateByClassName($className) |
64 | 64 | { |
65 | 65 | $class = new \ReflectionClass($className); |
66 | - $tplFile = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $class->getShortName() . self::TEMPLATE_FILE_EXT; |
|
66 | + $tplFile = dirname($class->getFileName()).DIRECTORY_SEPARATOR.$class->getShortName().self::TEMPLATE_FILE_EXT; |
|
67 | 67 | return $this->getTemplateByFileName($tplFile); |
68 | 68 | } |
69 | 69 | |
@@ -73,38 +73,38 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getTemplateByFileName($fileName) |
75 | 75 | { |
76 | - if(($fileName = $this->getLocalizedTemplate($fileName)) !== null) |
|
76 | + if (($fileName = $this->getLocalizedTemplate($fileName)) !== null) |
|
77 | 77 | { |
78 | 78 | Prado::trace("Loading template $fileName", '\Prado\Web\UI\TTemplateManager'); |
79 | - if(($cache = $this->getApplication()->getCache()) === null) |
|
79 | + if (($cache = $this->getApplication()->getCache()) === null) |
|
80 | 80 | return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
81 | 81 | else |
82 | 82 | { |
83 | - $array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName); |
|
84 | - if(is_array($array)) |
|
83 | + $array = $cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName); |
|
84 | + if (is_array($array)) |
|
85 | 85 | { |
86 | 86 | list($template, $timestamps) = $array; |
87 | - if($this->getApplication()->getMode() === TApplicationMode::Performance) |
|
87 | + if ($this->getApplication()->getMode() === TApplicationMode::Performance) |
|
88 | 88 | return $template; |
89 | 89 | $cacheValid = true; |
90 | - foreach($timestamps as $tplFile => $timestamp) |
|
90 | + foreach ($timestamps as $tplFile => $timestamp) |
|
91 | 91 | { |
92 | - if(!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
|
92 | + if (!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
|
93 | 93 | { |
94 | 94 | $cacheValid = false; |
95 | 95 | break; |
96 | 96 | } |
97 | 97 | } |
98 | - if($cacheValid) |
|
98 | + if ($cacheValid) |
|
99 | 99 | return $template; |
100 | 100 | } |
101 | 101 | $template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
102 | 102 | $includedFiles = $template->getIncludedFiles(); |
103 | 103 | $timestamps = []; |
104 | 104 | $timestamps[$fileName] = filemtime($fileName); |
105 | - foreach($includedFiles as $includedFile) |
|
105 | + foreach ($includedFiles as $includedFile) |
|
106 | 106 | $timestamps[$includedFile] = filemtime($includedFile); |
107 | - $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, [$template,$timestamps]); |
|
107 | + $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName, [$template, $timestamps]); |
|
108 | 108 | return $template; |
109 | 109 | } |
110 | 110 | } |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected function getLocalizedTemplate($filename) |
121 | 121 | { |
122 | - if(($app = $this->getApplication()->getGlobalization(false)) === null) |
|
123 | - return is_file($filename)?$filename:null; |
|
124 | - foreach($app->getLocalizedResource($filename) as $file) |
|
122 | + if (($app = $this->getApplication()->getGlobalization(false)) === null) |
|
123 | + return is_file($filename) ? $filename : null; |
|
124 | + foreach ($app->getLocalizedResource($filename) as $file) |
|
125 | 125 | { |
126 | - if(($file = realpath($file)) !== false && is_file($file)) |
|
126 | + if (($file = realpath($file)) !== false && is_file($file)) |
|
127 | 127 | return $file; |
128 | 128 | } |
129 | 129 | return null; |
@@ -76,16 +76,17 @@ discard block |
||
76 | 76 | if(($fileName = $this->getLocalizedTemplate($fileName)) !== null) |
77 | 77 | { |
78 | 78 | Prado::trace("Loading template $fileName", '\Prado\Web\UI\TTemplateManager'); |
79 | - if(($cache = $this->getApplication()->getCache()) === null) |
|
80 | - return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
81 | - else |
|
79 | + if(($cache = $this->getApplication()->getCache()) === null) { |
|
80 | + return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
81 | + } else |
|
82 | 82 | { |
83 | 83 | $array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName); |
84 | 84 | if(is_array($array)) |
85 | 85 | { |
86 | 86 | list($template, $timestamps) = $array; |
87 | - if($this->getApplication()->getMode() === TApplicationMode::Performance) |
|
88 | - return $template; |
|
87 | + if($this->getApplication()->getMode() === TApplicationMode::Performance) { |
|
88 | + return $template; |
|
89 | + } |
|
89 | 90 | $cacheValid = true; |
90 | 91 | foreach($timestamps as $tplFile => $timestamp) |
91 | 92 | { |
@@ -95,21 +96,23 @@ discard block |
||
95 | 96 | break; |
96 | 97 | } |
97 | 98 | } |
98 | - if($cacheValid) |
|
99 | - return $template; |
|
99 | + if($cacheValid) { |
|
100 | + return $template; |
|
101 | + } |
|
100 | 102 | } |
101 | 103 | $template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
102 | 104 | $includedFiles = $template->getIncludedFiles(); |
103 | 105 | $timestamps = []; |
104 | 106 | $timestamps[$fileName] = filemtime($fileName); |
105 | - foreach($includedFiles as $includedFile) |
|
106 | - $timestamps[$includedFile] = filemtime($includedFile); |
|
107 | + foreach($includedFiles as $includedFile) { |
|
108 | + $timestamps[$includedFile] = filemtime($includedFile); |
|
109 | + } |
|
107 | 110 | $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, [$template,$timestamps]); |
108 | 111 | return $template; |
109 | 112 | } |
113 | + } else { |
|
114 | + return null; |
|
110 | 115 | } |
111 | - else |
|
112 | - return null; |
|
113 | 116 | } |
114 | 117 | |
115 | 118 | /** |
@@ -119,12 +122,14 @@ discard block |
||
119 | 122 | */ |
120 | 123 | protected function getLocalizedTemplate($filename) |
121 | 124 | { |
122 | - if(($app = $this->getApplication()->getGlobalization(false)) === null) |
|
123 | - return is_file($filename)?$filename:null; |
|
125 | + if(($app = $this->getApplication()->getGlobalization(false)) === null) { |
|
126 | + return is_file($filename)?$filename:null; |
|
127 | + } |
|
124 | 128 | foreach($app->getLocalizedResource($filename) as $file) |
125 | 129 | { |
126 | - if(($file = realpath($file)) !== false && is_file($file)) |
|
127 | - return $file; |
|
130 | + if(($file = realpath($file)) !== false && is_file($file)) { |
|
131 | + return $file; |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | return null; |
130 | 135 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | */ |
65 | 65 | public function load() |
66 | 66 | { |
67 | - if(($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
67 | + if (($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
68 | 68 | return $data; |
69 | 69 | else |
70 | 70 | throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); |
@@ -64,10 +64,11 @@ |
||
64 | 64 | */ |
65 | 65 | public function load() |
66 | 66 | { |
67 | - if(($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
68 | - return $data; |
|
69 | - else |
|
70 | - throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); |
|
67 | + if(($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) { |
|
68 | + return $data; |
|
69 | + } else { |
|
70 | + throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); |
|
71 | + } |
|
71 | 72 | } |
72 | 73 | } |
73 | 74 |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | |
199 | 199 | $this->determinePostBackMode(); |
200 | 200 | |
201 | - if($this->getIsPostBack()) |
|
201 | + if ($this->getIsPostBack()) |
|
202 | 202 | { |
203 | - if($this->getIsCallback()) |
|
203 | + if ($this->getIsCallback()) |
|
204 | 204 | $this->processCallbackRequest($writer); |
205 | 205 | else |
206 | 206 | $this->processPostBackRequest($writer); |
@@ -292,13 +292,13 @@ discard block |
||
292 | 292 | |
293 | 293 | protected static function decodeUTF8($data, $enc) |
294 | 294 | { |
295 | - if(is_array($data)) |
|
295 | + if (is_array($data)) |
|
296 | 296 | { |
297 | - foreach($data as $k => $v) |
|
297 | + foreach ($data as $k => $v) |
|
298 | 298 | $data[$k] = self::decodeUTF8($v, $enc); |
299 | 299 | return $data; |
300 | - } elseif(is_string($data)) { |
|
301 | - return iconv('UTF-8', $enc . '//IGNORE', $data); |
|
300 | + } elseif (is_string($data)) { |
|
301 | + return iconv('UTF-8', $enc.'//IGNORE', $data); |
|
302 | 302 | } else { |
303 | 303 | return $data; |
304 | 304 | } |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | $this->setAdapter(new TActivePageAdapter($this)); |
314 | 314 | |
315 | 315 | $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
316 | - if(strlen($callbackEventParameter) > 0) |
|
317 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
316 | + if (strlen($callbackEventParameter) > 0) |
|
317 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string) $callbackEventParameter); |
|
318 | 318 | |
319 | 319 | // Decode Callback postData from UTF-8 to current Charset |
320 | 320 | if (($g = $this->getApplication()->getGlobalization(false)) !== null && |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | */ |
385 | 385 | public function getCallbackClient() |
386 | 386 | { |
387 | - if($this->getAdapter() !== null) |
|
387 | + if ($this->getAdapter() !== null) |
|
388 | 388 | return $this->getAdapter()->getCallbackClientHandler(); |
389 | 389 | else |
390 | 390 | return new TCallbackClientScript(); |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | */ |
451 | 451 | public function setForm(TForm $form) |
452 | 452 | { |
453 | - if($this->_form === null) |
|
453 | + if ($this->_form === null) |
|
454 | 454 | $this->_form = $form; |
455 | 455 | else |
456 | 456 | throw new TInvalidOperationException('page_form_duplicated'); |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | */ |
465 | 465 | public function getValidators($validationGroup = null) |
466 | 466 | { |
467 | - if(!$this->_validators) |
|
467 | + if (!$this->_validators) |
|
468 | 468 | $this->_validators = new TList; |
469 | - if(empty($validationGroup) === true) |
|
469 | + if (empty($validationGroup) === true) |
|
470 | 470 | return $this->_validators; |
471 | 471 | else |
472 | 472 | { |
473 | 473 | $list = new TList; |
474 | - foreach($this->_validators as $validator) |
|
475 | - if($validator->getValidationGroup() === $validationGroup) |
|
474 | + foreach ($this->_validators as $validator) |
|
475 | + if ($validator->getValidationGroup() === $validationGroup) |
|
476 | 476 | $list->add($validator); |
477 | 477 | return $list; |
478 | 478 | } |
@@ -488,18 +488,18 @@ discard block |
||
488 | 488 | { |
489 | 489 | Prado::trace("Page validate()", 'Prado\Web\UI\TPage'); |
490 | 490 | $this->_validated = true; |
491 | - if($this->_validators && $this->_validators->getCount()) |
|
491 | + if ($this->_validators && $this->_validators->getCount()) |
|
492 | 492 | { |
493 | - if($validationGroup === null) |
|
493 | + if ($validationGroup === null) |
|
494 | 494 | { |
495 | - foreach($this->_validators as $validator) |
|
495 | + foreach ($this->_validators as $validator) |
|
496 | 496 | $validator->validate(); |
497 | 497 | } |
498 | 498 | else |
499 | 499 | { |
500 | - foreach($this->_validators as $validator) |
|
500 | + foreach ($this->_validators as $validator) |
|
501 | 501 | { |
502 | - if($validator->getValidationGroup() === $validationGroup) |
|
502 | + if ($validator->getValidationGroup() === $validationGroup) |
|
503 | 503 | $validator->validate(); |
504 | 504 | } |
505 | 505 | } |
@@ -514,12 +514,12 @@ discard block |
||
514 | 514 | */ |
515 | 515 | public function getIsValid() |
516 | 516 | { |
517 | - if($this->_validated) |
|
517 | + if ($this->_validated) |
|
518 | 518 | { |
519 | - if($this->_validators && $this->_validators->getCount()) |
|
519 | + if ($this->_validators && $this->_validators->getCount()) |
|
520 | 520 | { |
521 | - foreach($this->_validators as $validator) |
|
522 | - if(!$validator->getIsValid()) |
|
521 | + foreach ($this->_validators as $validator) |
|
522 | + if (!$validator->getIsValid()) |
|
523 | 523 | return false; |
524 | 524 | } |
525 | 525 | return true; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | */ |
534 | 534 | public function getTheme() |
535 | 535 | { |
536 | - if(is_string($this->_theme)) |
|
536 | + if (is_string($this->_theme)) |
|
537 | 537 | $this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme); |
538 | 538 | return $this->_theme; |
539 | 539 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public function setTheme($value) |
546 | 546 | { |
547 | - $this->_theme = empty($value)?null:$value; |
|
547 | + $this->_theme = empty($value) ?null:$value; |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | public function getStyleSheetTheme() |
555 | 555 | { |
556 | - if(is_string($this->_styleSheet)) |
|
556 | + if (is_string($this->_styleSheet)) |
|
557 | 557 | $this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
558 | 558 | return $this->_styleSheet; |
559 | 559 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public function setStyleSheetTheme($value) |
566 | 566 | { |
567 | - $this->_styleSheet = empty($value)?null:$value; |
|
567 | + $this->_styleSheet = empty($value) ?null:$value; |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public function applyControlSkin($control) |
576 | 576 | { |
577 | - if(($theme = $this->getTheme()) !== null) |
|
577 | + if (($theme = $this->getTheme()) !== null) |
|
578 | 578 | $theme->applySkin($control); |
579 | 579 | } |
580 | 580 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function applyControlStyleSheet($control) |
587 | 587 | { |
588 | - if(($theme = $this->getStyleSheetTheme()) !== null) |
|
588 | + if (($theme = $this->getStyleSheetTheme()) !== null) |
|
589 | 589 | $theme->applySkin($control); |
590 | 590 | } |
591 | 591 | |
@@ -594,10 +594,10 @@ discard block |
||
594 | 594 | */ |
595 | 595 | public function getClientScript() |
596 | 596 | { |
597 | - if(!$this->_clientScript) { |
|
597 | + if (!$this->_clientScript) { |
|
598 | 598 | $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
599 | 599 | |
600 | - if($className !== '\Prado\Web\UI\TClientScriptManager' && !is_subclass_of($className, '\Prado\Web\UI\TClientScriptManager')) |
|
600 | + if ($className !== '\Prado\Web\UI\TClientScriptManager' && !is_subclass_of($className, '\Prado\Web\UI\TClientScriptManager')) |
|
601 | 601 | throw new THttpException(404, 'page_csmanagerclass_invalid', $className); |
602 | 602 | |
603 | 603 | $this->_clientScript = new $className($this); |
@@ -671,23 +671,23 @@ discard block |
||
671 | 671 | $this->raiseEvent('OnPreRenderComplete', $this, $param); |
672 | 672 | $cs = $this->getClientScript(); |
673 | 673 | $theme = $this->getTheme(); |
674 | - if($theme instanceof ITheme) |
|
674 | + if ($theme instanceof ITheme) |
|
675 | 675 | { |
676 | - foreach($theme->getStyleSheetFiles() as $url) |
|
676 | + foreach ($theme->getStyleSheetFiles() as $url) |
|
677 | 677 | $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
678 | - foreach($theme->getJavaScriptFiles() as $url) |
|
678 | + foreach ($theme->getJavaScriptFiles() as $url) |
|
679 | 679 | $cs->registerHeadScriptFile($url, $url); |
680 | 680 | } |
681 | 681 | $styleSheet = $this->getStyleSheetTheme(); |
682 | - if($styleSheet instanceof ITheme) |
|
682 | + if ($styleSheet instanceof ITheme) |
|
683 | 683 | { |
684 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
684 | + foreach ($styleSheet->getStyleSheetFiles() as $url) |
|
685 | 685 | $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
686 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
686 | + foreach ($styleSheet->getJavaScriptFiles() as $url) |
|
687 | 687 | $cs->registerHeadScriptFile($url, $url); |
688 | 688 | } |
689 | 689 | |
690 | - if($cs->getRequiresHead() && $this->getHead() === null) |
|
690 | + if ($cs->getRequiresHead() && $this->getHead() === null) |
|
691 | 691 | throw new TConfigurationException('page_head_required'); |
692 | 692 | } |
693 | 693 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | private function getCssMediaType($url) |
703 | 703 | { |
704 | 704 | $segs = explode('.', basename($url)); |
705 | - if(isset($segs[2])) |
|
705 | + if (isset($segs[2])) |
|
706 | 706 | return $segs[count($segs) - 2]; |
707 | 707 | else |
708 | 708 | return ''; |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | private function determinePostBackMode() |
728 | 728 | { |
729 | 729 | $postData = $this->getRequest(); |
730 | - if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
730 | + if ($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
731 | 731 | $this->_postData = $postData; |
732 | 732 | } |
733 | 733 | |
@@ -807,10 +807,10 @@ discard block |
||
807 | 807 | */ |
808 | 808 | public function registerRequiresPostData($control) |
809 | 809 | { |
810 | - $id = is_string($control)?$control:$control->getUniqueID(); |
|
810 | + $id = is_string($control) ? $control : $control->getUniqueID(); |
|
811 | 811 | $this->_controlsRegisteredForPostData[$id] = true; |
812 | 812 | $params = func_get_args(); |
813 | - foreach($this->getCachingStack() as $item) |
|
813 | + foreach ($this->getCachingStack() as $item) |
|
814 | 814 | $item->registerAction('Page', 'registerRequiresPostData', [$id]); |
815 | 815 | } |
816 | 816 | |
@@ -819,10 +819,10 @@ discard block |
||
819 | 819 | */ |
820 | 820 | public function getPostBackEventTarget() |
821 | 821 | { |
822 | - if($this->_postBackEventTarget === null && $this->_postData !== null) |
|
822 | + if ($this->_postBackEventTarget === null && $this->_postData !== null) |
|
823 | 823 | { |
824 | 824 | $eventTarget = $this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
825 | - if(!empty($eventTarget)) |
|
825 | + if (!empty($eventTarget)) |
|
826 | 826 | $this->_postBackEventTarget = $this->findControl($eventTarget); |
827 | 827 | } |
828 | 828 | return $this->_postBackEventTarget; |
@@ -842,9 +842,9 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public function getPostBackEventParameter() |
844 | 844 | { |
845 | - if($this->_postBackEventParameter === null && $this->_postData !== null) |
|
845 | + if ($this->_postBackEventParameter === null && $this->_postData !== null) |
|
846 | 846 | { |
847 | - if(($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) |
|
847 | + if (($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) |
|
848 | 848 | $this->_postBackEventParameter = ''; |
849 | 849 | } |
850 | 850 | return $this->_postBackEventParameter; |
@@ -866,37 +866,37 @@ discard block |
||
866 | 866 | protected function processPostData($postData, $beforeLoad) |
867 | 867 | { |
868 | 868 | $this->_isLoadingPostData = true; |
869 | - if($beforeLoad) |
|
869 | + if ($beforeLoad) |
|
870 | 870 | $this->_restPostData = new TMap; |
871 | - foreach($postData as $key => $value) |
|
871 | + foreach ($postData as $key => $value) |
|
872 | 872 | { |
873 | - if($this->isSystemPostField($key)) |
|
873 | + if ($this->isSystemPostField($key)) |
|
874 | 874 | continue; |
875 | - elseif($control = $this->findControl($key)) |
|
875 | + elseif ($control = $this->findControl($key)) |
|
876 | 876 | { |
877 | - if($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
|
877 | + if ($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
|
878 | 878 | { |
879 | - if($control->loadPostData($key, $postData)) |
|
879 | + if ($control->loadPostData($key, $postData)) |
|
880 | 880 | $this->_controlsPostDataChanged[] = $control; |
881 | 881 | } |
882 | - elseif($control instanceof IPostBackEventHandler && |
|
882 | + elseif ($control instanceof IPostBackEventHandler && |
|
883 | 883 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
884 | 884 | { |
885 | - $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
|
885 | + $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
|
886 | 886 | } |
887 | 887 | unset($this->_controlsRequiringPostData[$key]); |
888 | 888 | } |
889 | - elseif($beforeLoad) |
|
889 | + elseif ($beforeLoad) |
|
890 | 890 | $this->_restPostData->add($key, $value); |
891 | 891 | } |
892 | 892 | |
893 | - foreach($this->_controlsRequiringPostData as $key => $value) |
|
893 | + foreach ($this->_controlsRequiringPostData as $key => $value) |
|
894 | 894 | { |
895 | - if($control = $this->findControl($key)) |
|
895 | + if ($control = $this->findControl($key)) |
|
896 | 896 | { |
897 | - if($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
|
897 | + if ($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
|
898 | 898 | { |
899 | - if($control->loadPostData($key, $this->_postData)) |
|
899 | + if ($control->loadPostData($key, $this->_postData)) |
|
900 | 900 | $this->_controlsPostDataChanged[] = $control; |
901 | 901 | } |
902 | 902 | else |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | */ |
921 | 921 | protected function raiseChangedEvents() |
922 | 922 | { |
923 | - foreach($this->_controlsPostDataChanged as $control) |
|
923 | + foreach ($this->_controlsPostDataChanged as $control) |
|
924 | 924 | $control->raisePostDataChangedEvent(); |
925 | 925 | } |
926 | 926 | |
@@ -929,9 +929,9 @@ discard block |
||
929 | 929 | */ |
930 | 930 | protected function raisePostBackEvent() |
931 | 931 | { |
932 | - if(($postBackHandler = $this->getPostBackEventTarget()) === null) |
|
932 | + if (($postBackHandler = $this->getPostBackEventTarget()) === null) |
|
933 | 933 | $this->validate(); |
934 | - elseif($postBackHandler instanceof IPostBackEventHandler) |
|
934 | + elseif ($postBackHandler instanceof IPostBackEventHandler) |
|
935 | 935 | $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
936 | 936 | } |
937 | 937 | |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | */ |
951 | 951 | public function ensureRenderInForm($control) |
952 | 952 | { |
953 | - if(!$this->getIsCallback() && !$this->_inFormRender) |
|
953 | + if (!$this->getIsCallback() && !$this->_inFormRender) |
|
954 | 954 | throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
955 | 955 | } |
956 | 956 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | */ |
960 | 960 | public function beginFormRender($writer) |
961 | 961 | { |
962 | - if($this->_formRendered) |
|
962 | + if ($this->_formRendered) |
|
963 | 963 | throw new TConfigurationException('page_form_duplicated'); |
964 | 964 | $this->_formRendered = true; |
965 | 965 | $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState()); |
@@ -971,15 +971,15 @@ discard block |
||
971 | 971 | */ |
972 | 972 | public function endFormRender($writer) |
973 | 973 | { |
974 | - if($this->_focus) |
|
974 | + if ($this->_focus) |
|
975 | 975 | { |
976 | - if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
976 | + if (($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
977 | 977 | $focus = $this->_focus->getClientID(); |
978 | 978 | else |
979 | 979 | $focus = $this->_focus; |
980 | 980 | $this->getClientScript()->registerFocusControl($focus); |
981 | 981 | } |
982 | - elseif($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
982 | + elseif ($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
983 | 983 | $this->getClientScript()->registerFocusControl($lastFocus); |
984 | 984 | $this->_inFormRender = false; |
985 | 985 | } |
@@ -1023,10 +1023,10 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | public function setHead(THead $value) |
1025 | 1025 | { |
1026 | - if($this->_head) |
|
1026 | + if ($this->_head) |
|
1027 | 1027 | throw new TInvalidOperationException('page_head_duplicated'); |
1028 | 1028 | $this->_head = $value; |
1029 | - if($this->_title !== null) |
|
1029 | + if ($this->_title !== null) |
|
1030 | 1030 | { |
1031 | 1031 | $this->_head->setTitle($this->_title); |
1032 | 1032 | $this->_title = null; |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | */ |
1039 | 1039 | public function getTitle() |
1040 | 1040 | { |
1041 | - if($this->_head) |
|
1041 | + if ($this->_head) |
|
1042 | 1042 | return $this->_head->getTitle(); |
1043 | 1043 | else |
1044 | 1044 | return $this->_title === null ? '' : $this->_title; |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | */ |
1053 | 1053 | public function setTitle($value) |
1054 | 1054 | { |
1055 | - if($this->_head) |
|
1055 | + if ($this->_head) |
|
1056 | 1056 | $this->_head->setTitle($value); |
1057 | 1057 | else |
1058 | 1058 | $this->_title = $value; |
@@ -1107,10 +1107,10 @@ discard block |
||
1107 | 1107 | */ |
1108 | 1108 | public function getStatePersister() |
1109 | 1109 | { |
1110 | - if($this->_statePersister === null) |
|
1110 | + if ($this->_statePersister === null) |
|
1111 | 1111 | { |
1112 | 1112 | $this->_statePersister = Prado::createComponent($this->_statePersisterClass); |
1113 | - if(!($this->_statePersister instanceof IPageStatePersister)) |
|
1113 | + if (!($this->_statePersister instanceof IPageStatePersister)) |
|
1114 | 1114 | throw new TInvalidDataTypeException('page_statepersister_invalid'); |
1115 | 1115 | $this->_statePersister->setPage($this); |
1116 | 1116 | } |
@@ -1194,9 +1194,9 @@ discard block |
||
1194 | 1194 | */ |
1195 | 1195 | public function registerCachingAction($context, $funcName, $funcParams) |
1196 | 1196 | { |
1197 | - if($this->_cachingStack) |
|
1197 | + if ($this->_cachingStack) |
|
1198 | 1198 | { |
1199 | - foreach($this->_cachingStack as $cache) |
|
1199 | + foreach ($this->_cachingStack as $cache) |
|
1200 | 1200 | $cache->registerAction($context, $funcName, $funcParams); |
1201 | 1201 | } |
1202 | 1202 | } |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | */ |
1207 | 1207 | public function getCachingStack() |
1208 | 1208 | { |
1209 | - if(!$this->_cachingStack) |
|
1209 | + if (!$this->_cachingStack) |
|
1210 | 1210 | $this->_cachingStack = new TStack; |
1211 | 1211 | return $this->_cachingStack; |
1212 | 1212 | } |
@@ -200,13 +200,14 @@ discard block |
||
200 | 200 | |
201 | 201 | if($this->getIsPostBack()) |
202 | 202 | { |
203 | - if($this->getIsCallback()) |
|
204 | - $this->processCallbackRequest($writer); |
|
205 | - else |
|
206 | - $this->processPostBackRequest($writer); |
|
203 | + if($this->getIsCallback()) { |
|
204 | + $this->processCallbackRequest($writer); |
|
205 | + } else { |
|
206 | + $this->processPostBackRequest($writer); |
|
207 | + } |
|
208 | + } else { |
|
209 | + $this->processNormalRequest($writer); |
|
207 | 210 | } |
208 | - else |
|
209 | - $this->processNormalRequest($writer); |
|
210 | 211 | |
211 | 212 | $this->_writer = null; |
212 | 213 | } |
@@ -294,8 +295,9 @@ discard block |
||
294 | 295 | { |
295 | 296 | if(is_array($data)) |
296 | 297 | { |
297 | - foreach($data as $k => $v) |
|
298 | - $data[$k] = self::decodeUTF8($v, $enc); |
|
298 | + foreach($data as $k => $v) { |
|
299 | + $data[$k] = self::decodeUTF8($v, $enc); |
|
300 | + } |
|
299 | 301 | return $data; |
300 | 302 | } elseif(is_string($data)) { |
301 | 303 | return iconv('UTF-8', $enc . '//IGNORE', $data); |
@@ -313,14 +315,16 @@ discard block |
||
313 | 315 | $this->setAdapter(new TActivePageAdapter($this)); |
314 | 316 | |
315 | 317 | $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
316 | - if(strlen($callbackEventParameter) > 0) |
|
317 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
318 | + if(strlen($callbackEventParameter) > 0) { |
|
319 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
320 | + } |
|
318 | 321 | |
319 | 322 | // Decode Callback postData from UTF-8 to current Charset |
320 | 323 | if (($g = $this->getApplication()->getGlobalization(false)) !== null && |
321 | - strtoupper($enc = $g->getCharset()) != 'UTF-8') |
|
322 | - foreach ($this->_postData as $k => $v) |
|
324 | + strtoupper($enc = $g->getCharset()) != 'UTF-8') { |
|
325 | + foreach ($this->_postData as $k => $v) |
|
323 | 326 | $this->_postData[$k] = self::decodeUTF8($v, $enc); |
327 | + } |
|
324 | 328 | |
325 | 329 | Prado::trace("Page onPreInit()", 'Prado\Web\UI\TPage'); |
326 | 330 | $this->onPreInit(null); |
@@ -384,10 +388,11 @@ discard block |
||
384 | 388 | */ |
385 | 389 | public function getCallbackClient() |
386 | 390 | { |
387 | - if($this->getAdapter() !== null) |
|
388 | - return $this->getAdapter()->getCallbackClientHandler(); |
|
389 | - else |
|
390 | - return new TCallbackClientScript(); |
|
391 | + if($this->getAdapter() !== null) { |
|
392 | + return $this->getAdapter()->getCallbackClientHandler(); |
|
393 | + } else { |
|
394 | + return new TCallbackClientScript(); |
|
395 | + } |
|
391 | 396 | } |
392 | 397 | |
393 | 398 | /** |
@@ -450,10 +455,11 @@ discard block |
||
450 | 455 | */ |
451 | 456 | public function setForm(TForm $form) |
452 | 457 | { |
453 | - if($this->_form === null) |
|
454 | - $this->_form = $form; |
|
455 | - else |
|
456 | - throw new TInvalidOperationException('page_form_duplicated'); |
|
458 | + if($this->_form === null) { |
|
459 | + $this->_form = $form; |
|
460 | + } else { |
|
461 | + throw new TInvalidOperationException('page_form_duplicated'); |
|
462 | + } |
|
457 | 463 | } |
458 | 464 | |
459 | 465 | /** |
@@ -464,16 +470,18 @@ discard block |
||
464 | 470 | */ |
465 | 471 | public function getValidators($validationGroup = null) |
466 | 472 | { |
467 | - if(!$this->_validators) |
|
468 | - $this->_validators = new TList; |
|
469 | - if(empty($validationGroup) === true) |
|
470 | - return $this->_validators; |
|
471 | - else |
|
473 | + if(!$this->_validators) { |
|
474 | + $this->_validators = new TList; |
|
475 | + } |
|
476 | + if(empty($validationGroup) === true) { |
|
477 | + return $this->_validators; |
|
478 | + } else |
|
472 | 479 | { |
473 | 480 | $list = new TList; |
474 | - foreach($this->_validators as $validator) |
|
475 | - if($validator->getValidationGroup() === $validationGroup) |
|
481 | + foreach($this->_validators as $validator) { |
|
482 | + if($validator->getValidationGroup() === $validationGroup) |
|
476 | 483 | $list->add($validator); |
484 | + } |
|
477 | 485 | return $list; |
478 | 486 | } |
479 | 487 | } |
@@ -492,15 +500,16 @@ discard block |
||
492 | 500 | { |
493 | 501 | if($validationGroup === null) |
494 | 502 | { |
495 | - foreach($this->_validators as $validator) |
|
496 | - $validator->validate(); |
|
497 | - } |
|
498 | - else |
|
503 | + foreach($this->_validators as $validator) { |
|
504 | + $validator->validate(); |
|
505 | + } |
|
506 | + } else |
|
499 | 507 | { |
500 | 508 | foreach($this->_validators as $validator) |
501 | 509 | { |
502 | - if($validator->getValidationGroup() === $validationGroup) |
|
503 | - $validator->validate(); |
|
510 | + if($validator->getValidationGroup() === $validationGroup) { |
|
511 | + $validator->validate(); |
|
512 | + } |
|
504 | 513 | } |
505 | 514 | } |
506 | 515 | } |
@@ -518,14 +527,15 @@ discard block |
||
518 | 527 | { |
519 | 528 | if($this->_validators && $this->_validators->getCount()) |
520 | 529 | { |
521 | - foreach($this->_validators as $validator) |
|
522 | - if(!$validator->getIsValid()) |
|
530 | + foreach($this->_validators as $validator) { |
|
531 | + if(!$validator->getIsValid()) |
|
523 | 532 | return false; |
533 | + } |
|
524 | 534 | } |
525 | 535 | return true; |
536 | + } else { |
|
537 | + throw new TInvalidOperationException('page_isvalid_unknown'); |
|
526 | 538 | } |
527 | - else |
|
528 | - throw new TInvalidOperationException('page_isvalid_unknown'); |
|
529 | 539 | } |
530 | 540 | |
531 | 541 | /** |
@@ -533,8 +543,9 @@ discard block |
||
533 | 543 | */ |
534 | 544 | public function getTheme() |
535 | 545 | { |
536 | - if(is_string($this->_theme)) |
|
537 | - $this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme); |
|
546 | + if(is_string($this->_theme)) { |
|
547 | + $this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme); |
|
548 | + } |
|
538 | 549 | return $this->_theme; |
539 | 550 | } |
540 | 551 | |
@@ -553,8 +564,9 @@ discard block |
||
553 | 564 | */ |
554 | 565 | public function getStyleSheetTheme() |
555 | 566 | { |
556 | - if(is_string($this->_styleSheet)) |
|
557 | - $this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
567 | + if(is_string($this->_styleSheet)) { |
|
568 | + $this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
569 | + } |
|
558 | 570 | return $this->_styleSheet; |
559 | 571 | } |
560 | 572 | |
@@ -574,8 +586,9 @@ discard block |
||
574 | 586 | */ |
575 | 587 | public function applyControlSkin($control) |
576 | 588 | { |
577 | - if(($theme = $this->getTheme()) !== null) |
|
578 | - $theme->applySkin($control); |
|
589 | + if(($theme = $this->getTheme()) !== null) { |
|
590 | + $theme->applySkin($control); |
|
591 | + } |
|
579 | 592 | } |
580 | 593 | |
581 | 594 | /** |
@@ -585,8 +598,9 @@ discard block |
||
585 | 598 | */ |
586 | 599 | public function applyControlStyleSheet($control) |
587 | 600 | { |
588 | - if(($theme = $this->getStyleSheetTheme()) !== null) |
|
589 | - $theme->applySkin($control); |
|
601 | + if(($theme = $this->getStyleSheetTheme()) !== null) { |
|
602 | + $theme->applySkin($control); |
|
603 | + } |
|
590 | 604 | } |
591 | 605 | |
592 | 606 | /** |
@@ -597,8 +611,9 @@ discard block |
||
597 | 611 | if(!$this->_clientScript) { |
598 | 612 | $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
599 | 613 | |
600 | - if($className !== '\Prado\Web\UI\TClientScriptManager' && !is_subclass_of($className, '\Prado\Web\UI\TClientScriptManager')) |
|
601 | - throw new THttpException(404, 'page_csmanagerclass_invalid', $className); |
|
614 | + if($className !== '\Prado\Web\UI\TClientScriptManager' && !is_subclass_of($className, '\Prado\Web\UI\TClientScriptManager')) { |
|
615 | + throw new THttpException(404, 'page_csmanagerclass_invalid', $className); |
|
616 | + } |
|
602 | 617 | |
603 | 618 | $this->_clientScript = new $className($this); |
604 | 619 | } |
@@ -673,22 +688,27 @@ discard block |
||
673 | 688 | $theme = $this->getTheme(); |
674 | 689 | if($theme instanceof ITheme) |
675 | 690 | { |
676 | - foreach($theme->getStyleSheetFiles() as $url) |
|
677 | - $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
678 | - foreach($theme->getJavaScriptFiles() as $url) |
|
679 | - $cs->registerHeadScriptFile($url, $url); |
|
691 | + foreach($theme->getStyleSheetFiles() as $url) { |
|
692 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
693 | + } |
|
694 | + foreach($theme->getJavaScriptFiles() as $url) { |
|
695 | + $cs->registerHeadScriptFile($url, $url); |
|
696 | + } |
|
680 | 697 | } |
681 | 698 | $styleSheet = $this->getStyleSheetTheme(); |
682 | 699 | if($styleSheet instanceof ITheme) |
683 | 700 | { |
684 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
685 | - $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
686 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
687 | - $cs->registerHeadScriptFile($url, $url); |
|
701 | + foreach($styleSheet->getStyleSheetFiles() as $url) { |
|
702 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
703 | + } |
|
704 | + foreach($styleSheet->getJavaScriptFiles() as $url) { |
|
705 | + $cs->registerHeadScriptFile($url, $url); |
|
706 | + } |
|
688 | 707 | } |
689 | 708 | |
690 | - if($cs->getRequiresHead() && $this->getHead() === null) |
|
691 | - throw new TConfigurationException('page_head_required'); |
|
709 | + if($cs->getRequiresHead() && $this->getHead() === null) { |
|
710 | + throw new TConfigurationException('page_head_required'); |
|
711 | + } |
|
692 | 712 | } |
693 | 713 | |
694 | 714 | /** |
@@ -702,10 +722,11 @@ discard block |
||
702 | 722 | private function getCssMediaType($url) |
703 | 723 | { |
704 | 724 | $segs = explode('.', basename($url)); |
705 | - if(isset($segs[2])) |
|
706 | - return $segs[count($segs) - 2]; |
|
707 | - else |
|
708 | - return ''; |
|
725 | + if(isset($segs[2])) { |
|
726 | + return $segs[count($segs) - 2]; |
|
727 | + } else { |
|
728 | + return ''; |
|
729 | + } |
|
709 | 730 | } |
710 | 731 | |
711 | 732 | /** |
@@ -727,8 +748,9 @@ discard block |
||
727 | 748 | private function determinePostBackMode() |
728 | 749 | { |
729 | 750 | $postData = $this->getRequest(); |
730 | - if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
731 | - $this->_postData = $postData; |
|
751 | + if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) { |
|
752 | + $this->_postData = $postData; |
|
753 | + } |
|
732 | 754 | } |
733 | 755 | |
734 | 756 | /** |
@@ -810,8 +832,9 @@ discard block |
||
810 | 832 | $id = is_string($control)?$control:$control->getUniqueID(); |
811 | 833 | $this->_controlsRegisteredForPostData[$id] = true; |
812 | 834 | $params = func_get_args(); |
813 | - foreach($this->getCachingStack() as $item) |
|
814 | - $item->registerAction('Page', 'registerRequiresPostData', [$id]); |
|
835 | + foreach($this->getCachingStack() as $item) { |
|
836 | + $item->registerAction('Page', 'registerRequiresPostData', [$id]); |
|
837 | + } |
|
815 | 838 | } |
816 | 839 | |
817 | 840 | /** |
@@ -822,8 +845,9 @@ discard block |
||
822 | 845 | if($this->_postBackEventTarget === null && $this->_postData !== null) |
823 | 846 | { |
824 | 847 | $eventTarget = $this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
825 | - if(!empty($eventTarget)) |
|
826 | - $this->_postBackEventTarget = $this->findControl($eventTarget); |
|
848 | + if(!empty($eventTarget)) { |
|
849 | + $this->_postBackEventTarget = $this->findControl($eventTarget); |
|
850 | + } |
|
827 | 851 | } |
828 | 852 | return $this->_postBackEventTarget; |
829 | 853 | } |
@@ -844,8 +868,9 @@ discard block |
||
844 | 868 | { |
845 | 869 | if($this->_postBackEventParameter === null && $this->_postData !== null) |
846 | 870 | { |
847 | - if(($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) |
|
848 | - $this->_postBackEventParameter = ''; |
|
871 | + if(($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) { |
|
872 | + $this->_postBackEventParameter = ''; |
|
873 | + } |
|
849 | 874 | } |
850 | 875 | return $this->_postBackEventParameter; |
851 | 876 | } |
@@ -866,28 +891,29 @@ discard block |
||
866 | 891 | protected function processPostData($postData, $beforeLoad) |
867 | 892 | { |
868 | 893 | $this->_isLoadingPostData = true; |
869 | - if($beforeLoad) |
|
870 | - $this->_restPostData = new TMap; |
|
894 | + if($beforeLoad) { |
|
895 | + $this->_restPostData = new TMap; |
|
896 | + } |
|
871 | 897 | foreach($postData as $key => $value) |
872 | 898 | { |
873 | - if($this->isSystemPostField($key)) |
|
874 | - continue; |
|
875 | - elseif($control = $this->findControl($key)) |
|
899 | + if($this->isSystemPostField($key)) { |
|
900 | + continue; |
|
901 | + } elseif($control = $this->findControl($key)) |
|
876 | 902 | { |
877 | 903 | if($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
878 | 904 | { |
879 | - if($control->loadPostData($key, $postData)) |
|
880 | - $this->_controlsPostDataChanged[] = $control; |
|
881 | - } |
|
882 | - elseif($control instanceof IPostBackEventHandler && |
|
905 | + if($control->loadPostData($key, $postData)) { |
|
906 | + $this->_controlsPostDataChanged[] = $control; |
|
907 | + } |
|
908 | + } elseif($control instanceof IPostBackEventHandler && |
|
883 | 909 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
884 | 910 | { |
885 | 911 | $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
886 | 912 | } |
887 | 913 | unset($this->_controlsRequiringPostData[$key]); |
914 | + } elseif($beforeLoad) { |
|
915 | + $this->_restPostData->add($key, $value); |
|
888 | 916 | } |
889 | - elseif($beforeLoad) |
|
890 | - $this->_restPostData->add($key, $value); |
|
891 | 917 | } |
892 | 918 | |
893 | 919 | foreach($this->_controlsRequiringPostData as $key => $value) |
@@ -896,11 +922,12 @@ discard block |
||
896 | 922 | { |
897 | 923 | if($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
898 | 924 | { |
899 | - if($control->loadPostData($key, $this->_postData)) |
|
900 | - $this->_controlsPostDataChanged[] = $control; |
|
925 | + if($control->loadPostData($key, $this->_postData)) { |
|
926 | + $this->_controlsPostDataChanged[] = $control; |
|
927 | + } |
|
928 | + } else { |
|
929 | + throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
|
901 | 930 | } |
902 | - else |
|
903 | - throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
|
904 | 931 | unset($this->_controlsRequiringPostData[$key]); |
905 | 932 | } |
906 | 933 | } |
@@ -920,8 +947,9 @@ discard block |
||
920 | 947 | */ |
921 | 948 | protected function raiseChangedEvents() |
922 | 949 | { |
923 | - foreach($this->_controlsPostDataChanged as $control) |
|
924 | - $control->raisePostDataChangedEvent(); |
|
950 | + foreach($this->_controlsPostDataChanged as $control) { |
|
951 | + $control->raisePostDataChangedEvent(); |
|
952 | + } |
|
925 | 953 | } |
926 | 954 | |
927 | 955 | /** |
@@ -929,10 +957,11 @@ discard block |
||
929 | 957 | */ |
930 | 958 | protected function raisePostBackEvent() |
931 | 959 | { |
932 | - if(($postBackHandler = $this->getPostBackEventTarget()) === null) |
|
933 | - $this->validate(); |
|
934 | - elseif($postBackHandler instanceof IPostBackEventHandler) |
|
935 | - $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
|
960 | + if(($postBackHandler = $this->getPostBackEventTarget()) === null) { |
|
961 | + $this->validate(); |
|
962 | + } elseif($postBackHandler instanceof IPostBackEventHandler) { |
|
963 | + $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
|
964 | + } |
|
936 | 965 | } |
937 | 966 | |
938 | 967 | /** |
@@ -950,8 +979,9 @@ discard block |
||
950 | 979 | */ |
951 | 980 | public function ensureRenderInForm($control) |
952 | 981 | { |
953 | - if(!$this->getIsCallback() && !$this->_inFormRender) |
|
954 | - throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
|
982 | + if(!$this->getIsCallback() && !$this->_inFormRender) { |
|
983 | + throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
|
984 | + } |
|
955 | 985 | } |
956 | 986 | |
957 | 987 | /** |
@@ -959,8 +989,9 @@ discard block |
||
959 | 989 | */ |
960 | 990 | public function beginFormRender($writer) |
961 | 991 | { |
962 | - if($this->_formRendered) |
|
963 | - throw new TConfigurationException('page_form_duplicated'); |
|
992 | + if($this->_formRendered) { |
|
993 | + throw new TConfigurationException('page_form_duplicated'); |
|
994 | + } |
|
964 | 995 | $this->_formRendered = true; |
965 | 996 | $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState()); |
966 | 997 | $this->_inFormRender = true; |
@@ -973,14 +1004,15 @@ discard block |
||
973 | 1004 | { |
974 | 1005 | if($this->_focus) |
975 | 1006 | { |
976 | - if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
977 | - $focus = $this->_focus->getClientID(); |
|
978 | - else |
|
979 | - $focus = $this->_focus; |
|
1007 | + if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) { |
|
1008 | + $focus = $this->_focus->getClientID(); |
|
1009 | + } else { |
|
1010 | + $focus = $this->_focus; |
|
1011 | + } |
|
980 | 1012 | $this->getClientScript()->registerFocusControl($focus); |
1013 | + } elseif($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) { |
|
1014 | + $this->getClientScript()->registerFocusControl($lastFocus); |
|
981 | 1015 | } |
982 | - elseif($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
983 | - $this->getClientScript()->registerFocusControl($lastFocus); |
|
984 | 1016 | $this->_inFormRender = false; |
985 | 1017 | } |
986 | 1018 | |
@@ -1023,8 +1055,9 @@ discard block |
||
1023 | 1055 | */ |
1024 | 1056 | public function setHead(THead $value) |
1025 | 1057 | { |
1026 | - if($this->_head) |
|
1027 | - throw new TInvalidOperationException('page_head_duplicated'); |
|
1058 | + if($this->_head) { |
|
1059 | + throw new TInvalidOperationException('page_head_duplicated'); |
|
1060 | + } |
|
1028 | 1061 | $this->_head = $value; |
1029 | 1062 | if($this->_title !== null) |
1030 | 1063 | { |
@@ -1038,10 +1071,11 @@ discard block |
||
1038 | 1071 | */ |
1039 | 1072 | public function getTitle() |
1040 | 1073 | { |
1041 | - if($this->_head) |
|
1042 | - return $this->_head->getTitle(); |
|
1043 | - else |
|
1044 | - return $this->_title === null ? '' : $this->_title; |
|
1074 | + if($this->_head) { |
|
1075 | + return $this->_head->getTitle(); |
|
1076 | + } else { |
|
1077 | + return $this->_title === null ? '' : $this->_title; |
|
1078 | + } |
|
1045 | 1079 | } |
1046 | 1080 | |
1047 | 1081 | /** |
@@ -1052,10 +1086,11 @@ discard block |
||
1052 | 1086 | */ |
1053 | 1087 | public function setTitle($value) |
1054 | 1088 | { |
1055 | - if($this->_head) |
|
1056 | - $this->_head->setTitle($value); |
|
1057 | - else |
|
1058 | - $this->_title = $value; |
|
1089 | + if($this->_head) { |
|
1090 | + $this->_head->setTitle($value); |
|
1091 | + } else { |
|
1092 | + $this->_title = $value; |
|
1093 | + } |
|
1059 | 1094 | } |
1060 | 1095 | |
1061 | 1096 | /** |
@@ -1110,8 +1145,9 @@ discard block |
||
1110 | 1145 | if($this->_statePersister === null) |
1111 | 1146 | { |
1112 | 1147 | $this->_statePersister = Prado::createComponent($this->_statePersisterClass); |
1113 | - if(!($this->_statePersister instanceof IPageStatePersister)) |
|
1114 | - throw new TInvalidDataTypeException('page_statepersister_invalid'); |
|
1148 | + if(!($this->_statePersister instanceof IPageStatePersister)) { |
|
1149 | + throw new TInvalidDataTypeException('page_statepersister_invalid'); |
|
1150 | + } |
|
1115 | 1151 | $this->_statePersister->setPage($this); |
1116 | 1152 | } |
1117 | 1153 | return $this->_statePersister; |
@@ -1196,8 +1232,9 @@ discard block |
||
1196 | 1232 | { |
1197 | 1233 | if($this->_cachingStack) |
1198 | 1234 | { |
1199 | - foreach($this->_cachingStack as $cache) |
|
1200 | - $cache->registerAction($context, $funcName, $funcParams); |
|
1235 | + foreach($this->_cachingStack as $cache) { |
|
1236 | + $cache->registerAction($context, $funcName, $funcParams); |
|
1237 | + } |
|
1201 | 1238 | } |
1202 | 1239 | } |
1203 | 1240 | |
@@ -1206,8 +1243,9 @@ discard block |
||
1206 | 1243 | */ |
1207 | 1244 | public function getCachingStack() |
1208 | 1245 | { |
1209 | - if(!$this->_cachingStack) |
|
1210 | - $this->_cachingStack = new TStack; |
|
1246 | + if(!$this->_cachingStack) { |
|
1247 | + $this->_cachingStack = new TStack; |
|
1248 | + } |
|
1211 | 1249 | return $this->_cachingStack; |
1212 | 1250 | } |
1213 | 1251 | |
@@ -1216,7 +1254,8 @@ discard block |
||
1216 | 1254 | */ |
1217 | 1255 | public function flushWriter() |
1218 | 1256 | { |
1219 | - if ($this->_writer) |
|
1220 | - $this->Response->write($this->_writer->flush()); |
|
1257 | + if ($this->_writer) { |
|
1258 | + $this->Response->write($this->_writer->flush()); |
|
1259 | + } |
|
1221 | 1260 | } |
1222 | 1261 | } |
1223 | 1262 | \ No newline at end of file |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $this->_initialized = true; |
83 | 83 | $service = $this->getService(); |
84 | - if($service instanceof TPageService) |
|
84 | + if ($service instanceof TPageService) |
|
85 | 85 | $service->setThemeManager($this); |
86 | 86 | else |
87 | 87 | throw new TConfigurationException('thememanager_service_unavailable'); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getTheme($name) |
95 | 95 | { |
96 | - $themePath = $this->getBasePath() . DIRECTORY_SEPARATOR . $name; |
|
97 | - $themeUrl = rtrim($this->getBaseUrl(), '/') . '/' . $name; |
|
96 | + $themePath = $this->getBasePath().DIRECTORY_SEPARATOR.$name; |
|
97 | + $themeUrl = rtrim($this->getBaseUrl(), '/').'/'.$name; |
|
98 | 98 | return Prado::createComponent($this->getThemeClass(), $themePath, $themeUrl); |
99 | 99 | } |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string|null $class Theme class name in namespace format |
103 | 103 | */ |
104 | 104 | public function setThemeClass($class) { |
105 | - $this->_themeClass = $class === null ? self::DEFAULT_THEMECLASS : (string)$class; |
|
105 | + $this->_themeClass = $class === null ? self::DEFAULT_THEMECLASS : (string) $class; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | $themes = []; |
121 | 121 | $basePath = $this->getBasePath(); |
122 | 122 | $folder = @opendir($basePath); |
123 | - while($file = @readdir($folder)) |
|
123 | + while ($file = @readdir($folder)) |
|
124 | 124 | { |
125 | - if($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath . DIRECTORY_SEPARATOR . $file)) |
|
125 | + if ($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath.DIRECTORY_SEPARATOR.$file)) |
|
126 | 126 | $themes[] = $file; |
127 | 127 | } |
128 | 128 | closedir($folder); |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getBasePath() |
137 | 137 | { |
138 | - if($this->_basePath === null) |
|
138 | + if ($this->_basePath === null) |
|
139 | 139 | { |
140 | - $this->_basePath = dirname($this->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
141 | - if(($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) |
|
140 | + $this->_basePath = dirname($this->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
141 | + if (($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) |
|
142 | 142 | throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
143 | 143 | $this->_basePath = $basePath; |
144 | 144 | } |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function setBasePath($value) |
153 | 153 | { |
154 | - if($this->_initialized) |
|
154 | + if ($this->_initialized) |
|
155 | 155 | throw new TInvalidOperationException('thememanager_basepath_unchangeable'); |
156 | 156 | else |
157 | 157 | { |
158 | 158 | $this->_basePath = Prado::getPathOfNamespace($value); |
159 | - if($this->_basePath === null || !is_dir($this->_basePath)) |
|
159 | + if ($this->_basePath === null || !is_dir($this->_basePath)) |
|
160 | 160 | throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
161 | 161 | } |
162 | 162 | } |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getBaseUrl() |
169 | 169 | { |
170 | - if($this->_baseUrl === null) |
|
170 | + if ($this->_baseUrl === null) |
|
171 | 171 | { |
172 | 172 | $appPath = dirname($this->getRequest()->getApplicationFilePath()); |
173 | 173 | $basePath = $this->getBasePath(); |
174 | - if(strpos($basePath, $appPath) === false) |
|
174 | + if (strpos($basePath, $appPath) === false) |
|
175 | 175 | throw new TConfigurationException('thememanager_baseurl_required'); |
176 | 176 | $appUrl = rtrim(dirname($this->getRequest()->getApplicationUrl()), '/\\'); |
177 | - $this->_baseUrl = $appUrl . strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
|
177 | + $this->_baseUrl = $appUrl.strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
|
178 | 178 | } |
179 | 179 | return $this->_baseUrl; |
180 | 180 | } |
@@ -81,10 +81,11 @@ discard block |
||
81 | 81 | { |
82 | 82 | $this->_initialized = true; |
83 | 83 | $service = $this->getService(); |
84 | - if($service instanceof TPageService) |
|
85 | - $service->setThemeManager($this); |
|
86 | - else |
|
87 | - throw new TConfigurationException('thememanager_service_unavailable'); |
|
84 | + if($service instanceof TPageService) { |
|
85 | + $service->setThemeManager($this); |
|
86 | + } else { |
|
87 | + throw new TConfigurationException('thememanager_service_unavailable'); |
|
88 | + } |
|
88 | 89 | } |
89 | 90 | |
90 | 91 | /** |
@@ -122,8 +123,9 @@ discard block |
||
122 | 123 | $folder = @opendir($basePath); |
123 | 124 | while($file = @readdir($folder)) |
124 | 125 | { |
125 | - if($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath . DIRECTORY_SEPARATOR . $file)) |
|
126 | - $themes[] = $file; |
|
126 | + if($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath . DIRECTORY_SEPARATOR . $file)) { |
|
127 | + $themes[] = $file; |
|
128 | + } |
|
127 | 129 | } |
128 | 130 | closedir($folder); |
129 | 131 | return $themes; |
@@ -138,8 +140,9 @@ discard block |
||
138 | 140 | if($this->_basePath === null) |
139 | 141 | { |
140 | 142 | $this->_basePath = dirname($this->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
141 | - if(($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) |
|
142 | - throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
|
143 | + if(($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) { |
|
144 | + throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
|
145 | + } |
|
143 | 146 | $this->_basePath = $basePath; |
144 | 147 | } |
145 | 148 | return $this->_basePath; |
@@ -151,13 +154,14 @@ discard block |
||
151 | 154 | */ |
152 | 155 | public function setBasePath($value) |
153 | 156 | { |
154 | - if($this->_initialized) |
|
155 | - throw new TInvalidOperationException('thememanager_basepath_unchangeable'); |
|
156 | - else |
|
157 | + if($this->_initialized) { |
|
158 | + throw new TInvalidOperationException('thememanager_basepath_unchangeable'); |
|
159 | + } else |
|
157 | 160 | { |
158 | 161 | $this->_basePath = Prado::getPathOfNamespace($value); |
159 | - if($this->_basePath === null || !is_dir($this->_basePath)) |
|
160 | - throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
|
162 | + if($this->_basePath === null || !is_dir($this->_basePath)) { |
|
163 | + throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
|
164 | + } |
|
161 | 165 | } |
162 | 166 | } |
163 | 167 | |
@@ -171,8 +175,9 @@ discard block |
||
171 | 175 | { |
172 | 176 | $appPath = dirname($this->getRequest()->getApplicationFilePath()); |
173 | 177 | $basePath = $this->getBasePath(); |
174 | - if(strpos($basePath, $appPath) === false) |
|
175 | - throw new TConfigurationException('thememanager_baseurl_required'); |
|
178 | + if(strpos($basePath, $appPath) === false) { |
|
179 | + throw new TConfigurationException('thememanager_baseurl_required'); |
|
180 | + } |
|
176 | 181 | $appUrl = rtrim(dirname($this->getRequest()->getApplicationUrl()), '/\\'); |
177 | 182 | $this->_baseUrl = $appUrl . strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
178 | 183 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function addAttributes($attrs) |
102 | 102 | { |
103 | - foreach($attrs as $name => $value) |
|
103 | + foreach ($attrs as $name => $value) |
|
104 | 104 | $this->_attributes[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
105 | 105 | } |
106 | 106 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function addStyleAttributes($attrs) |
131 | 131 | { |
132 | - foreach($attrs as $name => $value) |
|
132 | + foreach ($attrs as $name => $value) |
|
133 | 133 | $this->_styles[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
134 | 134 | } |
135 | 135 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function writeLine($str = '') |
179 | 179 | { |
180 | - $this->_writer->write($str . "\n"); |
|
180 | + $this->_writer->write($str."\n"); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -194,17 +194,17 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function renderBeginTag($tagName) |
196 | 196 | { |
197 | - $str = '<' . $tagName; |
|
198 | - foreach($this->_attributes as $name => $value) |
|
199 | - $str .= ' ' . $name . '="' . $value . '"'; |
|
200 | - if(!empty($this->_styles)) |
|
197 | + $str = '<'.$tagName; |
|
198 | + foreach ($this->_attributes as $name => $value) |
|
199 | + $str .= ' '.$name.'="'.$value.'"'; |
|
200 | + if (!empty($this->_styles)) |
|
201 | 201 | { |
202 | 202 | $str .= ' style="'; |
203 | - foreach($this->_styles as $name => $value) |
|
204 | - $str .= $name . ':' . $value . ';'; |
|
203 | + foreach ($this->_styles as $name => $value) |
|
204 | + $str .= $name.':'.$value.';'; |
|
205 | 205 | $str .= '"'; |
206 | 206 | } |
207 | - if(isset(self::$_simpleTags[$tagName])) |
|
207 | + if (isset(self::$_simpleTags[$tagName])) |
|
208 | 208 | { |
209 | 209 | $str .= ' />'; |
210 | 210 | $this->_openTags[] = ''; |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function renderEndTag() |
226 | 226 | { |
227 | - if(!empty($this->_openTags) && ($tagName = array_pop($this->_openTags)) !== '') |
|
228 | - $this->_writer->write('</' . $tagName . '>'); |
|
227 | + if (!empty($this->_openTags) && ($tagName = array_pop($this->_openTags)) !== '') |
|
228 | + $this->_writer->write('</'.$tagName.'>'); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 |
@@ -100,8 +100,9 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function addAttributes($attrs) |
102 | 102 | { |
103 | - foreach($attrs as $name => $value) |
|
104 | - $this->_attributes[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
103 | + foreach($attrs as $name => $value) { |
|
104 | + $this->_attributes[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
105 | + } |
|
105 | 106 | } |
106 | 107 | |
107 | 108 | /** |
@@ -129,8 +130,9 @@ discard block |
||
129 | 130 | */ |
130 | 131 | public function addStyleAttributes($attrs) |
131 | 132 | { |
132 | - foreach($attrs as $name => $value) |
|
133 | - $this->_styles[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
133 | + foreach($attrs as $name => $value) { |
|
134 | + $this->_styles[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
135 | + } |
|
134 | 136 | } |
135 | 137 | |
136 | 138 | /** |
@@ -195,21 +197,22 @@ discard block |
||
195 | 197 | public function renderBeginTag($tagName) |
196 | 198 | { |
197 | 199 | $str = '<' . $tagName; |
198 | - foreach($this->_attributes as $name => $value) |
|
199 | - $str .= ' ' . $name . '="' . $value . '"'; |
|
200 | + foreach($this->_attributes as $name => $value) { |
|
201 | + $str .= ' ' . $name . '="' . $value . '"'; |
|
202 | + } |
|
200 | 203 | if(!empty($this->_styles)) |
201 | 204 | { |
202 | 205 | $str .= ' style="'; |
203 | - foreach($this->_styles as $name => $value) |
|
204 | - $str .= $name . ':' . $value . ';'; |
|
206 | + foreach($this->_styles as $name => $value) { |
|
207 | + $str .= $name . ':' . $value . ';'; |
|
208 | + } |
|
205 | 209 | $str .= '"'; |
206 | 210 | } |
207 | 211 | if(isset(self::$_simpleTags[$tagName])) |
208 | 212 | { |
209 | 213 | $str .= ' />'; |
210 | 214 | $this->_openTags[] = ''; |
211 | - } |
|
212 | - else |
|
215 | + } else |
|
213 | 216 | { |
214 | 217 | $str .= '>'; |
215 | 218 | $this->_openTags[] = $tagName; |
@@ -224,8 +227,9 @@ discard block |
||
224 | 227 | */ |
225 | 228 | public function renderEndTag() |
226 | 229 | { |
227 | - if(!empty($this->_openTags) && ($tagName = array_pop($this->_openTags)) !== '') |
|
228 | - $this->_writer->write('</' . $tagName . '>'); |
|
230 | + if(!empty($this->_openTags) && ($tagName = array_pop($this->_openTags)) !== '') { |
|
231 | + $this->_writer->write('</' . $tagName . '>'); |
|
232 | + } |
|
229 | 233 | } |
230 | 234 | } |
231 | 235 |
@@ -114,17 +114,17 @@ discard block |
||
114 | 114 | * Indexes for the rare fields. |
115 | 115 | * In order to save memory, rare fields will only be created if they are needed. |
116 | 116 | */ |
117 | - const RF_CONTROLS = 0; // child controls |
|
118 | - const RF_CHILD_STATE = 1; // child state field |
|
119 | - const RF_NAMED_CONTROLS = 2; // list of controls whose namingcontainer is this control |
|
120 | - const RF_NAMED_CONTROLS_ID = 3; // counter for automatic id |
|
121 | - const RF_SKIN_ID = 4; // skin ID |
|
122 | - const RF_DATA_BINDINGS = 5; // data bindings |
|
123 | - const RF_EVENTS = 6; // event handlers |
|
124 | - const RF_CONTROLSTATE = 7; // controlstate |
|
125 | - const RF_NAMED_OBJECTS = 8; // controls declared with ID on template |
|
126 | - const RF_ADAPTER = 9; // adapter |
|
127 | - const RF_AUTO_BINDINGS = 10; // auto data bindings |
|
117 | + const RF_CONTROLS = 0; // child controls |
|
118 | + const RF_CHILD_STATE = 1; // child state field |
|
119 | + const RF_NAMED_CONTROLS = 2; // list of controls whose namingcontainer is this control |
|
120 | + const RF_NAMED_CONTROLS_ID = 3; // counter for automatic id |
|
121 | + const RF_SKIN_ID = 4; // skin ID |
|
122 | + const RF_DATA_BINDINGS = 5; // data bindings |
|
123 | + const RF_EVENTS = 6; // event handlers |
|
124 | + const RF_CONTROLSTATE = 7; // controlstate |
|
125 | + const RF_NAMED_OBJECTS = 8; // controls declared with ID on template |
|
126 | + const RF_ADAPTER = 9; // adapter |
|
127 | + const RF_AUTO_BINDINGS = 10; // auto data bindings |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @var string control ID |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function __get($name) |
195 | 195 | { |
196 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
196 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
197 | 197 | return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
198 | 198 | else |
199 | 199 | return parent::__get($name); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @see __get |
218 | 218 | */ |
219 | 219 | public function __isset($name) { |
220 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
220 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
221 | 221 | return true; |
222 | 222 | } else { |
223 | 223 | return parent::__isset($name); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function getAdapter() |
239 | 239 | { |
240 | - return isset($this->_rf[self::RF_ADAPTER])?$this->_rf[self::RF_ADAPTER]:null; |
|
240 | + return isset($this->_rf[self::RF_ADAPTER]) ? $this->_rf[self::RF_ADAPTER] : null; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function getNamingContainer() |
263 | 263 | { |
264 | - if(!$this->_namingContainer && $this->_parent) |
|
264 | + if (!$this->_namingContainer && $this->_parent) |
|
265 | 265 | { |
266 | - if($this->_parent instanceof INamingContainer) |
|
266 | + if ($this->_parent instanceof INamingContainer) |
|
267 | 267 | $this->_namingContainer = $this->_parent; |
268 | 268 | else |
269 | 269 | $this->_namingContainer = $this->_parent->getNamingContainer(); |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function getPage() |
278 | 278 | { |
279 | - if(!$this->_page) |
|
279 | + if (!$this->_page) |
|
280 | 280 | { |
281 | - if($this->_parent) |
|
281 | + if ($this->_parent) |
|
282 | 282 | $this->_page = $this->_parent->getPage(); |
283 | - elseif($this->_tplControl) |
|
283 | + elseif ($this->_tplControl) |
|
284 | 284 | $this->_page = $this->_tplControl->getPage(); |
285 | 285 | } |
286 | 286 | return $this->_page; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function getTemplateControl() |
313 | 313 | { |
314 | - if(!$this->_tplControl && $this->_parent) |
|
314 | + if (!$this->_tplControl && $this->_parent) |
|
315 | 315 | $this->_tplControl = $this->_parent->getTemplateControl(); |
316 | 316 | return $this->_tplControl; |
317 | 317 | } |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | public function getSourceTemplateControl() |
325 | 325 | { |
326 | 326 | $control = $this; |
327 | - while(($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null) |
|
327 | + while (($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null) |
|
328 | 328 | { |
329 | - if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
329 | + if (($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
330 | 330 | return $control; |
331 | 331 | } |
332 | 332 | return $this->getPage(); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function getID($hideAutoID = true) |
367 | 367 | { |
368 | - if($hideAutoID) |
|
368 | + if ($hideAutoID) |
|
369 | 369 | return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
370 | 370 | else |
371 | 371 | return $this->_id; |
@@ -377,12 +377,12 @@ discard block |
||
377 | 377 | */ |
378 | 378 | public function setID($id) |
379 | 379 | { |
380 | - if(!preg_match(self::ID_FORMAT, $id)) |
|
380 | + if (!preg_match(self::ID_FORMAT, $id)) |
|
381 | 381 | throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
382 | 382 | $this->_id = $id; |
383 | 383 | $this->_flags |= self::IS_ID_SET; |
384 | 384 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
385 | - if($this->_namingContainer) |
|
385 | + if ($this->_namingContainer) |
|
386 | 386 | $this->_namingContainer->clearNameTable(); |
387 | 387 | } |
388 | 388 | |
@@ -395,17 +395,17 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function getUniqueID() |
397 | 397 | { |
398 | - if($this->_uid === '' || $this->_uid === null) // need to build the UniqueID |
|
398 | + if ($this->_uid === '' || $this->_uid === null) // need to build the UniqueID |
|
399 | 399 | { |
400 | - $this->_uid = ''; // set to not-null, so that clearCachedUniqueID() may take action |
|
401 | - if($namingContainer = $this->getNamingContainer()) |
|
400 | + $this->_uid = ''; // set to not-null, so that clearCachedUniqueID() may take action |
|
401 | + if ($namingContainer = $this->getNamingContainer()) |
|
402 | 402 | { |
403 | - if($this->getPage() === $namingContainer) |
|
403 | + if ($this->getPage() === $namingContainer) |
|
404 | 404 | return ($this->_uid = $this->_id); |
405 | - elseif(($prefix = $namingContainer->getUniqueID()) === '') |
|
405 | + elseif (($prefix = $namingContainer->getUniqueID()) === '') |
|
406 | 406 | return $this->_id; |
407 | 407 | else |
408 | - return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
|
408 | + return ($this->_uid = $prefix.self::ID_SEPARATOR.$this->_id); |
|
409 | 409 | } |
410 | 410 | else // no naming container |
411 | 411 | return $this->_id; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public function getSkinID() |
451 | 451 | { |
452 | - return isset($this->_rf[self::RF_SKIN_ID])?$this->_rf[self::RF_SKIN_ID]:''; |
|
452 | + return isset($this->_rf[self::RF_SKIN_ID]) ? $this->_rf[self::RF_SKIN_ID] : ''; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | */ |
459 | 459 | public function setSkinID($value) |
460 | 460 | { |
461 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
461 | + if (($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
462 | 462 | throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
463 | 463 | else |
464 | 464 | $this->_rf[self::RF_SKIN_ID] = $value; |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function getEnableTheming() |
481 | 481 | { |
482 | - if($this->_flags & self::IS_DISABLE_THEMING) |
|
482 | + if ($this->_flags & self::IS_DISABLE_THEMING) |
|
483 | 483 | return false; |
484 | 484 | else |
485 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
485 | + return $this->_parent ? $this->_parent->getEnableTheming() : true; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | */ |
492 | 492 | public function setEnableTheming($value) |
493 | 493 | { |
494 | - if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
494 | + if ($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
495 | 495 | throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
496 | - elseif(TPropertyValue::ensureBoolean($value)) |
|
496 | + elseif (TPropertyValue::ensureBoolean($value)) |
|
497 | 497 | $this->_flags &= ~self::IS_DISABLE_THEMING; |
498 | 498 | else |
499 | 499 | $this->_flags |= self::IS_DISABLE_THEMING; |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | */ |
535 | 535 | public function getControls() |
536 | 536 | { |
537 | - if(!isset($this->_rf[self::RF_CONTROLS])) |
|
537 | + if (!isset($this->_rf[self::RF_CONTROLS])) |
|
538 | 538 | $this->_rf[self::RF_CONTROLS] = $this->createControlCollection(); |
539 | 539 | return $this->_rf[self::RF_CONTROLS]; |
540 | 540 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | */ |
547 | 547 | protected function createControlCollection() |
548 | 548 | { |
549 | - return $this->getAllowChildControls()?new TControlCollection($this):new TEmptyControlCollection($this); |
|
549 | + return $this->getAllowChildControls() ? new TControlCollection($this) : new TEmptyControlCollection($this); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -558,10 +558,10 @@ discard block |
||
558 | 558 | */ |
559 | 559 | public function getVisible($checkParents = true) |
560 | 560 | { |
561 | - if($checkParents) |
|
561 | + if ($checkParents) |
|
562 | 562 | { |
563 | - for($control = $this;$control;$control = $control->_parent) |
|
564 | - if(!$control->getVisible(false)) |
|
563 | + for ($control = $this; $control; $control = $control->_parent) |
|
564 | + if (!$control->getVisible(false)) |
|
565 | 565 | return false; |
566 | 566 | return true; |
567 | 567 | } |
@@ -589,10 +589,10 @@ discard block |
||
589 | 589 | */ |
590 | 590 | public function getEnabled($checkParents = false) |
591 | 591 | { |
592 | - if($checkParents) |
|
592 | + if ($checkParents) |
|
593 | 593 | { |
594 | - for($control = $this;$control;$control = $control->_parent) |
|
595 | - if(!$control->getViewState('Enabled', true)) |
|
594 | + for ($control = $this; $control; $control = $control->_parent) |
|
595 | + if (!$control->getViewState('Enabled', true)) |
|
596 | 596 | return false; |
597 | 597 | return true; |
598 | 598 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | */ |
614 | 614 | public function getHasAttributes() |
615 | 615 | { |
616 | - if($attributes = $this->getViewState('Attributes', null)) |
|
616 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
617 | 617 | return $attributes->getCount() > 0; |
618 | 618 | else |
619 | 619 | return false; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | */ |
628 | 628 | public function getAttributes() |
629 | 629 | { |
630 | - if($attributes = $this->getViewState('Attributes', null)) |
|
630 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
631 | 631 | return $attributes; |
632 | 632 | else |
633 | 633 | { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | */ |
643 | 643 | public function hasAttribute($name) |
644 | 644 | { |
645 | - if($attributes = $this->getViewState('Attributes', null)) |
|
645 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
646 | 646 | return $attributes->contains($name); |
647 | 647 | else |
648 | 648 | return false; |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | */ |
654 | 654 | public function getAttribute($name) |
655 | 655 | { |
656 | - if($attributes = $this->getViewState('Attributes', null)) |
|
656 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
657 | 657 | return $attributes->itemAt($name); |
658 | 658 | else |
659 | 659 | return null; |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | */ |
677 | 677 | public function removeAttribute($name) |
678 | 678 | { |
679 | - if($attributes = $this->getViewState('Attributes', null)) |
|
679 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
680 | 680 | return $attributes->remove($name); |
681 | 681 | else |
682 | 682 | return null; |
@@ -687,10 +687,10 @@ discard block |
||
687 | 687 | */ |
688 | 688 | public function getEnableViewState($checkParents = false) |
689 | 689 | { |
690 | - if($checkParents) |
|
690 | + if ($checkParents) |
|
691 | 691 | { |
692 | - for($control = $this;$control !== null;$control = $control->getParent()) |
|
693 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
692 | + for ($control = $this; $control !== null; $control = $control->getParent()) |
|
693 | + if ($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
694 | 694 | return false; |
695 | 695 | return true; |
696 | 696 | } |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function setEnableViewState($value) |
705 | 705 | { |
706 | - if(TPropertyValue::ensureBoolean($value)) |
|
706 | + if (TPropertyValue::ensureBoolean($value)) |
|
707 | 707 | $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
708 | 708 | else |
709 | 709 | $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | */ |
721 | 721 | protected function getControlState($key, $defaultValue = null) |
722 | 722 | { |
723 | - return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue; |
|
723 | + return isset($this->_rf[self::RF_CONTROLSTATE][$key]) ? $this->_rf[self::RF_CONTROLSTATE][$key] : $defaultValue; |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | */ |
736 | 736 | protected function setControlState($key, $value, $defaultValue = null) |
737 | 737 | { |
738 | - if($value === $defaultValue) |
|
738 | + if ($value === $defaultValue) |
|
739 | 739 | unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
740 | 740 | else |
741 | 741 | $this->_rf[self::RF_CONTROLSTATE][$key] = $value; |
@@ -772,11 +772,11 @@ discard block |
||
772 | 772 | */ |
773 | 773 | public function getViewState($key, $defaultValue = null) |
774 | 774 | { |
775 | - if(isset($this->_viewState[$key])) |
|
776 | - return $this->_viewState[$key] !== null?$this->_viewState[$key]:$defaultValue; |
|
777 | - elseif(isset($this->_tempState[$key])) |
|
775 | + if (isset($this->_viewState[$key])) |
|
776 | + return $this->_viewState[$key] !== null ? $this->_viewState[$key] : $defaultValue; |
|
777 | + elseif (isset($this->_tempState[$key])) |
|
778 | 778 | { |
779 | - if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
779 | + if (is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
780 | 780 | $this->_viewState[$key] = $this->_tempState[$key]; |
781 | 781 | return $this->_tempState[$key]; |
782 | 782 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | */ |
797 | 797 | public function setViewState($key, $value, $defaultValue = null) |
798 | 798 | { |
799 | - if($this->_trackViewState) |
|
799 | + if ($this->_trackViewState) |
|
800 | 800 | { |
801 | 801 | unset($this->_tempState[$key]); |
802 | 802 | $this->_viewState[$key] = $value; |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | else |
805 | 805 | { |
806 | 806 | unset($this->_viewState[$key]); |
807 | - if($value === $defaultValue) |
|
807 | + if ($value === $defaultValue) |
|
808 | 808 | unset($this->_tempState[$key]); |
809 | 809 | else |
810 | 810 | $this->_tempState[$key] = $value; |
@@ -870,11 +870,11 @@ discard block |
||
870 | 870 | protected function dataBindProperties() |
871 | 871 | { |
872 | 872 | Prado::trace("Data bind properties", 'Prado\Web\UI\TControl'); |
873 | - if(isset($this->_rf[self::RF_DATA_BINDINGS])) |
|
873 | + if (isset($this->_rf[self::RF_DATA_BINDINGS])) |
|
874 | 874 | { |
875 | - if(($context = $this->getTemplateControl()) === null) |
|
875 | + if (($context = $this->getTemplateControl()) === null) |
|
876 | 876 | $context = $this; |
877 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) |
|
877 | + foreach ($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) |
|
878 | 878 | $this->setSubProperty($property, $context->evaluateExpression($expression)); |
879 | 879 | } |
880 | 880 | } |
@@ -884,11 +884,11 @@ discard block |
||
884 | 884 | */ |
885 | 885 | protected function autoDataBindProperties() |
886 | 886 | { |
887 | - if(isset($this->_rf[self::RF_AUTO_BINDINGS])) |
|
887 | + if (isset($this->_rf[self::RF_AUTO_BINDINGS])) |
|
888 | 888 | { |
889 | - if(($context = $this->getTemplateControl()) === null) |
|
889 | + if (($context = $this->getTemplateControl()) === null) |
|
890 | 890 | $context = $this; |
891 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) |
|
891 | + foreach ($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) |
|
892 | 892 | $this->setSubProperty($property, $context->evaluateExpression($expression)); |
893 | 893 | } |
894 | 894 | } |
@@ -899,10 +899,10 @@ discard block |
||
899 | 899 | protected function dataBindChildren() |
900 | 900 | { |
901 | 901 | Prado::trace("dataBindChildren()", 'Prado\Web\UI\TControl'); |
902 | - if(isset($this->_rf[self::RF_CONTROLS])) |
|
902 | + if (isset($this->_rf[self::RF_CONTROLS])) |
|
903 | 903 | { |
904 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
905 | - if($control instanceof IBindable) |
|
904 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
905 | + if ($control instanceof IBindable) |
|
906 | 906 | $control->dataBind(); |
907 | 907 | } |
908 | 908 | } |
@@ -922,11 +922,11 @@ discard block |
||
922 | 922 | */ |
923 | 923 | final protected function setChildControlsCreated($value) |
924 | 924 | { |
925 | - if($value) |
|
925 | + if ($value) |
|
926 | 926 | $this->_flags |= self::IS_CHILD_CREATED; |
927 | 927 | else |
928 | 928 | { |
929 | - if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
929 | + if ($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
930 | 930 | $this->getControls()->clear(); |
931 | 931 | $this->_flags &= ~self::IS_CHILD_CREATED; |
932 | 932 | } |
@@ -939,19 +939,19 @@ discard block |
||
939 | 939 | */ |
940 | 940 | public function ensureChildControls() |
941 | 941 | { |
942 | - if(!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD)) |
|
942 | + if (!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD)) |
|
943 | 943 | { |
944 | 944 | try |
945 | 945 | { |
946 | 946 | $this->_flags |= self::IS_CREATING_CHILD; |
947 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
947 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
948 | 948 | $this->_rf[self::RF_ADAPTER]->createChildControls(); |
949 | 949 | else |
950 | 950 | $this->createChildControls(); |
951 | 951 | $this->_flags &= ~self::IS_CREATING_CHILD; |
952 | 952 | $this->_flags |= self::IS_CHILD_CREATED; |
953 | 953 | } |
954 | - catch(Exception $e) |
|
954 | + catch (Exception $e) |
|
955 | 955 | { |
956 | 956 | $this->_flags &= ~self::IS_CREATING_CHILD; |
957 | 957 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -984,21 +984,21 @@ discard block |
||
984 | 984 | public function findControl($id) |
985 | 985 | { |
986 | 986 | $id = strtr($id, '.', self::ID_SEPARATOR); |
987 | - $container = ($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
|
988 | - if(!$container || !$container->getHasControls()) |
|
987 | + $container = ($this instanceof INamingContainer) ? $this : $this->getNamingContainer(); |
|
988 | + if (!$container || !$container->getHasControls()) |
|
989 | 989 | return null; |
990 | - if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
|
990 | + if (!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
|
991 | 991 | { |
992 | 992 | $container->_rf[self::RF_NAMED_CONTROLS] = []; |
993 | 993 | $container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]); |
994 | 994 | } |
995 | - if(($pos = strpos($id, self::ID_SEPARATOR)) === false) |
|
996 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
995 | + if (($pos = strpos($id, self::ID_SEPARATOR)) === false) |
|
996 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id]) ? $container->_rf[self::RF_NAMED_CONTROLS][$id] : null; |
|
997 | 997 | else |
998 | 998 | { |
999 | 999 | $cid = substr($id, 0, $pos); |
1000 | 1000 | $sid = substr($id, $pos + 1); |
1001 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
1001 | + if (isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
1002 | 1002 | return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
1003 | 1003 | else |
1004 | 1004 | return null; |
@@ -1014,13 +1014,13 @@ discard block |
||
1014 | 1014 | public function findControlsByType($type, $strict = true) |
1015 | 1015 | { |
1016 | 1016 | $controls = []; |
1017 | - if($this->getHasControls()) |
|
1017 | + if ($this->getHasControls()) |
|
1018 | 1018 | { |
1019 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1019 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1020 | 1020 | { |
1021 | - if(is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) |
|
1021 | + if (is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) |
|
1022 | 1022 | $controls[] = $control; |
1023 | - if(($control instanceof TControl) && $control->getHasControls()) |
|
1023 | + if (($control instanceof TControl) && $control->getHasControls()) |
|
1024 | 1024 | $controls = array_merge($controls, $control->findControlsByType($type, $strict)); |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1039,13 +1039,13 @@ discard block |
||
1039 | 1039 | public function findControlsByID($id) |
1040 | 1040 | { |
1041 | 1041 | $controls = []; |
1042 | - if($this->getHasControls()) |
|
1042 | + if ($this->getHasControls()) |
|
1043 | 1043 | { |
1044 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1044 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1045 | 1045 | { |
1046 | - if($control instanceof TControl) |
|
1046 | + if ($control instanceof TControl) |
|
1047 | 1047 | { |
1048 | - if($control->_id === $id) |
|
1048 | + if ($control->_id === $id) |
|
1049 | 1049 | $controls[] = $control; |
1050 | 1050 | $controls = array_merge($controls, $control->findControlsByID($id)); |
1051 | 1051 | } |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | */ |
1075 | 1075 | public function registerObject($name, $object) |
1076 | 1076 | { |
1077 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1077 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1078 | 1078 | throw new TInvalidOperationException('control_object_reregistered', $name); |
1079 | 1079 | $this->_rf[self::RF_NAMED_OBJECTS][$name] = $object; |
1080 | 1080 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | */ |
1148 | 1148 | public function getRegisteredObject($name) |
1149 | 1149 | { |
1150 | - return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null; |
|
1150 | + return isset($this->_rf[self::RF_NAMED_OBJECTS][$name]) ? $this->_rf[self::RF_NAMED_OBJECTS][$name] : null; |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | final protected function isDescendentOf($ancestor) |
1191 | 1191 | { |
1192 | 1192 | $control = $this; |
1193 | - while($control !== $ancestor && $control->_parent) |
|
1193 | + while ($control !== $ancestor && $control->_parent) |
|
1194 | 1194 | $control = $control->_parent; |
1195 | 1195 | return $control === $ancestor; |
1196 | 1196 | } |
@@ -1203,27 +1203,27 @@ discard block |
||
1203 | 1203 | */ |
1204 | 1204 | public function addedControl($control) |
1205 | 1205 | { |
1206 | - if($control->_parent) |
|
1206 | + if ($control->_parent) |
|
1207 | 1207 | $control->_parent->getControls()->remove($control); |
1208 | 1208 | $control->_parent = $this; |
1209 | 1209 | $control->_page = $this->getPage(); |
1210 | - $namingContainer = ($this instanceof INamingContainer)?$this:$this->_namingContainer; |
|
1211 | - if($namingContainer) |
|
1210 | + $namingContainer = ($this instanceof INamingContainer) ? $this : $this->_namingContainer; |
|
1211 | + if ($namingContainer) |
|
1212 | 1212 | { |
1213 | 1213 | $control->_namingContainer = $namingContainer; |
1214 | - if($control->_id === '') |
|
1214 | + if ($control->_id === '') |
|
1215 | 1215 | $control->generateAutomaticID(); |
1216 | 1216 | else |
1217 | 1217 | $namingContainer->clearNameTable(); |
1218 | 1218 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
1221 | + if ($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
1222 | 1222 | { |
1223 | 1223 | $control->initRecursive($namingContainer); |
1224 | - if($this->_stage >= self::CS_STATE_LOADED) |
|
1224 | + if ($this->_stage >= self::CS_STATE_LOADED) |
|
1225 | 1225 | { |
1226 | - if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
|
1226 | + if (isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
|
1227 | 1227 | { |
1228 | 1228 | $state = $this->_rf[self::RF_CHILD_STATE][$control->_id]; |
1229 | 1229 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
@@ -1231,10 +1231,10 @@ discard block |
||
1231 | 1231 | else |
1232 | 1232 | $state = null; |
1233 | 1233 | $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1234 | - if($this->_stage >= self::CS_LOADED) |
|
1234 | + if ($this->_stage >= self::CS_LOADED) |
|
1235 | 1235 | { |
1236 | 1236 | $control->loadRecursive(); |
1237 | - if($this->_stage >= self::CS_PRERENDERED) |
|
1237 | + if ($this->_stage >= self::CS_PRERENDERED) |
|
1238 | 1238 | $control->preRenderRecursive(); |
1239 | 1239 | } |
1240 | 1240 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | */ |
1249 | 1249 | public function removedControl($control) |
1250 | 1250 | { |
1251 | - if($this->_namingContainer) |
|
1251 | + if ($this->_namingContainer) |
|
1252 | 1252 | $this->_namingContainer->clearNameTable(); |
1253 | 1253 | $control->unloadRecursive(); |
1254 | 1254 | $control->_parent = null; |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | $control->_namingContainer = null; |
1257 | 1257 | $control->_tplControl = null; |
1258 | 1258 | //$control->_stage=self::CS_CONSTRUCTED; |
1259 | - if(!($control->_flags & self::IS_ID_SET)) |
|
1259 | + if (!($control->_flags & self::IS_ID_SET)) |
|
1260 | 1260 | $control->_id = ''; |
1261 | 1261 | else |
1262 | 1262 | unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
@@ -1271,32 +1271,32 @@ discard block |
||
1271 | 1271 | protected function initRecursive($namingContainer = null) |
1272 | 1272 | { |
1273 | 1273 | $this->ensureChildControls(); |
1274 | - if($this->getHasControls()) |
|
1274 | + if ($this->getHasControls()) |
|
1275 | 1275 | { |
1276 | - if($this instanceof INamingContainer) |
|
1276 | + if ($this instanceof INamingContainer) |
|
1277 | 1277 | $namingContainer = $this; |
1278 | 1278 | $page = $this->getPage(); |
1279 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1279 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1280 | 1280 | { |
1281 | - if($control instanceof TControl) |
|
1281 | + if ($control instanceof TControl) |
|
1282 | 1282 | { |
1283 | 1283 | $control->_namingContainer = $namingContainer; |
1284 | 1284 | $control->_page = $page; |
1285 | - if($control->_id === '' && $namingContainer) |
|
1285 | + if ($control->_id === '' && $namingContainer) |
|
1286 | 1286 | $control->generateAutomaticID(); |
1287 | 1287 | $control->initRecursive($namingContainer); |
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | } |
1291 | - if($this->_stage < self::CS_INITIALIZED) |
|
1291 | + if ($this->_stage < self::CS_INITIALIZED) |
|
1292 | 1292 | { |
1293 | 1293 | $this->_stage = self::CS_CHILD_INITIALIZED; |
1294 | - if(($page = $this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
|
1294 | + if (($page = $this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
|
1295 | 1295 | { |
1296 | 1296 | $page->applyControlSkin($this); |
1297 | 1297 | $this->_flags |= self::IS_SKIN_APPLIED; |
1298 | 1298 | } |
1299 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1299 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1300 | 1300 | $this->_rf[self::RF_ADAPTER]->onInit(null); |
1301 | 1301 | else |
1302 | 1302 | $this->onInit(null); |
@@ -1310,22 +1310,22 @@ discard block |
||
1310 | 1310 | */ |
1311 | 1311 | protected function loadRecursive() |
1312 | 1312 | { |
1313 | - if($this->_stage < self::CS_LOADED) |
|
1313 | + if ($this->_stage < self::CS_LOADED) |
|
1314 | 1314 | { |
1315 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1315 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1316 | 1316 | $this->_rf[self::RF_ADAPTER]->onLoad(null); |
1317 | 1317 | else |
1318 | 1318 | $this->onLoad(null); |
1319 | 1319 | } |
1320 | - if($this->getHasControls()) |
|
1320 | + if ($this->getHasControls()) |
|
1321 | 1321 | { |
1322 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1322 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1323 | 1323 | { |
1324 | - if($control instanceof TControl) |
|
1324 | + if ($control instanceof TControl) |
|
1325 | 1325 | $control->loadRecursive(); |
1326 | 1326 | } |
1327 | 1327 | } |
1328 | - if($this->_stage < self::CS_LOADED) |
|
1328 | + if ($this->_stage < self::CS_LOADED) |
|
1329 | 1329 | $this->_stage = self::CS_LOADED; |
1330 | 1330 | } |
1331 | 1331 | |
@@ -1337,19 +1337,19 @@ discard block |
||
1337 | 1337 | { |
1338 | 1338 | $this->autoDataBindProperties(); |
1339 | 1339 | |
1340 | - if($this->getVisible(false)) |
|
1340 | + if ($this->getVisible(false)) |
|
1341 | 1341 | { |
1342 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1342 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1343 | 1343 | $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
1344 | 1344 | else |
1345 | 1345 | $this->onPreRender(null); |
1346 | - if($this->getHasControls()) |
|
1346 | + if ($this->getHasControls()) |
|
1347 | 1347 | { |
1348 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1348 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1349 | 1349 | { |
1350 | - if($control instanceof TControl) |
|
1350 | + if ($control instanceof TControl) |
|
1351 | 1351 | $control->preRenderRecursive(); |
1352 | - elseif($control instanceof TCompositeLiteral) |
|
1352 | + elseif ($control instanceof TCompositeLiteral) |
|
1353 | 1353 | $control->evaluateDynamicContent(); |
1354 | 1354 | } |
1355 | 1355 | } |
@@ -1363,15 +1363,15 @@ discard block |
||
1363 | 1363 | */ |
1364 | 1364 | protected function unloadRecursive() |
1365 | 1365 | { |
1366 | - if(!($this->_flags & self::IS_ID_SET)) |
|
1366 | + if (!($this->_flags & self::IS_ID_SET)) |
|
1367 | 1367 | $this->_id = ''; |
1368 | - if($this->getHasControls()) |
|
1368 | + if ($this->getHasControls()) |
|
1369 | 1369 | { |
1370 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1371 | - if($control instanceof TControl) |
|
1370 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1371 | + if ($control instanceof TControl) |
|
1372 | 1372 | $control->unloadRecursive(); |
1373 | 1373 | } |
1374 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1374 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1375 | 1375 | $this->_rf[self::RF_ADAPTER]->onUnload(null); |
1376 | 1376 | else |
1377 | 1377 | $this->onUnload(null); |
@@ -1447,9 +1447,9 @@ discard block |
||
1447 | 1447 | protected function raiseBubbleEvent($sender, $param) |
1448 | 1448 | { |
1449 | 1449 | $control = $this; |
1450 | - while($control = $control->_parent) |
|
1450 | + while ($control = $control->_parent) |
|
1451 | 1451 | { |
1452 | - if($control->bubbleEvent($sender, $param)) |
|
1452 | + if ($control->bubbleEvent($sender, $param)) |
|
1453 | 1453 | break; |
1454 | 1454 | } |
1455 | 1455 | } |
@@ -1486,7 +1486,7 @@ discard block |
||
1486 | 1486 | */ |
1487 | 1487 | public function broadcastEvent($name, $sender, $param) |
1488 | 1488 | { |
1489 | - $rootControl = (($page = $this->getPage()) === null)?$this:$page; |
|
1489 | + $rootControl = (($page = $this->getPage()) === null) ? $this : $page; |
|
1490 | 1490 | $rootControl->broadcastEventInternal($name, $sender, new TBroadcastEventParameter($name, $param)); |
1491 | 1491 | } |
1492 | 1492 | |
@@ -1499,15 +1499,15 @@ discard block |
||
1499 | 1499 | */ |
1500 | 1500 | private function broadcastEventInternal($name, $sender, $param) |
1501 | 1501 | { |
1502 | - if($this->hasEvent($name)) |
|
1502 | + if ($this->hasEvent($name)) |
|
1503 | 1503 | $this->raiseEvent($name, $sender, $param->getParameter()); |
1504 | - if($this instanceof IBroadcastEventReceiver) |
|
1504 | + if ($this instanceof IBroadcastEventReceiver) |
|
1505 | 1505 | $this->broadcastEventReceived($sender, $param); |
1506 | - if($this->getHasControls()) |
|
1506 | + if ($this->getHasControls()) |
|
1507 | 1507 | { |
1508 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1508 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1509 | 1509 | { |
1510 | - if($control instanceof TControl) |
|
1510 | + if ($control instanceof TControl) |
|
1511 | 1511 | $control->broadcastEventInternal($name, $sender, $param); |
1512 | 1512 | } |
1513 | 1513 | } |
@@ -1532,19 +1532,19 @@ discard block |
||
1532 | 1532 | */ |
1533 | 1533 | protected function traverseChildControls($param, $preCallback = null, $postCallback = null) |
1534 | 1534 | { |
1535 | - if($preCallback !== null) |
|
1535 | + if ($preCallback !== null) |
|
1536 | 1536 | call_user_func($preCallback, $this, $param); |
1537 | - if($this->getHasControls()) |
|
1537 | + if ($this->getHasControls()) |
|
1538 | 1538 | { |
1539 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1539 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1540 | 1540 | { |
1541 | - if($control instanceof TControl) |
|
1541 | + if ($control instanceof TControl) |
|
1542 | 1542 | { |
1543 | 1543 | $control->traverseChildControls($param, $preCallback, $postCallback); |
1544 | 1544 | } |
1545 | 1545 | } |
1546 | 1546 | } |
1547 | - if($postCallback !== null) |
|
1547 | + if ($postCallback !== null) |
|
1548 | 1548 | call_user_func($postCallback, $this, $param); |
1549 | 1549 | } |
1550 | 1550 | |
@@ -1555,9 +1555,9 @@ discard block |
||
1555 | 1555 | */ |
1556 | 1556 | public function renderControl($writer) |
1557 | 1557 | { |
1558 | - if($this instanceof IActiveControl || $this->getVisible(false)) |
|
1558 | + if ($this instanceof IActiveControl || $this->getVisible(false)) |
|
1559 | 1559 | { |
1560 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1560 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1561 | 1561 | $this->_rf[self::RF_ADAPTER]->render($writer); |
1562 | 1562 | else |
1563 | 1563 | $this->render($writer); |
@@ -1584,15 +1584,15 @@ discard block |
||
1584 | 1584 | */ |
1585 | 1585 | public function renderChildren($writer) |
1586 | 1586 | { |
1587 | - if($this->getHasControls()) |
|
1587 | + if ($this->getHasControls()) |
|
1588 | 1588 | { |
1589 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1589 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1590 | 1590 | { |
1591 | - if(is_string($control)) |
|
1591 | + if (is_string($control)) |
|
1592 | 1592 | $writer->write($control); |
1593 | - elseif($control instanceof TControl) |
|
1593 | + elseif ($control instanceof TControl) |
|
1594 | 1594 | $control->renderControl($writer); |
1595 | - elseif($control instanceof IRenderable) |
|
1595 | + elseif ($control instanceof IRenderable) |
|
1596 | 1596 | $control->render($writer); |
1597 | 1597 | } |
1598 | 1598 | } |
@@ -1624,33 +1624,33 @@ discard block |
||
1624 | 1624 | */ |
1625 | 1625 | protected function loadStateRecursive(&$state, $needViewState = true) |
1626 | 1626 | { |
1627 | - if(is_array($state)) |
|
1627 | + if (is_array($state)) |
|
1628 | 1628 | { |
1629 | 1629 | // A null state means the stateful properties all take default values. |
1630 | 1630 | // So if the state is enabled, we have to assign the null value. |
1631 | 1631 | $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1632 | - if(isset($state[1])) |
|
1632 | + if (isset($state[1])) |
|
1633 | 1633 | { |
1634 | 1634 | $this->_rf[self::RF_CONTROLSTATE] = &$state[1]; |
1635 | 1635 | unset($state[1]); |
1636 | 1636 | } |
1637 | 1637 | else |
1638 | 1638 | unset($this->_rf[self::RF_CONTROLSTATE]); |
1639 | - if($needViewState) |
|
1639 | + if ($needViewState) |
|
1640 | 1640 | { |
1641 | - if(isset($state[0])) |
|
1641 | + if (isset($state[0])) |
|
1642 | 1642 | $this->_viewState = &$state[0]; |
1643 | 1643 | else |
1644 | 1644 | $this->_viewState = []; |
1645 | 1645 | } |
1646 | 1646 | unset($state[0]); |
1647 | - if($this->getHasControls()) |
|
1647 | + if ($this->getHasControls()) |
|
1648 | 1648 | { |
1649 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1649 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1650 | 1650 | { |
1651 | - if($control instanceof TControl) |
|
1651 | + if ($control instanceof TControl) |
|
1652 | 1652 | { |
1653 | - if(isset($state[$control->_id])) |
|
1653 | + if (isset($state[$control->_id])) |
|
1654 | 1654 | { |
1655 | 1655 | $control->loadStateRecursive($state[$control->_id], $needViewState); |
1656 | 1656 | unset($state[$control->_id]); |
@@ -1658,11 +1658,11 @@ discard block |
||
1658 | 1658 | } |
1659 | 1659 | } |
1660 | 1660 | } |
1661 | - if(!empty($state)) |
|
1661 | + if (!empty($state)) |
|
1662 | 1662 | $this->_rf[self::RF_CHILD_STATE] = &$state; |
1663 | 1663 | } |
1664 | 1664 | $this->_stage = self::CS_STATE_LOADED; |
1665 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1665 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1666 | 1666 | $this->_rf[self::RF_ADAPTER]->loadState(); |
1667 | 1667 | else |
1668 | 1668 | $this->loadState(); |
@@ -1676,26 +1676,26 @@ discard block |
||
1676 | 1676 | */ |
1677 | 1677 | protected function &saveStateRecursive($needViewState = true) |
1678 | 1678 | { |
1679 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1679 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1680 | 1680 | $this->_rf[self::RF_ADAPTER]->saveState(); |
1681 | 1681 | else |
1682 | 1682 | $this->saveState(); |
1683 | 1683 | $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1684 | 1684 | $state = []; |
1685 | - if($this->getHasControls()) |
|
1685 | + if ($this->getHasControls()) |
|
1686 | 1686 | { |
1687 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1687 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1688 | 1688 | { |
1689 | - if($control instanceof TControl) |
|
1689 | + if ($control instanceof TControl) |
|
1690 | 1690 | { |
1691 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1691 | + if (count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1692 | 1692 | $state[$control->_id] = $tmp; |
1693 | 1693 | } |
1694 | 1694 | } |
1695 | 1695 | } |
1696 | - if($needViewState && !empty($this->_viewState)) |
|
1696 | + if ($needViewState && !empty($this->_viewState)) |
|
1697 | 1697 | $state[0] = &$this->_viewState; |
1698 | - if(isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1698 | + if (isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1699 | 1699 | $state[1] = &$this->_rf[self::RF_CONTROLSTATE]; |
1700 | 1700 | return $state; |
1701 | 1701 | } |
@@ -1707,12 +1707,12 @@ discard block |
||
1707 | 1707 | */ |
1708 | 1708 | public function applyStyleSheetSkin($page) |
1709 | 1709 | { |
1710 | - if($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
|
1710 | + if ($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
|
1711 | 1711 | { |
1712 | 1712 | $page->applyControlStyleSheet($this); |
1713 | 1713 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
1714 | 1714 | } |
1715 | - elseif($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1715 | + elseif ($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1716 | 1716 | throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
1717 | 1717 | } |
1718 | 1718 | |
@@ -1723,10 +1723,10 @@ discard block |
||
1723 | 1723 | */ |
1724 | 1724 | private function clearCachedUniqueID($recursive) |
1725 | 1725 | { |
1726 | - if($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
|
1726 | + if ($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
|
1727 | 1727 | { |
1728 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1729 | - if($control instanceof TControl) |
|
1728 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1729 | + if ($control instanceof TControl) |
|
1730 | 1730 | $control->clearCachedUniqueID($recursive); |
1731 | 1731 | } |
1732 | 1732 | $this->_uid = null; |
@@ -1738,10 +1738,10 @@ discard block |
||
1738 | 1738 | private function generateAutomaticID() |
1739 | 1739 | { |
1740 | 1740 | $this->_flags &= ~self::IS_ID_SET; |
1741 | - if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1741 | + if (!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1742 | 1742 | $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0; |
1743 | 1743 | $id = $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
1744 | - $this->_id = self::AUTOMATIC_ID_PREFIX . $id; |
|
1744 | + $this->_id = self::AUTOMATIC_ID_PREFIX.$id; |
|
1745 | 1745 | $this->_namingContainer->clearNameTable(); |
1746 | 1746 | } |
1747 | 1747 | |
@@ -1761,18 +1761,18 @@ discard block |
||
1761 | 1761 | */ |
1762 | 1762 | private function fillNameTable($container, $controls) |
1763 | 1763 | { |
1764 | - foreach($controls as $control) |
|
1764 | + foreach ($controls as $control) |
|
1765 | 1765 | { |
1766 | - if($control instanceof TControl) |
|
1766 | + if ($control instanceof TControl) |
|
1767 | 1767 | { |
1768 | - if($control->_id !== '') |
|
1768 | + if ($control->_id !== '') |
|
1769 | 1769 | { |
1770 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1770 | + if (isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1771 | 1771 | throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
1772 | 1772 | else |
1773 | 1773 | $container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control; |
1774 | 1774 | } |
1775 | - if(!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1775 | + if (!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1776 | 1776 | $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
1777 | 1777 | } |
1778 | 1778 | } |
@@ -193,10 +193,11 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function __get($name) |
195 | 195 | { |
196 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
197 | - return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
|
198 | - else |
|
199 | - return parent::__get($name); |
|
196 | + if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
197 | + return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
|
198 | + } else { |
|
199 | + return parent::__get($name); |
|
200 | + } |
|
200 | 201 | } |
201 | 202 | |
202 | 203 | /** |
@@ -263,10 +264,11 @@ discard block |
||
263 | 264 | { |
264 | 265 | if(!$this->_namingContainer && $this->_parent) |
265 | 266 | { |
266 | - if($this->_parent instanceof INamingContainer) |
|
267 | - $this->_namingContainer = $this->_parent; |
|
268 | - else |
|
269 | - $this->_namingContainer = $this->_parent->getNamingContainer(); |
|
267 | + if($this->_parent instanceof INamingContainer) { |
|
268 | + $this->_namingContainer = $this->_parent; |
|
269 | + } else { |
|
270 | + $this->_namingContainer = $this->_parent->getNamingContainer(); |
|
271 | + } |
|
270 | 272 | } |
271 | 273 | return $this->_namingContainer; |
272 | 274 | } |
@@ -278,10 +280,11 @@ discard block |
||
278 | 280 | { |
279 | 281 | if(!$this->_page) |
280 | 282 | { |
281 | - if($this->_parent) |
|
282 | - $this->_page = $this->_parent->getPage(); |
|
283 | - elseif($this->_tplControl) |
|
284 | - $this->_page = $this->_tplControl->getPage(); |
|
283 | + if($this->_parent) { |
|
284 | + $this->_page = $this->_parent->getPage(); |
|
285 | + } elseif($this->_tplControl) { |
|
286 | + $this->_page = $this->_tplControl->getPage(); |
|
287 | + } |
|
285 | 288 | } |
286 | 289 | return $this->_page; |
287 | 290 | } |
@@ -311,8 +314,9 @@ discard block |
||
311 | 314 | */ |
312 | 315 | public function getTemplateControl() |
313 | 316 | { |
314 | - if(!$this->_tplControl && $this->_parent) |
|
315 | - $this->_tplControl = $this->_parent->getTemplateControl(); |
|
317 | + if(!$this->_tplControl && $this->_parent) { |
|
318 | + $this->_tplControl = $this->_parent->getTemplateControl(); |
|
319 | + } |
|
316 | 320 | return $this->_tplControl; |
317 | 321 | } |
318 | 322 | |
@@ -326,8 +330,9 @@ discard block |
||
326 | 330 | $control = $this; |
327 | 331 | while(($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null) |
328 | 332 | { |
329 | - if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
330 | - return $control; |
|
333 | + if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) { |
|
334 | + return $control; |
|
335 | + } |
|
331 | 336 | } |
332 | 337 | return $this->getPage(); |
333 | 338 | } |
@@ -365,10 +370,11 @@ discard block |
||
365 | 370 | */ |
366 | 371 | public function getID($hideAutoID = true) |
367 | 372 | { |
368 | - if($hideAutoID) |
|
369 | - return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
|
370 | - else |
|
371 | - return $this->_id; |
|
373 | + if($hideAutoID) { |
|
374 | + return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
|
375 | + } else { |
|
376 | + return $this->_id; |
|
377 | + } |
|
372 | 378 | } |
373 | 379 | |
374 | 380 | /** |
@@ -377,13 +383,15 @@ discard block |
||
377 | 383 | */ |
378 | 384 | public function setID($id) |
379 | 385 | { |
380 | - if(!preg_match(self::ID_FORMAT, $id)) |
|
381 | - throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
|
386 | + if(!preg_match(self::ID_FORMAT, $id)) { |
|
387 | + throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
|
388 | + } |
|
382 | 389 | $this->_id = $id; |
383 | 390 | $this->_flags |= self::IS_ID_SET; |
384 | 391 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
385 | - if($this->_namingContainer) |
|
386 | - $this->_namingContainer->clearNameTable(); |
|
392 | + if($this->_namingContainer) { |
|
393 | + $this->_namingContainer->clearNameTable(); |
|
394 | + } |
|
387 | 395 | } |
388 | 396 | |
389 | 397 | /** |
@@ -395,23 +403,28 @@ discard block |
||
395 | 403 | */ |
396 | 404 | public function getUniqueID() |
397 | 405 | { |
398 | - if($this->_uid === '' || $this->_uid === null) // need to build the UniqueID |
|
406 | + if($this->_uid === '' || $this->_uid === null) { |
|
407 | + // need to build the UniqueID |
|
399 | 408 | { |
400 | - $this->_uid = ''; // set to not-null, so that clearCachedUniqueID() may take action |
|
409 | + $this->_uid = ''; |
|
410 | + } |
|
411 | + // set to not-null, so that clearCachedUniqueID() may take action |
|
401 | 412 | if($namingContainer = $this->getNamingContainer()) |
402 | 413 | { |
403 | - if($this->getPage() === $namingContainer) |
|
404 | - return ($this->_uid = $this->_id); |
|
405 | - elseif(($prefix = $namingContainer->getUniqueID()) === '') |
|
406 | - return $this->_id; |
|
407 | - else |
|
408 | - return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
|
409 | - } |
|
410 | - else // no naming container |
|
414 | + if($this->getPage() === $namingContainer) { |
|
415 | + return ($this->_uid = $this->_id); |
|
416 | + } elseif(($prefix = $namingContainer->getUniqueID()) === '') { |
|
417 | + return $this->_id; |
|
418 | + } else { |
|
419 | + return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
|
420 | + } |
|
421 | + } else { |
|
422 | + // no naming container |
|
411 | 423 | return $this->_id; |
424 | + } |
|
425 | + } else { |
|
426 | + return $this->_uid; |
|
412 | 427 | } |
413 | - else |
|
414 | - return $this->_uid; |
|
415 | 428 | } |
416 | 429 | |
417 | 430 | /** |
@@ -458,10 +471,11 @@ discard block |
||
458 | 471 | */ |
459 | 472 | public function setSkinID($value) |
460 | 473 | { |
461 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
462 | - throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
|
463 | - else |
|
464 | - $this->_rf[self::RF_SKIN_ID] = $value; |
|
474 | + if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) { |
|
475 | + throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
|
476 | + } else { |
|
477 | + $this->_rf[self::RF_SKIN_ID] = $value; |
|
478 | + } |
|
465 | 479 | } |
466 | 480 | |
467 | 481 | /** |
@@ -479,10 +493,11 @@ discard block |
||
479 | 493 | */ |
480 | 494 | public function getEnableTheming() |
481 | 495 | { |
482 | - if($this->_flags & self::IS_DISABLE_THEMING) |
|
483 | - return false; |
|
484 | - else |
|
485 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
496 | + if($this->_flags & self::IS_DISABLE_THEMING) { |
|
497 | + return false; |
|
498 | + } else { |
|
499 | + return $this->_parent?$this->_parent->getEnableTheming():true; |
|
500 | + } |
|
486 | 501 | } |
487 | 502 | |
488 | 503 | /** |
@@ -491,12 +506,13 @@ discard block |
||
491 | 506 | */ |
492 | 507 | public function setEnableTheming($value) |
493 | 508 | { |
494 | - if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
495 | - throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
|
496 | - elseif(TPropertyValue::ensureBoolean($value)) |
|
497 | - $this->_flags &= ~self::IS_DISABLE_THEMING; |
|
498 | - else |
|
499 | - $this->_flags |= self::IS_DISABLE_THEMING; |
|
509 | + if($this->_stage >= self::CS_CHILD_INITIALIZED) { |
|
510 | + throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
|
511 | + } elseif(TPropertyValue::ensureBoolean($value)) { |
|
512 | + $this->_flags &= ~self::IS_DISABLE_THEMING; |
|
513 | + } else { |
|
514 | + $this->_flags |= self::IS_DISABLE_THEMING; |
|
515 | + } |
|
500 | 516 | } |
501 | 517 | |
502 | 518 | /** |
@@ -534,8 +550,9 @@ discard block |
||
534 | 550 | */ |
535 | 551 | public function getControls() |
536 | 552 | { |
537 | - if(!isset($this->_rf[self::RF_CONTROLS])) |
|
538 | - $this->_rf[self::RF_CONTROLS] = $this->createControlCollection(); |
|
553 | + if(!isset($this->_rf[self::RF_CONTROLS])) { |
|
554 | + $this->_rf[self::RF_CONTROLS] = $this->createControlCollection(); |
|
555 | + } |
|
539 | 556 | return $this->_rf[self::RF_CONTROLS]; |
540 | 557 | } |
541 | 558 | |
@@ -560,13 +577,14 @@ discard block |
||
560 | 577 | { |
561 | 578 | if($checkParents) |
562 | 579 | { |
563 | - for($control = $this;$control;$control = $control->_parent) |
|
564 | - if(!$control->getVisible(false)) |
|
580 | + for($control = $this;$control;$control = $control->_parent) { |
|
581 | + if(!$control->getVisible(false)) |
|
565 | 582 | return false; |
583 | + } |
|
566 | 584 | return true; |
585 | + } else { |
|
586 | + return $this->getViewState('Visible', true); |
|
567 | 587 | } |
568 | - else |
|
569 | - return $this->getViewState('Visible', true); |
|
570 | 588 | } |
571 | 589 | |
572 | 590 | /** |
@@ -591,13 +609,14 @@ discard block |
||
591 | 609 | { |
592 | 610 | if($checkParents) |
593 | 611 | { |
594 | - for($control = $this;$control;$control = $control->_parent) |
|
595 | - if(!$control->getViewState('Enabled', true)) |
|
612 | + for($control = $this;$control;$control = $control->_parent) { |
|
613 | + if(!$control->getViewState('Enabled', true)) |
|
596 | 614 | return false; |
615 | + } |
|
597 | 616 | return true; |
617 | + } else { |
|
618 | + return $this->getViewState('Enabled', true); |
|
598 | 619 | } |
599 | - else |
|
600 | - return $this->getViewState('Enabled', true); |
|
601 | 620 | } |
602 | 621 | |
603 | 622 | /** |
@@ -613,10 +632,11 @@ discard block |
||
613 | 632 | */ |
614 | 633 | public function getHasAttributes() |
615 | 634 | { |
616 | - if($attributes = $this->getViewState('Attributes', null)) |
|
617 | - return $attributes->getCount() > 0; |
|
618 | - else |
|
619 | - return false; |
|
635 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
636 | + return $attributes->getCount() > 0; |
|
637 | + } else { |
|
638 | + return false; |
|
639 | + } |
|
620 | 640 | } |
621 | 641 | |
622 | 642 | /** |
@@ -627,9 +647,9 @@ discard block |
||
627 | 647 | */ |
628 | 648 | public function getAttributes() |
629 | 649 | { |
630 | - if($attributes = $this->getViewState('Attributes', null)) |
|
631 | - return $attributes; |
|
632 | - else |
|
650 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
651 | + return $attributes; |
|
652 | + } else |
|
633 | 653 | { |
634 | 654 | $attributes = new TAttributeCollection; |
635 | 655 | $this->setViewState('Attributes', $attributes, null); |
@@ -642,10 +662,11 @@ discard block |
||
642 | 662 | */ |
643 | 663 | public function hasAttribute($name) |
644 | 664 | { |
645 | - if($attributes = $this->getViewState('Attributes', null)) |
|
646 | - return $attributes->contains($name); |
|
647 | - else |
|
648 | - return false; |
|
665 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
666 | + return $attributes->contains($name); |
|
667 | + } else { |
|
668 | + return false; |
|
669 | + } |
|
649 | 670 | } |
650 | 671 | |
651 | 672 | /** |
@@ -653,10 +674,11 @@ discard block |
||
653 | 674 | */ |
654 | 675 | public function getAttribute($name) |
655 | 676 | { |
656 | - if($attributes = $this->getViewState('Attributes', null)) |
|
657 | - return $attributes->itemAt($name); |
|
658 | - else |
|
659 | - return null; |
|
677 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
678 | + return $attributes->itemAt($name); |
|
679 | + } else { |
|
680 | + return null; |
|
681 | + } |
|
660 | 682 | } |
661 | 683 | |
662 | 684 | /** |
@@ -676,10 +698,11 @@ discard block |
||
676 | 698 | */ |
677 | 699 | public function removeAttribute($name) |
678 | 700 | { |
679 | - if($attributes = $this->getViewState('Attributes', null)) |
|
680 | - return $attributes->remove($name); |
|
681 | - else |
|
682 | - return null; |
|
701 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
702 | + return $attributes->remove($name); |
|
703 | + } else { |
|
704 | + return null; |
|
705 | + } |
|
683 | 706 | } |
684 | 707 | |
685 | 708 | /** |
@@ -689,13 +712,14 @@ discard block |
||
689 | 712 | { |
690 | 713 | if($checkParents) |
691 | 714 | { |
692 | - for($control = $this;$control !== null;$control = $control->getParent()) |
|
693 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
715 | + for($control = $this;$control !== null;$control = $control->getParent()) { |
|
716 | + if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
694 | 717 | return false; |
718 | + } |
|
695 | 719 | return true; |
720 | + } else { |
|
721 | + return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
|
696 | 722 | } |
697 | - else |
|
698 | - return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
|
699 | 723 | } |
700 | 724 | |
701 | 725 | /** |
@@ -703,10 +727,11 @@ discard block |
||
703 | 727 | */ |
704 | 728 | public function setEnableViewState($value) |
705 | 729 | { |
706 | - if(TPropertyValue::ensureBoolean($value)) |
|
707 | - $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
|
708 | - else |
|
709 | - $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
|
730 | + if(TPropertyValue::ensureBoolean($value)) { |
|
731 | + $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
|
732 | + } else { |
|
733 | + $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
|
734 | + } |
|
710 | 735 | } |
711 | 736 | |
712 | 737 | /** |
@@ -735,10 +760,11 @@ discard block |
||
735 | 760 | */ |
736 | 761 | protected function setControlState($key, $value, $defaultValue = null) |
737 | 762 | { |
738 | - if($value === $defaultValue) |
|
739 | - unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
|
740 | - else |
|
741 | - $this->_rf[self::RF_CONTROLSTATE][$key] = $value; |
|
763 | + if($value === $defaultValue) { |
|
764 | + unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
|
765 | + } else { |
|
766 | + $this->_rf[self::RF_CONTROLSTATE][$key] = $value; |
|
767 | + } |
|
742 | 768 | } |
743 | 769 | |
744 | 770 | /** |
@@ -772,16 +798,17 @@ discard block |
||
772 | 798 | */ |
773 | 799 | public function getViewState($key, $defaultValue = null) |
774 | 800 | { |
775 | - if(isset($this->_viewState[$key])) |
|
776 | - return $this->_viewState[$key] !== null?$this->_viewState[$key]:$defaultValue; |
|
777 | - elseif(isset($this->_tempState[$key])) |
|
801 | + if(isset($this->_viewState[$key])) { |
|
802 | + return $this->_viewState[$key] !== null?$this->_viewState[$key]:$defaultValue; |
|
803 | + } elseif(isset($this->_tempState[$key])) |
|
778 | 804 | { |
779 | - if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
780 | - $this->_viewState[$key] = $this->_tempState[$key]; |
|
805 | + if(is_object($this->_tempState[$key]) && $this->_trackViewState) { |
|
806 | + $this->_viewState[$key] = $this->_tempState[$key]; |
|
807 | + } |
|
781 | 808 | return $this->_tempState[$key]; |
809 | + } else { |
|
810 | + return $defaultValue; |
|
782 | 811 | } |
783 | - else |
|
784 | - return $defaultValue; |
|
785 | 812 | } |
786 | 813 | |
787 | 814 | /** |
@@ -800,14 +827,14 @@ discard block |
||
800 | 827 | { |
801 | 828 | unset($this->_tempState[$key]); |
802 | 829 | $this->_viewState[$key] = $value; |
803 | - } |
|
804 | - else |
|
830 | + } else |
|
805 | 831 | { |
806 | 832 | unset($this->_viewState[$key]); |
807 | - if($value === $defaultValue) |
|
808 | - unset($this->_tempState[$key]); |
|
809 | - else |
|
810 | - $this->_tempState[$key] = $value; |
|
833 | + if($value === $defaultValue) { |
|
834 | + unset($this->_tempState[$key]); |
|
835 | + } else { |
|
836 | + $this->_tempState[$key] = $value; |
|
837 | + } |
|
811 | 838 | } |
812 | 839 | } |
813 | 840 | |
@@ -872,10 +899,12 @@ discard block |
||
872 | 899 | Prado::trace("Data bind properties", 'Prado\Web\UI\TControl'); |
873 | 900 | if(isset($this->_rf[self::RF_DATA_BINDINGS])) |
874 | 901 | { |
875 | - if(($context = $this->getTemplateControl()) === null) |
|
876 | - $context = $this; |
|
877 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) |
|
878 | - $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
902 | + if(($context = $this->getTemplateControl()) === null) { |
|
903 | + $context = $this; |
|
904 | + } |
|
905 | + foreach($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) { |
|
906 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
907 | + } |
|
879 | 908 | } |
880 | 909 | } |
881 | 910 | |
@@ -886,10 +915,12 @@ discard block |
||
886 | 915 | { |
887 | 916 | if(isset($this->_rf[self::RF_AUTO_BINDINGS])) |
888 | 917 | { |
889 | - if(($context = $this->getTemplateControl()) === null) |
|
890 | - $context = $this; |
|
891 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) |
|
892 | - $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
918 | + if(($context = $this->getTemplateControl()) === null) { |
|
919 | + $context = $this; |
|
920 | + } |
|
921 | + foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) { |
|
922 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
923 | + } |
|
893 | 924 | } |
894 | 925 | } |
895 | 926 | |
@@ -901,9 +932,10 @@ discard block |
||
901 | 932 | Prado::trace("dataBindChildren()", 'Prado\Web\UI\TControl'); |
902 | 933 | if(isset($this->_rf[self::RF_CONTROLS])) |
903 | 934 | { |
904 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
905 | - if($control instanceof IBindable) |
|
935 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
936 | + if($control instanceof IBindable) |
|
906 | 937 | $control->dataBind(); |
938 | + } |
|
907 | 939 | } |
908 | 940 | } |
909 | 941 | |
@@ -922,12 +954,13 @@ discard block |
||
922 | 954 | */ |
923 | 955 | final protected function setChildControlsCreated($value) |
924 | 956 | { |
925 | - if($value) |
|
926 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
927 | - else |
|
957 | + if($value) { |
|
958 | + $this->_flags |= self::IS_CHILD_CREATED; |
|
959 | + } else |
|
928 | 960 | { |
929 | - if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
930 | - $this->getControls()->clear(); |
|
961 | + if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) { |
|
962 | + $this->getControls()->clear(); |
|
963 | + } |
|
931 | 964 | $this->_flags &= ~self::IS_CHILD_CREATED; |
932 | 965 | } |
933 | 966 | } |
@@ -944,14 +977,14 @@ discard block |
||
944 | 977 | try |
945 | 978 | { |
946 | 979 | $this->_flags |= self::IS_CREATING_CHILD; |
947 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
948 | - $this->_rf[self::RF_ADAPTER]->createChildControls(); |
|
949 | - else |
|
950 | - $this->createChildControls(); |
|
980 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
981 | + $this->_rf[self::RF_ADAPTER]->createChildControls(); |
|
982 | + } else { |
|
983 | + $this->createChildControls(); |
|
984 | + } |
|
951 | 985 | $this->_flags &= ~self::IS_CREATING_CHILD; |
952 | 986 | $this->_flags |= self::IS_CHILD_CREATED; |
953 | - } |
|
954 | - catch(Exception $e) |
|
987 | + } catch(Exception $e) |
|
955 | 988 | { |
956 | 989 | $this->_flags &= ~self::IS_CREATING_CHILD; |
957 | 990 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -985,23 +1018,25 @@ discard block |
||
985 | 1018 | { |
986 | 1019 | $id = strtr($id, '.', self::ID_SEPARATOR); |
987 | 1020 | $container = ($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
988 | - if(!$container || !$container->getHasControls()) |
|
989 | - return null; |
|
1021 | + if(!$container || !$container->getHasControls()) { |
|
1022 | + return null; |
|
1023 | + } |
|
990 | 1024 | if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
991 | 1025 | { |
992 | 1026 | $container->_rf[self::RF_NAMED_CONTROLS] = []; |
993 | 1027 | $container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]); |
994 | 1028 | } |
995 | - if(($pos = strpos($id, self::ID_SEPARATOR)) === false) |
|
996 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
997 | - else |
|
1029 | + if(($pos = strpos($id, self::ID_SEPARATOR)) === false) { |
|
1030 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
1031 | + } else |
|
998 | 1032 | { |
999 | 1033 | $cid = substr($id, 0, $pos); |
1000 | 1034 | $sid = substr($id, $pos + 1); |
1001 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
1002 | - return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
|
1003 | - else |
|
1004 | - return null; |
|
1035 | + if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) { |
|
1036 | + return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
|
1037 | + } else { |
|
1038 | + return null; |
|
1039 | + } |
|
1005 | 1040 | } |
1006 | 1041 | } |
1007 | 1042 | |
@@ -1018,10 +1053,12 @@ discard block |
||
1018 | 1053 | { |
1019 | 1054 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1020 | 1055 | { |
1021 | - if(is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) |
|
1022 | - $controls[] = $control; |
|
1023 | - if(($control instanceof TControl) && $control->getHasControls()) |
|
1024 | - $controls = array_merge($controls, $control->findControlsByType($type, $strict)); |
|
1056 | + if(is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) { |
|
1057 | + $controls[] = $control; |
|
1058 | + } |
|
1059 | + if(($control instanceof TControl) && $control->getHasControls()) { |
|
1060 | + $controls = array_merge($controls, $control->findControlsByType($type, $strict)); |
|
1061 | + } |
|
1025 | 1062 | } |
1026 | 1063 | } |
1027 | 1064 | return $controls; |
@@ -1045,8 +1082,9 @@ discard block |
||
1045 | 1082 | { |
1046 | 1083 | if($control instanceof TControl) |
1047 | 1084 | { |
1048 | - if($control->_id === $id) |
|
1049 | - $controls[] = $control; |
|
1085 | + if($control->_id === $id) { |
|
1086 | + $controls[] = $control; |
|
1087 | + } |
|
1050 | 1088 | $controls = array_merge($controls, $control->findControlsByID($id)); |
1051 | 1089 | } |
1052 | 1090 | } |
@@ -1074,8 +1112,9 @@ discard block |
||
1074 | 1112 | */ |
1075 | 1113 | public function registerObject($name, $object) |
1076 | 1114 | { |
1077 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1078 | - throw new TInvalidOperationException('control_object_reregistered', $name); |
|
1115 | + if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
1116 | + throw new TInvalidOperationException('control_object_reregistered', $name); |
|
1117 | + } |
|
1079 | 1118 | $this->_rf[self::RF_NAMED_OBJECTS][$name] = $object; |
1080 | 1119 | } |
1081 | 1120 | |
@@ -1190,8 +1229,9 @@ discard block |
||
1190 | 1229 | final protected function isDescendentOf($ancestor) |
1191 | 1230 | { |
1192 | 1231 | $control = $this; |
1193 | - while($control !== $ancestor && $control->_parent) |
|
1194 | - $control = $control->_parent; |
|
1232 | + while($control !== $ancestor && $control->_parent) { |
|
1233 | + $control = $control->_parent; |
|
1234 | + } |
|
1195 | 1235 | return $control === $ancestor; |
1196 | 1236 | } |
1197 | 1237 | |
@@ -1203,18 +1243,20 @@ discard block |
||
1203 | 1243 | */ |
1204 | 1244 | public function addedControl($control) |
1205 | 1245 | { |
1206 | - if($control->_parent) |
|
1207 | - $control->_parent->getControls()->remove($control); |
|
1246 | + if($control->_parent) { |
|
1247 | + $control->_parent->getControls()->remove($control); |
|
1248 | + } |
|
1208 | 1249 | $control->_parent = $this; |
1209 | 1250 | $control->_page = $this->getPage(); |
1210 | 1251 | $namingContainer = ($this instanceof INamingContainer)?$this:$this->_namingContainer; |
1211 | 1252 | if($namingContainer) |
1212 | 1253 | { |
1213 | 1254 | $control->_namingContainer = $namingContainer; |
1214 | - if($control->_id === '') |
|
1215 | - $control->generateAutomaticID(); |
|
1216 | - else |
|
1217 | - $namingContainer->clearNameTable(); |
|
1255 | + if($control->_id === '') { |
|
1256 | + $control->generateAutomaticID(); |
|
1257 | + } else { |
|
1258 | + $namingContainer->clearNameTable(); |
|
1259 | + } |
|
1218 | 1260 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
1219 | 1261 | } |
1220 | 1262 | |
@@ -1227,15 +1269,16 @@ discard block |
||
1227 | 1269 | { |
1228 | 1270 | $state = $this->_rf[self::RF_CHILD_STATE][$control->_id]; |
1229 | 1271 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
1272 | + } else { |
|
1273 | + $state = null; |
|
1230 | 1274 | } |
1231 | - else |
|
1232 | - $state = null; |
|
1233 | 1275 | $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1234 | 1276 | if($this->_stage >= self::CS_LOADED) |
1235 | 1277 | { |
1236 | 1278 | $control->loadRecursive(); |
1237 | - if($this->_stage >= self::CS_PRERENDERED) |
|
1238 | - $control->preRenderRecursive(); |
|
1279 | + if($this->_stage >= self::CS_PRERENDERED) { |
|
1280 | + $control->preRenderRecursive(); |
|
1281 | + } |
|
1239 | 1282 | } |
1240 | 1283 | } |
1241 | 1284 | } |
@@ -1248,18 +1291,20 @@ discard block |
||
1248 | 1291 | */ |
1249 | 1292 | public function removedControl($control) |
1250 | 1293 | { |
1251 | - if($this->_namingContainer) |
|
1252 | - $this->_namingContainer->clearNameTable(); |
|
1294 | + if($this->_namingContainer) { |
|
1295 | + $this->_namingContainer->clearNameTable(); |
|
1296 | + } |
|
1253 | 1297 | $control->unloadRecursive(); |
1254 | 1298 | $control->_parent = null; |
1255 | 1299 | $control->_page = null; |
1256 | 1300 | $control->_namingContainer = null; |
1257 | 1301 | $control->_tplControl = null; |
1258 | 1302 | //$control->_stage=self::CS_CONSTRUCTED; |
1259 | - if(!($control->_flags & self::IS_ID_SET)) |
|
1260 | - $control->_id = ''; |
|
1261 | - else |
|
1262 | - unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
|
1303 | + if(!($control->_flags & self::IS_ID_SET)) { |
|
1304 | + $control->_id = ''; |
|
1305 | + } else { |
|
1306 | + unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
|
1307 | + } |
|
1263 | 1308 | $control->clearCachedUniqueID(true); |
1264 | 1309 | } |
1265 | 1310 | |
@@ -1273,8 +1318,9 @@ discard block |
||
1273 | 1318 | $this->ensureChildControls(); |
1274 | 1319 | if($this->getHasControls()) |
1275 | 1320 | { |
1276 | - if($this instanceof INamingContainer) |
|
1277 | - $namingContainer = $this; |
|
1321 | + if($this instanceof INamingContainer) { |
|
1322 | + $namingContainer = $this; |
|
1323 | + } |
|
1278 | 1324 | $page = $this->getPage(); |
1279 | 1325 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1280 | 1326 | { |
@@ -1282,8 +1328,9 @@ discard block |
||
1282 | 1328 | { |
1283 | 1329 | $control->_namingContainer = $namingContainer; |
1284 | 1330 | $control->_page = $page; |
1285 | - if($control->_id === '' && $namingContainer) |
|
1286 | - $control->generateAutomaticID(); |
|
1331 | + if($control->_id === '' && $namingContainer) { |
|
1332 | + $control->generateAutomaticID(); |
|
1333 | + } |
|
1287 | 1334 | $control->initRecursive($namingContainer); |
1288 | 1335 | } |
1289 | 1336 | } |
@@ -1296,10 +1343,11 @@ discard block |
||
1296 | 1343 | $page->applyControlSkin($this); |
1297 | 1344 | $this->_flags |= self::IS_SKIN_APPLIED; |
1298 | 1345 | } |
1299 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1300 | - $this->_rf[self::RF_ADAPTER]->onInit(null); |
|
1301 | - else |
|
1302 | - $this->onInit(null); |
|
1346 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1347 | + $this->_rf[self::RF_ADAPTER]->onInit(null); |
|
1348 | + } else { |
|
1349 | + $this->onInit(null); |
|
1350 | + } |
|
1303 | 1351 | $this->_stage = self::CS_INITIALIZED; |
1304 | 1352 | } |
1305 | 1353 | } |
@@ -1312,21 +1360,24 @@ discard block |
||
1312 | 1360 | { |
1313 | 1361 | if($this->_stage < self::CS_LOADED) |
1314 | 1362 | { |
1315 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1316 | - $this->_rf[self::RF_ADAPTER]->onLoad(null); |
|
1317 | - else |
|
1318 | - $this->onLoad(null); |
|
1363 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1364 | + $this->_rf[self::RF_ADAPTER]->onLoad(null); |
|
1365 | + } else { |
|
1366 | + $this->onLoad(null); |
|
1367 | + } |
|
1319 | 1368 | } |
1320 | 1369 | if($this->getHasControls()) |
1321 | 1370 | { |
1322 | 1371 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1323 | 1372 | { |
1324 | - if($control instanceof TControl) |
|
1325 | - $control->loadRecursive(); |
|
1373 | + if($control instanceof TControl) { |
|
1374 | + $control->loadRecursive(); |
|
1375 | + } |
|
1326 | 1376 | } |
1327 | 1377 | } |
1328 | - if($this->_stage < self::CS_LOADED) |
|
1329 | - $this->_stage = self::CS_LOADED; |
|
1378 | + if($this->_stage < self::CS_LOADED) { |
|
1379 | + $this->_stage = self::CS_LOADED; |
|
1380 | + } |
|
1330 | 1381 | } |
1331 | 1382 | |
1332 | 1383 | /** |
@@ -1339,18 +1390,20 @@ discard block |
||
1339 | 1390 | |
1340 | 1391 | if($this->getVisible(false)) |
1341 | 1392 | { |
1342 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1343 | - $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
|
1344 | - else |
|
1345 | - $this->onPreRender(null); |
|
1393 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1394 | + $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
|
1395 | + } else { |
|
1396 | + $this->onPreRender(null); |
|
1397 | + } |
|
1346 | 1398 | if($this->getHasControls()) |
1347 | 1399 | { |
1348 | 1400 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1349 | 1401 | { |
1350 | - if($control instanceof TControl) |
|
1351 | - $control->preRenderRecursive(); |
|
1352 | - elseif($control instanceof TCompositeLiteral) |
|
1353 | - $control->evaluateDynamicContent(); |
|
1402 | + if($control instanceof TControl) { |
|
1403 | + $control->preRenderRecursive(); |
|
1404 | + } elseif($control instanceof TCompositeLiteral) { |
|
1405 | + $control->evaluateDynamicContent(); |
|
1406 | + } |
|
1354 | 1407 | } |
1355 | 1408 | } |
1356 | 1409 | } |
@@ -1363,18 +1416,21 @@ discard block |
||
1363 | 1416 | */ |
1364 | 1417 | protected function unloadRecursive() |
1365 | 1418 | { |
1366 | - if(!($this->_flags & self::IS_ID_SET)) |
|
1367 | - $this->_id = ''; |
|
1419 | + if(!($this->_flags & self::IS_ID_SET)) { |
|
1420 | + $this->_id = ''; |
|
1421 | + } |
|
1368 | 1422 | if($this->getHasControls()) |
1369 | 1423 | { |
1370 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1371 | - if($control instanceof TControl) |
|
1424 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
1425 | + if($control instanceof TControl) |
|
1372 | 1426 | $control->unloadRecursive(); |
1427 | + } |
|
1428 | + } |
|
1429 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1430 | + $this->_rf[self::RF_ADAPTER]->onUnload(null); |
|
1431 | + } else { |
|
1432 | + $this->onUnload(null); |
|
1373 | 1433 | } |
1374 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1375 | - $this->_rf[self::RF_ADAPTER]->onUnload(null); |
|
1376 | - else |
|
1377 | - $this->onUnload(null); |
|
1378 | 1434 | } |
1379 | 1435 | |
1380 | 1436 | /** |
@@ -1449,8 +1505,9 @@ discard block |
||
1449 | 1505 | $control = $this; |
1450 | 1506 | while($control = $control->_parent) |
1451 | 1507 | { |
1452 | - if($control->bubbleEvent($sender, $param)) |
|
1453 | - break; |
|
1508 | + if($control->bubbleEvent($sender, $param)) { |
|
1509 | + break; |
|
1510 | + } |
|
1454 | 1511 | } |
1455 | 1512 | } |
1456 | 1513 | |
@@ -1499,16 +1556,19 @@ discard block |
||
1499 | 1556 | */ |
1500 | 1557 | private function broadcastEventInternal($name, $sender, $param) |
1501 | 1558 | { |
1502 | - if($this->hasEvent($name)) |
|
1503 | - $this->raiseEvent($name, $sender, $param->getParameter()); |
|
1504 | - if($this instanceof IBroadcastEventReceiver) |
|
1505 | - $this->broadcastEventReceived($sender, $param); |
|
1559 | + if($this->hasEvent($name)) { |
|
1560 | + $this->raiseEvent($name, $sender, $param->getParameter()); |
|
1561 | + } |
|
1562 | + if($this instanceof IBroadcastEventReceiver) { |
|
1563 | + $this->broadcastEventReceived($sender, $param); |
|
1564 | + } |
|
1506 | 1565 | if($this->getHasControls()) |
1507 | 1566 | { |
1508 | 1567 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1509 | 1568 | { |
1510 | - if($control instanceof TControl) |
|
1511 | - $control->broadcastEventInternal($name, $sender, $param); |
|
1569 | + if($control instanceof TControl) { |
|
1570 | + $control->broadcastEventInternal($name, $sender, $param); |
|
1571 | + } |
|
1512 | 1572 | } |
1513 | 1573 | } |
1514 | 1574 | } |
@@ -1532,8 +1592,9 @@ discard block |
||
1532 | 1592 | */ |
1533 | 1593 | protected function traverseChildControls($param, $preCallback = null, $postCallback = null) |
1534 | 1594 | { |
1535 | - if($preCallback !== null) |
|
1536 | - call_user_func($preCallback, $this, $param); |
|
1595 | + if($preCallback !== null) { |
|
1596 | + call_user_func($preCallback, $this, $param); |
|
1597 | + } |
|
1537 | 1598 | if($this->getHasControls()) |
1538 | 1599 | { |
1539 | 1600 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
@@ -1544,8 +1605,9 @@ discard block |
||
1544 | 1605 | } |
1545 | 1606 | } |
1546 | 1607 | } |
1547 | - if($postCallback !== null) |
|
1548 | - call_user_func($postCallback, $this, $param); |
|
1608 | + if($postCallback !== null) { |
|
1609 | + call_user_func($postCallback, $this, $param); |
|
1610 | + } |
|
1549 | 1611 | } |
1550 | 1612 | |
1551 | 1613 | /** |
@@ -1557,10 +1619,11 @@ discard block |
||
1557 | 1619 | { |
1558 | 1620 | if($this instanceof IActiveControl || $this->getVisible(false)) |
1559 | 1621 | { |
1560 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1561 | - $this->_rf[self::RF_ADAPTER]->render($writer); |
|
1562 | - else |
|
1563 | - $this->render($writer); |
|
1622 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1623 | + $this->_rf[self::RF_ADAPTER]->render($writer); |
|
1624 | + } else { |
|
1625 | + $this->render($writer); |
|
1626 | + } |
|
1564 | 1627 | } |
1565 | 1628 | } |
1566 | 1629 | |
@@ -1588,12 +1651,13 @@ discard block |
||
1588 | 1651 | { |
1589 | 1652 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1590 | 1653 | { |
1591 | - if(is_string($control)) |
|
1592 | - $writer->write($control); |
|
1593 | - elseif($control instanceof TControl) |
|
1594 | - $control->renderControl($writer); |
|
1595 | - elseif($control instanceof IRenderable) |
|
1596 | - $control->render($writer); |
|
1654 | + if(is_string($control)) { |
|
1655 | + $writer->write($control); |
|
1656 | + } elseif($control instanceof TControl) { |
|
1657 | + $control->renderControl($writer); |
|
1658 | + } elseif($control instanceof IRenderable) { |
|
1659 | + $control->render($writer); |
|
1660 | + } |
|
1597 | 1661 | } |
1598 | 1662 | } |
1599 | 1663 | } |
@@ -1633,15 +1697,16 @@ discard block |
||
1633 | 1697 | { |
1634 | 1698 | $this->_rf[self::RF_CONTROLSTATE] = &$state[1]; |
1635 | 1699 | unset($state[1]); |
1700 | + } else { |
|
1701 | + unset($this->_rf[self::RF_CONTROLSTATE]); |
|
1636 | 1702 | } |
1637 | - else |
|
1638 | - unset($this->_rf[self::RF_CONTROLSTATE]); |
|
1639 | 1703 | if($needViewState) |
1640 | 1704 | { |
1641 | - if(isset($state[0])) |
|
1642 | - $this->_viewState = &$state[0]; |
|
1643 | - else |
|
1644 | - $this->_viewState = []; |
|
1705 | + if(isset($state[0])) { |
|
1706 | + $this->_viewState = &$state[0]; |
|
1707 | + } else { |
|
1708 | + $this->_viewState = []; |
|
1709 | + } |
|
1645 | 1710 | } |
1646 | 1711 | unset($state[0]); |
1647 | 1712 | if($this->getHasControls()) |
@@ -1658,14 +1723,16 @@ discard block |
||
1658 | 1723 | } |
1659 | 1724 | } |
1660 | 1725 | } |
1661 | - if(!empty($state)) |
|
1662 | - $this->_rf[self::RF_CHILD_STATE] = &$state; |
|
1726 | + if(!empty($state)) { |
|
1727 | + $this->_rf[self::RF_CHILD_STATE] = &$state; |
|
1728 | + } |
|
1663 | 1729 | } |
1664 | 1730 | $this->_stage = self::CS_STATE_LOADED; |
1665 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1666 | - $this->_rf[self::RF_ADAPTER]->loadState(); |
|
1667 | - else |
|
1668 | - $this->loadState(); |
|
1731 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1732 | + $this->_rf[self::RF_ADAPTER]->loadState(); |
|
1733 | + } else { |
|
1734 | + $this->loadState(); |
|
1735 | + } |
|
1669 | 1736 | } |
1670 | 1737 | |
1671 | 1738 | /** |
@@ -1676,10 +1743,11 @@ discard block |
||
1676 | 1743 | */ |
1677 | 1744 | protected function &saveStateRecursive($needViewState = true) |
1678 | 1745 | { |
1679 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1680 | - $this->_rf[self::RF_ADAPTER]->saveState(); |
|
1681 | - else |
|
1682 | - $this->saveState(); |
|
1746 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1747 | + $this->_rf[self::RF_ADAPTER]->saveState(); |
|
1748 | + } else { |
|
1749 | + $this->saveState(); |
|
1750 | + } |
|
1683 | 1751 | $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1684 | 1752 | $state = []; |
1685 | 1753 | if($this->getHasControls()) |
@@ -1688,15 +1756,18 @@ discard block |
||
1688 | 1756 | { |
1689 | 1757 | if($control instanceof TControl) |
1690 | 1758 | { |
1691 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1692 | - $state[$control->_id] = $tmp; |
|
1759 | + if(count($tmp = &$control->saveStateRecursive($needViewState))) { |
|
1760 | + $state[$control->_id] = $tmp; |
|
1761 | + } |
|
1693 | 1762 | } |
1694 | 1763 | } |
1695 | 1764 | } |
1696 | - if($needViewState && !empty($this->_viewState)) |
|
1697 | - $state[0] = &$this->_viewState; |
|
1698 | - if(isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1699 | - $state[1] = &$this->_rf[self::RF_CONTROLSTATE]; |
|
1765 | + if($needViewState && !empty($this->_viewState)) { |
|
1766 | + $state[0] = &$this->_viewState; |
|
1767 | + } |
|
1768 | + if(isset($this->_rf[self::RF_CONTROLSTATE])) { |
|
1769 | + $state[1] = &$this->_rf[self::RF_CONTROLSTATE]; |
|
1770 | + } |
|
1700 | 1771 | return $state; |
1701 | 1772 | } |
1702 | 1773 | |
@@ -1711,9 +1782,9 @@ discard block |
||
1711 | 1782 | { |
1712 | 1783 | $page->applyControlStyleSheet($this); |
1713 | 1784 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
1785 | + } elseif($this->_flags & self::IS_STYLESHEET_APPLIED) { |
|
1786 | + throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
|
1714 | 1787 | } |
1715 | - elseif($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1716 | - throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
|
1717 | 1788 | } |
1718 | 1789 | |
1719 | 1790 | /** |
@@ -1725,9 +1796,10 @@ discard block |
||
1725 | 1796 | { |
1726 | 1797 | if($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
1727 | 1798 | { |
1728 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1729 | - if($control instanceof TControl) |
|
1799 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
1800 | + if($control instanceof TControl) |
|
1730 | 1801 | $control->clearCachedUniqueID($recursive); |
1802 | + } |
|
1731 | 1803 | } |
1732 | 1804 | $this->_uid = null; |
1733 | 1805 | } |
@@ -1738,8 +1810,9 @@ discard block |
||
1738 | 1810 | private function generateAutomaticID() |
1739 | 1811 | { |
1740 | 1812 | $this->_flags &= ~self::IS_ID_SET; |
1741 | - if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1742 | - $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0; |
|
1813 | + if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) { |
|
1814 | + $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0; |
|
1815 | + } |
|
1743 | 1816 | $id = $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
1744 | 1817 | $this->_id = self::AUTOMATIC_ID_PREFIX . $id; |
1745 | 1818 | $this->_namingContainer->clearNameTable(); |
@@ -1767,13 +1840,15 @@ discard block |
||
1767 | 1840 | { |
1768 | 1841 | if($control->_id !== '') |
1769 | 1842 | { |
1770 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1771 | - throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
|
1772 | - else |
|
1773 | - $container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control; |
|
1843 | + if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) { |
|
1844 | + throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
|
1845 | + } else { |
|
1846 | + $container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control; |
|
1847 | + } |
|
1848 | + } |
|
1849 | + if(!($control instanceof INamingContainer) && $control->getHasControls()) { |
|
1850 | + $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
|
1774 | 1851 | } |
1775 | - if(!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1776 | - $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
|
1777 | 1852 | } |
1778 | 1853 | } |
1779 | 1854 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function setHistorySize($value) |
87 | 87 | { |
88 | - if(($value = TPropertyValue::ensureInteger($value)) > 0) |
|
88 | + if (($value = TPropertyValue::ensureInteger($value)) > 0) |
|
89 | 89 | $this->_historySize = $value; |
90 | 90 | else |
91 | 91 | throw new TInvalidDataValueException('sessionpagestatepersister_historysize_invalid'); |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | $session = $this->_page->getSession(); |
100 | 100 | $session->open(); |
101 | 101 | $data = serialize($state); |
102 | - $timestamp = (string)microtime(true); |
|
103 | - $key = self::STATE_SESSION_KEY . $timestamp; |
|
102 | + $timestamp = (string) microtime(true); |
|
103 | + $key = self::STATE_SESSION_KEY.$timestamp; |
|
104 | 104 | $session->add($key, $data); |
105 | - if(($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) |
|
105 | + if (($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) |
|
106 | 106 | $queue = []; |
107 | 107 | $queue[] = $key; |
108 | - if(count($queue) > $this->getHistorySize()) |
|
108 | + if (count($queue) > $this->getHistorySize()) |
|
109 | 109 | { |
110 | 110 | $expiredKey = array_shift($queue); |
111 | 111 | $session->remove($expiredKey); |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function load() |
123 | 123 | { |
124 | - if(($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
124 | + if (($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
125 | 125 | { |
126 | 126 | $session = $this->_page->getSession(); |
127 | 127 | $session->open(); |
128 | - $key = self::STATE_SESSION_KEY . $timestamp; |
|
129 | - if(($data = $session->itemAt($key)) !== null) |
|
128 | + $key = self::STATE_SESSION_KEY.$timestamp; |
|
129 | + if (($data = $session->itemAt($key)) !== null) |
|
130 | 130 | return unserialize($data); |
131 | 131 | } |
132 | 132 | throw new THttpException(400, 'sessionpagestatepersister_pagestate_corrupted'); |
@@ -85,10 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function setHistorySize($value) |
87 | 87 | { |
88 | - if(($value = TPropertyValue::ensureInteger($value)) > 0) |
|
89 | - $this->_historySize = $value; |
|
90 | - else |
|
91 | - throw new TInvalidDataValueException('sessionpagestatepersister_historysize_invalid'); |
|
88 | + if(($value = TPropertyValue::ensureInteger($value)) > 0) { |
|
89 | + $this->_historySize = $value; |
|
90 | + } else { |
|
91 | + throw new TInvalidDataValueException('sessionpagestatepersister_historysize_invalid'); |
|
92 | + } |
|
92 | 93 | } |
93 | 94 | /** |
94 | 95 | * Saves state in session. |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | $timestamp = (string)microtime(true); |
103 | 104 | $key = self::STATE_SESSION_KEY . $timestamp; |
104 | 105 | $session->add($key, $data); |
105 | - if(($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) |
|
106 | - $queue = []; |
|
106 | + if(($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) { |
|
107 | + $queue = []; |
|
108 | + } |
|
107 | 109 | $queue[] = $key; |
108 | 110 | if(count($queue) > $this->getHistorySize()) |
109 | 111 | { |
@@ -126,8 +128,9 @@ discard block |
||
126 | 128 | $session = $this->_page->getSession(); |
127 | 129 | $session->open(); |
128 | 130 | $key = self::STATE_SESSION_KEY . $timestamp; |
129 | - if(($data = $session->itemAt($key)) !== null) |
|
130 | - return unserialize($data); |
|
131 | + if(($data = $session->itemAt($key)) !== null) { |
|
132 | + return unserialize($data); |
|
133 | + } |
|
131 | 134 | } |
132 | 135 | throw new THttpException(400, 'sessionpagestatepersister_pagestate_corrupted'); |
133 | 136 | } |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | protected function registerPradoScriptInternal($name) |
169 | 169 | { |
170 | 170 | // $this->checkIfNotInRender(); |
171 | - if(!isset($this->_registeredScripts[$name])) |
|
171 | + if (!isset($this->_registeredScripts[$name])) |
|
172 | 172 | { |
173 | - if(self::$_scripts === null) |
|
173 | + if (self::$_scripts === null) |
|
174 | 174 | { |
175 | - $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::PACKAGES_FILE; |
|
175 | + $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
176 | 176 | list($folders, $packages, $deps) = include($packageFile); |
177 | 177 | self::$_scriptsFolders = $folders; |
178 | 178 | self::$_scripts = $deps; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | else |
185 | 185 | throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
186 | 186 | |
187 | - if(($packages = array_keys($this->_registeredScripts)) !== []) |
|
187 | + if (($packages = array_keys($this->_registeredScripts)) !== []) |
|
188 | 188 | { |
189 | 189 | $packagesUrl = []; |
190 | 190 | $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | list($path, $baseUrl) = $this->getPackagePathUrl($base); |
201 | 201 | |
202 | 202 | $this->_expandedScripts[$script] = true; |
203 | - if($isDebug) |
|
203 | + if ($isDebug) |
|
204 | 204 | { |
205 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
205 | + if (!in_array($url = $baseUrl.'/'.$subPath, $packagesUrl)) |
|
206 | 206 | $packagesUrl[] = $url; |
207 | 207 | } else { |
208 | 208 | $minPath = preg_replace('/^(.*)(?<!\.min)\.js$/', "\\1.min.js", $subPath); |
209 | - if (!in_array($url = $baseUrl . '/' . $minPath, $packagesUrl)) |
|
209 | + if (!in_array($url = $baseUrl.'/'.$minPath, $packagesUrl)) |
|
210 | 210 | { |
211 | - if(!is_file($filePath = $path . DIRECTORY_SEPARATOR . $minPath)) |
|
211 | + if (!is_file($filePath = $path.DIRECTORY_SEPARATOR.$minPath)) |
|
212 | 212 | { |
213 | - file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base . '/' . $subPath))); |
|
213 | + file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$subPath))); |
|
214 | 214 | chmod($filePath, PRADO_CHMOD); |
215 | 215 | } |
216 | 216 | $packagesUrl[] = $url; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | } |
222 | 222 | } |
223 | - foreach($packagesUrl as $url) |
|
223 | + foreach ($packagesUrl as $url) |
|
224 | 224 | $this->registerScriptFile($url, $url); |
225 | 225 | } |
226 | 226 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function getPradoScriptAssetUrl($script = 'prado') |
233 | 233 | { |
234 | - if(!isset(self::$_scriptsFolders[$script])) |
|
234 | + if (!isset(self::$_scriptsFolders[$script])) |
|
235 | 235 | $this->registerPradoScriptInternal($script); |
236 | 236 | |
237 | 237 | $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function getPradoScriptAssetPath($script = 'prado') |
246 | 246 | { |
247 | - if(!isset(self::$_scriptsFolders[$script])) |
|
247 | + if (!isset(self::$_scriptsFolders[$script])) |
|
248 | 248 | $this->registerPradoScriptInternal($script); |
249 | 249 | |
250 | 250 | $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | protected function getPackagePathUrl($base) |
273 | 273 | { |
274 | 274 | $assets = Prado::getApplication()->getAssetManager(); |
275 | - if(strpos($base, $assets->getBaseUrl()) === false) |
|
275 | + if (strpos($base, $assets->getBaseUrl()) === false) |
|
276 | 276 | { |
277 | 277 | return [$assets->getPublishedPath($base), $assets->publishFilePath($base)]; |
278 | 278 | } |
279 | 279 | else |
280 | 280 | { |
281 | - return [$assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base]; |
|
281 | + return [$assets->getBasePath().str_replace($assets->getBaseUrl(), '', $base), $base]; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | { |
291 | 291 | list($base, $subPath) = explode("/", $script, 2); |
292 | 292 | |
293 | - if(!array_key_exists($base, self::$_scriptsFolders)) |
|
293 | + if (!array_key_exists($base, self::$_scriptsFolders)) |
|
294 | 294 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
295 | 295 | |
296 | 296 | $namespace = self::$_scriptsFolders[$base]; |
297 | - if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
297 | + if (($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
298 | 298 | $namespace = $dir; |
299 | 299 | } |
300 | 300 | |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | { |
310 | 310 | list($base, $subPath) = explode("/", $script, 2); |
311 | 311 | |
312 | - if(!array_key_exists($base, self::$_stylesFolders)) |
|
312 | + if (!array_key_exists($base, self::$_stylesFolders)) |
|
313 | 313 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
314 | 314 | |
315 | 315 | $namespace = self::$_stylesFolders[$base]; |
316 | - if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
316 | + if (($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
317 | 317 | $namespace = $dir; |
318 | 318 | } |
319 | 319 | |
@@ -362,10 +362,10 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function registerPostBackControl($class, $options) |
364 | 364 | { |
365 | - if($class === null) { |
|
365 | + if ($class === null) { |
|
366 | 366 | return; |
367 | 367 | } |
368 | - if(!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
368 | + if (!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
369 | 369 | $options['FormID'] = $form->getClientID(); |
370 | 370 | $optionString = TJavaScript::encode($options); |
371 | 371 | $code = "new {$class}({$optionString});"; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | */ |
386 | 386 | public function registerDefaultButton($panel, $button) |
387 | 387 | { |
388 | - $panelID = is_string($panel)?$panel:$panel->getUniqueID(); |
|
388 | + $panelID = is_string($panel) ? $panel : $panel->getUniqueID(); |
|
389 | 389 | |
390 | - if(is_string($button)) |
|
390 | + if (is_string($button)) |
|
391 | 391 | $buttonID = $button; |
392 | 392 | else |
393 | 393 | { |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
398 | 398 | $code = "new Prado.WebUI.DefaultButton($options);"; |
399 | 399 | |
400 | - $this->_endScripts['prado:' . $panelID] = $code; |
|
400 | + $this->_endScripts['prado:'.$panelID] = $code; |
|
401 | 401 | $this->registerPradoScriptInternal('prado'); |
402 | 402 | |
403 | - $params = [$panelID,$buttonID]; |
|
403 | + $params = [$panelID, $buttonID]; |
|
404 | 404 | $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
405 | 405 | } |
406 | 406 | |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | public function registerFocusControl($target) |
427 | 427 | { |
428 | 428 | $this->registerPradoScriptInternal('jquery'); |
429 | - if($target instanceof TControl) |
|
429 | + if ($target instanceof TControl) |
|
430 | 430 | $target = $target->getClientID(); |
431 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();'; |
|
431 | + $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
|
432 | 432 | |
433 | 433 | $params = func_get_args(); |
434 | 434 | $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | protected function registerPradoStyleInternal($name) |
453 | 453 | { |
454 | 454 | // $this->checkIfNotInRender(); |
455 | - if(!isset($this->_registeredStyles[$name])) |
|
455 | + if (!isset($this->_registeredStyles[$name])) |
|
456 | 456 | { |
457 | - if(self::$_styles === null) |
|
457 | + if (self::$_styles === null) |
|
458 | 458 | { |
459 | - $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::CSS_PACKAGES_FILE; |
|
459 | + $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
460 | 460 | list($folders, $packages, $deps) = include($packageFile); |
461 | 461 | self::$_stylesFolders = $folders; |
462 | 462 | self::$_styles = $deps; |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | else |
469 | 469 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
470 | 470 | |
471 | - if(($packages = array_keys($this->_registeredStyles)) !== []) |
|
471 | + if (($packages = array_keys($this->_registeredStyles)) !== []) |
|
472 | 472 | { |
473 | 473 | $packagesUrl = []; |
474 | 474 | $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
@@ -485,13 +485,13 @@ discard block |
||
485 | 485 | |
486 | 486 | $this->_expandedStyles[$style] = true; |
487 | 487 | // TODO minify css? |
488 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
488 | + if (!in_array($url = $baseUrl.'/'.$subPath, $packagesUrl)) |
|
489 | 489 | $packagesUrl[] = $url; |
490 | 490 | } |
491 | 491 | } |
492 | 492 | } |
493 | 493 | } |
494 | - foreach($packagesUrl as $url) |
|
494 | + foreach ($packagesUrl as $url) |
|
495 | 495 | $this->registerStyleSheetFile($url, $url); |
496 | 496 | } |
497 | 497 | } |
@@ -521,10 +521,10 @@ discard block |
||
521 | 521 | */ |
522 | 522 | public function registerStyleSheetFile($key, $url, $media = '') |
523 | 523 | { |
524 | - if($media === '') |
|
524 | + if ($media === '') |
|
525 | 525 | $this->_styleSheetFiles[$key] = $url; |
526 | 526 | else |
527 | - $this->_styleSheetFiles[$key] = [$url,$media]; |
|
527 | + $this->_styleSheetFiles[$key] = [$url, $media]; |
|
528 | 528 | |
529 | 529 | $params = func_get_args(); |
530 | 530 | $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | }, $this->_styleSheetFiles) |
556 | 556 | ); |
557 | 557 | |
558 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) |
|
558 | + foreach (Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) |
|
559 | 559 | if (substr($url, strlen($url) - 4) == '.css') |
560 | 560 | $stylesheets[] = $url; |
561 | 561 | |
@@ -749,12 +749,12 @@ discard block |
||
749 | 749 | public function renderStyleSheetFiles($writer) |
750 | 750 | { |
751 | 751 | $str = ''; |
752 | - foreach($this->_styleSheetFiles as $url) |
|
752 | + foreach ($this->_styleSheetFiles as $url) |
|
753 | 753 | { |
754 | - if(is_array($url)) |
|
755 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
754 | + if (is_array($url)) |
|
755 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
756 | 756 | else |
757 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
757 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
758 | 758 | } |
759 | 759 | $writer->write($str); |
760 | 760 | } |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | */ |
765 | 765 | public function renderStyleSheets($writer) |
766 | 766 | { |
767 | - if(count($this->_styleSheets)) |
|
768 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
767 | + if (count($this->_styleSheets)) |
|
768 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n", $this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | protected function renderScriptFiles($writer, array $scripts) |
805 | 805 | { |
806 | - foreach($scripts as $script) |
|
806 | + foreach ($scripts as $script) |
|
807 | 807 | { |
808 | 808 | $writer->write(TJavaScript::renderScriptFile($script)); |
809 | 809 | $this->markScriptFileAsRendered($script); |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | */ |
821 | 821 | public function renderAllPendingScriptFiles($writer) |
822 | 822 | { |
823 | - if(!empty($this->_scriptFiles)) |
|
823 | + if (!empty($this->_scriptFiles)) |
|
824 | 824 | { |
825 | 825 | $addedScripts = array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
826 | 826 | $this->renderScriptFiles($writer, $addedScripts); |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | */ |
877 | 877 | public function flushScriptFiles($writer, $control = null) |
878 | 878 | { |
879 | - if(!$this->_page->getIsCallback()) |
|
879 | + if (!$this->_page->getIsCallback()) |
|
880 | 880 | { |
881 | 881 | $this->_page->ensureRenderInForm($control); |
882 | 882 | $this->renderAllPendingScriptFiles($writer); |
@@ -895,23 +895,23 @@ discard block |
||
895 | 895 | { |
896 | 896 | if ($initial) $this->_renderedHiddenFields = []; |
897 | 897 | $str = ''; |
898 | - foreach($this->_hiddenFields as $name => $value) |
|
898 | + foreach ($this->_hiddenFields as $name => $value) |
|
899 | 899 | { |
900 | 900 | if (in_array($name, $this->_renderedHiddenFields)) continue; |
901 | 901 | $id = strtr($name, ':', '_'); |
902 | - if(is_array($value)) |
|
902 | + if (is_array($value)) |
|
903 | 903 | { |
904 | - foreach($value as $v) |
|
905 | - $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
904 | + foreach ($value as $v) |
|
905 | + $str .= '<input type="text" style="display:none" autocomplete="off" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
906 | 906 | } |
907 | 907 | else |
908 | 908 | { |
909 | - $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
909 | + $str .= '<input type="text" style="display:none" autocomplete="off" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
910 | 910 | } |
911 | 911 | $this->_renderedHiddenFields[] = $name; |
912 | 912 | } |
913 | - if($str !== '') |
|
914 | - $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
913 | + if ($str !== '') |
|
914 | + $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | public function getHiddenFields() |
@@ -179,10 +179,11 @@ discard block |
||
179 | 179 | self::$_scriptsPackages = $packages; |
180 | 180 | } |
181 | 181 | |
182 | - if (isset(self::$_scripts[$name])) |
|
183 | - $this->_registeredScripts[$name] = true; |
|
184 | - else |
|
185 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
182 | + if (isset(self::$_scripts[$name])) { |
|
183 | + $this->_registeredScripts[$name] = true; |
|
184 | + } else { |
|
185 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
186 | + } |
|
186 | 187 | |
187 | 188 | if(($packages = array_keys($this->_registeredScripts)) !== []) |
188 | 189 | { |
@@ -202,8 +203,9 @@ discard block |
||
202 | 203 | $this->_expandedScripts[$script] = true; |
203 | 204 | if($isDebug) |
204 | 205 | { |
205 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
206 | - $packagesUrl[] = $url; |
|
206 | + if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) { |
|
207 | + $packagesUrl[] = $url; |
|
208 | + } |
|
207 | 209 | } else { |
208 | 210 | $minPath = preg_replace('/^(.*)(?<!\.min)\.js$/', "\\1.min.js", $subPath); |
209 | 211 | if (!in_array($url = $baseUrl . '/' . $minPath, $packagesUrl)) |
@@ -220,8 +222,9 @@ discard block |
||
220 | 222 | } |
221 | 223 | } |
222 | 224 | } |
223 | - foreach($packagesUrl as $url) |
|
224 | - $this->registerScriptFile($url, $url); |
|
225 | + foreach($packagesUrl as $url) { |
|
226 | + $this->registerScriptFile($url, $url); |
|
227 | + } |
|
225 | 228 | } |
226 | 229 | } |
227 | 230 | } |
@@ -231,8 +234,9 @@ discard block |
||
231 | 234 | */ |
232 | 235 | public function getPradoScriptAssetUrl($script = 'prado') |
233 | 236 | { |
234 | - if(!isset(self::$_scriptsFolders[$script])) |
|
235 | - $this->registerPradoScriptInternal($script); |
|
237 | + if(!isset(self::$_scriptsFolders[$script])) { |
|
238 | + $this->registerPradoScriptInternal($script); |
|
239 | + } |
|
236 | 240 | |
237 | 241 | $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
238 | 242 | $assets = Prado::getApplication()->getAssetManager(); |
@@ -244,8 +248,9 @@ discard block |
||
244 | 248 | */ |
245 | 249 | public function getPradoScriptAssetPath($script = 'prado') |
246 | 250 | { |
247 | - if(!isset(self::$_scriptsFolders[$script])) |
|
248 | - $this->registerPradoScriptInternal($script); |
|
251 | + if(!isset(self::$_scriptsFolders[$script])) { |
|
252 | + $this->registerPradoScriptInternal($script); |
|
253 | + } |
|
249 | 254 | |
250 | 255 | $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
251 | 256 | $assets = Prado::getApplication()->getAssetManager(); |
@@ -275,8 +280,7 @@ discard block |
||
275 | 280 | if(strpos($base, $assets->getBaseUrl()) === false) |
276 | 281 | { |
277 | 282 | return [$assets->getPublishedPath($base), $assets->publishFilePath($base)]; |
278 | - } |
|
279 | - else |
|
283 | + } else |
|
280 | 284 | { |
281 | 285 | return [$assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base]; |
282 | 286 | } |
@@ -290,8 +294,9 @@ discard block |
||
290 | 294 | { |
291 | 295 | list($base, $subPath) = explode("/", $script, 2); |
292 | 296 | |
293 | - if(!array_key_exists($base, self::$_scriptsFolders)) |
|
294 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
|
297 | + if(!array_key_exists($base, self::$_scriptsFolders)) { |
|
298 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
|
299 | + } |
|
295 | 300 | |
296 | 301 | $namespace = self::$_scriptsFolders[$base]; |
297 | 302 | if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
@@ -309,8 +314,9 @@ discard block |
||
309 | 314 | { |
310 | 315 | list($base, $subPath) = explode("/", $script, 2); |
311 | 316 | |
312 | - if(!array_key_exists($base, self::$_stylesFolders)) |
|
313 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
|
317 | + if(!array_key_exists($base, self::$_stylesFolders)) { |
|
318 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
|
319 | + } |
|
314 | 320 | |
315 | 321 | $namespace = self::$_stylesFolders[$base]; |
316 | 322 | if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
@@ -365,8 +371,9 @@ discard block |
||
365 | 371 | if($class === null) { |
366 | 372 | return; |
367 | 373 | } |
368 | - if(!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
369 | - $options['FormID'] = $form->getClientID(); |
|
374 | + if(!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) { |
|
375 | + $options['FormID'] = $form->getClientID(); |
|
376 | + } |
|
370 | 377 | $optionString = TJavaScript::encode($options); |
371 | 378 | $code = "new {$class}({$optionString});"; |
372 | 379 | |
@@ -387,9 +394,9 @@ discard block |
||
387 | 394 | { |
388 | 395 | $panelID = is_string($panel)?$panel:$panel->getUniqueID(); |
389 | 396 | |
390 | - if(is_string($button)) |
|
391 | - $buttonID = $button; |
|
392 | - else |
|
397 | + if(is_string($button)) { |
|
398 | + $buttonID = $button; |
|
399 | + } else |
|
393 | 400 | { |
394 | 401 | $button->setIsDefaultButton(true); |
395 | 402 | $buttonID = $button->getUniqueID(); |
@@ -426,8 +433,9 @@ discard block |
||
426 | 433 | public function registerFocusControl($target) |
427 | 434 | { |
428 | 435 | $this->registerPradoScriptInternal('jquery'); |
429 | - if($target instanceof TControl) |
|
430 | - $target = $target->getClientID(); |
|
436 | + if($target instanceof TControl) { |
|
437 | + $target = $target->getClientID(); |
|
438 | + } |
|
431 | 439 | $this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();'; |
432 | 440 | |
433 | 441 | $params = func_get_args(); |
@@ -463,10 +471,11 @@ discard block |
||
463 | 471 | self::$_stylesPackages = $packages; |
464 | 472 | } |
465 | 473 | |
466 | - if (isset(self::$_styles[$name])) |
|
467 | - $this->_registeredStyles[$name] = true; |
|
468 | - else |
|
469 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
|
474 | + if (isset(self::$_styles[$name])) { |
|
475 | + $this->_registeredStyles[$name] = true; |
|
476 | + } else { |
|
477 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
|
478 | + } |
|
470 | 479 | |
471 | 480 | if(($packages = array_keys($this->_registeredStyles)) !== []) |
472 | 481 | { |
@@ -485,14 +494,16 @@ discard block |
||
485 | 494 | |
486 | 495 | $this->_expandedStyles[$style] = true; |
487 | 496 | // TODO minify css? |
488 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
489 | - $packagesUrl[] = $url; |
|
497 | + if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) { |
|
498 | + $packagesUrl[] = $url; |
|
499 | + } |
|
490 | 500 | } |
491 | 501 | } |
492 | 502 | } |
493 | 503 | } |
494 | - foreach($packagesUrl as $url) |
|
495 | - $this->registerStyleSheetFile($url, $url); |
|
504 | + foreach($packagesUrl as $url) { |
|
505 | + $this->registerStyleSheetFile($url, $url); |
|
506 | + } |
|
496 | 507 | } |
497 | 508 | } |
498 | 509 | } |
@@ -521,10 +532,11 @@ discard block |
||
521 | 532 | */ |
522 | 533 | public function registerStyleSheetFile($key, $url, $media = '') |
523 | 534 | { |
524 | - if($media === '') |
|
525 | - $this->_styleSheetFiles[$key] = $url; |
|
526 | - else |
|
527 | - $this->_styleSheetFiles[$key] = [$url,$media]; |
|
535 | + if($media === '') { |
|
536 | + $this->_styleSheetFiles[$key] = $url; |
|
537 | + } else { |
|
538 | + $this->_styleSheetFiles[$key] = [$url,$media]; |
|
539 | + } |
|
528 | 540 | |
529 | 541 | $params = func_get_args(); |
530 | 542 | $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
@@ -555,9 +567,10 @@ discard block |
||
555 | 567 | }, $this->_styleSheetFiles) |
556 | 568 | ); |
557 | 569 | |
558 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) |
|
559 | - if (substr($url, strlen($url) - 4) == '.css') |
|
570 | + foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) { |
|
571 | + if (substr($url, strlen($url) - 4) == '.css') |
|
560 | 572 | $stylesheets[] = $url; |
573 | + } |
|
561 | 574 | |
562 | 575 | $stylesheets = array_unique($stylesheets); |
563 | 576 | |
@@ -751,10 +764,11 @@ discard block |
||
751 | 764 | $str = ''; |
752 | 765 | foreach($this->_styleSheetFiles as $url) |
753 | 766 | { |
754 | - if(is_array($url)) |
|
755 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
756 | - else |
|
757 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
767 | + if(is_array($url)) { |
|
768 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
769 | + } else { |
|
770 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
771 | + } |
|
758 | 772 | } |
759 | 773 | $writer->write($str); |
760 | 774 | } |
@@ -764,8 +778,9 @@ discard block |
||
764 | 778 | */ |
765 | 779 | public function renderStyleSheets($writer) |
766 | 780 | { |
767 | - if(count($this->_styleSheets)) |
|
768 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
781 | + if(count($this->_styleSheets)) { |
|
782 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
783 | + } |
|
769 | 784 | } |
770 | 785 | |
771 | 786 | /** |
@@ -893,25 +908,30 @@ discard block |
||
893 | 908 | |
894 | 909 | protected function renderHiddenFieldsInt($writer, $initial) |
895 | 910 | { |
896 | - if ($initial) $this->_renderedHiddenFields = []; |
|
911 | + if ($initial) { |
|
912 | + $this->_renderedHiddenFields = []; |
|
913 | + } |
|
897 | 914 | $str = ''; |
898 | 915 | foreach($this->_hiddenFields as $name => $value) |
899 | 916 | { |
900 | - if (in_array($name, $this->_renderedHiddenFields)) continue; |
|
917 | + if (in_array($name, $this->_renderedHiddenFields)) { |
|
918 | + continue; |
|
919 | + } |
|
901 | 920 | $id = strtr($name, ':', '_'); |
902 | 921 | if(is_array($value)) |
903 | 922 | { |
904 | - foreach($value as $v) |
|
905 | - $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
906 | - } |
|
907 | - else |
|
923 | + foreach($value as $v) { |
|
924 | + $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
925 | + } |
|
926 | + } else |
|
908 | 927 | { |
909 | 928 | $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
910 | 929 | } |
911 | 930 | $this->_renderedHiddenFields[] = $name; |
912 | 931 | } |
913 | - if($str !== '') |
|
914 | - $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
932 | + if($str !== '') { |
|
933 | + $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
934 | + } |
|
915 | 935 | } |
916 | 936 | |
917 | 937 | public function getHiddenFields() |
@@ -924,7 +944,8 @@ discard block |
||
924 | 944 | */ |
925 | 945 | protected function checkIfNotInRender() |
926 | 946 | { |
927 | - if ($form = $this->_page->InFormRender) |
|
928 | - throw new \Exception('Operation invalid when page is already rendering'); |
|
947 | + if ($form = $this->_page->InFormRender) { |
|
948 | + throw new \Exception('Operation invalid when page is already rendering'); |
|
949 | + } |
|
929 | 950 | } |
930 | 951 | } |