@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected function loadTemplate() |
| 119 | 119 | { |
| 120 | - Prado::trace("Loading template ".get_class($this),'\Prado\Web\UI\TTemplateControl'); |
|
| 120 | + Prado::trace("Loading template ".get_class($this), '\Prado\Web\UI\TTemplateControl'); |
|
| 121 | 121 | $template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
| 122 | 122 | return $template; |
| 123 | 123 | } |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | foreach($tpl->getDirective() as $name=>$value) |
| 135 | 135 | { |
| 136 | 136 | if(is_string($value)) |
| 137 | - $this->setSubProperty($name,$value); |
|
| 137 | + $this->setSubProperty($name, $value); |
|
| 138 | 138 | else |
| 139 | - throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name); |
|
| 139 | + throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name); |
|
| 140 | 140 | } |
| 141 | 141 | $tpl->instantiateIn($this); |
| 142 | 142 | } |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | * @param string ID of the content |
| 148 | 148 | * @param TContent |
| 149 | 149 | */ |
| 150 | - public function registerContent($id,TContent $object) |
|
| 150 | + public function registerContent($id, TContent $object) |
|
| 151 | 151 | { |
| 152 | 152 | if(isset($this->_contents[$id])) |
| 153 | - throw new TConfigurationException('templatecontrol_contentid_duplicated',$id); |
|
| 153 | + throw new TConfigurationException('templatecontrol_contentid_duplicated', $id); |
|
| 154 | 154 | else |
| 155 | 155 | $this->_contents[$id]=$object; |
| 156 | 156 | } |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | * @param string placeholder ID |
| 162 | 162 | * @param TContentPlaceHolder placeholder control |
| 163 | 163 | */ |
| 164 | - public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
|
| 164 | + public function registerContentPlaceHolder($id, TContentPlaceHolder $object) |
|
| 165 | 165 | { |
| 166 | 166 | if(isset($this->_placeholders[$id])) |
| 167 | - throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id); |
|
| 167 | + throw new TConfigurationException('templatecontrol_placeholderid_duplicated', $id); |
|
| 168 | 168 | else |
| 169 | 169 | $this->_placeholders[$id]=$object; |
| 170 | 170 | } |
@@ -199,17 +199,17 @@ discard block |
||
| 199 | 199 | * @param string ID of the content control |
| 200 | 200 | * @param TContent the content to be injected |
| 201 | 201 | */ |
| 202 | - public function injectContent($id,$content) |
|
| 202 | + public function injectContent($id, $content) |
|
| 203 | 203 | { |
| 204 | 204 | if(isset($this->_placeholders[$id])) |
| 205 | 205 | { |
| 206 | 206 | $placeholder=$this->_placeholders[$id]; |
| 207 | 207 | $controls=$placeholder->getParent()->getControls(); |
| 208 | 208 | $loc=$controls->remove($placeholder); |
| 209 | - $controls->insertAt($loc,$content); |
|
| 209 | + $controls->insertAt($loc, $content); |
|
| 210 | 210 | } |
| 211 | 211 | else |
| 212 | - throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
|
| 212 | + throw new TConfigurationException('templatecontrol_placeholder_inexistent', $id); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -233,10 +233,10 @@ discard block |
||
| 233 | 233 | $this->getControls()->add($master); |
| 234 | 234 | $master->ensureChildControls(); |
| 235 | 235 | foreach($this->_contents as $id=>$content) |
| 236 | - $master->injectContent($id,$content); |
|
| 236 | + $master->injectContent($id, $content); |
|
| 237 | 237 | } |
| 238 | 238 | else if(!empty($this->_contents)) |
| 239 | - throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
|
| 239 | + throw new TConfigurationException('templatecontrol_mastercontrol_required', get_class($this)); |
|
| 240 | 240 | parent::initRecursive($namingContainer); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -247,38 +247,38 @@ discard block |
||
| 247 | 247 | * @param Boolean $throwExceptions Wheter or not to throw exceptions |
| 248 | 248 | * @author Daniel Sampedro <[email protected]> |
| 249 | 249 | */ |
| 250 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
| 250 | + public function tryToUpdateView($arObj, $throwExceptions=false) |
|
| 251 | 251 | { |
| 252 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
| 253 | - foreach (array_keys($objAttrs) as $key) |
|
| 252 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
| 253 | + foreach(array_keys($objAttrs) as $key) |
|
| 254 | 254 | { |
| 255 | 255 | try |
| 256 | 256 | { |
| 257 | - if ($key != "RELATIONS") |
|
| 257 | + if($key!="RELATIONS") |
|
| 258 | 258 | { |
| 259 | - $control = $this->{$key}; |
|
| 260 | - if ($control instanceof TTextBox) |
|
| 261 | - $control->Text = $arObj->{$key}; |
|
| 262 | - elseif ($control instanceof TCheckBox) |
|
| 263 | - $control->Checked = (boolean) $arObj->{$key}; |
|
| 264 | - elseif ($control instanceof TDatePicker) |
|
| 265 | - $control->Date = $arObj->{$key}; |
|
| 259 | + $control=$this->{$key}; |
|
| 260 | + if($control instanceof TTextBox) |
|
| 261 | + $control->Text=$arObj->{$key}; |
|
| 262 | + elseif($control instanceof TCheckBox) |
|
| 263 | + $control->Checked=(boolean) $arObj->{$key}; |
|
| 264 | + elseif($control instanceof TDatePicker) |
|
| 265 | + $control->Date=$arObj->{$key}; |
|
| 266 | 266 | } |
| 267 | 267 | else |
| 268 | 268 | { |
| 269 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
| 269 | + foreach($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
| 270 | 270 | { |
| 271 | - $relControl = $this->{$relKey}; |
|
| 272 | - switch ($relValues[0]) |
|
| 271 | + $relControl=$this->{$relKey}; |
|
| 272 | + switch($relValues[0]) |
|
| 273 | 273 | { |
| 274 | 274 | case TActiveRecord::BELONGS_TO: |
| 275 | 275 | case TActiveRecord::HAS_ONE: |
| 276 | - $relControl->Text = $arObj->{$relKey}; |
|
| 276 | + $relControl->Text=$arObj->{$relKey}; |
|
| 277 | 277 | break; |
| 278 | 278 | case TActiveRecord::HAS_MANY: |
| 279 | - if ($relControl instanceof TListControl) |
|
| 279 | + if($relControl instanceof TListControl) |
|
| 280 | 280 | { |
| 281 | - $relControl->DataSource = $arObj->{$relKey}; |
|
| 281 | + $relControl->DataSource=$arObj->{$relKey}; |
|
| 282 | 282 | $relControl->dataBind(); |
| 283 | 283 | } |
| 284 | 284 | break; |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | break; |
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | - catch (Exception $ex) |
|
| 290 | + catch(Exception $ex) |
|
| 291 | 291 | { |
| 292 | - if ($throwExceptions) |
|
| 292 | + if($throwExceptions) |
|
| 293 | 293 | throw $ex; |
| 294 | 294 | } |
| 295 | 295 | } |
@@ -301,26 +301,26 @@ discard block |
||
| 301 | 301 | * @param Boolean $throwExceptions Wheter or not to throw exceptions |
| 302 | 302 | * @author Daniel Sampedro <[email protected]> |
| 303 | 303 | */ |
| 304 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
| 304 | + public function tryToUpdateAR($arObj, $throwExceptions=false) |
|
| 305 | 305 | { |
| 306 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
| 307 | - foreach (array_keys($objAttrs) as $key) |
|
| 306 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
| 307 | + foreach(array_keys($objAttrs) as $key) |
|
| 308 | 308 | { |
| 309 | 309 | try |
| 310 | 310 | { |
| 311 | - if ($key == "RELATIONS") |
|
| 311 | + if($key=="RELATIONS") |
|
| 312 | 312 | break; |
| 313 | - $control = $this->{$key}; |
|
| 314 | - if ($control instanceof TTextBox) |
|
| 315 | - $arObj->{$key} = $control->Text; |
|
| 316 | - elseif ($control instanceof TCheckBox) |
|
| 317 | - $arObj->{$key} = $control->Checked; |
|
| 318 | - elseif ($control instanceof TDatePicker) |
|
| 319 | - $arObj->{$key} = $control->Date; |
|
| 313 | + $control=$this->{$key}; |
|
| 314 | + if($control instanceof TTextBox) |
|
| 315 | + $arObj->{$key}=$control->Text; |
|
| 316 | + elseif($control instanceof TCheckBox) |
|
| 317 | + $arObj->{$key}=$control->Checked; |
|
| 318 | + elseif($control instanceof TDatePicker) |
|
| 319 | + $arObj->{$key}=$control->Date; |
|
| 320 | 320 | } |
| 321 | - catch (Exception $ex) |
|
| 321 | + catch(Exception $ex) |
|
| 322 | 322 | { |
| 323 | - if ($throwExceptions) |
|
| 323 | + if($throwExceptions) |
|
| 324 | 324 | throw $ex; |
| 325 | 325 | } |
| 326 | 326 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | return array( |
| 67 | 67 | 'text' => $this->getText(), |
| 68 | 68 | 'click' => new TJavaScriptLiteral("function(){new Prado.Callback('".$this->getUniqueID()."', 'onClick');}" |
| 69 | - )) ; |
|
| 69 | + )); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function getText() |
| 76 | 76 | { |
| 77 | - return $this->getViewState('Text',''); |
|
| 77 | + return $this->getViewState('Text', ''); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function setText($value) |
| 84 | 84 | { |
| 85 | - $this->setViewState('Text',$value,''); |
|
| 85 | + $this->setViewState('Text', $value, ''); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Raises the OnClick event |
| 90 | 90 | * @param object $params event parameters |
| 91 | 91 | */ |
| 92 | - public function onClick ($params) |
|
| 92 | + public function onClick($params) |
|
| 93 | 93 | { |
| 94 | 94 | $this->raiseEvent('OnClick', $this, $params); |
| 95 | 95 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function raiseCallbackEvent($param) |
| 103 | 103 | { |
| 104 | - if($param->CallbackParameter === 'onClick') |
|
| 104 | + if($param->CallbackParameter==='onClick') |
|
| 105 | 105 | $this->onClick($param); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @since 3.1.9 |
| 39 | 39 | */ |
| 40 | 40 | class TActiveLiteralColumn extends TLiteralColumn { |
| 41 | - protected function initializeHeaderCell($cell,$columnIndex) { |
|
| 41 | + protected function initializeHeaderCell($cell, $columnIndex) { |
|
| 42 | 42 | $text=$this->getHeaderText(); |
| 43 | 43 | |
| 44 | 44 | if(($classPath=$this->getHeaderRenderer())!=='') { |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | else if($this->getAllowSorting()) { |
| 57 | 57 | $sortExpression=$this->getSortExpression(); |
| 58 | 58 | if(($url=$this->getHeaderImageUrl())!=='') { |
| 59 | - $button= new TActiveImageButton; |
|
| 59 | + $button=new TActiveImageButton; |
|
| 60 | 60 | $button->setImageUrl($url); |
| 61 | 61 | $button->setCommandName(TDataGrid::CMD_SORT); |
| 62 | 62 | $button->setCommandParameter($sortExpression); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $cell->getControls()->add($button); |
| 69 | 69 | } |
| 70 | 70 | else if($text!=='') { |
| 71 | - $button= new TActiveLinkButton; |
|
| 71 | + $button=new TActiveLinkButton; |
|
| 72 | 72 | $button->setText($text); |
| 73 | 73 | $button->setCommandName(TDataGrid::CMD_SORT); |
| 74 | 74 | $button->setCommandParameter($sortExpression); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | else { |
| 82 | 82 | if(($url=$this->getHeaderImageUrl())!=='') { |
| 83 | - $image= new TActiveImage; |
|
| 83 | + $image=new TActiveImage; |
|
| 84 | 84 | $image->setImageUrl($url); |
| 85 | 85 | if($text!=='') { |
| 86 | 86 | $image->setAlternateText($text); |
@@ -37,40 +37,40 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Callback response data header name. |
| 39 | 39 | */ |
| 40 | - const CALLBACK_DATA_HEADER = 'X-PRADO-DATA'; |
|
| 40 | + const CALLBACK_DATA_HEADER='X-PRADO-DATA'; |
|
| 41 | 41 | /** |
| 42 | 42 | * Callback response client-side action header name. |
| 43 | 43 | */ |
| 44 | - const CALLBACK_ACTION_HEADER = 'X-PRADO-ACTIONS'; |
|
| 44 | + const CALLBACK_ACTION_HEADER='X-PRADO-ACTIONS'; |
|
| 45 | 45 | /** |
| 46 | 46 | * Callback error header name. |
| 47 | 47 | */ |
| 48 | - const CALLBACK_ERROR_HEADER = 'X-PRADO-ERROR'; |
|
| 48 | + const CALLBACK_ERROR_HEADER='X-PRADO-ERROR'; |
|
| 49 | 49 | /** |
| 50 | 50 | * Callback page state header name. |
| 51 | 51 | */ |
| 52 | - const CALLBACK_PAGESTATE_HEADER = 'X-PRADO-PAGESTATE'; |
|
| 52 | + const CALLBACK_PAGESTATE_HEADER='X-PRADO-PAGESTATE'; |
|
| 53 | 53 | /** |
| 54 | 54 | * Script list header name. |
| 55 | 55 | */ |
| 56 | - const CALLBACK_SCRIPTLIST_HEADER = 'X-PRADO-SCRIPTLIST'; |
|
| 56 | + const CALLBACK_SCRIPTLIST_HEADER='X-PRADO-SCRIPTLIST'; |
|
| 57 | 57 | /** |
| 58 | 58 | * Stylesheet list header name. |
| 59 | 59 | */ |
| 60 | - const CALLBACK_STYLESHEETLIST_HEADER = 'X-PRADO-STYLESHEETLIST'; |
|
| 60 | + const CALLBACK_STYLESHEETLIST_HEADER='X-PRADO-STYLESHEETLIST'; |
|
| 61 | 61 | /** |
| 62 | 62 | * Stylesheet header name. |
| 63 | 63 | */ |
| 64 | - const CALLBACK_STYLESHEET_HEADER = 'X-PRADO-STYLESHEET'; |
|
| 64 | + const CALLBACK_STYLESHEET_HEADER='X-PRADO-STYLESHEET'; |
|
| 65 | 65 | /** |
| 66 | 66 | * Hidden field list header name. |
| 67 | 67 | */ |
| 68 | - const CALLBACK_HIDDENFIELDLIST_HEADER = 'X-PRADO-HIDDENFIELDLIST'; |
|
| 68 | + const CALLBACK_HIDDENFIELDLIST_HEADER='X-PRADO-HIDDENFIELDLIST'; |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Callback redirect url header name. |
| 72 | 72 | */ |
| 73 | - const CALLBACK_REDIRECT = 'X-PRADO-REDIRECT'; |
|
| 73 | + const CALLBACK_REDIRECT='X-PRADO-REDIRECT'; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * @var ICallbackEventHandler callback event handler. |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | parent::__construct($control); |
| 97 | 97 | |
| 98 | 98 | //TODO: can this be done later? |
| 99 | - $response = $this->getApplication()->getResponse(); |
|
| 99 | + $response=$this->getApplication()->getResponse(); |
|
| 100 | 100 | $response->setAdapter(new TCallbackResponseAdapter($response)); |
| 101 | 101 | |
| 102 | 102 | $this->trapCallbackErrorsExceptions(); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function processCallbackEvent($writer) |
| 110 | 110 | { |
| 111 | - Prado::trace("ActivePage raiseCallbackEvent()",'Prado\Web\UI\ActiveControls\TActivePageAdapter'); |
|
| 111 | + Prado::trace("ActivePage raiseCallbackEvent()", 'Prado\Web\UI\ActiveControls\TActivePageAdapter'); |
|
| 112 | 112 | $this->raiseCallbackEvent(); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | * @param TControl control for defered rendering |
| 118 | 118 | * @param THtmlWriter the renderer |
| 119 | 119 | */ |
| 120 | - public function registerControlToRender($control,$writer) |
|
| 120 | + public function registerControlToRender($control, $writer) |
|
| 121 | 121 | { |
| 122 | - $id = $control->getUniqueID(); |
|
| 122 | + $id=$control->getUniqueID(); |
|
| 123 | 123 | if(!isset($this->_controlsToRender[$id])) |
| 124 | - $this->_controlsToRender[$id] = array($control,$writer); |
|
| 124 | + $this->_controlsToRender[$id]=array($control, $writer); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function renderCallbackResponse($writer) |
| 140 | 140 | { |
| 141 | - Prado::trace("ActivePage renderCallbackResponse()",'Prado\Web\UI\ActiveControls\TActivePageAdapter'); |
|
| 142 | - if(($url = $this->getResponse()->getAdapter()->getRedirectedUrl())===null) |
|
| 141 | + Prado::trace("ActivePage renderCallbackResponse()", 'Prado\Web\UI\ActiveControls\TActivePageAdapter'); |
|
| 142 | + if(($url=$this->getResponse()->getAdapter()->getRedirectedUrl())===null) |
|
| 143 | 143 | $this->renderResponse($writer); |
| 144 | 144 | else |
| 145 | 145 | $this->redirect($url); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | protected function redirect($url) |
| 153 | 153 | { |
| 154 | - Prado::trace("ActivePage redirect()",'Prado\Web\UI\ActiveControls\TActivePageAdapter'); |
|
| 154 | + Prado::trace("ActivePage redirect()", 'Prado\Web\UI\ActiveControls\TActivePageAdapter'); |
|
| 155 | 155 | $this->appendContentPart($this->getResponse(), self::CALLBACK_REDIRECT, $url); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -162,31 +162,31 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | protected function renderResponse($writer) |
| 164 | 164 | { |
| 165 | - Prado::trace("ActivePage renderResponse()",'Prado\Web\UI\ActiveControls\TActivePageAdapter'); |
|
| 165 | + Prado::trace("ActivePage renderResponse()", 'Prado\Web\UI\ActiveControls\TActivePageAdapter'); |
|
| 166 | 166 | //renders all the defered render() calls. |
| 167 | 167 | foreach($this->_controlsToRender as $rid => $forRender) |
| 168 | 168 | $forRender[0]->render($forRender[1]); |
| 169 | 169 | |
| 170 | - $response = $this->getResponse(); |
|
| 170 | + $response=$this->getResponse(); |
|
| 171 | 171 | |
| 172 | 172 | //send response data in header |
| 173 | 173 | if($response->getHasAdapter()) |
| 174 | 174 | { |
| 175 | - $responseData = $response->getAdapter()->getResponseData(); |
|
| 175 | + $responseData=$response->getAdapter()->getResponseData(); |
|
| 176 | 176 | if($responseData!==null) |
| 177 | 177 | { |
| 178 | - $data = TJavaScript::jsonEncode($responseData); |
|
| 178 | + $data=TJavaScript::jsonEncode($responseData); |
|
| 179 | 179 | |
| 180 | 180 | $this->appendContentPart($response, self::CALLBACK_DATA_HEADER, $data); |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | //sends page state in header |
| 185 | - if(($handler = $this->getCallbackEventTarget()) !== null) |
|
| 185 | + if(($handler=$this->getCallbackEventTarget())!==null) |
|
| 186 | 186 | { |
| 187 | 187 | if($handler->getActiveControl()->getClientSide()->getEnablePageStateUpdate()) |
| 188 | 188 | { |
| 189 | - $pagestate = $this->getPage()->getClientState(); |
|
| 189 | + $pagestate=$this->getPage()->getClientState(); |
|
| 190 | 190 | $this->appendContentPart($response, self::CALLBACK_PAGESTATE_HEADER, $pagestate); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -197,37 +197,37 @@ discard block |
||
| 197 | 197 | //output the end javascript |
| 198 | 198 | if($this->getPage()->getClientScript()->hasEndScripts()) |
| 199 | 199 | { |
| 200 | - $writer = $response->createHtmlWriter(); |
|
| 200 | + $writer=$response->createHtmlWriter(); |
|
| 201 | 201 | $this->getPage()->getClientScript()->renderEndScriptsCallback($writer); |
| 202 | 202 | $this->getPage()->getCallbackClient()->evaluateScript($writer); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | //output the actions |
| 206 | - $executeJavascript = $this->getCallbackClientHandler()->getClientFunctionsToExecute(); |
|
| 207 | - $actions = TJavaScript::jsonEncode($executeJavascript); |
|
| 206 | + $executeJavascript=$this->getCallbackClientHandler()->getClientFunctionsToExecute(); |
|
| 207 | + $actions=TJavaScript::jsonEncode($executeJavascript); |
|
| 208 | 208 | $this->appendContentPart($response, self::CALLBACK_ACTION_HEADER, $actions); |
| 209 | 209 | |
| 210 | 210 | |
| 211 | - $cs = $this->Page->getClientScript(); |
|
| 211 | + $cs=$this->Page->getClientScript(); |
|
| 212 | 212 | |
| 213 | 213 | // collect all stylesheet file references |
| 214 | - $stylesheets = $cs->getStyleSheetUrls(); |
|
| 215 | - if (count($stylesheets)>0) |
|
| 214 | + $stylesheets=$cs->getStyleSheetUrls(); |
|
| 215 | + if(count($stylesheets) > 0) |
|
| 216 | 216 | $this->appendContentPart($response, self::CALLBACK_STYLESHEETLIST_HEADER, TJavaScript::jsonEncode($stylesheets)); |
| 217 | 217 | |
| 218 | 218 | // collect all stylesheet snippets references |
| 219 | - $stylesheets = $cs->getStyleSheetCodes(); |
|
| 220 | - if (count($stylesheets)>0) |
|
| 219 | + $stylesheets=$cs->getStyleSheetCodes(); |
|
| 220 | + if(count($stylesheets) > 0) |
|
| 221 | 221 | $this->appendContentPart($response, self::CALLBACK_STYLESHEET_HEADER, TJavaScript::jsonEncode($stylesheets)); |
| 222 | 222 | |
| 223 | 223 | // collect all script file references |
| 224 | - $scripts = $cs->getScriptUrls(); |
|
| 225 | - if (count($scripts)>0) |
|
| 224 | + $scripts=$cs->getScriptUrls(); |
|
| 225 | + if(count($scripts) > 0) |
|
| 226 | 226 | $this->appendContentPart($response, self::CALLBACK_SCRIPTLIST_HEADER, TJavaScript::jsonEncode($scripts)); |
| 227 | 227 | |
| 228 | 228 | // collect all hidden field references |
| 229 | - $fields = $cs->getHiddenFields(); |
|
| 230 | - if (count($fields)>0) |
|
| 229 | + $fields=$cs->getHiddenFields(); |
|
| 230 | + if(count($fields) > 0) |
|
| 231 | 231 | $this->appendContentPart($response, self::CALLBACK_HIDDENFIELDLIST_HEADER, TJavaScript::jsonEncode($fields)); |
| 232 | 232 | } |
| 233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | private function appendContentPart($response, $delimiter, $data) |
| 238 | 238 | { |
| 239 | - $content = $response->createHtmlWriter(); |
|
| 239 | + $content=$response->createHtmlWriter(); |
|
| 240 | 240 | $content->getWriter()->setBoundary($delimiter); |
| 241 | 241 | $content->write($data); |
| 242 | 242 | } |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | if($callbackHandler instanceof ICallbackEventHandler) |
| 255 | 255 | { |
| 256 | - $param = $this->getCallbackEventParameter(); |
|
| 257 | - $result = new TCallbackEventParameter($this->getResponse(), $param); |
|
| 256 | + $param=$this->getCallbackEventParameter(); |
|
| 257 | + $result=new TCallbackEventParameter($this->getResponse(), $param); |
|
| 258 | 258 | $callbackHandler->raiseCallbackEvent($result); |
| 259 | 259 | } |
| 260 | 260 | else |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | else |
| 267 | 267 | { |
| 268 | - $target = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET); |
|
| 268 | + $target=$this->getRequest()->itemAt(TPage::FIELD_CALLBACK_TARGET); |
|
| 269 | 269 | throw new TInvalidCallbackException('callback_invalid_target', $target); |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | { |
| 303 | 303 | if($this->_callbackEventParameter===null) |
| 304 | 304 | { |
| 305 | - $param = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
| 305 | + $param=$this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
| 306 | 306 | $this->_callbackEventParameter=$param; |
| 307 | 307 | } |
| 308 | 308 | return $this->_callbackEventParameter; |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | public function getCallbackClientHandler() |
| 325 | 325 | { |
| 326 | 326 | if($this->_callbackClient===null) |
| 327 | - $this->_callbackClient = new TCallbackClientScript; |
|
| 327 | + $this->_callbackClient=new TCallbackClientScript; |
|
| 328 | 328 | return $this->_callbackClient; |
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | \ No newline at end of file |
@@ -74,21 +74,21 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | if(($fileName=$this->getLocalizedTemplate($fileName))!==null) |
| 76 | 76 | { |
| 77 | - Prado::trace("Loading template $fileName",'\Prado\Web\UI\TTemplateManager'); |
|
| 77 | + Prado::trace("Loading template $fileName", '\Prado\Web\UI\TTemplateManager'); |
|
| 78 | 78 | if(($cache=$this->getApplication()->getCache())===null) |
| 79 | - return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName); |
|
| 79 | + return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
| 80 | 80 | else |
| 81 | 81 | { |
| 82 | 82 | $array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName); |
| 83 | 83 | if(is_array($array)) |
| 84 | 84 | { |
| 85 | - list($template,$timestamps)=$array; |
|
| 85 | + list($template, $timestamps)=$array; |
|
| 86 | 86 | if($this->getApplication()->getMode()===TApplicationMode::Performance) |
| 87 | 87 | return $template; |
| 88 | 88 | $cacheValid=true; |
| 89 | 89 | foreach($timestamps as $tplFile=>$timestamp) |
| 90 | 90 | { |
| 91 | - if(!is_file($tplFile) || filemtime($tplFile)>$timestamp) |
|
| 91 | + if(!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
|
| 92 | 92 | { |
| 93 | 93 | $cacheValid=false; |
| 94 | 94 | break; |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | if($cacheValid) |
| 98 | 98 | return $template; |
| 99 | 99 | } |
| 100 | - $template=new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName); |
|
| 100 | + $template=new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
| 101 | 101 | $includedFiles=$template->getIncludedFiles(); |
| 102 | 102 | $timestamps=array(); |
| 103 | 103 | $timestamps[$fileName]=filemtime($fileName); |
| 104 | 104 | foreach($includedFiles as $includedFile) |
| 105 | 105 | $timestamps[$includedFile]=filemtime($includedFile); |
| 106 | - $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps)); |
|
| 106 | + $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName, array($template, $timestamps)); |
|
| 107 | 107 | return $template; |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | protected function getLocalizedTemplate($filename) |
| 120 | 120 | { |
| 121 | 121 | if(($app=$this->getApplication()->getGlobalization(false))===null) |
| 122 | - return is_file($filename)?$filename:null; |
|
| 122 | + return is_file($filename) ? $filename : null; |
|
| 123 | 123 | foreach($app->getLocalizedResource($filename) as $file) |
| 124 | 124 | { |
| 125 | 125 | if(($file=realpath($file))!==false && is_file($file)) |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | if($this->_basePath===null) |
| 92 | 92 | $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
| 93 | 93 | if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
| 94 | - throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath); |
|
| 94 | + throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
|
| 95 | 95 | if($this->_baseUrl===null) |
| 96 | - $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH; |
|
| 96 | + $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\').'/'.self::DEFAULT_BASEPATH; |
|
| 97 | 97 | $application->setAssetManager($this); |
| 98 | 98 | $this->_initialized=true; |
| 99 | 99 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $this->_basePath=Prado::getPathOfNamespace($value); |
| 122 | 122 | if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
| 123 | - throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value); |
|
| 123 | + throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | if($this->_initialized) |
| 142 | 142 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
| 143 | 143 | else |
| 144 | - $this->_baseUrl=rtrim($value,'/'); |
|
| 144 | + $this->_baseUrl=rtrim($value, '/'); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -158,19 +158,19 @@ discard block |
||
| 158 | 158 | * @throws TInvalidDataValueException if the file path to be published is |
| 159 | 159 | * invalid |
| 160 | 160 | */ |
| 161 | - public function publishFilePath($path,$checkTimestamp=false) |
|
| 161 | + public function publishFilePath($path, $checkTimestamp=false) |
|
| 162 | 162 | { |
| 163 | 163 | if(isset($this->_published[$path])) |
| 164 | 164 | return $this->_published[$path]; |
| 165 | 165 | else if(empty($path) || ($fullpath=realpath($path))===false) |
| 166 | - throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path); |
|
| 166 | + throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
|
| 167 | 167 | else if(is_file($fullpath)) |
| 168 | 168 | { |
| 169 | 169 | $dir=$this->hash(dirname($fullpath)); |
| 170 | 170 | $fileName=basename($fullpath); |
| 171 | 171 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
| 172 | 172 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
| 173 | - $this->copyFile($fullpath,$dst); |
|
| 173 | + $this->copyFile($fullpath, $dst); |
|
| 174 | 174 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
| 175 | 175 | } |
| 176 | 176 | else |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | $dir=$this->hash($fullpath); |
| 179 | 179 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
| 180 | 180 | { |
| 181 | - Prado::trace("Publishing directory $fullpath",'Prado\Web\TAssetManager'); |
|
| 182 | - $this->copyDirectory($fullpath,$this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
| 181 | + Prado::trace("Publishing directory $fullpath", 'Prado\Web\TAssetManager'); |
|
| 182 | + $this->copyDirectory($fullpath, $this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
| 183 | 183 | } |
| 184 | 184 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
| 185 | 185 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | protected function setPublished($values=array()) |
| 202 | 202 | { |
| 203 | - $this->_published = $values; |
|
| 203 | + $this->_published=$values; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | protected function hash($dir) |
| 245 | 245 | { |
| 246 | - return sprintf('%x',crc32($dir.Prado::getVersion())); |
|
| 246 | + return sprintf('%x', crc32($dir.Prado::getVersion())); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @param string source file path |
| 254 | 254 | * @param string destination directory (if not exists, it will be created) |
| 255 | 255 | */ |
| 256 | - protected function copyFile($src,$dst) |
|
| 256 | + protected function copyFile($src, $dst) |
|
| 257 | 257 | { |
| 258 | 258 | if(!is_dir($dst)) |
| 259 | 259 | { |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | @chmod($dst, PRADO_CHMOD); |
| 262 | 262 | } |
| 263 | 263 | $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
| 264 | - if(@filemtime($dstFile)<@filemtime($src)) |
|
| 264 | + if(@filemtime($dstFile) < @filemtime($src)) |
|
| 265 | 265 | { |
| 266 | - Prado::trace("Publishing file $src to $dstFile",'Prado\Web\TAssetManager'); |
|
| 267 | - @copy($src,$dstFile); |
|
| 266 | + Prado::trace("Publishing file $src to $dstFile", 'Prado\Web\TAssetManager'); |
|
| 267 | + @copy($src, $dstFile); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * @param string the destination directory |
| 277 | 277 | * @todo a generic solution to ignore certain directories and files |
| 278 | 278 | */ |
| 279 | - public function copyDirectory($src,$dst) |
|
| 279 | + public function copyDirectory($src, $dst) |
|
| 280 | 280 | { |
| 281 | 281 | if(!is_dir($dst)) |
| 282 | 282 | { |
@@ -291,14 +291,14 @@ discard block |
||
| 291 | 291 | continue; |
| 292 | 292 | else if(is_file($src.DIRECTORY_SEPARATOR.$file)) |
| 293 | 293 | { |
| 294 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
| 294 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$file) < @filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
| 295 | 295 | { |
| 296 | - @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
| 296 | + @copy($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
| 297 | 297 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | else |
| 301 | - $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
| 301 | + $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
| 302 | 302 | } |
| 303 | 303 | closedir($folder); |
| 304 | 304 | } else { |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | if(isset($this->_published[$md5sum])) |
| 323 | 323 | return $this->_published[$md5sum]; |
| 324 | 324 | else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
| 325 | - throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum); |
|
| 325 | + throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
|
| 326 | 326 | else |
| 327 | 327 | { |
| 328 | 328 | $dir=$this->hash(dirname($fullpath)); |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
| 331 | 331 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
| 332 | 332 | { |
| 333 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName)<@filemtime($fullpath)) |
|
| 333 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName) < @filemtime($fullpath)) |
|
| 334 | 334 | { |
| 335 | - $this->copyFile($fullpath,$dst); |
|
| 336 | - $this->deployTarFile($tarfile,$dst); |
|
| 335 | + $this->copyFile($fullpath, $dst); |
|
| 336 | + $this->deployTarFile($tarfile, $dst); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | * @param string path where the contents of tar file are to be extracted |
| 348 | 348 | * @return boolean true if extract successful, false otherwise. |
| 349 | 349 | */ |
| 350 | - protected function deployTarFile($path,$destination) |
|
| 350 | + protected function deployTarFile($path, $destination) |
|
| 351 | 351 | { |
| 352 | 352 | if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
| 353 | - throw new TIOException('assetmanager_tarfile_invalid',$path); |
|
| 353 | + throw new TIOException('assetmanager_tarfile_invalid', $path); |
|
| 354 | 354 | else |
| 355 | 355 | { |
| 356 | - $tar = new TTarFileExtractor($fullpath); |
|
| 356 | + $tar=new TTarFileExtractor($fullpath); |
|
| 357 | 357 | return $tar->extract($destination); |
| 358 | 358 | } |
| 359 | 359 | } |