@@ -63,26 +63,26 @@ discard block |
||
| 63 | 63 | /** |
| 64 | 64 | * @var boolean whether to allow custom paging |
| 65 | 65 | */ |
| 66 | - private $_customPaging = false; |
|
| 66 | + private $_customPaging=false; |
|
| 67 | 67 | /** |
| 68 | 68 | * @var integer number of items in each page |
| 69 | 69 | */ |
| 70 | - private $_pageSize = 10; |
|
| 70 | + private $_pageSize=10; |
|
| 71 | 71 | /** |
| 72 | 72 | * @var integer current page index |
| 73 | 73 | */ |
| 74 | - private $_currentPageIndex = -1; |
|
| 74 | + private $_currentPageIndex=-1; |
|
| 75 | 75 | /** |
| 76 | 76 | * @var integer user-assigned number of items in data source |
| 77 | 77 | */ |
| 78 | - private $_virtualCount = -1; |
|
| 78 | + private $_virtualCount=-1; |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Constructor. |
| 82 | 82 | * @param array|Iterator the initial data. Default is null, meaning no initialization. |
| 83 | 83 | * @param boolean whether the list is read-only. Always true for paged list. |
| 84 | 84 | */ |
| 85 | - public function __construct($data = null, $readOnly = false) |
|
| 85 | + public function __construct($data=null, $readOnly=false) |
|
| 86 | 86 | { |
| 87 | 87 | parent::__construct($data, true); |
| 88 | 88 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function setCustomPaging($value) |
| 102 | 102 | { |
| 103 | - $this->_customPaging = TPropertyValue::ensureBoolean($value); |
|
| 103 | + $this->_customPaging=TPropertyValue::ensureBoolean($value); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function setPageSize($value) |
| 118 | 118 | { |
| 119 | - if(($value = TPropertyValue::ensureInteger($value)) > 0) |
|
| 120 | - $this->_pageSize = $value; |
|
| 119 | + if(($value=TPropertyValue::ensureInteger($value)) > 0) |
|
| 120 | + $this->_pageSize=$value; |
|
| 121 | 121 | else |
| 122 | 122 | throw new TInvalidDataValueException('pagedlist_pagesize_invalid'); |
| 123 | 123 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function setCurrentPageIndex($value) |
| 138 | 138 | { |
| 139 | - if($this->gotoPage($value = TPropertyValue::ensureInteger($value)) === false) |
|
| 139 | + if($this->gotoPage($value=TPropertyValue::ensureInteger($value))===false) |
|
| 140 | 140 | throw new TInvalidDataValueException('pagedlist_currentpageindex_invalid'); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -169,21 +169,21 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function gotoPage($pageIndex) |
| 171 | 171 | { |
| 172 | - if($pageIndex === $this->_currentPageIndex) |
|
| 172 | + if($pageIndex===$this->_currentPageIndex) |
|
| 173 | 173 | return $pageIndex; |
| 174 | 174 | if($this->_customPaging) |
| 175 | 175 | { |
| 176 | 176 | if($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount())) |
| 177 | 177 | { |
| 178 | - $param = new TPagedListFetchDataEventParameter($pageIndex, $this->_pageSize * $pageIndex, $this->_pageSize); |
|
| 178 | + $param=new TPagedListFetchDataEventParameter($pageIndex, $this->_pageSize * $pageIndex, $this->_pageSize); |
|
| 179 | 179 | $this->onFetchData($param); |
| 180 | - if(($data = $param->getData()) !== null) |
|
| 180 | + if(($data=$param->getData())!==null) |
|
| 181 | 181 | { |
| 182 | 182 | $this->setReadOnly(false); |
| 183 | 183 | $this->copyFrom($data); |
| 184 | 184 | $this->setReadOnly(true); |
| 185 | - $oldPage = $this->_currentPageIndex; |
|
| 186 | - $this->_currentPageIndex = $pageIndex; |
|
| 185 | + $oldPage=$this->_currentPageIndex; |
|
| 186 | + $this->_currentPageIndex=$pageIndex; |
|
| 187 | 187 | $this->onPageIndexChanged(new TPagedListPageChangedEventParameter($oldPage)); |
| 188 | 188 | return $pageIndex; |
| 189 | 189 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | if($pageIndex >= 0 && $pageIndex < $this->getPageCount()) |
| 199 | 199 | { |
| 200 | - $this->_currentPageIndex = $pageIndex; |
|
| 200 | + $this->_currentPageIndex=$pageIndex; |
|
| 201 | 201 | $this->onPageIndexChanged(null); |
| 202 | 202 | return $pageIndex; |
| 203 | 203 | } |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function setVirtualCount($value) |
| 239 | 239 | { |
| 240 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
| 241 | - $value = -1; |
|
| 242 | - $this->_virtualCount = $value; |
|
| 240 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
| 241 | + $value=-1; |
|
| 242 | + $this->_virtualCount=$value; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -250,12 +250,12 @@ discard block |
||
| 250 | 250 | if($this->_customPaging) |
| 251 | 251 | { |
| 252 | 252 | if($this->_virtualCount >= 0) |
| 253 | - return (int)(($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize); |
|
| 253 | + return (int) (($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize); |
|
| 254 | 254 | else |
| 255 | 255 | return -1; |
| 256 | 256 | } |
| 257 | 257 | else |
| 258 | - return (int)((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize); |
|
| 258 | + return (int) ((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | public function getIsFirstPage() |
| 265 | 265 | { |
| 266 | - return $this->_currentPageIndex === 0; |
|
| 266 | + return $this->_currentPageIndex===0; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | public function getIsLastPage() |
| 273 | 273 | { |
| 274 | - return $this->_currentPageIndex === $this->getPageCount() - 1; |
|
| 274 | + return $this->_currentPageIndex===$this->getPageCount() - 1; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | return parent::getCount(); |
| 284 | 284 | else |
| 285 | 285 | { |
| 286 | - if($this->_currentPageIndex === $this->getPageCount() - 1) |
|
| 286 | + if($this->_currentPageIndex===$this->getPageCount() - 1) |
|
| 287 | 287 | return parent::getCount() - $this->_pageSize * $this->_currentPageIndex; |
| 288 | 288 | else |
| 289 | 289 | return $this->_pageSize; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | return parent::getIterator(); |
| 300 | 300 | else |
| 301 | 301 | { |
| 302 | - $data = $this->toArray(); |
|
| 302 | + $data=$this->toArray(); |
|
| 303 | 303 | return new \ArrayIterator($data); |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -325,9 +325,9 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function indexOf($item) |
| 327 | 327 | { |
| 328 | - $c = $this->getCount(); |
|
| 329 | - for($i = 0;$i < $c;++$i) |
|
| 330 | - if($this->itemAt($i) === $item) |
|
| 328 | + $c=$this->getCount(); |
|
| 329 | + for($i=0; $i < $c; ++$i) |
|
| 330 | + if($this->itemAt($i)===$item) |
|
| 331 | 331 | return $i; |
| 332 | 332 | return -1; |
| 333 | 333 | } |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | public function toArray() |
| 362 | 362 | { |
| 363 | - $c = $this->getCount(); |
|
| 364 | - $array = []; |
|
| 365 | - for($i = 0;$i < $c;++$i) |
|
| 366 | - $array[$i] = $this->itemAt($i); |
|
| 363 | + $c=$this->getCount(); |
|
| 364 | + $array=[]; |
|
| 365 | + for($i=0; $i < $c; ++$i) |
|
| 366 | + $array[$i]=$this->itemAt($i); |
|
| 367 | 367 | return $array; |
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | \ No newline at end of file |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | class TAttributeCollection extends TMap |
| 43 | 43 | { |
| 44 | - private $_caseSensitive = false; |
|
| 44 | + private $_caseSensitive=false; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Returns an array with the names of all variables of this object that should NOT be serialized |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | protected function _getZappableSleepProps(&$exprops) |
| 53 | 53 | { |
| 54 | 54 | parent::_getZappableSleepProps($exprops); |
| 55 | - if ($this->_caseSensitive === false) |
|
| 56 | - $exprops[] = "\0Prado\Collections\TAttributeCollection\0_caseSensitive"; |
|
| 55 | + if($this->_caseSensitive===false) |
|
| 56 | + $exprops[]="\0Prado\Collections\TAttributeCollection\0_caseSensitive"; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function __get($name) |
| 68 | 68 | { |
| 69 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
| 69 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function setCaseSensitive($value) |
| 97 | 97 | { |
| 98 | - $this->_caseSensitive = TPropertyValue::ensureBoolean($value); |
|
| 98 | + $this->_caseSensitive=TPropertyValue::ensureBoolean($value); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function itemAt($key) |
| 108 | 108 | { |
| 109 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
| 109 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function add($key, $value) |
| 120 | 120 | { |
| 121 | - parent::add($this->_caseSensitive?$key:strtolower($key), $value); |
|
| 121 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function remove($key) |
| 131 | 131 | { |
| 132 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
| 132 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function contains($key) |
| 142 | 142 | { |
| 143 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
| 143 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | * internal data storage |
| 42 | 42 | * @var array |
| 43 | 43 | */ |
| 44 | - private $_d = []; |
|
| 44 | + private $_d=[]; |
|
| 45 | 45 | /** |
| 46 | 46 | * number of items |
| 47 | 47 | * @var integer |
| 48 | 48 | */ |
| 49 | - private $_c = 0; |
|
| 49 | + private $_c=0; |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Constructor. |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | * @param array|Iterator the intial data. Default is null, meaning no initialization. |
| 55 | 55 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
| 56 | 56 | */ |
| 57 | - public function __construct($data = null) |
|
| 57 | + public function __construct($data=null) |
|
| 58 | 58 | { |
| 59 | - if($data !== null) |
|
| 59 | + if($data!==null) |
|
| 60 | 60 | $this->copyFrom($data); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | $this->clear(); |
| 82 | 82 | foreach($data as $item) |
| 83 | 83 | { |
| 84 | - $this->_d[] = $item; |
|
| 84 | + $this->_d[]=$item; |
|
| 85 | 85 | ++$this->_c; |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | - elseif($data !== null) |
|
| 88 | + elseif($data!==null) |
|
| 89 | 89 | throw new TInvalidDataTypeException('queue_data_not_iterable'); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function clear() |
| 96 | 96 | { |
| 97 | - $this->_c = 0; |
|
| 98 | - $this->_d = []; |
|
| 97 | + $this->_c=0; |
|
| 98 | + $this->_d=[]; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function contains($item) |
| 106 | 106 | { |
| 107 | - return array_search($item, $this->_d, true) !== false; |
|
| 107 | + return array_search($item, $this->_d, true)!==false; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function peek() |
| 117 | 117 | { |
| 118 | - if($this->_c === 0) |
|
| 118 | + if($this->_c===0) |
|
| 119 | 119 | throw new TInvalidOperationException('queue_empty'); |
| 120 | 120 | else |
| 121 | 121 | return $this->_d[0]; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function dequeue() |
| 130 | 130 | { |
| 131 | - if($this->_c === 0) |
|
| 131 | + if($this->_c===0) |
|
| 132 | 132 | throw new TInvalidOperationException('queue_empty'); |
| 133 | 133 | else |
| 134 | 134 | { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | public function enqueue($item) |
| 145 | 145 | { |
| 146 | 146 | ++$this->_c; |
| 147 | - $this->_d[] = $item; |
|
| 147 | + $this->_d[]=$item; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public static function ensureBoolean($value) |
| 64 | 64 | { |
| 65 | - if (is_string($value)) |
|
| 66 | - return strcasecmp($value, 'true') == 0 || $value != 0; |
|
| 65 | + if(is_string($value)) |
|
| 66 | + return strcasecmp($value, 'true')==0 || $value!=0; |
|
| 67 | 67 | else |
| 68 | - return (boolean)$value; |
|
| 68 | + return (boolean) $value; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public static function ensureString($value) |
| 79 | 79 | { |
| 80 | - if (TJavaScript::isJsLiteral($value)) |
|
| 80 | + if(TJavaScript::isJsLiteral($value)) |
|
| 81 | 81 | return $value; |
| 82 | - if (is_bool($value)) |
|
| 83 | - return $value?'true':'false'; |
|
| 82 | + if(is_bool($value)) |
|
| 83 | + return $value ? 'true' : 'false'; |
|
| 84 | 84 | else |
| 85 | - return (string)$value; |
|
| 85 | + return (string) $value; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public static function ensureInteger($value) |
| 94 | 94 | { |
| 95 | - return (integer)$value; |
|
| 95 | + return (integer) $value; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public static function ensureFloat($value) |
| 104 | 104 | { |
| 105 | - return (float)$value; |
|
| 105 | + return (float) $value; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -118,18 +118,18 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | if(is_string($value)) |
| 120 | 120 | { |
| 121 | - $value = trim($value); |
|
| 122 | - $len = strlen($value); |
|
| 123 | - if ($len >= 2 && $value[0] == '(' && $value[$len - 1] == ')') |
|
| 121 | + $value=trim($value); |
|
| 122 | + $len=strlen($value); |
|
| 123 | + if($len >= 2 && $value[0]=='(' && $value[$len - 1]==')') |
|
| 124 | 124 | { |
| 125 | - eval('$array=array' . $value . ';'); |
|
| 125 | + eval('$array=array'.$value.';'); |
|
| 126 | 126 | return $array; |
| 127 | 127 | } |
| 128 | 128 | else |
| 129 | - return $len > 0?[$value]:[]; |
|
| 129 | + return $len > 0 ? [$value] : []; |
|
| 130 | 130 | } |
| 131 | 131 | else |
| 132 | - return (array)$value; |
|
| 132 | + return (array) $value; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public static function ensureObject($value) |
| 141 | 141 | { |
| 142 | - return (object)$value; |
|
| 142 | + return (object) $value; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public static function ensureEnum($value, $enums) |
| 162 | 162 | { |
| 163 | - static $types = []; |
|
| 164 | - if(func_num_args() === 2 && is_string($enums)) |
|
| 163 | + static $types=[]; |
|
| 164 | + if(func_num_args()===2 && is_string($enums)) |
|
| 165 | 165 | { |
| 166 | 166 | if(!isset($types[$enums])) |
| 167 | - $types[$enums] = new \ReflectionClass($enums); |
|
| 167 | + $types[$enums]=new \ReflectionClass($enums); |
|
| 168 | 168 | if($types[$enums]->hasConstant($value)) |
| 169 | 169 | return $value; |
| 170 | 170 | else |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | elseif(!is_array($enums)) |
| 176 | 176 | { |
| 177 | - $enums = func_get_args(); |
|
| 177 | + $enums=func_get_args(); |
|
| 178 | 178 | array_shift($enums); |
| 179 | 179 | } |
| 180 | 180 | if(in_array($value, $enums, true)) |
@@ -190,6 +190,6 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public static function ensureNullIfEmpty($value) |
| 192 | 192 | { |
| 193 | - return empty($value)?null:$value; |
|
| 193 | + return empty($value) ?null:$value; |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * Name of the value stored in cache |
| 29 | 29 | */ |
| 30 | - const CACHE_NAME = 'prado:appstate'; |
|
| 30 | + const CACHE_NAME='prado:appstate'; |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Initializes module. |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | protected function getStateFilePath() |
| 45 | 45 | { |
| 46 | - return $this->getApplication()->getRuntimePath() . '/global.cache'; |
|
| 46 | + return $this->getApplication()->getRuntimePath().'/global.cache'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function load() |
| 54 | 54 | { |
| 55 | - if(($cache = $this->getApplication()->getCache()) !== null && ($value = $cache->get(self::CACHE_NAME)) !== false) |
|
| 55 | + if(($cache=$this->getApplication()->getCache())!==null && ($value=$cache->get(self::CACHE_NAME))!==false) |
|
| 56 | 56 | return unserialize($value); |
| 57 | 57 | else |
| 58 | 58 | { |
| 59 | - if(($content = @file_get_contents($this->getStateFilePath())) !== false) |
|
| 59 | + if(($content=@file_get_contents($this->getStateFilePath()))!==false) |
|
| 60 | 60 | return unserialize($content); |
| 61 | 61 | else |
| 62 | 62 | return null; |
@@ -69,18 +69,18 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function save($state) |
| 71 | 71 | { |
| 72 | - $content = serialize($state); |
|
| 73 | - $saveFile = true; |
|
| 74 | - if(($cache = $this->getApplication()->getCache()) !== null) |
|
| 72 | + $content=serialize($state); |
|
| 73 | + $saveFile=true; |
|
| 74 | + if(($cache=$this->getApplication()->getCache())!==null) |
|
| 75 | 75 | { |
| 76 | - if($cache->get(self::CACHE_NAME) === $content) |
|
| 77 | - $saveFile = false; |
|
| 76 | + if($cache->get(self::CACHE_NAME)===$content) |
|
| 77 | + $saveFile=false; |
|
| 78 | 78 | else |
| 79 | 79 | $cache->set(self::CACHE_NAME, $content); |
| 80 | 80 | } |
| 81 | 81 | if($saveFile) |
| 82 | 82 | { |
| 83 | - $fileName = $this->getStateFilePath(); |
|
| 83 | + $fileName=$this->getStateFilePath(); |
|
| 84 | 84 | file_put_contents($fileName, $content, LOCK_EX); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public function setID($value) |
| 52 | 52 | { |
| 53 | - $this->_id = $value; |
|
| 53 | + $this->_id=$value; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | class THttpResponse extends \Prado\TModule implements \Prado\IO\ITextWriter |
| 68 | 68 | { |
| 69 | - const DEFAULT_CONTENTTYPE = 'text/html'; |
|
| 70 | - const DEFAULT_CHARSET = 'UTF-8'; |
|
| 69 | + const DEFAULT_CONTENTTYPE='text/html'; |
|
| 70 | + const DEFAULT_CHARSET='UTF-8'; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * @var The differents defined status code by RFC 2616 {@link http://www.faqs.org/rfcs/rfc2616} |
| 74 | 74 | */ |
| 75 | - private static $HTTP_STATUS_CODES = [ |
|
| 75 | + private static $HTTP_STATUS_CODES=[ |
|
| 76 | 76 | 100 => 'Continue', 101 => 'Switching Protocols', |
| 77 | 77 | 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', |
| 78 | 78 | 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @var boolean whether to buffer output |
| 85 | 85 | */ |
| 86 | - private $_bufferOutput = true; |
|
| 86 | + private $_bufferOutput=true; |
|
| 87 | 87 | /** |
| 88 | 88 | * @var boolean if the application is initialized |
| 89 | 89 | */ |
| 90 | - private $_initialized = false; |
|
| 90 | + private $_initialized=false; |
|
| 91 | 91 | /** |
| 92 | 92 | * @var THttpCookieCollection list of cookies to return |
| 93 | 93 | */ |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | /** |
| 96 | 96 | * @var integer response status code |
| 97 | 97 | */ |
| 98 | - private $_status = 200; |
|
| 98 | + private $_status=200; |
|
| 99 | 99 | /** |
| 100 | 100 | * @var string reason correspond to status code |
| 101 | 101 | */ |
| 102 | - private $_reason = 'OK'; |
|
| 102 | + private $_reason='OK'; |
|
| 103 | 103 | /** |
| 104 | 104 | * @var string HTML writer type |
| 105 | 105 | */ |
| 106 | - private $_htmlWriterType = '\Prado\Web\UI\THtmlWriter'; |
|
| 106 | + private $_htmlWriterType='\Prado\Web\UI\THtmlWriter'; |
|
| 107 | 107 | /** |
| 108 | 108 | * @var string content type |
| 109 | 109 | */ |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | /** |
| 112 | 112 | * @var string|boolean character set, e.g. UTF-8 or false if no character set should be send to client |
| 113 | 113 | */ |
| 114 | - private $_charset = ''; |
|
| 114 | + private $_charset=''; |
|
| 115 | 115 | /** |
| 116 | 116 | * @var THttpResponseAdapter adapter. |
| 117 | 117 | */ |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function setAdapter(THttpResponseAdapter $adapter) |
| 142 | 142 | { |
| 143 | - $this->_adapter = $adapter; |
|
| 143 | + $this->_adapter=$adapter; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function getHasAdapter() |
| 158 | 158 | { |
| 159 | - return $this->_adapter !== null; |
|
| 159 | + return $this->_adapter!==null; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | if($this->_bufferOutput) |
| 171 | 171 | ob_start(); |
| 172 | - $this->_initialized = true; |
|
| 172 | + $this->_initialized=true; |
|
| 173 | 173 | $this->getApplication()->setResponse($this); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function setCacheControl($value) |
| 205 | 205 | { |
| 206 | - session_cache_limiter(TPropertyValue::ensureEnum($value, ['none','nocache','private','private_no_expire','public'])); |
|
| 206 | + session_cache_limiter(TPropertyValue::ensureEnum($value, ['none', 'nocache', 'private', 'private_no_expire', 'public'])); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function setContentType($type) |
| 213 | 213 | { |
| 214 | - if ($this->_contentTypeHeaderSent) |
|
| 214 | + if($this->_contentTypeHeaderSent) |
|
| 215 | 215 | throw new \Exception('Unable to alter content-type as it has been already sent'); |
| 216 | - $this->_contentType = $type; |
|
| 216 | + $this->_contentType=$type; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function setCharset($charset) |
| 239 | 239 | { |
| 240 | - $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
|
| 240 | + $this->_charset=(strToLower($charset)==='false') ? false : (string) $charset; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | if($this->_initialized) |
| 258 | 258 | throw new TInvalidOperationException('httpresponse_bufferoutput_unchangeable'); |
| 259 | 259 | else |
| 260 | - $this->_bufferOutput = TPropertyValue::ensureBoolean($value); |
|
| 260 | + $this->_bufferOutput=TPropertyValue::ensureBoolean($value); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -276,24 +276,24 @@ discard block |
||
| 276 | 276 | * @param integer HTTP status code |
| 277 | 277 | * @param string HTTP status reason, defaults to standard HTTP reasons |
| 278 | 278 | */ |
| 279 | - public function setStatusCode($status, $reason = null) |
|
| 279 | + public function setStatusCode($status, $reason=null) |
|
| 280 | 280 | { |
| 281 | - if ($this->_httpHeaderSent) |
|
| 281 | + if($this->_httpHeaderSent) |
|
| 282 | 282 | throw new \Exception('Unable to alter response as HTTP header already sent'); |
| 283 | - $status = TPropertyValue::ensureInteger($status); |
|
| 283 | + $status=TPropertyValue::ensureInteger($status); |
|
| 284 | 284 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
| 285 | - $this->_reason = self::$HTTP_STATUS_CODES[$status]; |
|
| 286 | - }else{ |
|
| 287 | - if($reason === null || $reason === '') { |
|
| 285 | + $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
|
| 286 | + } else { |
|
| 287 | + if($reason===null || $reason==='') { |
|
| 288 | 288 | throw new TInvalidDataValueException("response_status_reason_missing"); |
| 289 | 289 | } |
| 290 | - $reason = TPropertyValue::ensureString($reason); |
|
| 291 | - if(strpos($reason, "\r") != false || strpos($reason, "\n") != false) { |
|
| 290 | + $reason=TPropertyValue::ensureString($reason); |
|
| 291 | + if(strpos($reason, "\r")!=false || strpos($reason, "\n")!=false) { |
|
| 292 | 292 | throw new TInvalidDataValueException("response_status_reason_barchars"); |
| 293 | 293 | } |
| 294 | - $this->_reason = $reason; |
|
| 294 | + $this->_reason=$reason; |
|
| 295 | 295 | } |
| 296 | - $this->_status = $status; |
|
| 296 | + $this->_status=$status; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | public function getCookies() |
| 310 | 310 | { |
| 311 | - if($this->_cookies === null) |
|
| 312 | - $this->_cookies = new THttpCookieCollection($this); |
|
| 311 | + if($this->_cookies===null) |
|
| 312 | + $this->_cookies=new THttpCookieCollection($this); |
|
| 313 | 313 | return $this->_cookies; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | public function write($str) |
| 322 | 322 | { |
| 323 | 323 | // when starting output make sure we send the headers first |
| 324 | - if (!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
| 324 | + if(!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
| 325 | 325 | $this->ensureHeadersSent(); |
| 326 | 326 | echo $str; |
| 327 | 327 | } |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | * @param integer size of file or content in bytes if already known. Defaults to 'null' means auto-detect. |
| 339 | 339 | * @throws TInvalidDataValueException if the file cannot be found |
| 340 | 340 | */ |
| 341 | - public function writeFile($fileName, $content = null, $mimeType = null, $headers = null, $forceDownload = true, $clientFileName = null, $fileSize = null) |
|
| 341 | + public function writeFile($fileName, $content=null, $mimeType=null, $headers=null, $forceDownload=true, $clientFileName=null, $fileSize=null) |
|
| 342 | 342 | { |
| 343 | - static $defaultMimeTypes = [ |
|
| 343 | + static $defaultMimeTypes=[ |
|
| 344 | 344 | 'css' => 'text/css', |
| 345 | 345 | 'gif' => 'image/gif', |
| 346 | 346 | 'png' => 'image/png', |
@@ -353,26 +353,26 @@ discard block |
||
| 353 | 353 | 'xls' => 'application/vnd.ms-excel', |
| 354 | 354 | ]; |
| 355 | 355 | |
| 356 | - if($mimeType === null) |
|
| 356 | + if($mimeType===null) |
|
| 357 | 357 | { |
| 358 | - $mimeType = 'text/plain'; |
|
| 358 | + $mimeType='text/plain'; |
|
| 359 | 359 | if(function_exists('mime_content_type')) |
| 360 | - $mimeType = mime_content_type($fileName); |
|
| 361 | - elseif(($ext = strrchr($fileName, '.')) !== false) |
|
| 360 | + $mimeType=mime_content_type($fileName); |
|
| 361 | + elseif(($ext=strrchr($fileName, '.'))!==false) |
|
| 362 | 362 | { |
| 363 | - $ext = substr($ext, 1); |
|
| 363 | + $ext=substr($ext, 1); |
|
| 364 | 364 | if(isset($defaultMimeTypes[$ext])) |
| 365 | - $mimeType = $defaultMimeTypes[$ext]; |
|
| 365 | + $mimeType=$defaultMimeTypes[$ext]; |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if($clientFileName === null) |
|
| 370 | - $clientFileName = basename($fileName); |
|
| 369 | + if($clientFileName===null) |
|
| 370 | + $clientFileName=basename($fileName); |
|
| 371 | 371 | else |
| 372 | - $clientFileName = basename($clientFileName); |
|
| 372 | + $clientFileName=basename($clientFileName); |
|
| 373 | 373 | |
| 374 | - if($fileSize === null || $fileSize < 0) |
|
| 375 | - $fileSize = ($content === null?filesize($fileName):strlen($content)); |
|
| 374 | + if($fileSize===null || $fileSize < 0) |
|
| 375 | + $fileSize=($content===null ?filesize($fileName) : strlen($content)); |
|
| 376 | 376 | |
| 377 | 377 | $this->sendHttpHeader(); |
| 378 | 378 | if(is_array($headers)) |
@@ -386,13 +386,13 @@ discard block |
||
| 386 | 386 | header('Expires: 0'); |
| 387 | 387 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| 388 | 388 | header("Content-Type: $mimeType"); |
| 389 | - $this->_contentTypeHeaderSent = true; |
|
| 389 | + $this->_contentTypeHeaderSent=true; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - header('Content-Length: ' . $fileSize); |
|
| 393 | - header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\""); |
|
| 392 | + header('Content-Length: '.$fileSize); |
|
| 393 | + header("Content-Disposition: ".($forceDownload ? 'attachment' : 'inline')."; filename=\"$clientFileName\""); |
|
| 394 | 394 | header('Content-Transfer-Encoding: binary'); |
| 395 | - if($content === null) |
|
| 395 | + if($content===null) |
|
| 396 | 396 | readfile($fileName); |
| 397 | 397 | else |
| 398 | 398 | echo $content; |
@@ -430,25 +430,25 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | // Under IIS, explicitly send an HTTP response including the status code |
| 432 | 432 | // this is handled automatically by PHP on Apache and others |
| 433 | - $isIIS = (stripos($this->getRequest()->getServerSoftware(), "microsoft-iis") !== false); |
|
| 434 | - if($url[0] === '/') |
|
| 435 | - $url = $this->getRequest()->getBaseUrl() . $url; |
|
| 436 | - if ($this->_status >= 300 && $this->_status < 400) |
|
| 433 | + $isIIS=(stripos($this->getRequest()->getServerSoftware(), "microsoft-iis")!==false); |
|
| 434 | + if($url[0]==='/') |
|
| 435 | + $url=$this->getRequest()->getBaseUrl().$url; |
|
| 436 | + if($this->_status >= 300 && $this->_status < 400) |
|
| 437 | 437 | { |
| 438 | 438 | // The status code has been modified to a valid redirection status, send it |
| 439 | 439 | if($isIIS) |
| 440 | 440 | { |
| 441 | - header('HTTP/1.1 ' . $this->_status . ' ' . self::$HTTP_STATUS_CODES[ |
|
| 441 | + header('HTTP/1.1 '.$this->_status.' '.self::$HTTP_STATUS_CODES[ |
|
| 442 | 442 | array_key_exists($this->_status, self::$HTTP_STATUS_CODES) |
| 443 | 443 | ? $this->_status |
| 444 | 444 | : 302 |
| 445 | 445 | ]); |
| 446 | 446 | } |
| 447 | - header('Location: ' . str_replace('&', '&', $url), true, $this->_status); |
|
| 447 | + header('Location: '.str_replace('&', '&', $url), true, $this->_status); |
|
| 448 | 448 | } else { |
| 449 | 449 | if($isIIS) |
| 450 | - header('HTTP/1.1 302 ' . self::$HTTP_STATUS_CODES[302]); |
|
| 451 | - header('Location: ' . str_replace('&', '&', $url)); |
|
| 450 | + header('HTTP/1.1 302 '.self::$HTTP_STATUS_CODES[302]); |
|
| 451 | + header('Location: '.str_replace('&', '&', $url)); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | if(!$this->getApplication()->getRequestCompleted()) |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | /** |
| 471 | 471 | * Flush the response contents and headers. |
| 472 | 472 | */ |
| 473 | - public function flush($continueBuffering = true) |
|
| 473 | + public function flush($continueBuffering=true) |
|
| 474 | 474 | { |
| 475 | 475 | if($this->getHasAdapter()) |
| 476 | 476 | $this->_adapter->flushContent($continueBuffering); |
@@ -492,18 +492,18 @@ discard block |
||
| 492 | 492 | * This method is used internally. Please use {@link flush} instead. |
| 493 | 493 | * @param boolean whether to continue buffering after flush if buffering was active |
| 494 | 494 | */ |
| 495 | - public function flushContent($continueBuffering = true) |
|
| 495 | + public function flushContent($continueBuffering=true) |
|
| 496 | 496 | { |
| 497 | 497 | Prado::trace("Flushing output", 'Prado\Web\THttpResponse'); |
| 498 | 498 | $this->ensureHeadersSent(); |
| 499 | 499 | if($this->_bufferOutput) |
| 500 | 500 | { |
| 501 | 501 | // avoid forced send of http headers (ob_flush() does that) if there's no output yet |
| 502 | - if (ob_get_length() > 0) |
|
| 502 | + if(ob_get_length() > 0) |
|
| 503 | 503 | { |
| 504 | - if (!$continueBuffering) |
|
| 504 | + if(!$continueBuffering) |
|
| 505 | 505 | { |
| 506 | - $this->_bufferOutput = false; |
|
| 506 | + $this->_bufferOutput=false; |
|
| 507 | 507 | ob_end_flush(); |
| 508 | 508 | } |
| 509 | 509 | else |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | */ |
| 521 | 521 | protected function ensureHttpHeaderSent() |
| 522 | 522 | { |
| 523 | - if (!$this->_httpHeaderSent) |
|
| 523 | + if(!$this->_httpHeaderSent) |
|
| 524 | 524 | $this->sendHttpHeader(); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -529,13 +529,13 @@ discard block |
||
| 529 | 529 | */ |
| 530 | 530 | protected function sendHttpHeader() |
| 531 | 531 | { |
| 532 | - $protocol = $this->getRequest()->getHttpProtocolVersion(); |
|
| 533 | - if($this->getRequest()->getHttpProtocolVersion() === null) |
|
| 534 | - $protocol = 'HTTP/1.1'; |
|
| 532 | + $protocol=$this->getRequest()->getHttpProtocolVersion(); |
|
| 533 | + if($this->getRequest()->getHttpProtocolVersion()===null) |
|
| 534 | + $protocol='HTTP/1.1'; |
|
| 535 | 535 | |
| 536 | - header($protocol . ' ' . $this->_status . ' ' . $this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
|
| 536 | + header($protocol.' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
|
| 537 | 537 | |
| 538 | - $this->_httpHeaderSent = true; |
|
| 538 | + $this->_httpHeaderSent=true; |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | /** |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | protected function ensureContentTypeHeaderSent() |
| 545 | 545 | { |
| 546 | - if (!$this->_contentTypeHeaderSent) |
|
| 546 | + if(!$this->_contentTypeHeaderSent) |
|
| 547 | 547 | $this->sendContentTypeHeader(); |
| 548 | 548 | } |
| 549 | 549 | |
@@ -552,20 +552,20 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | protected function sendContentTypeHeader() |
| 554 | 554 | { |
| 555 | - $contentType = $this->_contentType === null?self::DEFAULT_CONTENTTYPE:$this->_contentType; |
|
| 556 | - $charset = $this->getCharset(); |
|
| 557 | - if($charset === false) { |
|
| 558 | - $this->appendHeader('Content-Type: ' . $contentType); |
|
| 555 | + $contentType=$this->_contentType===null ?self::DEFAULT_CONTENTTYPE : $this->_contentType; |
|
| 556 | + $charset=$this->getCharset(); |
|
| 557 | + if($charset===false) { |
|
| 558 | + $this->appendHeader('Content-Type: '.$contentType); |
|
| 559 | 559 | return; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - if($charset === '' && ($globalization = $this->getApplication()->getGlobalization(false)) !== null) |
|
| 563 | - $charset = $globalization->getCharset(); |
|
| 562 | + if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) |
|
| 563 | + $charset=$globalization->getCharset(); |
|
| 564 | 564 | |
| 565 | - if($charset === '') $charset = self::DEFAULT_CHARSET; |
|
| 566 | - $this->appendHeader('Content-Type: ' . $contentType . ';charset=' . $charset); |
|
| 565 | + if($charset==='') $charset=self::DEFAULT_CHARSET; |
|
| 566 | + $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); |
|
| 567 | 567 | |
| 568 | - $this->_contentTypeHeaderSent = true; |
|
| 568 | + $this->_contentTypeHeaderSent=true; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | public function getContents() |
| 578 | 578 | { |
| 579 | 579 | Prado::trace("Retrieving output", 'Prado\Web\THttpResponse'); |
| 580 | - return $this->_bufferOutput?ob_get_contents():''; |
|
| 580 | + return $this->_bufferOutput ?ob_get_contents() : ''; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /** |
@@ -594,21 +594,21 @@ discard block |
||
| 594 | 594 | * @param integer|null Either {@link CASE_UPPER} or {@link CASE_LOWER} or as is null (default) |
| 595 | 595 | * @return array |
| 596 | 596 | */ |
| 597 | - public function getHeaders($case = null) |
|
| 597 | + public function getHeaders($case=null) |
|
| 598 | 598 | { |
| 599 | - $result = []; |
|
| 600 | - $headers = headers_list(); |
|
| 599 | + $result=[]; |
|
| 600 | + $headers=headers_list(); |
|
| 601 | 601 | foreach($headers as $header) { |
| 602 | - $tmp = explode(':', $header); |
|
| 603 | - $key = trim(array_shift($tmp)); |
|
| 604 | - $value = trim(implode(':', $tmp)); |
|
| 602 | + $tmp=explode(':', $header); |
|
| 603 | + $key=trim(array_shift($tmp)); |
|
| 604 | + $value=trim(implode(':', $tmp)); |
|
| 605 | 605 | if(isset($result[$key])) |
| 606 | - $result[$key] .= ', ' . $value; |
|
| 606 | + $result[$key].=', '.$value; |
|
| 607 | 607 | else |
| 608 | - $result[$key] = $value; |
|
| 608 | + $result[$key]=$value; |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if($case !== null) |
|
| 611 | + if($case!==null) |
|
| 612 | 612 | return array_change_key_case($result, $case); |
| 613 | 613 | |
| 614 | 614 | return $result; |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * @param string header |
| 620 | 620 | * @param boolean whether the header should replace a previous similar header, or add a second header of the same type |
| 621 | 621 | */ |
| 622 | - public function appendHeader($value, $replace = true) |
|
| 622 | + public function appendHeader($value, $replace=true) |
|
| 623 | 623 | { |
| 624 | 624 | Prado::trace("Sending header '$value'", 'Prado\Web\THttpResponse'); |
| 625 | 625 | header($value, $replace); |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | * @param string The extra headers. It's used when the message parameter is set to 1. This message type uses the same internal function as mail() does. |
| 635 | 635 | * @see http://us2.php.net/manual/en/function.error-log.php |
| 636 | 636 | */ |
| 637 | - public function appendLog($message, $messageType = 0, $destination = '', $extraHeaders = '') |
|
| 637 | + public function appendLog($message, $messageType=0, $destination='', $extraHeaders='') |
|
| 638 | 638 | { |
| 639 | 639 | error_log($message, $messageType, $destination, $extraHeaders); |
| 640 | 640 | } |
@@ -646,10 +646,10 @@ discard block |
||
| 646 | 646 | */ |
| 647 | 647 | public function addCookie($cookie) |
| 648 | 648 | { |
| 649 | - $request = $this->getRequest(); |
|
| 649 | + $request=$this->getRequest(); |
|
| 650 | 650 | if($request->getEnableCookieValidation()) |
| 651 | 651 | { |
| 652 | - $value = $this->getApplication()->getSecurityManager()->hashData($cookie->getValue()); |
|
| 652 | + $value=$this->getApplication()->getSecurityManager()->hashData($cookie->getValue()); |
|
| 653 | 653 | setcookie( |
| 654 | 654 | $cookie->getName(), |
| 655 | 655 | $value, |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | */ |
| 705 | 705 | public function setHtmlWriterType($value) |
| 706 | 706 | { |
| 707 | - $this->_htmlWriterType = $value; |
|
| 707 | + $this->_htmlWriterType=$value; |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | /** |
@@ -712,10 +712,10 @@ discard block |
||
| 712 | 712 | * If the type of the HTML writer is not supplied, {@link getHtmlWriterType HtmlWriterType} will be assumed. |
| 713 | 713 | * @param string type of the HTML writer to be created. If null, {@link getHtmlWriterType HtmlWriterType} will be assumed. |
| 714 | 714 | */ |
| 715 | - public function createHtmlWriter($type = null) |
|
| 715 | + public function createHtmlWriter($type=null) |
|
| 716 | 716 | { |
| 717 | - if($type === null) |
|
| 718 | - $type = $this->getHtmlWriterType(); |
|
| 717 | + if($type===null) |
|
| 718 | + $type=$this->getHtmlWriterType(); |
|
| 719 | 719 | if($this->getHasAdapter()) |
| 720 | 720 | return $this->_adapter->createNewHtmlWriter($type, $this); |
| 721 | 721 | else |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | abstract class TJsonResponse extends \Prado\TApplicationComponent |
| 28 | 28 | { |
| 29 | - private $_id = ''; |
|
| 29 | + private $_id=''; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Initializes the feed. |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function setID($value) |
| 51 | 51 | { |
| 52 | - $this->_id = $value; |
|
| 52 | + $this->_id=$value; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -81,31 +81,31 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * Configuration file name |
| 83 | 83 | */ |
| 84 | - const CONFIG_FILE_XML = 'config.xml'; |
|
| 84 | + const CONFIG_FILE_XML='config.xml'; |
|
| 85 | 85 | /** |
| 86 | 86 | * Configuration file name |
| 87 | 87 | */ |
| 88 | - const CONFIG_FILE_PHP = 'config.php'; |
|
| 88 | + const CONFIG_FILE_PHP='config.php'; |
|
| 89 | 89 | /** |
| 90 | 90 | * Default base path |
| 91 | 91 | */ |
| 92 | - const DEFAULT_BASEPATH = 'Pages'; |
|
| 92 | + const DEFAULT_BASEPATH='Pages'; |
|
| 93 | 93 | /** |
| 94 | 94 | * Fallback base path - used to be the default up to Prado < 3.2 |
| 95 | 95 | */ |
| 96 | - const FALLBACK_BASEPATH = 'pages'; |
|
| 96 | + const FALLBACK_BASEPATH='pages'; |
|
| 97 | 97 | /** |
| 98 | 98 | * Prefix of ID used for storing parsed configuration in cache |
| 99 | 99 | */ |
| 100 | - const CONFIG_CACHE_PREFIX = 'prado:pageservice:'; |
|
| 100 | + const CONFIG_CACHE_PREFIX='prado:pageservice:'; |
|
| 101 | 101 | /** |
| 102 | 102 | * Page template file extension |
| 103 | 103 | */ |
| 104 | - const PAGE_FILE_EXT = '.page'; |
|
| 104 | + const PAGE_FILE_EXT='.page'; |
|
| 105 | 105 | /** |
| 106 | 106 | * Prefix of Pages used for instantiating new pages |
| 107 | 107 | */ |
| 108 | - const PAGE_NAMESPACE_PREFIX = 'Application\\Pages\\'; |
|
| 108 | + const PAGE_NAMESPACE_PREFIX='Application\\Pages\\'; |
|
| 109 | 109 | /** |
| 110 | 110 | * @var string root path of pages |
| 111 | 111 | */ |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | /** |
| 114 | 114 | * @var string base path class in namespace format |
| 115 | 115 | */ |
| 116 | - private $_basePageClass = '\Prado\Web\UI\TPage'; |
|
| 116 | + private $_basePageClass='\Prado\Web\UI\TPage'; |
|
| 117 | 117 | /** |
| 118 | 118 | * @var string clientscript manager class in namespace format |
| 119 | 119 | * @since 3.1.7 |
| 120 | 120 | */ |
| 121 | - private $_clientScriptManagerClass = '\Prado\Web\UI\TClientScriptManager'; |
|
| 121 | + private $_clientScriptManagerClass='\Prado\Web\UI\TClientScriptManager'; |
|
| 122 | 122 | /** |
| 123 | 123 | * @var string default page |
| 124 | 124 | */ |
| 125 | - private $_defaultPage = 'Home'; |
|
| 125 | + private $_defaultPage='Home'; |
|
| 126 | 126 | /** |
| 127 | 127 | * @var string requested page (path) |
| 128 | 128 | */ |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @var array list of initial page property values |
| 136 | 136 | */ |
| 137 | - private $_properties = []; |
|
| 137 | + private $_properties=[]; |
|
| 138 | 138 | /** |
| 139 | 139 | * @var boolean whether service is initialized |
| 140 | 140 | */ |
| 141 | - private $_initialized = false; |
|
| 141 | + private $_initialized=false; |
|
| 142 | 142 | /** |
| 143 | 143 | * @var TThemeManager theme manager |
| 144 | 144 | */ |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | Prado::trace("Initializing TPageService", '\Prado\Web\Services\TPageService'); |
| 159 | 159 | |
| 160 | - $pageConfig = $this->loadPageConfig($config); |
|
| 160 | + $pageConfig=$this->loadPageConfig($config); |
|
| 161 | 161 | |
| 162 | 162 | $this->initPageContext($pageConfig); |
| 163 | 163 | |
| 164 | - $this->_initialized = true; |
|
| 164 | + $this->_initialized=true; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | protected function initPageContext($pageConfig) |
| 175 | 175 | { |
| 176 | - $application = $this->getApplication(); |
|
| 176 | + $application=$this->getApplication(); |
|
| 177 | 177 | foreach($pageConfig->getApplicationConfigurations() as $appConfig) |
| 178 | 178 | $application->applyConfiguration($appConfig); |
| 179 | 179 | |
@@ -187,20 +187,20 @@ discard block |
||
| 187 | 187 | protected function applyConfiguration($config) |
| 188 | 188 | { |
| 189 | 189 | // initial page properties (to be set when page runs) |
| 190 | - $this->_properties = array_merge($this->_properties, $config->getProperties()); |
|
| 190 | + $this->_properties=array_merge($this->_properties, $config->getProperties()); |
|
| 191 | 191 | $this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules()); |
| 192 | - $pagePath = $this->getRequestedPagePath(); |
|
| 192 | + $pagePath=$this->getRequestedPagePath(); |
|
| 193 | 193 | // external configurations |
| 194 | 194 | foreach($config->getExternalConfigurations() as $filePath => $params) |
| 195 | 195 | { |
| 196 | - list($configPagePath, $condition) = $params; |
|
| 197 | - if($condition !== true) |
|
| 198 | - $condition = $this->evaluateExpression($condition); |
|
| 196 | + list($configPagePath, $condition)=$params; |
|
| 197 | + if($condition!==true) |
|
| 198 | + $condition=$this->evaluateExpression($condition); |
|
| 199 | 199 | if($condition) |
| 200 | 200 | { |
| 201 | - if(($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path)) |
|
| 201 | + if(($path=Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 202 | 202 | throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
| 203 | - $c = new TPageConfiguration($pagePath); |
|
| 203 | + $c=new TPageConfiguration($pagePath); |
|
| 204 | 204 | $c->loadFromFile($path, $configPagePath); |
| 205 | 205 | $this->applyConfiguration($c); |
| 206 | 206 | } |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function determineRequestedPagePath() |
| 216 | 216 | { |
| 217 | - $pagePath = $this->getRequest()->getServiceParameter(); |
|
| 217 | + $pagePath=$this->getRequest()->getServiceParameter(); |
|
| 218 | 218 | if(empty($pagePath)) |
| 219 | - $pagePath = $this->getDefaultPage(); |
|
| 219 | + $pagePath=$this->getDefaultPage(); |
|
| 220 | 220 | return $pagePath; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | protected function loadPageConfig($config) |
| 229 | 229 | { |
| 230 | - $application = $this->getApplication(); |
|
| 231 | - $pagePath = $this->getRequestedPagePath(); |
|
| 232 | - if(($cache = $application->getCache()) === null) |
|
| 230 | + $application=$this->getApplication(); |
|
| 231 | + $pagePath=$this->getRequestedPagePath(); |
|
| 232 | + if(($cache=$application->getCache())===null) |
|
| 233 | 233 | { |
| 234 | - $pageConfig = new TPageConfiguration($pagePath); |
|
| 235 | - if($config !== null) |
|
| 234 | + $pageConfig=new TPageConfiguration($pagePath); |
|
| 235 | + if($config!==null) |
|
| 236 | 236 | { |
| 237 | - if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 237 | + if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 238 | 238 | $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
| 239 | 239 | else |
| 240 | 240 | $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
@@ -243,61 +243,61 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | else |
| 245 | 245 | { |
| 246 | - $configCached = true; |
|
| 247 | - $currentTimestamp = []; |
|
| 248 | - $arr = $cache->get(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath); |
|
| 246 | + $configCached=true; |
|
| 247 | + $currentTimestamp=[]; |
|
| 248 | + $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
|
| 249 | 249 | if(is_array($arr)) |
| 250 | 250 | { |
| 251 | - list($pageConfig, $timestamps) = $arr; |
|
| 252 | - if($application->getMode() !== TApplicationMode::Performance) |
|
| 251 | + list($pageConfig, $timestamps)=$arr; |
|
| 252 | + if($application->getMode()!==TApplicationMode::Performance) |
|
| 253 | 253 | { |
| 254 | 254 | foreach($timestamps as $fileName => $timestamp) |
| 255 | 255 | { |
| 256 | - if($fileName === 0) // application config file |
|
| 256 | + if($fileName===0) // application config file |
|
| 257 | 257 | { |
| 258 | - $appConfigFile = $application->getConfigurationFile(); |
|
| 259 | - $currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile); |
|
| 258 | + $appConfigFile=$application->getConfigurationFile(); |
|
| 259 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
| 260 | 260 | if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
| 261 | - $configCached = false; |
|
| 261 | + $configCached=false; |
|
| 262 | 262 | } |
| 263 | 263 | else |
| 264 | 264 | { |
| 265 | - $currentTimestamp[$fileName] = @filemtime($fileName); |
|
| 265 | + $currentTimestamp[$fileName]=@filemtime($fileName); |
|
| 266 | 266 | if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
| 267 | - $configCached = false; |
|
| 267 | + $configCached=false; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | else |
| 273 | 273 | { |
| 274 | - $configCached = false; |
|
| 275 | - $paths = explode('.', $pagePath); |
|
| 276 | - $configPath = $this->getBasePath(); |
|
| 277 | - $fileName = $this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP |
|
| 274 | + $configCached=false; |
|
| 275 | + $paths=explode('.', $pagePath); |
|
| 276 | + $configPath=$this->getBasePath(); |
|
| 277 | + $fileName=$this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 278 | 278 | ? self::CONFIG_FILE_PHP |
| 279 | 279 | : self::CONFIG_FILE_XML; |
| 280 | 280 | foreach($paths as $path) |
| 281 | 281 | { |
| 282 | - $configFile = $configPath . DIRECTORY_SEPARATOR . $fileName; |
|
| 283 | - $currentTimestamp[$configFile] = @filemtime($configFile); |
|
| 284 | - $configPath .= DIRECTORY_SEPARATOR . $path; |
|
| 282 | + $configFile=$configPath.DIRECTORY_SEPARATOR.$fileName; |
|
| 283 | + $currentTimestamp[$configFile]=@filemtime($configFile); |
|
| 284 | + $configPath.=DIRECTORY_SEPARATOR.$path; |
|
| 285 | 285 | } |
| 286 | - $appConfigFile = $application->getConfigurationFile(); |
|
| 287 | - $currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile); |
|
| 286 | + $appConfigFile=$application->getConfigurationFile(); |
|
| 287 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
| 288 | 288 | } |
| 289 | 289 | if(!$configCached) |
| 290 | 290 | { |
| 291 | - $pageConfig = new TPageConfiguration($pagePath); |
|
| 292 | - if($config !== null) |
|
| 291 | + $pageConfig=new TPageConfiguration($pagePath); |
|
| 292 | + if($config!==null) |
|
| 293 | 293 | { |
| 294 | - if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 294 | + if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 295 | 295 | $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
| 296 | 296 | else |
| 297 | 297 | $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
| 298 | 298 | } |
| 299 | 299 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 300 | - $cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, [$pageConfig,$currentTimestamp]); |
|
| 300 | + $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, [$pageConfig, $currentTimestamp]); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | return $pageConfig; |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | { |
| 311 | 311 | if(!$this->_templateManager) |
| 312 | 312 | { |
| 313 | - $this->_templateManager = new TTemplateManager; |
|
| 313 | + $this->_templateManager=new TTemplateManager; |
|
| 314 | 314 | $this->_templateManager->init(null); |
| 315 | 315 | } |
| 316 | 316 | return $this->_templateManager; |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function setTemplateManager(TTemplateManager $value) |
| 323 | 323 | { |
| 324 | - $this->_templateManager = $value; |
|
| 324 | + $this->_templateManager=$value; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | { |
| 332 | 332 | if(!$this->_themeManager) |
| 333 | 333 | { |
| 334 | - $this->_themeManager = new TThemeManager; |
|
| 334 | + $this->_themeManager=new TThemeManager; |
|
| 335 | 335 | $this->_themeManager->init(null); |
| 336 | 336 | } |
| 337 | 337 | return $this->_themeManager; |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function setThemeManager(TThemeManager $value) |
| 344 | 344 | { |
| 345 | - $this->_themeManager = $value; |
|
| 345 | + $this->_themeManager=$value; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | public function getRequestedPagePath() |
| 352 | 352 | { |
| 353 | - if($this->_pagePath === null) |
|
| 353 | + if($this->_pagePath===null) |
|
| 354 | 354 | { |
| 355 | - $this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
| 355 | + $this->_pagePath=strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
| 356 | 356 | if(empty($this->_pagePath)) |
| 357 | 357 | throw new THttpException(404, 'pageservice_page_required'); |
| 358 | 358 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | if($this->_initialized) |
| 385 | 385 | throw new TInvalidOperationException('pageservice_defaultpage_unchangeable'); |
| 386 | 386 | else |
| 387 | - $this->_defaultPage = $value; |
|
| 387 | + $this->_defaultPage=$value; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -400,13 +400,13 @@ discard block |
||
| 400 | 400 | */ |
| 401 | 401 | public function getBasePath() |
| 402 | 402 | { |
| 403 | - if($this->_basePath === null) |
|
| 403 | + if($this->_basePath===null) |
|
| 404 | 404 | { |
| 405 | - $basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
| 406 | - if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) |
|
| 405 | + $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
| 406 | + if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
|
| 407 | 407 | { |
| 408 | - $basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH; |
|
| 409 | - if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) |
|
| 408 | + $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
|
| 409 | + if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
|
| 410 | 410 | throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
| 411 | 411 | } |
| 412 | 412 | } |
@@ -421,9 +421,9 @@ discard block |
||
| 421 | 421 | { |
| 422 | 422 | if($this->_initialized) |
| 423 | 423 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
| 424 | - elseif(($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path)) |
|
| 424 | + elseif(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
|
| 425 | 425 | throw new TConfigurationException('pageservice_basepath_invalid', $value); |
| 426 | - $this->_basePath = realpath($path); |
|
| 426 | + $this->_basePath=realpath($path); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | /** |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | public function setBasePageClass($value) |
| 436 | 436 | { |
| 437 | - $this->_basePageClass = $value; |
|
| 437 | + $this->_basePageClass=$value; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | /** |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function setClientScriptManagerClass($value) |
| 454 | 454 | { |
| 455 | - $this->_clientScriptManagerClass = $value; |
|
| 455 | + $this->_clientScriptManagerClass=$value; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | public function run() |
| 473 | 473 | { |
| 474 | 474 | Prado::trace("Running page service", 'Prado\Web\Services\TPageService'); |
| 475 | - $this->_page = $this->createPage($this->getRequestedPagePath()); |
|
| 475 | + $this->_page=$this->createPage($this->getRequestedPagePath()); |
|
| 476 | 476 | $this->runPage($this->_page, $this->_properties); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -485,40 +485,40 @@ discard block |
||
| 485 | 485 | */ |
| 486 | 486 | protected function createPage($pagePath) |
| 487 | 487 | { |
| 488 | - $path = $this->getBasePath() . DIRECTORY_SEPARATOR . strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
| 489 | - $hasTemplateFile = is_file($path . self::PAGE_FILE_EXT); |
|
| 490 | - $hasClassFile = is_file($path . Prado::CLASS_FILE_EXT); |
|
| 488 | + $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
| 489 | + $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
|
| 490 | + $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
|
| 491 | 491 | |
| 492 | 492 | if(!$hasTemplateFile && !$hasClassFile) |
| 493 | 493 | throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
| 494 | 494 | |
| 495 | 495 | if($hasClassFile) |
| 496 | 496 | { |
| 497 | - $className = basename($path); |
|
| 498 | - $namespacedClassName = static::PAGE_NAMESPACE_PREFIX . str_replace('.', '\\', $pagePath); |
|
| 497 | + $className=basename($path); |
|
| 498 | + $namespacedClassName=static::PAGE_NAMESPACE_PREFIX.str_replace('.', '\\', $pagePath); |
|
| 499 | 499 | |
| 500 | 500 | if(!class_exists($className, false) && !class_exists($namespacedClassName, false)) |
| 501 | - include_once($path . Prado::CLASS_FILE_EXT); |
|
| 501 | + include_once($path.Prado::CLASS_FILE_EXT); |
|
| 502 | 502 | |
| 503 | 503 | if(!class_exists($className, false)) |
| 504 | - $className = $namespacedClassName; |
|
| 504 | + $className=$namespacedClassName; |
|
| 505 | 505 | } |
| 506 | 506 | else |
| 507 | 507 | { |
| 508 | - $className = $this->getBasePageClass(); |
|
| 508 | + $className=$this->getBasePageClass(); |
|
| 509 | 509 | Prado::using($className); |
| 510 | - if(($pos = strrpos($className, '.')) !== false) |
|
| 511 | - $className = substr($className, $pos + 1); |
|
| 510 | + if(($pos=strrpos($className, '.'))!==false) |
|
| 511 | + $className=substr($className, $pos + 1); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - if($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage')) |
|
| 514 | + if($className!=='\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage')) |
|
| 515 | 515 | throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
| 516 | 516 | |
| 517 | - $page = Prado::createComponent($className); |
|
| 517 | + $page=Prado::createComponent($className); |
|
| 518 | 518 | $page->setPagePath($pagePath); |
| 519 | 519 | |
| 520 | 520 | if($hasTemplateFile) |
| 521 | - $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT)); |
|
| 521 | + $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT)); |
|
| 522 | 522 | |
| 523 | 523 | return $page; |
| 524 | 524 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
| 544 | 544 | * @return string URL for the page and GET parameters |
| 545 | 545 | */ |
| 546 | - public function constructUrl($pagePath, $getParams = null, $encodeAmpersand = true, $encodeGetItems = true) |
|
| 546 | + public function constructUrl($pagePath, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
| 547 | 547 | { |
| 548 | 548 | return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
| 549 | 549 | } |