@@ -140,6 +140,7 @@ |
||
140 | 140 | /** |
141 | 141 | * Renders content provided by TJsonResponse::getJsonContent() as |
142 | 142 | * javascript in JSON format. |
143 | + * @param TJsonResponse $service |
|
143 | 144 | */ |
144 | 145 | protected function createJsonResponse($service,$properties,$config) |
145 | 146 | { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @var array registered services |
56 | 56 | */ |
57 | - private $_services=array(); |
|
57 | + private $_services = array(); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Initializes this module. |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected function loadJsonServices($config) |
74 | 74 | { |
75 | - if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
75 | + if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
76 | 76 | { |
77 | - if(is_array($config)) |
|
77 | + if (is_array($config)) |
|
78 | 78 | { |
79 | - foreach($config['json'] as $id => $json) |
|
79 | + foreach ($config['json'] as $id => $json) |
|
80 | 80 | $this->_services[$id] = $json; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | - foreach($config->getElementsByTagName('json') as $json) |
|
85 | + foreach ($config->getElementsByTagName('json') as $json) |
|
86 | 86 | { |
87 | - if(($id=$json->getAttribute('id'))!==null) |
|
88 | - $this->_services[$id]=$json; |
|
87 | + if (($id = $json->getAttribute('id')) !== null) |
|
88 | + $this->_services[$id] = $json; |
|
89 | 89 | else |
90 | 90 | throw new TConfigurationException('jsonservice_id_required'); |
91 | 91 | } |
@@ -98,58 +98,58 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function run() |
100 | 100 | { |
101 | - $id=$this->getRequest()->getServiceParameter(); |
|
102 | - if(isset($this->_services[$id])) |
|
101 | + $id = $this->getRequest()->getServiceParameter(); |
|
102 | + if (isset($this->_services[$id])) |
|
103 | 103 | { |
104 | - $serviceConfig=$this->_services[$id]; |
|
105 | - if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
104 | + $serviceConfig = $this->_services[$id]; |
|
105 | + if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
106 | 106 | { |
107 | - if(isset($serviceConfig['class'])) |
|
107 | + if (isset($serviceConfig['class'])) |
|
108 | 108 | { |
109 | - $service=Prado::createComponent($serviceConfig['class']); |
|
110 | - if($service instanceof TJsonResponse) |
|
109 | + $service = Prado::createComponent($serviceConfig['class']); |
|
110 | + if ($service instanceof TJsonResponse) |
|
111 | 111 | { |
112 | - $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:array(); |
|
113 | - $this->createJsonResponse($service,$properties,$serviceConfig); |
|
112 | + $properties = isset($serviceConfig['properties']) ? $serviceConfig['properties'] : array(); |
|
113 | + $this->createJsonResponse($service, $properties, $serviceConfig); |
|
114 | 114 | } |
115 | 115 | else |
116 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
116 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
117 | 117 | } |
118 | 118 | else |
119 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
119 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
120 | 120 | } |
121 | 121 | else |
122 | 122 | { |
123 | - $properties=$serviceConfig->getAttributes(); |
|
124 | - if(($class=$properties->remove('class'))!==null) |
|
123 | + $properties = $serviceConfig->getAttributes(); |
|
124 | + if (($class = $properties->remove('class')) !== null) |
|
125 | 125 | { |
126 | - $service=Prado::createComponent($class); |
|
127 | - if($service instanceof TJsonResponse) |
|
128 | - $this->createJsonResponse($service,$properties,$serviceConfig); |
|
126 | + $service = Prado::createComponent($class); |
|
127 | + if ($service instanceof TJsonResponse) |
|
128 | + $this->createJsonResponse($service, $properties, $serviceConfig); |
|
129 | 129 | else |
130 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
130 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
131 | 131 | } |
132 | 132 | else |
133 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
133 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | else |
137 | - throw new THttpException(404,'jsonservice_provider_unknown',$id); |
|
137 | + throw new THttpException(404, 'jsonservice_provider_unknown', $id); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Renders content provided by TJsonResponse::getJsonContent() as |
142 | 142 | * javascript in JSON format. |
143 | 143 | */ |
144 | - protected function createJsonResponse($service,$properties,$config) |
|
144 | + protected function createJsonResponse($service, $properties, $config) |
|
145 | 145 | { |
146 | 146 | // init service properties |
147 | - foreach($properties as $name=>$value) |
|
148 | - $service->setSubproperty($name,$value); |
|
147 | + foreach ($properties as $name=>$value) |
|
148 | + $service->setSubproperty($name, $value); |
|
149 | 149 | $service->init($config); |
150 | 150 | |
151 | 151 | //send content if not null |
152 | - if(($content=$service->getJsonContent())!==null) |
|
152 | + if (($content = $service->getJsonContent()) !== null) |
|
153 | 153 | { |
154 | 154 | $response = $this->getResponse(); |
155 | 155 | $response->setContentType('application/json'); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | abstract class TJsonResponse extends TApplicationComponent |
177 | 177 | { |
178 | - private $_id=''; |
|
178 | + private $_id = ''; |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Initializes the feed. |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function setID($value) |
200 | 200 | { |
201 | - $this->_id=$value; |
|
201 | + $this->_id = $value; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | { |
77 | 77 | if(is_array($config)) |
78 | 78 | { |
79 | - foreach($config['json'] as $id => $json) |
|
80 | - $this->_services[$id] = $json; |
|
79 | + foreach($config['json'] as $id => $json) { |
|
80 | + $this->_services[$id] = $json; |
|
81 | + } |
|
81 | 82 | } |
82 | - } |
|
83 | - else |
|
83 | + } else |
|
84 | 84 | { |
85 | 85 | foreach($config->getElementsByTagName('json') as $json) |
86 | 86 | { |
@@ -111,14 +111,11 @@ discard block |
||
111 | 111 | { |
112 | 112 | $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:array(); |
113 | 113 | $this->createJsonResponse($service,$properties,$serviceConfig); |
114 | - } |
|
115 | - else |
|
114 | + } else |
|
116 | 115 | throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
117 | - } |
|
118 | - else |
|
116 | + } else |
|
119 | 117 | throw new TConfigurationException('jsonservice_class_required',$id); |
120 | - } |
|
121 | - else |
|
118 | + } else |
|
122 | 119 | { |
123 | 120 | $properties=$serviceConfig->getAttributes(); |
124 | 121 | if(($class=$properties->remove('class'))!==null) |
@@ -128,12 +125,10 @@ discard block |
||
128 | 125 | $this->createJsonResponse($service,$properties,$serviceConfig); |
129 | 126 | else |
130 | 127 | throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
131 | - } |
|
132 | - else |
|
128 | + } else |
|
133 | 129 | throw new TConfigurationException('jsonservice_class_required',$id); |
134 | 130 | } |
135 | - } |
|
136 | - else |
|
131 | + } else |
|
137 | 132 | throw new THttpException(404,'jsonservice_provider_unknown',$id); |
138 | 133 | } |
139 | 134 | |
@@ -144,8 +139,9 @@ discard block |
||
144 | 139 | protected function createJsonResponse($service,$properties,$config) |
145 | 140 | { |
146 | 141 | // init service properties |
147 | - foreach($properties as $name=>$value) |
|
148 | - $service->setSubproperty($name,$value); |
|
142 | + foreach($properties as $name=>$value) { |
|
143 | + $service->setSubproperty($name,$value); |
|
144 | + } |
|
149 | 145 | $service->init($config); |
150 | 146 | |
151 | 147 | //send content if not null |
@@ -369,6 +369,7 @@ discard block |
||
369 | 369 | |
370 | 370 | /** |
371 | 371 | * @param string default page path to be served if no explicit page is request |
372 | + * @param string $value |
|
372 | 373 | * @throws TInvalidOperationException if the page service is initialized |
373 | 374 | */ |
374 | 375 | public function setDefaultPage($value) |
@@ -528,6 +529,7 @@ discard block |
||
528 | 529 | * @param array list of GET parameters, null if no GET parameters required |
529 | 530 | * @param boolean whether to encode the ampersand in URL, defaults to true. |
530 | 531 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
532 | + * @param string $pagePath |
|
531 | 533 | * @return string URL for the page and GET parameters |
532 | 534 | */ |
533 | 535 | public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
@@ -670,6 +672,9 @@ discard block |
||
670 | 672 | } |
671 | 673 | } |
672 | 674 | |
675 | + /** |
|
676 | + * @param string $configPath |
|
677 | + */ |
|
673 | 678 | public function loadFromPhp($config,$configPath,$configPagePath) |
674 | 679 | { |
675 | 680 | $this->loadApplicationConfigurationFromPhp($config,$configPath); |
@@ -683,6 +688,8 @@ discard block |
||
683 | 688 | * @param TXmlElement config xml element |
684 | 689 | * @param string the directory containing this configuration |
685 | 690 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
691 | + * @param TXmlDocument $dom |
|
692 | + * @param string $configPath |
|
686 | 693 | */ |
687 | 694 | public function loadFromXml($dom,$configPath,$configPagePath) |
688 | 695 | { |
@@ -166,8 +166,9 @@ discard block |
||
166 | 166 | protected function initPageContext($pageConfig) |
167 | 167 | { |
168 | 168 | $application=$this->getApplication(); |
169 | - foreach($pageConfig->getApplicationConfigurations() as $appConfig) |
|
170 | - $application->applyConfiguration($appConfig); |
|
169 | + foreach($pageConfig->getApplicationConfigurations() as $appConfig) { |
|
170 | + $application->applyConfiguration($appConfig); |
|
171 | + } |
|
171 | 172 | |
172 | 173 | $this->applyConfiguration($pageConfig); |
173 | 174 | } |
@@ -232,8 +233,7 @@ discard block |
||
232 | 233 | $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
233 | 234 | } |
234 | 235 | $pageConfig->loadFromFiles($this->getBasePath()); |
235 | - } |
|
236 | - else |
|
236 | + } else |
|
237 | 237 | { |
238 | 238 | $configCached=true; |
239 | 239 | $currentTimestamp=array(); |
@@ -251,8 +251,7 @@ discard block |
||
251 | 251 | $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
252 | 252 | if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
253 | 253 | $configCached=false; |
254 | - } |
|
255 | - else |
|
254 | + } else |
|
256 | 255 | { |
257 | 256 | $currentTimestamp[$fileName]=@filemtime($fileName); |
258 | 257 | if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
@@ -260,8 +259,7 @@ discard block |
||
260 | 259 | } |
261 | 260 | } |
262 | 261 | } |
263 | - } |
|
264 | - else |
|
262 | + } else |
|
265 | 263 | { |
266 | 264 | $configCached=false; |
267 | 265 | $paths=explode('.',$pagePath); |
@@ -489,8 +487,7 @@ discard block |
||
489 | 487 | $className=basename($path); |
490 | 488 | if(!class_exists($className,false)) |
491 | 489 | include_once($path.Prado::CLASS_FILE_EXT); |
492 | - } |
|
493 | - else |
|
490 | + } else |
|
494 | 491 | { |
495 | 492 | $className=$this->getBasePageClass(); |
496 | 493 | Prado::using($className); |
@@ -517,8 +514,9 @@ discard block |
||
517 | 514 | */ |
518 | 515 | protected function runPage($page,$properties) |
519 | 516 | { |
520 | - foreach($properties as $name=>$value) |
|
521 | - $page->setSubProperty($name,$value); |
|
517 | + foreach($properties as $name=>$value) { |
|
518 | + $page->setSubProperty($name,$value); |
|
519 | + } |
|
522 | 520 | $page->run($this->getResponse()->createHtmlWriter()); |
523 | 521 | } |
524 | 522 | |
@@ -659,8 +657,7 @@ discard block |
||
659 | 657 | { |
660 | 658 | $fcontent = include $fname; |
661 | 659 | $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
662 | - } |
|
663 | - else |
|
660 | + } else |
|
664 | 661 | { |
665 | 662 | $dom=new TXmlDocument; |
666 | 663 | if($dom->loadFromFile($fname)) |
@@ -77,68 +77,68 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * Configuration file name |
79 | 79 | */ |
80 | - const CONFIG_FILE_XML='config.xml'; |
|
80 | + const CONFIG_FILE_XML = 'config.xml'; |
|
81 | 81 | /** |
82 | 82 | * Configuration file name |
83 | 83 | */ |
84 | - const CONFIG_FILE_PHP='config.php'; |
|
84 | + const CONFIG_FILE_PHP = 'config.php'; |
|
85 | 85 | /** |
86 | 86 | * Default base path |
87 | 87 | */ |
88 | - const DEFAULT_BASEPATH='Pages'; |
|
88 | + const DEFAULT_BASEPATH = 'Pages'; |
|
89 | 89 | /** |
90 | 90 | * Fallback base path - used to be the default up to Prado < 3.2 |
91 | 91 | */ |
92 | - const FALLBACK_BASEPATH='pages'; |
|
92 | + const FALLBACK_BASEPATH = 'pages'; |
|
93 | 93 | /** |
94 | 94 | * Prefix of ID used for storing parsed configuration in cache |
95 | 95 | */ |
96 | - const CONFIG_CACHE_PREFIX='prado:pageservice:'; |
|
96 | + const CONFIG_CACHE_PREFIX = 'prado:pageservice:'; |
|
97 | 97 | /** |
98 | 98 | * Page template file extension |
99 | 99 | */ |
100 | - const PAGE_FILE_EXT='.page'; |
|
100 | + const PAGE_FILE_EXT = '.page'; |
|
101 | 101 | /** |
102 | 102 | * @var string root path of pages |
103 | 103 | */ |
104 | - private $_basePath=null; |
|
104 | + private $_basePath = null; |
|
105 | 105 | /** |
106 | 106 | * @var string base path class in namespace format |
107 | 107 | */ |
108 | - private $_basePageClass='TPage'; |
|
108 | + private $_basePageClass = 'TPage'; |
|
109 | 109 | /** |
110 | 110 | * @var string clientscript manager class in namespace format |
111 | 111 | * @since 3.1.7 |
112 | 112 | */ |
113 | - private $_clientScriptManagerClass='System.Web.UI.TClientScriptManager'; |
|
113 | + private $_clientScriptManagerClass = 'System.Web.UI.TClientScriptManager'; |
|
114 | 114 | /** |
115 | 115 | * @var string default page |
116 | 116 | */ |
117 | - private $_defaultPage='Home'; |
|
117 | + private $_defaultPage = 'Home'; |
|
118 | 118 | /** |
119 | 119 | * @var string requested page (path) |
120 | 120 | */ |
121 | - private $_pagePath=null; |
|
121 | + private $_pagePath = null; |
|
122 | 122 | /** |
123 | 123 | * @var TPage the requested page |
124 | 124 | */ |
125 | - private $_page=null; |
|
125 | + private $_page = null; |
|
126 | 126 | /** |
127 | 127 | * @var array list of initial page property values |
128 | 128 | */ |
129 | - private $_properties=array(); |
|
129 | + private $_properties = array(); |
|
130 | 130 | /** |
131 | 131 | * @var boolean whether service is initialized |
132 | 132 | */ |
133 | - private $_initialized=false; |
|
133 | + private $_initialized = false; |
|
134 | 134 | /** |
135 | 135 | * @var TThemeManager theme manager |
136 | 136 | */ |
137 | - private $_themeManager=null; |
|
137 | + private $_themeManager = null; |
|
138 | 138 | /** |
139 | 139 | * @var TTemplateManager template manager |
140 | 140 | */ |
141 | - private $_templateManager=null; |
|
141 | + private $_templateManager = null; |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Initializes the service. |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function init($config) |
149 | 149 | { |
150 | - Prado::trace("Initializing TPageService",'System.Web.Services.TPageService'); |
|
150 | + Prado::trace("Initializing TPageService", 'System.Web.Services.TPageService'); |
|
151 | 151 | |
152 | - $pageConfig=$this->loadPageConfig($config); |
|
152 | + $pageConfig = $this->loadPageConfig($config); |
|
153 | 153 | |
154 | 154 | $this->initPageContext($pageConfig); |
155 | 155 | |
156 | - $this->_initialized=true; |
|
156 | + $this->_initialized = true; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | */ |
166 | 166 | protected function initPageContext($pageConfig) |
167 | 167 | { |
168 | - $application=$this->getApplication(); |
|
169 | - foreach($pageConfig->getApplicationConfigurations() as $appConfig) |
|
168 | + $application = $this->getApplication(); |
|
169 | + foreach ($pageConfig->getApplicationConfigurations() as $appConfig) |
|
170 | 170 | $application->applyConfiguration($appConfig); |
171 | 171 | |
172 | 172 | $this->applyConfiguration($pageConfig); |
@@ -179,21 +179,21 @@ discard block |
||
179 | 179 | protected function applyConfiguration($config) |
180 | 180 | { |
181 | 181 | // initial page properties (to be set when page runs) |
182 | - $this->_properties=array_merge($this->_properties, $config->getProperties()); |
|
182 | + $this->_properties = array_merge($this->_properties, $config->getProperties()); |
|
183 | 183 | $this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules()); |
184 | - $pagePath=$this->getRequestedPagePath(); |
|
184 | + $pagePath = $this->getRequestedPagePath(); |
|
185 | 185 | // external configurations |
186 | - foreach($config->getExternalConfigurations() as $filePath=>$params) |
|
186 | + foreach ($config->getExternalConfigurations() as $filePath=>$params) |
|
187 | 187 | { |
188 | - list($configPagePath,$condition)=$params; |
|
189 | - if($condition!==true) |
|
190 | - $condition=$this->evaluateExpression($condition); |
|
191 | - if($condition) |
|
188 | + list($configPagePath, $condition) = $params; |
|
189 | + if ($condition !== true) |
|
190 | + $condition = $this->evaluateExpression($condition); |
|
191 | + if ($condition) |
|
192 | 192 | { |
193 | - if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
194 | - throw new TConfigurationException('pageservice_includefile_invalid',$filePath); |
|
195 | - $c=new TPageConfiguration($pagePath); |
|
196 | - $c->loadFromFile($path,$configPagePath); |
|
193 | + if (($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path)) |
|
194 | + throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
|
195 | + $c = new TPageConfiguration($pagePath); |
|
196 | + $c->loadFromFile($path, $configPagePath); |
|
197 | 197 | $this->applyConfiguration($c); |
198 | 198 | } |
199 | 199 | } |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function determineRequestedPagePath() |
208 | 208 | { |
209 | - $pagePath=$this->getRequest()->getServiceParameter(); |
|
210 | - if(empty($pagePath)) |
|
211 | - $pagePath=$this->getDefaultPage(); |
|
209 | + $pagePath = $this->getRequest()->getServiceParameter(); |
|
210 | + if (empty($pagePath)) |
|
211 | + $pagePath = $this->getDefaultPage(); |
|
212 | 212 | return $pagePath; |
213 | 213 | } |
214 | 214 | |
@@ -219,77 +219,77 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function loadPageConfig($config) |
221 | 221 | { |
222 | - $application=$this->getApplication(); |
|
223 | - $pagePath=$this->getRequestedPagePath(); |
|
224 | - if(($cache=$application->getCache())===null) |
|
222 | + $application = $this->getApplication(); |
|
223 | + $pagePath = $this->getRequestedPagePath(); |
|
224 | + if (($cache = $application->getCache()) === null) |
|
225 | 225 | { |
226 | - $pageConfig=new TPageConfiguration($pagePath); |
|
227 | - if($config!==null) |
|
226 | + $pageConfig = new TPageConfiguration($pagePath); |
|
227 | + if ($config !== null) |
|
228 | 228 | { |
229 | - if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
230 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
229 | + if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
230 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
231 | 231 | else |
232 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
232 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
233 | 233 | } |
234 | 234 | $pageConfig->loadFromFiles($this->getBasePath()); |
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | - $configCached=true; |
|
239 | - $currentTimestamp=array(); |
|
240 | - $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
|
241 | - if(is_array($arr)) |
|
238 | + $configCached = true; |
|
239 | + $currentTimestamp = array(); |
|
240 | + $arr = $cache->get(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath); |
|
241 | + if (is_array($arr)) |
|
242 | 242 | { |
243 | - list($pageConfig,$timestamps)=$arr; |
|
244 | - if($application->getMode()!==TApplicationMode::Performance) |
|
243 | + list($pageConfig, $timestamps) = $arr; |
|
244 | + if ($application->getMode() !== TApplicationMode::Performance) |
|
245 | 245 | { |
246 | - foreach($timestamps as $fileName=>$timestamp) |
|
246 | + foreach ($timestamps as $fileName=>$timestamp) |
|
247 | 247 | { |
248 | - if($fileName===0) // application config file |
|
248 | + if ($fileName === 0) // application config file |
|
249 | 249 | { |
250 | - $appConfigFile=$application->getConfigurationFile(); |
|
251 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
252 | - if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
|
253 | - $configCached=false; |
|
250 | + $appConfigFile = $application->getConfigurationFile(); |
|
251 | + $currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile); |
|
252 | + if ($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
|
253 | + $configCached = false; |
|
254 | 254 | } |
255 | 255 | else |
256 | 256 | { |
257 | - $currentTimestamp[$fileName]=@filemtime($fileName); |
|
258 | - if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
|
259 | - $configCached=false; |
|
257 | + $currentTimestamp[$fileName] = @filemtime($fileName); |
|
258 | + if ($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
|
259 | + $configCached = false; |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | 263 | } |
264 | 264 | else |
265 | 265 | { |
266 | - $configCached=false; |
|
267 | - $paths=explode('.',$pagePath); |
|
268 | - $configPath=$this->getBasePath(); |
|
269 | - $fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
266 | + $configCached = false; |
|
267 | + $paths = explode('.', $pagePath); |
|
268 | + $configPath = $this->getBasePath(); |
|
269 | + $fileName = $this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP |
|
270 | 270 | ? self::CONFIG_FILE_PHP |
271 | 271 | : self::CONFIG_FILE_XML; |
272 | - foreach($paths as $path) |
|
272 | + foreach ($paths as $path) |
|
273 | 273 | { |
274 | - $configFile=$configPath.DIRECTORY_SEPARATOR.$fileName; |
|
275 | - $currentTimestamp[$configFile]=@filemtime($configFile); |
|
276 | - $configPath.=DIRECTORY_SEPARATOR.$path; |
|
274 | + $configFile = $configPath . DIRECTORY_SEPARATOR . $fileName; |
|
275 | + $currentTimestamp[$configFile] = @filemtime($configFile); |
|
276 | + $configPath .= DIRECTORY_SEPARATOR . $path; |
|
277 | 277 | } |
278 | - $appConfigFile=$application->getConfigurationFile(); |
|
279 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
278 | + $appConfigFile = $application->getConfigurationFile(); |
|
279 | + $currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile); |
|
280 | 280 | } |
281 | - if(!$configCached) |
|
281 | + if (!$configCached) |
|
282 | 282 | { |
283 | - $pageConfig=new TPageConfiguration($pagePath); |
|
284 | - if($config!==null) |
|
283 | + $pageConfig = new TPageConfiguration($pagePath); |
|
284 | + if ($config !== null) |
|
285 | 285 | { |
286 | - if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
287 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
286 | + if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
287 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
288 | 288 | else |
289 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
289 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
290 | 290 | } |
291 | 291 | $pageConfig->loadFromFiles($this->getBasePath()); |
292 | - $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp)); |
|
292 | + $cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, array($pageConfig, $currentTimestamp)); |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 | return $pageConfig; |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function getTemplateManager() |
302 | 302 | { |
303 | - if(!$this->_templateManager) |
|
303 | + if (!$this->_templateManager) |
|
304 | 304 | { |
305 | - $this->_templateManager=new TTemplateManager; |
|
305 | + $this->_templateManager = new TTemplateManager; |
|
306 | 306 | $this->_templateManager->init(null); |
307 | 307 | } |
308 | 308 | return $this->_templateManager; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function setTemplateManager(TTemplateManager $value) |
315 | 315 | { |
316 | - $this->_templateManager=$value; |
|
316 | + $this->_templateManager = $value; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public function getThemeManager() |
323 | 323 | { |
324 | - if(!$this->_themeManager) |
|
324 | + if (!$this->_themeManager) |
|
325 | 325 | { |
326 | - $this->_themeManager=new TThemeManager; |
|
326 | + $this->_themeManager = new TThemeManager; |
|
327 | 327 | $this->_themeManager->init(null); |
328 | 328 | } |
329 | 329 | return $this->_themeManager; |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public function setThemeManager(TThemeManager $value) |
336 | 336 | { |
337 | - $this->_themeManager=$value; |
|
337 | + $this->_themeManager = $value; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | */ |
343 | 343 | public function getRequestedPagePath() |
344 | 344 | { |
345 | - if($this->_pagePath===null) |
|
345 | + if ($this->_pagePath === null) |
|
346 | 346 | { |
347 | - $this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..'); |
|
348 | - if(empty($this->_pagePath)) |
|
349 | - throw new THttpException(404,'pageservice_page_required'); |
|
347 | + $this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
348 | + if (empty($this->_pagePath)) |
|
349 | + throw new THttpException(404, 'pageservice_page_required'); |
|
350 | 350 | } |
351 | 351 | return $this->_pagePath; |
352 | 352 | } |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function setDefaultPage($value) |
375 | 375 | { |
376 | - if($this->_initialized) |
|
376 | + if ($this->_initialized) |
|
377 | 377 | throw new TInvalidOperationException('pageservice_defaultpage_unchangeable'); |
378 | 378 | else |
379 | - $this->_defaultPage=$value; |
|
379 | + $this->_defaultPage = $value; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
@@ -392,14 +392,14 @@ discard block |
||
392 | 392 | */ |
393 | 393 | public function getBasePath() |
394 | 394 | { |
395 | - if($this->_basePath===null) |
|
395 | + if ($this->_basePath === null) |
|
396 | 396 | { |
397 | - $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
398 | - if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
|
397 | + $basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
398 | + if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) |
|
399 | 399 | { |
400 | - $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
|
401 | - if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
|
402 | - throw new TConfigurationException('pageservice_basepath_invalid',$basePath); |
|
400 | + $basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH; |
|
401 | + if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) |
|
402 | + throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | return $this->_basePath; |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | */ |
412 | 412 | public function setBasePath($value) |
413 | 413 | { |
414 | - if($this->_initialized) |
|
414 | + if ($this->_initialized) |
|
415 | 415 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
416 | - else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
|
417 | - throw new TConfigurationException('pageservice_basepath_invalid',$value); |
|
418 | - $this->_basePath=realpath($path); |
|
416 | + else if (($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path)) |
|
417 | + throw new TConfigurationException('pageservice_basepath_invalid', $value); |
|
418 | + $this->_basePath = realpath($path); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | */ |
427 | 427 | public function setBasePageClass($value) |
428 | 428 | { |
429 | - $this->_basePageClass=$value; |
|
429 | + $this->_basePageClass = $value; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | */ |
445 | 445 | public function setClientScriptManagerClass($value) |
446 | 446 | { |
447 | - $this->_clientScriptManagerClass=$value; |
|
447 | + $this->_clientScriptManagerClass = $value; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public function run() |
465 | 465 | { |
466 | - Prado::trace("Running page service",'System.Web.Services.TPageService'); |
|
467 | - $this->_page=$this->createPage($this->getRequestedPagePath()); |
|
468 | - $this->runPage($this->_page,$this->_properties); |
|
466 | + Prado::trace("Running page service", 'System.Web.Services.TPageService'); |
|
467 | + $this->_page = $this->createPage($this->getRequestedPagePath()); |
|
468 | + $this->runPage($this->_page, $this->_properties); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -477,35 +477,35 @@ discard block |
||
477 | 477 | */ |
478 | 478 | protected function createPage($pagePath) |
479 | 479 | { |
480 | - $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR); |
|
481 | - $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
|
482 | - $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
|
480 | + $path = $this->getBasePath() . DIRECTORY_SEPARATOR . strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
481 | + $hasTemplateFile = is_file($path . self::PAGE_FILE_EXT); |
|
482 | + $hasClassFile = is_file($path . Prado::CLASS_FILE_EXT); |
|
483 | 483 | |
484 | - if(!$hasTemplateFile && !$hasClassFile) |
|
485 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
484 | + if (!$hasTemplateFile && !$hasClassFile) |
|
485 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
486 | 486 | |
487 | - if($hasClassFile) |
|
487 | + if ($hasClassFile) |
|
488 | 488 | { |
489 | - $className=basename($path); |
|
490 | - if(!class_exists($className,false)) |
|
491 | - include_once($path.Prado::CLASS_FILE_EXT); |
|
489 | + $className = basename($path); |
|
490 | + if (!class_exists($className, false)) |
|
491 | + include_once($path . Prado::CLASS_FILE_EXT); |
|
492 | 492 | } |
493 | 493 | else |
494 | 494 | { |
495 | - $className=$this->getBasePageClass(); |
|
495 | + $className = $this->getBasePageClass(); |
|
496 | 496 | Prado::using($className); |
497 | - if(($pos=strrpos($className,'.'))!==false) |
|
498 | - $className=substr($className,$pos+1); |
|
497 | + if (($pos = strrpos($className, '.')) !== false) |
|
498 | + $className = substr($className, $pos + 1); |
|
499 | 499 | } |
500 | 500 | |
501 | - if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage'))) |
|
502 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
501 | + if (!class_exists($className, false) || ($className !== 'TPage' && !is_subclass_of($className, 'TPage'))) |
|
502 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
503 | 503 | |
504 | - $page=Prado::createComponent($className); |
|
504 | + $page = Prado::createComponent($className); |
|
505 | 505 | $page->setPagePath($pagePath); |
506 | 506 | |
507 | - if($hasTemplateFile) |
|
508 | - $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT)); |
|
507 | + if ($hasTemplateFile) |
|
508 | + $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT)); |
|
509 | 509 | |
510 | 510 | return $page; |
511 | 511 | } |
@@ -515,10 +515,10 @@ discard block |
||
515 | 515 | * @param TPage the page instance to be run |
516 | 516 | * @param array list of initial page properties |
517 | 517 | */ |
518 | - protected function runPage($page,$properties) |
|
518 | + protected function runPage($page, $properties) |
|
519 | 519 | { |
520 | - foreach($properties as $name=>$value) |
|
521 | - $page->setSubProperty($name,$value); |
|
520 | + foreach ($properties as $name=>$value) |
|
521 | + $page->setSubProperty($name, $value); |
|
522 | 522 | $page->run($this->getResponse()->createHtmlWriter()); |
523 | 523 | } |
524 | 524 | |
@@ -530,9 +530,9 @@ discard block |
||
530 | 530 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
531 | 531 | * @return string URL for the page and GET parameters |
532 | 532 | */ |
533 | - public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
533 | + public function constructUrl($pagePath, $getParams = null, $encodeAmpersand = true, $encodeGetItems = true) |
|
534 | 534 | { |
535 | - return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); |
|
535 | + return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
|
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
@@ -553,23 +553,23 @@ discard block |
||
553 | 553 | /** |
554 | 554 | * @var array list of application configurations |
555 | 555 | */ |
556 | - private $_appConfigs=array(); |
|
556 | + private $_appConfigs = array(); |
|
557 | 557 | /** |
558 | 558 | * @var array list of page initial property values |
559 | 559 | */ |
560 | - private $_properties=array(); |
|
560 | + private $_properties = array(); |
|
561 | 561 | /** |
562 | 562 | * @var TAuthorizationRuleCollection list of authorization rules |
563 | 563 | */ |
564 | - private $_rules=array(); |
|
564 | + private $_rules = array(); |
|
565 | 565 | /** |
566 | 566 | * @var array list of included configurations |
567 | 567 | */ |
568 | - private $_includes=array(); |
|
568 | + private $_includes = array(); |
|
569 | 569 | /** |
570 | 570 | * @var string the currently request page in the format of Path.To.PageName |
571 | 571 | */ |
572 | - private $_pagePath=''; |
|
572 | + private $_pagePath = ''; |
|
573 | 573 | |
574 | 574 | /** |
575 | 575 | * Constructor. |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | */ |
578 | 578 | public function __construct($pagePath) |
579 | 579 | { |
580 | - $this->_pagePath=$pagePath; |
|
580 | + $this->_pagePath = $pagePath; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -624,24 +624,24 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function loadFromFiles($basePath) |
626 | 626 | { |
627 | - $paths=explode('.',$this->_pagePath); |
|
628 | - $page=array_pop($paths); |
|
629 | - $path=$basePath; |
|
630 | - $configPagePath=''; |
|
631 | - $fileName = Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
627 | + $paths = explode('.', $this->_pagePath); |
|
628 | + $page = array_pop($paths); |
|
629 | + $path = $basePath; |
|
630 | + $configPagePath = ''; |
|
631 | + $fileName = Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP |
|
632 | 632 | ? TPageService::CONFIG_FILE_PHP |
633 | 633 | : TPageService::CONFIG_FILE_XML; |
634 | - foreach($paths as $p) |
|
634 | + foreach ($paths as $p) |
|
635 | 635 | { |
636 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
637 | - $path.=DIRECTORY_SEPARATOR.$p; |
|
638 | - if($configPagePath==='') |
|
639 | - $configPagePath=$p; |
|
636 | + $this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath); |
|
637 | + $path .= DIRECTORY_SEPARATOR . $p; |
|
638 | + if ($configPagePath === '') |
|
639 | + $configPagePath = $p; |
|
640 | 640 | else |
641 | - $configPagePath.='.'.$p; |
|
641 | + $configPagePath .= '.' . $p; |
|
642 | 642 | } |
643 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
644 | - $this->_rules=new TAuthorizationRuleCollection($this->_rules); |
|
643 | + $this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath); |
|
644 | + $this->_rules = new TAuthorizationRuleCollection($this->_rules); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -649,31 +649,31 @@ discard block |
||
649 | 649 | * @param string config file name |
650 | 650 | * @param string the page path that the config file is associated with. The page path doesn't include the page name. |
651 | 651 | */ |
652 | - public function loadFromFile($fname,$configPagePath) |
|
652 | + public function loadFromFile($fname, $configPagePath) |
|
653 | 653 | { |
654 | - Prado::trace("Loading page configuration file $fname",'System.Web.Services.TPageService'); |
|
655 | - if(empty($fname) || !is_file($fname)) |
|
654 | + Prado::trace("Loading page configuration file $fname", 'System.Web.Services.TPageService'); |
|
655 | + if (empty($fname) || !is_file($fname)) |
|
656 | 656 | return; |
657 | 657 | |
658 | - if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
658 | + if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
659 | 659 | { |
660 | 660 | $fcontent = include $fname; |
661 | - $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
|
661 | + $this->loadFromPhp($fcontent, dirname($fname), $configPagePath); |
|
662 | 662 | } |
663 | 663 | else |
664 | 664 | { |
665 | - $dom=new TXmlDocument; |
|
666 | - if($dom->loadFromFile($fname)) |
|
667 | - $this->loadFromXml($dom,dirname($fname),$configPagePath); |
|
665 | + $dom = new TXmlDocument; |
|
666 | + if ($dom->loadFromFile($fname)) |
|
667 | + $this->loadFromXml($dom, dirname($fname), $configPagePath); |
|
668 | 668 | else |
669 | - throw new TConfigurationException('pageserviceconf_file_invalid',$fname); |
|
669 | + throw new TConfigurationException('pageserviceconf_file_invalid', $fname); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | |
673 | - public function loadFromPhp($config,$configPath,$configPagePath) |
|
673 | + public function loadFromPhp($config, $configPath, $configPagePath) |
|
674 | 674 | { |
675 | - $this->loadApplicationConfigurationFromPhp($config,$configPath); |
|
676 | - $this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath); |
|
675 | + $this->loadApplicationConfigurationFromPhp($config, $configPath); |
|
676 | + $this->loadPageConfigurationFromPhp($config, $configPath, $configPagePath); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -684,17 +684,17 @@ discard block |
||
684 | 684 | * @param string the directory containing this configuration |
685 | 685 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
686 | 686 | */ |
687 | - public function loadFromXml($dom,$configPath,$configPagePath) |
|
687 | + public function loadFromXml($dom, $configPath, $configPagePath) |
|
688 | 688 | { |
689 | - $this->loadApplicationConfigurationFromXml($dom,$configPath); |
|
690 | - $this->loadPageConfigurationFromXml($dom,$configPath,$configPagePath); |
|
689 | + $this->loadApplicationConfigurationFromXml($dom, $configPath); |
|
690 | + $this->loadPageConfigurationFromXml($dom, $configPath, $configPagePath); |
|
691 | 691 | } |
692 | 692 | |
693 | - public function loadApplicationConfigurationFromPhp($config,$configPath) |
|
693 | + public function loadApplicationConfigurationFromPhp($config, $configPath) |
|
694 | 694 | { |
695 | - $appConfig=new TApplicationConfiguration; |
|
696 | - $appConfig->loadFromPhp($config,$configPath); |
|
697 | - $this->_appConfigs[]=$appConfig; |
|
695 | + $appConfig = new TApplicationConfiguration; |
|
696 | + $appConfig->loadFromPhp($config, $configPath); |
|
697 | + $this->_appConfigs[] = $appConfig; |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -702,102 +702,102 @@ discard block |
||
702 | 702 | * @param TXmlElement config xml element |
703 | 703 | * @param string base path corresponding to this xml element |
704 | 704 | */ |
705 | - public function loadApplicationConfigurationFromXml($dom,$configPath) |
|
705 | + public function loadApplicationConfigurationFromXml($dom, $configPath) |
|
706 | 706 | { |
707 | - $appConfig=new TApplicationConfiguration; |
|
708 | - $appConfig->loadFromXml($dom,$configPath); |
|
709 | - $this->_appConfigs[]=$appConfig; |
|
707 | + $appConfig = new TApplicationConfiguration; |
|
708 | + $appConfig->loadFromXml($dom, $configPath); |
|
709 | + $this->_appConfigs[] = $appConfig; |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | public function loadPageConfigurationFromPhp($config, $configPath, $configPagePath) |
713 | 713 | { |
714 | 714 | // authorization |
715 | - if(isset($config['authorization']) && is_array($config['authorization'])) |
|
715 | + if (isset($config['authorization']) && is_array($config['authorization'])) |
|
716 | 716 | { |
717 | 717 | $rules = array(); |
718 | - foreach($config['authorization'] as $authorization) |
|
718 | + foreach ($config['authorization'] as $authorization) |
|
719 | 719 | { |
720 | - $patterns=isset($authorization['pages'])?$authorization['pages']:''; |
|
721 | - $ruleApplies=false; |
|
722 | - if(empty($patterns) || trim($patterns)==='*') // null or empty string |
|
723 | - $ruleApplies=true; |
|
720 | + $patterns = isset($authorization['pages']) ? $authorization['pages'] : ''; |
|
721 | + $ruleApplies = false; |
|
722 | + if (empty($patterns) || trim($patterns) === '*') // null or empty string |
|
723 | + $ruleApplies = true; |
|
724 | 724 | else |
725 | 725 | { |
726 | - foreach(explode(',',$patterns) as $pattern) |
|
726 | + foreach (explode(',', $patterns) as $pattern) |
|
727 | 727 | { |
728 | - if(($pattern=trim($pattern))!=='') |
|
728 | + if (($pattern = trim($pattern)) !== '') |
|
729 | 729 | { |
730 | 730 | // we know $configPagePath and $this->_pagePath |
731 | - if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
|
732 | - $pattern=$configPagePath.'.'.$pattern; |
|
733 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
731 | + if ($configPagePath !== '') // prepend the pattern with ConfigPagePath |
|
732 | + $pattern = $configPagePath . '.' . $pattern; |
|
733 | + if (strcasecmp($pattern, $this->_pagePath) === 0) |
|
734 | 734 | { |
735 | - $ruleApplies=true; |
|
735 | + $ruleApplies = true; |
|
736 | 736 | break; |
737 | 737 | } |
738 | - if($pattern[strlen($pattern)-1]==='*') // try wildcard matching |
|
738 | + if ($pattern[strlen($pattern) - 1] === '*') // try wildcard matching |
|
739 | 739 | { |
740 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
740 | + if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0) |
|
741 | 741 | { |
742 | - $ruleApplies=true; |
|
742 | + $ruleApplies = true; |
|
743 | 743 | break; |
744 | 744 | } |
745 | 745 | } |
746 | 746 | } |
747 | 747 | } |
748 | 748 | } |
749 | - if($ruleApplies) |
|
749 | + if ($ruleApplies) |
|
750 | 750 | { |
751 | - $action = isset($authorization['action'])?$authorization['action']:''; |
|
752 | - $users = isset($authorization['users'])?$authorization['users']:''; |
|
753 | - $roles = isset($authorization['roles'])?$authorization['roles']:''; |
|
754 | - $verb = isset($authorization['verb'])?$authorization['verb']:''; |
|
755 | - $ips = isset($authorization['ips'])?$authorization['ips']:''; |
|
756 | - $rules[]=new TAuthorizationRule($action,$users,$roles,$verb,$ips); |
|
751 | + $action = isset($authorization['action']) ? $authorization['action'] : ''; |
|
752 | + $users = isset($authorization['users']) ? $authorization['users'] : ''; |
|
753 | + $roles = isset($authorization['roles']) ? $authorization['roles'] : ''; |
|
754 | + $verb = isset($authorization['verb']) ? $authorization['verb'] : ''; |
|
755 | + $ips = isset($authorization['ips']) ? $authorization['ips'] : ''; |
|
756 | + $rules[] = new TAuthorizationRule($action, $users, $roles, $verb, $ips); |
|
757 | 757 | } |
758 | 758 | } |
759 | - $this->_rules=array_merge($rules,$this->_rules); |
|
759 | + $this->_rules = array_merge($rules, $this->_rules); |
|
760 | 760 | } |
761 | 761 | // pages |
762 | - if(isset($config['pages']) && is_array($config['pages'])) |
|
762 | + if (isset($config['pages']) && is_array($config['pages'])) |
|
763 | 763 | { |
764 | - if(isset($config['pages']['properties'])) |
|
764 | + if (isset($config['pages']['properties'])) |
|
765 | 765 | { |
766 | 766 | $this->_properties = array_merge($this->_properties, $config['pages']['properties']); |
767 | 767 | unset($config['pages']['properties']); |
768 | 768 | } |
769 | - foreach($config['pages'] as $id => $page) |
|
769 | + foreach ($config['pages'] as $id => $page) |
|
770 | 770 | { |
771 | 771 | $properties = array(); |
772 | - if(isset($page['properties'])) |
|
772 | + if (isset($page['properties'])) |
|
773 | 773 | { |
774 | - $properties=$page['properties']; |
|
774 | + $properties = $page['properties']; |
|
775 | 775 | unset($page['properties']); |
776 | 776 | } |
777 | - $matching=false; |
|
778 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
779 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
780 | - $matching=true; |
|
781 | - else if($id[strlen($id)-1]==='*') // try wildcard matching |
|
782 | - $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
783 | - if($matching) |
|
784 | - $this->_properties=array_merge($this->_properties,$properties); |
|
777 | + $matching = false; |
|
778 | + $id = ($configPagePath === '') ? $id : $configPagePath . '.' . $id; |
|
779 | + if (strcasecmp($id, $this->_pagePath) === 0) |
|
780 | + $matching = true; |
|
781 | + else if ($id[strlen($id) - 1] === '*') // try wildcard matching |
|
782 | + $matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0; |
|
783 | + if ($matching) |
|
784 | + $this->_properties = array_merge($this->_properties, $properties); |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | 788 | // external configurations |
789 | - if(isset($config['includes']) && is_array($config['includes'])) |
|
789 | + if (isset($config['includes']) && is_array($config['includes'])) |
|
790 | 790 | { |
791 | - foreach($config['includes'] as $include) |
|
791 | + foreach ($config['includes'] as $include) |
|
792 | 792 | { |
793 | - $when = isset($include['when'])?true:false; |
|
794 | - if(!isset($include['file'])) |
|
793 | + $when = isset($include['when']) ?true:false; |
|
794 | + if (!isset($include['file'])) |
|
795 | 795 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
796 | 796 | $filePath = $include['file']; |
797 | - if(isset($this->_includes[$filePath])) |
|
798 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
797 | + if (isset($this->_includes[$filePath])) |
|
798 | + $this->_includes[$filePath] = array($configPagePath, '(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'); |
|
799 | 799 | else |
800 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
800 | + $this->_includes[$filePath] = array($configPagePath, $when); |
|
801 | 801 | } |
802 | 802 | } |
803 | 803 | } |
@@ -808,82 +808,82 @@ discard block |
||
808 | 808 | * @param string base path corresponding to this xml element |
809 | 809 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
810 | 810 | */ |
811 | - public function loadPageConfigurationFromXml($dom,$configPath,$configPagePath) |
|
811 | + public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath) |
|
812 | 812 | { |
813 | 813 | // authorization |
814 | - if(($authorizationNode=$dom->getElementByTagName('authorization'))!==null) |
|
814 | + if (($authorizationNode = $dom->getElementByTagName('authorization')) !== null) |
|
815 | 815 | { |
816 | - $rules=array(); |
|
817 | - foreach($authorizationNode->getElements() as $node) |
|
816 | + $rules = array(); |
|
817 | + foreach ($authorizationNode->getElements() as $node) |
|
818 | 818 | { |
819 | - $patterns=$node->getAttribute('pages'); |
|
820 | - $ruleApplies=false; |
|
821 | - if(empty($patterns) || trim($patterns)==='*') // null or empty string |
|
822 | - $ruleApplies=true; |
|
819 | + $patterns = $node->getAttribute('pages'); |
|
820 | + $ruleApplies = false; |
|
821 | + if (empty($patterns) || trim($patterns) === '*') // null or empty string |
|
822 | + $ruleApplies = true; |
|
823 | 823 | else |
824 | 824 | { |
825 | - foreach(explode(',',$patterns) as $pattern) |
|
825 | + foreach (explode(',', $patterns) as $pattern) |
|
826 | 826 | { |
827 | - if(($pattern=trim($pattern))!=='') |
|
827 | + if (($pattern = trim($pattern)) !== '') |
|
828 | 828 | { |
829 | 829 | // we know $configPagePath and $this->_pagePath |
830 | - if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
|
831 | - $pattern=$configPagePath.'.'.$pattern; |
|
832 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
830 | + if ($configPagePath !== '') // prepend the pattern with ConfigPagePath |
|
831 | + $pattern = $configPagePath . '.' . $pattern; |
|
832 | + if (strcasecmp($pattern, $this->_pagePath) === 0) |
|
833 | 833 | { |
834 | - $ruleApplies=true; |
|
834 | + $ruleApplies = true; |
|
835 | 835 | break; |
836 | 836 | } |
837 | - if($pattern[strlen($pattern)-1]==='*') // try wildcard matching |
|
837 | + if ($pattern[strlen($pattern) - 1] === '*') // try wildcard matching |
|
838 | 838 | { |
839 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
839 | + if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0) |
|
840 | 840 | { |
841 | - $ruleApplies=true; |
|
841 | + $ruleApplies = true; |
|
842 | 842 | break; |
843 | 843 | } |
844 | 844 | } |
845 | 845 | } |
846 | 846 | } |
847 | 847 | } |
848 | - if($ruleApplies) |
|
849 | - $rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips')); |
|
848 | + if ($ruleApplies) |
|
849 | + $rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips')); |
|
850 | 850 | } |
851 | - $this->_rules=array_merge($rules,$this->_rules); |
|
851 | + $this->_rules = array_merge($rules, $this->_rules); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | // pages |
855 | - if(($pagesNode=$dom->getElementByTagName('pages'))!==null) |
|
855 | + if (($pagesNode = $dom->getElementByTagName('pages')) !== null) |
|
856 | 856 | { |
857 | - $this->_properties=array_merge($this->_properties,$pagesNode->getAttributes()->toArray()); |
|
857 | + $this->_properties = array_merge($this->_properties, $pagesNode->getAttributes()->toArray()); |
|
858 | 858 | // at the page folder |
859 | - foreach($pagesNode->getElementsByTagName('page') as $node) |
|
859 | + foreach ($pagesNode->getElementsByTagName('page') as $node) |
|
860 | 860 | { |
861 | - $properties=$node->getAttributes(); |
|
862 | - $id=$properties->remove('id'); |
|
863 | - if(empty($id)) |
|
864 | - throw new TConfigurationException('pageserviceconf_page_invalid',$configPath); |
|
865 | - $matching=false; |
|
866 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
867 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
868 | - $matching=true; |
|
869 | - else if($id[strlen($id)-1]==='*') // try wildcard matching |
|
870 | - $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
871 | - if($matching) |
|
872 | - $this->_properties=array_merge($this->_properties,$properties->toArray()); |
|
861 | + $properties = $node->getAttributes(); |
|
862 | + $id = $properties->remove('id'); |
|
863 | + if (empty($id)) |
|
864 | + throw new TConfigurationException('pageserviceconf_page_invalid', $configPath); |
|
865 | + $matching = false; |
|
866 | + $id = ($configPagePath === '') ? $id : $configPagePath . '.' . $id; |
|
867 | + if (strcasecmp($id, $this->_pagePath) === 0) |
|
868 | + $matching = true; |
|
869 | + else if ($id[strlen($id) - 1] === '*') // try wildcard matching |
|
870 | + $matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0; |
|
871 | + if ($matching) |
|
872 | + $this->_properties = array_merge($this->_properties, $properties->toArray()); |
|
873 | 873 | } |
874 | 874 | } |
875 | 875 | |
876 | 876 | // external configurations |
877 | - foreach($dom->getElementsByTagName('include') as $node) |
|
877 | + foreach ($dom->getElementsByTagName('include') as $node) |
|
878 | 878 | { |
879 | - if(($when=$node->getAttribute('when'))===null) |
|
880 | - $when=true; |
|
881 | - if(($filePath=$node->getAttribute('file'))===null) |
|
879 | + if (($when = $node->getAttribute('when')) === null) |
|
880 | + $when = true; |
|
881 | + if (($filePath = $node->getAttribute('file')) === null) |
|
882 | 882 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
883 | - if(isset($this->_includes[$filePath])) |
|
884 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
883 | + if (isset($this->_includes[$filePath])) |
|
884 | + $this->_includes[$filePath] = array($configPagePath, '(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'); |
|
885 | 885 | else |
886 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
886 | + $this->_includes[$filePath] = array($configPagePath, $when); |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | } |
@@ -258,6 +258,9 @@ discard block |
||
258 | 258 | */ |
259 | 259 | class TRpcException extends TException |
260 | 260 | { |
261 | + /** |
|
262 | + * @param string $message |
|
263 | + */ |
|
261 | 264 | public function __construct($message, $errorCode = -1) |
262 | 265 | { |
263 | 266 | $this->setErrorCode($errorCode); |
@@ -334,7 +337,7 @@ discard block |
||
334 | 337 | } |
335 | 338 | |
336 | 339 | /** |
337 | - * @return rpc server instance |
|
340 | + * @return TRpcServer server instance |
|
338 | 341 | */ |
339 | 342 | public function getRpcServer() |
340 | 343 | { |
@@ -366,6 +369,7 @@ discard block |
||
366 | 369 | /** |
367 | 370 | * @param string request payload |
368 | 371 | * Processed the request ans returns the response, if any |
372 | + * @param string $requestPayload |
|
369 | 373 | * @return processed response |
370 | 374 | * @abstract |
371 | 375 | */ |
@@ -641,7 +645,6 @@ discard block |
||
641 | 645 | /** |
642 | 646 | * Registers a new RPC method and handler details |
643 | 647 | * @param string $methodName |
644 | - * @param array $handlerDetails containing the callback handler |
|
645 | 648 | */ |
646 | 649 | public function addMethod($methodName, $methodDetails) |
647 | 650 | { |
@@ -90,28 +90,28 @@ discard block |
||
90 | 90 | { |
91 | 91 | $_properties = $this->apiProviders[$providerId]; |
92 | 92 | |
93 | - if(($_providerClass = $_properties->remove('class')) === null) |
|
93 | + if (($_providerClass = $_properties->remove('class')) === null) |
|
94 | 94 | throw new TConfigurationException('rpcservice_apiprovider_required'); |
95 | 95 | |
96 | 96 | Prado::using($_providerClass); |
97 | 97 | |
98 | 98 | $_providerClassName = ($_pos = strrpos($_providerClass, '.')) !== false ? substr($_providerClass, $_pos + 1) : $_providerClass; |
99 | - if(!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER)) |
|
99 | + if (!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER)) |
|
100 | 100 | throw new TConfigurationException('rpcservice_apiprovider_invalid'); |
101 | 101 | |
102 | - if(($_rpcServerClass = $_properties->remove('server')) === null) |
|
102 | + if (($_rpcServerClass = $_properties->remove('server')) === null) |
|
103 | 103 | $_rpcServerClass = self::BASE_RPC_SERVER; |
104 | 104 | |
105 | 105 | Prado::using($_rpcServerClass); |
106 | 106 | |
107 | 107 | $_rpcServerClassName = ($_pos = strrpos($_rpcServerClass, '.')) !== false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass; |
108 | - if($_rpcServerClassName!==self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) |
|
108 | + if ($_rpcServerClassName !== self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) |
|
109 | 109 | throw new TConfigurationException('rpcservice_rpcserver_invalid'); |
110 | 110 | |
111 | 111 | $_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler)); |
112 | 112 | $_apiProvider->setId($providerId); |
113 | 113 | |
114 | - foreach($_properties as $_key => $_value) |
|
114 | + foreach ($_properties as $_key => $_value) |
|
115 | 115 | $_apiProvider->setSubProperty($_key, $_value); |
116 | 116 | |
117 | 117 | return $_apiProvider; |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function loadConfig(TXmlElement $xml) |
134 | 134 | { |
135 | - foreach($xml->getElementsByTagName('rpcapi') as $_apiProviderXml) |
|
135 | + foreach ($xml->getElementsByTagName('rpcapi') as $_apiProviderXml) |
|
136 | 136 | { |
137 | 137 | $_properties = $_apiProviderXml->getAttributes(); |
138 | 138 | |
139 | - if(($_id = $_properties->remove('id')) === null || $_id == "") |
|
139 | + if (($_id = $_properties->remove('id')) === null || $_id == "") |
|
140 | 140 | throw new TConfigurationException('rpcservice_apiproviderid_required'); |
141 | 141 | |
142 | - if(isset($this->apiProviders[$_id])) |
|
142 | + if (isset($this->apiProviders[$_id])) |
|
143 | 143 | throw new TConfigurationException('rpcservice_apiproviderid_duplicated'); |
144 | 144 | |
145 | 145 | $this->apiProviders[$_id] = $_properties; |
@@ -153,22 +153,22 @@ discard block |
||
153 | 153 | { |
154 | 154 | $_request = $this->getRequest(); |
155 | 155 | |
156 | - if(($_providerId = $_request->getServiceParameter()) == "") |
|
156 | + if (($_providerId = $_request->getServiceParameter()) == "") |
|
157 | 157 | throw new THttpException(400, 'RPC API-Provider id required'); |
158 | 158 | |
159 | - if(($_method = $_request->getRequestType()) != 'POST') |
|
160 | - throw new THttpException(405, 'Invalid request method "'.$_method.'"!'); // TODO Exception muss "Allow POST" Header setzen |
|
159 | + if (($_method = $_request->getRequestType()) != 'POST') |
|
160 | + throw new THttpException(405, 'Invalid request method "' . $_method . '"!'); // TODO Exception muss "Allow POST" Header setzen |
|
161 | 161 | |
162 | - if(($_mimeType = $_request->getContentType()) === null) |
|
162 | + if (($_mimeType = $_request->getContentType()) === null) |
|
163 | 163 | throw new THttpException(406, 'Content-Type is missing!'); // TODO Exception muss gültige Content-Type werte zurück geben |
164 | 164 | |
165 | - if(!in_array($_mimeType, array_keys($this->protocolHandlers))) |
|
165 | + if (!in_array($_mimeType, array_keys($this->protocolHandlers))) |
|
166 | 166 | throw new THttpException(406, 'Unsupported Content-Type!'); // TODO see previous |
167 | 167 | |
168 | 168 | $_protocolHandlerClass = $this->protocolHandlers[$_mimeType]; |
169 | 169 | $_protocolHandler = new $_protocolHandlerClass; |
170 | 170 | |
171 | - if(($_result = $this->createApiProvider($_protocolHandler, $_providerId)->processRequest()) !== null) |
|
171 | + if (($_result = $this->createApiProvider($_protocolHandler, $_providerId)->processRequest()) !== null) |
|
172 | 172 | { |
173 | 173 | $_response = $this->getResponse(); |
174 | 174 | $_protocolHandler->createResponseHeaders($_response); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | { |
239 | 239 | return $this->handler->callMethod($this->getPayload()); |
240 | 240 | } |
241 | - catch(TRpcException $e) |
|
241 | + catch (TRpcException $e) |
|
242 | 242 | { |
243 | 243 | return $this->handler->createErrorResponse($e); |
244 | 244 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | { |
321 | 321 | $this->rpcServer = $rpcServer; |
322 | 322 | |
323 | - foreach($this->registerMethods() as $_methodName => $_methodDetails) |
|
323 | + foreach ($this->registerMethods() as $_methodName => $_methodDetails) |
|
324 | 324 | $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |
325 | 325 | } |
326 | 326 | |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function callApiMethod($methodName, $parameters) |
420 | 420 | { |
421 | - if(!isset($this->rpcMethods[$methodName])) |
|
422 | - throw new TRpcException('Method "'.$methodName.'" not found'); |
|
421 | + if (!isset($this->rpcMethods[$methodName])) |
|
422 | + throw new TRpcException('Method "' . $methodName . '" not found'); |
|
423 | 423 | |
424 | - if($parameters === null) |
|
424 | + if ($parameters === null) |
|
425 | 425 | $parameters = array(); |
426 | 426 | |
427 | - if(!is_array($parameters)) |
|
427 | + if (!is_array($parameters)) |
|
428 | 428 | $parameters = array($parameters); |
429 | 429 | return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters); |
430 | 430 | } |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | */ |
446 | 446 | class TJsonRpcProtocol extends TRpcProtocol |
447 | 447 | { |
448 | - protected $_id=null; |
|
449 | - protected $_specificationVersion=1.0; |
|
448 | + protected $_id = null; |
|
449 | + protected $_specificationVersion = 1.0; |
|
450 | 450 | |
451 | 451 | /** |
452 | 452 | * Handles the RPC request |
@@ -459,31 +459,31 @@ discard block |
||
459 | 459 | { |
460 | 460 | $_request = $this->decode($requestPayload); |
461 | 461 | |
462 | - if(isset($_request['jsonrpc'])) |
|
462 | + if (isset($_request['jsonrpc'])) |
|
463 | 463 | { |
464 | - $this->_specificationVersion=$_request['jsonrpc']; |
|
465 | - if($this->_specificationVersion > 2.0) |
|
464 | + $this->_specificationVersion = $_request['jsonrpc']; |
|
465 | + if ($this->_specificationVersion > 2.0) |
|
466 | 466 | throw new TRpcException('Unsupported specification version', '-32600'); |
467 | 467 | } |
468 | 468 | |
469 | - if(isset($_request['id'])) |
|
470 | - $this->_id=$_request['id']; |
|
469 | + if (isset($_request['id'])) |
|
470 | + $this->_id = $_request['id']; |
|
471 | 471 | |
472 | - if(!isset($_request['method'])) |
|
472 | + if (!isset($_request['method'])) |
|
473 | 473 | throw new TRpcException('Missing request method', '-32600'); |
474 | 474 | |
475 | - if(!isset($_request['params'])) |
|
475 | + if (!isset($_request['params'])) |
|
476 | 476 | $parameters = array(); |
477 | 477 | else |
478 | 478 | $parameters = $_request['params']; |
479 | 479 | |
480 | - if(!is_array($parameters)) |
|
480 | + if (!is_array($parameters)) |
|
481 | 481 | $parameters = array($parameters); |
482 | 482 | |
483 | 483 | // a request without an id is a notification that doesn't need a response |
484 | - if($this->_id !== null) |
|
484 | + if ($this->_id !== null) |
|
485 | 485 | { |
486 | - if($this->_specificationVersion==2.0) |
|
486 | + if ($this->_specificationVersion == 2.0) |
|
487 | 487 | { |
488 | 488 | return $this->encode(array( |
489 | 489 | 'jsonrpc' => '2.0', |
@@ -499,15 +499,15 @@ discard block |
||
499 | 499 | } |
500 | 500 | } |
501 | 501 | } |
502 | - catch(TRpcException $e) |
|
502 | + catch (TRpcException $e) |
|
503 | 503 | { |
504 | 504 | return $this->createErrorResponse($e); |
505 | 505 | } |
506 | - catch(THttpException $e) |
|
506 | + catch (THttpException $e) |
|
507 | 507 | { |
508 | 508 | throw $e; |
509 | 509 | } |
510 | - catch(Exception $e) |
|
510 | + catch (Exception $e) |
|
511 | 511 | { |
512 | 512 | return $this->createErrorResponse(new TRpcException('An internal error occured', '-32603')); |
513 | 513 | } |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | */ |
521 | 521 | public function createErrorResponse(TRpcException $exception) |
522 | 522 | { |
523 | - if($this->_specificationVersion==2.0) |
|
523 | + if ($this->_specificationVersion == 2.0) |
|
524 | 524 | { |
525 | 525 | return $this->encode(array( |
526 | 526 | 'id' => $this->_id, |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | private static function checkJsonError() |
581 | 581 | { |
582 | 582 | $errnum = json_last_error(); |
583 | - if($errnum != JSON_ERROR_NONE) |
|
583 | + if ($errnum != JSON_ERROR_NONE) |
|
584 | 584 | throw new Exception("JSON error: $msg", $err); |
585 | 585 | } |
586 | 586 | |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | */ |
594 | 594 | public function callApiMethod($methodName, $parameters) |
595 | 595 | { |
596 | - if(!isset($this->rpcMethods[$methodName])) |
|
597 | - throw new TRpcException('Method "'.$methodName.'" not found', '-32601'); |
|
596 | + if (!isset($this->rpcMethods[$methodName])) |
|
597 | + throw new TRpcException('Method "' . $methodName . '" not found', '-32601'); |
|
598 | 598 | |
599 | 599 | return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters); |
600 | 600 | } |
@@ -663,15 +663,15 @@ discard block |
||
663 | 663 | { |
664 | 664 | return xmlrpc_server_call_method($this->_xmlrpcServer, $requestPayload, null); |
665 | 665 | } |
666 | - catch(TRpcException $e) |
|
666 | + catch (TRpcException $e) |
|
667 | 667 | { |
668 | 668 | return $this->createErrorResponse($e); |
669 | 669 | } |
670 | - catch(THttpException $e) |
|
670 | + catch (THttpException $e) |
|
671 | 671 | { |
672 | 672 | throw $e; |
673 | 673 | } |
674 | - catch(Exception $e) |
|
674 | + catch (Exception $e) |
|
675 | 675 | { |
676 | 676 | return $this->createErrorResponse(new TRpcException('An internal error occured')); |
677 | 677 | } |
@@ -111,8 +111,9 @@ discard block |
||
111 | 111 | $_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler)); |
112 | 112 | $_apiProvider->setId($providerId); |
113 | 113 | |
114 | - foreach($_properties as $_key => $_value) |
|
115 | - $_apiProvider->setSubProperty($_key, $_value); |
|
114 | + foreach($_properties as $_key => $_value) { |
|
115 | + $_apiProvider->setSubProperty($_key, $_value); |
|
116 | + } |
|
116 | 117 | |
117 | 118 | return $_apiProvider; |
118 | 119 | } |
@@ -237,8 +238,7 @@ discard block |
||
237 | 238 | try |
238 | 239 | { |
239 | 240 | return $this->handler->callMethod($this->getPayload()); |
240 | - } |
|
241 | - catch(TRpcException $e) |
|
241 | + } catch(TRpcException $e) |
|
242 | 242 | { |
243 | 243 | return $this->handler->createErrorResponse($e); |
244 | 244 | } |
@@ -320,8 +320,9 @@ discard block |
||
320 | 320 | { |
321 | 321 | $this->rpcServer = $rpcServer; |
322 | 322 | |
323 | - foreach($this->registerMethods() as $_methodName => $_methodDetails) |
|
324 | - $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |
|
323 | + foreach($this->registerMethods() as $_methodName => $_methodDetails) { |
|
324 | + $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |
|
325 | + } |
|
325 | 326 | } |
326 | 327 | |
327 | 328 | /** |
@@ -498,16 +499,13 @@ discard block |
||
498 | 499 | )); |
499 | 500 | } |
500 | 501 | } |
501 | - } |
|
502 | - catch(TRpcException $e) |
|
502 | + } catch(TRpcException $e) |
|
503 | 503 | { |
504 | 504 | return $this->createErrorResponse($e); |
505 | - } |
|
506 | - catch(THttpException $e) |
|
505 | + } catch(THttpException $e) |
|
507 | 506 | { |
508 | 507 | throw $e; |
509 | - } |
|
510 | - catch(Exception $e) |
|
508 | + } catch(Exception $e) |
|
511 | 509 | { |
512 | 510 | return $this->createErrorResponse(new TRpcException('An internal error occured', '-32603')); |
513 | 511 | } |
@@ -662,16 +660,13 @@ discard block |
||
662 | 660 | try |
663 | 661 | { |
664 | 662 | return xmlrpc_server_call_method($this->_xmlrpcServer, $requestPayload, null); |
665 | - } |
|
666 | - catch(TRpcException $e) |
|
663 | + } catch(TRpcException $e) |
|
667 | 664 | { |
668 | 665 | return $this->createErrorResponse($e); |
669 | - } |
|
670 | - catch(THttpException $e) |
|
666 | + } catch(THttpException $e) |
|
671 | 667 | { |
672 | 668 | throw $e; |
673 | - } |
|
674 | - catch(Exception $e) |
|
669 | + } catch(Exception $e) |
|
675 | 670 | { |
676 | 671 | return $this->createErrorResponse(new TRpcException('An internal error occured')); |
677 | 672 | } |
@@ -31,6 +31,7 @@ |
||
31 | 31 | /** |
32 | 32 | * Constructor. Attach a response to be adapted. |
33 | 33 | * @param THttpResponse the response object the adapter is to attach to. |
34 | + * @param THttpResponse $response |
|
34 | 35 | */ |
35 | 36 | public function __construct($response) |
36 | 37 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct($response) |
36 | 36 | { |
37 | - $this->_response=$response; |
|
37 | + $this->_response = $response; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function createNewHtmlWriter($type, $writer) |
73 | 73 | { |
74 | - return $this->_response->createNewHtmlWriter($type,$writer); |
|
74 | + return $this->_response->createNewHtmlWriter($type, $writer); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 |
@@ -265,6 +265,7 @@ discard block |
||
265 | 265 | * If true, make sure the methods {@link _open}, {@link _close}, {@link _read}, |
266 | 266 | * {@link _write}, {@link _destroy}, and {@link _gc} are overridden in child |
267 | 267 | * class, because they will be used as the callback handlers. |
268 | + * @param boolean $value |
|
268 | 269 | */ |
269 | 270 | public function setUseCustomStorage($value) |
270 | 271 | { |
@@ -527,6 +528,7 @@ discard block |
||
527 | 528 | * Returns the session variable value with the session variable name. |
528 | 529 | * This method is exactly the same as {@link offsetGet}. |
529 | 530 | * @param mixed the session variable name |
531 | + * @param string $key |
|
530 | 532 | * @return mixed the session variable value, null if no such variable exists |
531 | 533 | */ |
532 | 534 | public function itemAt($key) |
@@ -539,6 +541,7 @@ discard block |
||
539 | 541 | * Note, if the specified name already exists, the old value will be removed first. |
540 | 542 | * @param mixed session variable name |
541 | 543 | * @param mixed session variable value |
544 | + * @param string $key |
|
542 | 545 | */ |
543 | 546 | public function add($key,$value) |
544 | 547 | { |
@@ -306,10 +306,10 @@ |
||
306 | 306 | { |
307 | 307 | $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
308 | 308 | if($value===THttpSessionCookieMode::None) |
309 | - { |
|
309 | + { |
|
310 | 310 | ini_set('session.use_cookies','0'); |
311 | 311 | ini_set('session.use_only_cookies','0'); |
312 | - } |
|
312 | + } |
|
313 | 313 | else if($value===THttpSessionCookieMode::Allow) |
314 | 314 | { |
315 | 315 | ini_set('session.use_cookies','1'); |
@@ -67,24 +67,24 @@ discard block |
||
67 | 67 | * @package System.Web |
68 | 68 | * @since 3.0 |
69 | 69 | */ |
70 | -class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
70 | +class THttpSession extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
71 | 71 | { |
72 | 72 | /** |
73 | 73 | * @var boolean whether this module has been initialized |
74 | 74 | */ |
75 | - private $_initialized=false; |
|
75 | + private $_initialized = false; |
|
76 | 76 | /** |
77 | 77 | * @var boolean whether the session has started |
78 | 78 | */ |
79 | - private $_started=false; |
|
79 | + private $_started = false; |
|
80 | 80 | /** |
81 | 81 | * @var boolean whether the session should be started when the module is initialized |
82 | 82 | */ |
83 | - private $_autoStart=false; |
|
83 | + private $_autoStart = false; |
|
84 | 84 | /** |
85 | 85 | * @var THttpCookie cookie to be used to store session ID and other data |
86 | 86 | */ |
87 | - private $_cookie=null; |
|
87 | + private $_cookie = null; |
|
88 | 88 | /** |
89 | 89 | * @var string module id |
90 | 90 | */ |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * @var boolean |
94 | 94 | */ |
95 | - private $_customStorage=false; |
|
95 | + private $_customStorage = false; |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @return string id of this module |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function setID($value) |
109 | 109 | { |
110 | - $this->_id=$value; |
|
110 | + $this->_id = $value; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function init($config) |
120 | 120 | { |
121 | - if($this->_autoStart) |
|
121 | + if ($this->_autoStart) |
|
122 | 122 | $this->open(); |
123 | - $this->_initialized=true; |
|
123 | + $this->_initialized = true; |
|
124 | 124 | $this->getApplication()->setSession($this); |
125 | 125 | register_shutdown_function(array($this, "close")); |
126 | 126 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function open() |
132 | 132 | { |
133 | - if(!$this->_started) |
|
133 | + if (!$this->_started) |
|
134 | 134 | { |
135 | - if($this->_customStorage) |
|
136 | - session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc')); |
|
137 | - if($this->_cookie!==null) |
|
138 | - session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly()); |
|
139 | - if(ini_get('session.auto_start')!=='1') |
|
135 | + if ($this->_customStorage) |
|
136 | + session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc')); |
|
137 | + if ($this->_cookie !== null) |
|
138 | + session_set_cookie_params($this->_cookie->getExpire(), $this->_cookie->getPath(), $this->_cookie->getDomain(), $this->_cookie->getSecure(), $this->_cookie->getHttpOnly()); |
|
139 | + if (ini_get('session.auto_start') !== '1') |
|
140 | 140 | session_start(); |
141 | - $this->_started=true; |
|
141 | + $this->_started = true; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function close() |
149 | 149 | { |
150 | - if($this->_started) |
|
150 | + if ($this->_started) |
|
151 | 151 | { |
152 | 152 | session_write_close(); |
153 | - $this->_started=false; |
|
153 | + $this->_started = false; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function destroy() |
161 | 161 | { |
162 | - if($this->_started) |
|
162 | + if ($this->_started) |
|
163 | 163 | { |
164 | 164 | session_destroy(); |
165 | - $this->_started=false; |
|
165 | + $this->_started = false; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return string old session id |
174 | 174 | * @link http://php.net/manual/en/function.session-regenerate-id.php |
175 | 175 | */ |
176 | - public function regenerate($deleteOld=false) |
|
176 | + public function regenerate($deleteOld = false) |
|
177 | 177 | { |
178 | 178 | $old = $this->getSessionID(); |
179 | 179 | session_regenerate_id($deleteOld); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function setSessionID($value) |
204 | 204 | { |
205 | - if($this->_started) |
|
205 | + if ($this->_started) |
|
206 | 206 | throw new TInvalidOperationException('httpsession_sessionid_unchangeable'); |
207 | 207 | else |
208 | 208 | session_id($value); |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function setSessionName($value) |
224 | 224 | { |
225 | - if($this->_started) |
|
225 | + if ($this->_started) |
|
226 | 226 | throw new TInvalidOperationException('httpsession_sessionname_unchangeable'); |
227 | - else if(ctype_alnum($value)) |
|
227 | + else if (ctype_alnum($value)) |
|
228 | 228 | session_name($value); |
229 | 229 | else |
230 | - throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value); |
|
230 | + throw new TInvalidDataValueException('httpsession_sessionname_invalid', $value); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function setSavePath($value) |
246 | 246 | { |
247 | - if($this->_started) |
|
247 | + if ($this->_started) |
|
248 | 248 | throw new TInvalidOperationException('httpsession_savepath_unchangeable'); |
249 | - else if(is_dir($value)) |
|
249 | + else if (is_dir($value)) |
|
250 | 250 | session_save_path($value); |
251 | 251 | else |
252 | - throw new TInvalidDataValueException('httpsession_savepath_invalid',$value); |
|
252 | + throw new TInvalidDataValueException('httpsession_savepath_invalid', $value); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function setUseCustomStorage($value) |
270 | 270 | { |
271 | - $this->_customStorage=TPropertyValue::ensureBoolean($value); |
|
271 | + $this->_customStorage = TPropertyValue::ensureBoolean($value); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function getCookie() |
278 | 278 | { |
279 | - if($this->_cookie===null) |
|
280 | - $this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID()); |
|
279 | + if ($this->_cookie === null) |
|
280 | + $this->_cookie = new THttpCookie($this->getSessionName(), $this->getSessionID()); |
|
281 | 281 | return $this->_cookie; |
282 | 282 | } |
283 | 283 | |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function getCookieMode() |
288 | 288 | { |
289 | - if(ini_get('session.use_cookies')==='0') |
|
289 | + if (ini_get('session.use_cookies') === '0') |
|
290 | 290 | return THttpSessionCookieMode::None; |
291 | - else if(ini_get('session.use_only_cookies')==='0') |
|
291 | + else if (ini_get('session.use_only_cookies') === '0') |
|
292 | 292 | return THttpSessionCookieMode::Allow; |
293 | 293 | else |
294 | 294 | return THttpSessionCookieMode::Only; |
@@ -300,25 +300,25 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function setCookieMode($value) |
302 | 302 | { |
303 | - if($this->_started) |
|
303 | + if ($this->_started) |
|
304 | 304 | throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); |
305 | 305 | else |
306 | 306 | { |
307 | - $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
|
308 | - if($value===THttpSessionCookieMode::None) |
|
307 | + $value = TPropertyValue::ensureEnum($value, 'THttpSessionCookieMode'); |
|
308 | + if ($value === THttpSessionCookieMode::None) |
|
309 | 309 | { |
310 | - ini_set('session.use_cookies','0'); |
|
311 | - ini_set('session.use_only_cookies','0'); |
|
310 | + ini_set('session.use_cookies', '0'); |
|
311 | + ini_set('session.use_only_cookies', '0'); |
|
312 | 312 | } |
313 | - else if($value===THttpSessionCookieMode::Allow) |
|
313 | + else if ($value === THttpSessionCookieMode::Allow) |
|
314 | 314 | { |
315 | - ini_set('session.use_cookies','1'); |
|
316 | - ini_set('session.use_only_cookies','0'); |
|
315 | + ini_set('session.use_cookies', '1'); |
|
316 | + ini_set('session.use_only_cookies', '0'); |
|
317 | 317 | } |
318 | 318 | else |
319 | 319 | { |
320 | - ini_set('session.use_cookies','1'); |
|
321 | - ini_set('session.use_only_cookies','1'); |
|
320 | + ini_set('session.use_cookies', '1'); |
|
321 | + ini_set('session.use_only_cookies', '1'); |
|
322 | 322 | ini_set('session.use_trans_sid', 0); |
323 | 323 | } |
324 | 324 | } |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function setAutoStart($value) |
340 | 340 | { |
341 | - if($this->_initialized) |
|
341 | + if ($this->_initialized) |
|
342 | 342 | throw new TInvalidOperationException('httpsession_autostart_unchangeable'); |
343 | 343 | else |
344 | - $this->_autoStart=TPropertyValue::ensureBoolean($value); |
|
344 | + $this->_autoStart = TPropertyValue::ensureBoolean($value); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -359,18 +359,18 @@ discard block |
||
359 | 359 | */ |
360 | 360 | public function setGCProbability($value) |
361 | 361 | { |
362 | - if($this->_started) |
|
362 | + if ($this->_started) |
|
363 | 363 | throw new TInvalidOperationException('httpsession_gcprobability_unchangeable'); |
364 | 364 | else |
365 | 365 | { |
366 | - $value=TPropertyValue::ensureInteger($value); |
|
367 | - if($value>=0 && $value<=100) |
|
366 | + $value = TPropertyValue::ensureInteger($value); |
|
367 | + if ($value >= 0 && $value <= 100) |
|
368 | 368 | { |
369 | - ini_set('session.gc_probability',$value); |
|
370 | - ini_set('session.gc_divisor','100'); |
|
369 | + ini_set('session.gc_probability', $value); |
|
370 | + ini_set('session.gc_divisor', '100'); |
|
371 | 371 | } |
372 | 372 | else |
373 | - throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
|
373 | + throw new TInvalidDataValueException('httpsession_gcprobability_invalid', $value); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public function getUseTransparentSessionID() |
381 | 381 | { |
382 | - return ini_get('session.use_trans_sid')==='1'; |
|
382 | + return ini_get('session.use_trans_sid') === '1'; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function setUseTransparentSessionID($value) |
389 | 389 | { |
390 | - if($this->_started) |
|
390 | + if ($this->_started) |
|
391 | 391 | throw new TInvalidOperationException('httpsession_transid_unchangeable'); |
392 | 392 | else |
393 | 393 | { |
394 | - $value=TPropertyValue::ensureBoolean($value); |
|
395 | - if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
394 | + $value = TPropertyValue::ensureBoolean($value); |
|
395 | + if ($value && $this->getCookieMode() == THttpSessionCookieMode::Only) |
|
396 | 396 | throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
397 | - ini_set('session.use_trans_sid',$value?'1':'0'); |
|
397 | + ini_set('session.use_trans_sid', $value ? '1' : '0'); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function setTimeout($value) |
414 | 414 | { |
415 | - if($this->_started) |
|
415 | + if ($this->_started) |
|
416 | 416 | throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable'); |
417 | 417 | else |
418 | - ini_set('session.gc_maxlifetime',$value); |
|
418 | + ini_set('session.gc_maxlifetime', $value); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @param string session name |
426 | 426 | * @return boolean whether session is opened successfully |
427 | 427 | */ |
428 | - public function _open($savePath,$sessionName) |
|
428 | + public function _open($savePath, $sessionName) |
|
429 | 429 | { |
430 | 430 | return true; |
431 | 431 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @param string session data |
459 | 459 | * @return boolean whether session write is successful |
460 | 460 | */ |
461 | - public function _write($id,$data) |
|
461 | + public function _write($id, $data) |
|
462 | 462 | { |
463 | 463 | return true; |
464 | 464 | } |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | * @param mixed session variable name |
541 | 541 | * @param mixed session variable value |
542 | 542 | */ |
543 | - public function add($key,$value) |
|
543 | + public function add($key, $value) |
|
544 | 544 | { |
545 | - $_SESSION[$key]=$value; |
|
545 | + $_SESSION[$key] = $value; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -552,9 +552,9 @@ discard block |
||
552 | 552 | */ |
553 | 553 | public function remove($key) |
554 | 554 | { |
555 | - if(isset($_SESSION[$key])) |
|
555 | + if (isset($_SESSION[$key])) |
|
556 | 556 | { |
557 | - $value=$_SESSION[$key]; |
|
557 | + $value = $_SESSION[$key]; |
|
558 | 558 | unset($_SESSION[$key]); |
559 | 559 | return $value; |
560 | 560 | } |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | */ |
568 | 568 | public function clear() |
569 | 569 | { |
570 | - foreach(array_keys($_SESSION) as $key) |
|
570 | + foreach (array_keys($_SESSION) as $key) |
|
571 | 571 | unset($_SESSION[$key]); |
572 | 572 | } |
573 | 573 | |
@@ -613,9 +613,9 @@ discard block |
||
613 | 613 | * @param integer the offset to set element |
614 | 614 | * @param mixed the element value |
615 | 615 | */ |
616 | - public function offsetSet($offset,$item) |
|
616 | + public function offsetSet($offset, $item) |
|
617 | 617 | { |
618 | - $_SESSION[$offset]=$item; |
|
618 | + $_SESSION[$offset] = $item; |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function __construct() |
659 | 659 | { |
660 | - $this->_keys=array_keys($_SESSION); |
|
660 | + $this->_keys = array_keys($_SESSION); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | */ |
667 | 667 | public function rewind() |
668 | 668 | { |
669 | - $this->_key=reset($this->_keys); |
|
669 | + $this->_key = reset($this->_keys); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | */ |
687 | 687 | public function current() |
688 | 688 | { |
689 | - return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null; |
|
689 | + return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -697,9 +697,9 @@ discard block |
||
697 | 697 | { |
698 | 698 | do |
699 | 699 | { |
700 | - $this->_key=next($this->_keys); |
|
700 | + $this->_key = next($this->_keys); |
|
701 | 701 | } |
702 | - while(!isset($_SESSION[$this->_key]) && $this->_key!==false); |
|
702 | + while (!isset($_SESSION[$this->_key]) && $this->_key !== false); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function valid() |
711 | 711 | { |
712 | - return $this->_key!==false; |
|
712 | + return $this->_key !== false; |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | */ |
731 | 731 | class THttpSessionCookieMode extends TEnumerable |
732 | 732 | { |
733 | - const None='None'; |
|
734 | - const Allow='Allow'; |
|
735 | - const Only='Only'; |
|
733 | + const None = 'None'; |
|
734 | + const Allow = 'Allow'; |
|
735 | + const Only = 'Only'; |
|
736 | 736 | } |
737 | 737 |
@@ -309,13 +309,11 @@ discard block |
||
309 | 309 | { |
310 | 310 | ini_set('session.use_cookies','0'); |
311 | 311 | ini_set('session.use_only_cookies','0'); |
312 | - } |
|
313 | - else if($value===THttpSessionCookieMode::Allow) |
|
312 | + } else if($value===THttpSessionCookieMode::Allow) |
|
314 | 313 | { |
315 | 314 | ini_set('session.use_cookies','1'); |
316 | 315 | ini_set('session.use_only_cookies','0'); |
317 | - } |
|
318 | - else |
|
316 | + } else |
|
319 | 317 | { |
320 | 318 | ini_set('session.use_cookies','1'); |
321 | 319 | ini_set('session.use_only_cookies','1'); |
@@ -368,8 +366,7 @@ discard block |
||
368 | 366 | { |
369 | 367 | ini_set('session.gc_probability',$value); |
370 | 368 | ini_set('session.gc_divisor','100'); |
371 | - } |
|
372 | - else |
|
369 | + } else |
|
373 | 370 | throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
374 | 371 | } |
375 | 372 | } |
@@ -557,8 +554,7 @@ discard block |
||
557 | 554 | $value=$_SESSION[$key]; |
558 | 555 | unset($_SESSION[$key]); |
559 | 556 | return $value; |
560 | - } |
|
561 | - else |
|
557 | + } else |
|
562 | 558 | return null; |
563 | 559 | } |
564 | 560 | |
@@ -567,8 +563,9 @@ discard block |
||
567 | 563 | */ |
568 | 564 | public function clear() |
569 | 565 | { |
570 | - foreach(array_keys($_SESSION) as $key) |
|
571 | - unset($_SESSION[$key]); |
|
566 | + foreach(array_keys($_SESSION) as $key) { |
|
567 | + unset($_SESSION[$key]); |
|
568 | + } |
|
572 | 569 | } |
573 | 570 | |
574 | 571 | /** |
@@ -175,6 +175,7 @@ |
||
175 | 175 | |
176 | 176 | /** |
177 | 177 | * @param string state tracker class. |
178 | + * @param string $value |
|
178 | 179 | */ |
179 | 180 | public function setStateTracker($value) |
180 | 181 | { |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @var string view state tracker class. |
50 | 50 | */ |
51 | - private $_stateTrackerClass='TCallbackPageStateTracker'; |
|
51 | + private $_stateTrackerClass = 'TCallbackPageStateTracker'; |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Constructor. |
55 | 55 | * @param IActiveControl active control to adapt. |
56 | 56 | * @param string Base active control class name. |
57 | 57 | */ |
58 | - public function __construct(IActiveControl $control, $baseCallbackClass=null) |
|
58 | + public function __construct(IActiveControl $control, $baseCallbackClass = null) |
|
59 | 59 | { |
60 | 60 | parent::__construct($control); |
61 | 61 | $this->setBaseControlClass($baseCallbackClass); |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | protected function setBaseControlClass($type) |
68 | 68 | { |
69 | - if($type===null) |
|
69 | + if ($type === null) |
|
70 | 70 | { |
71 | - if($this->getControl() instanceof ICallbackEventHandler) |
|
71 | + if ($this->getControl() instanceof ICallbackEventHandler) |
|
72 | 72 | $this->_activeControlType = 'TBaseActiveCallbackControl'; |
73 | 73 | else |
74 | 74 | $this->_activeControlType = 'TBaseActiveControl'; |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | public function render($writer) |
92 | 92 | { |
93 | 93 | $this->getPage()->getClientScript()->registerPradoScript('ajax'); |
94 | - if($this->_control->getVisible(false)) |
|
94 | + if ($this->_control->getVisible(false)) |
|
95 | 95 | { |
96 | 96 | parent::render($writer); |
97 | 97 | } else { |
98 | - $writer->write("<span id=\"".$this->_control->getClientID()."\" style=\"display:none\"></span>"); |
|
98 | + $writer->write("<span id=\"" . $this->_control->getClientID() . "\" style=\"display:none\"></span>"); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function setBaseActiveControl($control) |
106 | 106 | { |
107 | - $this->_baseActiveControl=$control; |
|
107 | + $this->_baseActiveControl = $control; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function getBaseActiveControl() |
114 | 114 | { |
115 | - if($this->_baseActiveControl===null) |
|
115 | + if ($this->_baseActiveControl === null) |
|
116 | 116 | { |
117 | 117 | $type = $this->_activeControlType; |
118 | 118 | $this->_baseActiveControl = new $type($this->getControl()); |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function getIsTrackingPageState() |
127 | 127 | { |
128 | - if($this->getPage()->getIsCallback()) |
|
128 | + if ($this->getPage()->getIsCallback()) |
|
129 | 129 | { |
130 | 130 | $target = $this->getPage()->getCallbackEventTarget(); |
131 | - if($target instanceof ICallbackEventHandler) |
|
131 | + if ($target instanceof ICallbackEventHandler) |
|
132 | 132 | { |
133 | 133 | $client = $target->getActiveControl()->getClientSide(); |
134 | 134 | return $client->getEnablePageStateUpdate(); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function onLoad($param) |
144 | 144 | { |
145 | - if($this->getIsTrackingPageState()) |
|
145 | + if ($this->getIsTrackingPageState()) |
|
146 | 146 | { |
147 | 147 | $stateTrackerClass = $this->_stateTrackerClass; |
148 | 148 | $this->_stateTracker = new $stateTrackerClass($this->getControl()); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function saveState() |
159 | 159 | { |
160 | - if(($this->_stateTracker!==null) |
|
160 | + if (($this->_stateTracker !== null) |
|
161 | 161 | && $this->getControl()->getActiveControl()->canUpdateClientSide(true)) |
162 | 162 | { |
163 | 163 | $this->_stateTracker->respondToChanges(); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function trackChanges() |
259 | 259 | { |
260 | - foreach($this->_states as $name => $value) |
|
260 | + foreach ($this->_states as $name => $value) |
|
261 | 261 | { |
262 | 262 | $obj = $this->_control->getViewState($name); |
263 | 263 | $this->_existingState[$name] = is_object($obj) ? clone($obj) : $obj; |
@@ -270,15 +270,15 @@ discard block |
||
270 | 270 | protected function getChanges() |
271 | 271 | { |
272 | 272 | $changes = array(); |
273 | - foreach($this->_states as $name => $details) |
|
273 | + foreach ($this->_states as $name => $details) |
|
274 | 274 | { |
275 | 275 | $new = $this->_control->getViewState($name); |
276 | 276 | $old = $this->_existingState[$name]; |
277 | - if($new !== $old) |
|
277 | + if ($new !== $old) |
|
278 | 278 | { |
279 | 279 | $diff = new $details[0]($new, $old, $this->_nullObject); |
280 | - if(($change = $diff->getDifference()) !== $this->_nullObject) |
|
281 | - $changes[] = array($details[1],array($change)); |
|
280 | + if (($change = $diff->getDifference()) !== $this->_nullObject) |
|
281 | + $changes[] = array($details[1], array($change)); |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | return $changes; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function respondToChanges() |
291 | 291 | { |
292 | - foreach($this->getChanges() as $change) |
|
292 | + foreach ($this->getChanges() as $change) |
|
293 | 293 | call_user_func_array($change[0], $change[1]); |
294 | 294 | } |
295 | 295 | |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | */ |
336 | 336 | protected function updateVisible($visible) |
337 | 337 | { |
338 | - if($visible === false) |
|
339 | - $this->client()->replaceContent($this->_control,"<span id=\"".$this->_control->getClientID()."\" style=\"display:none\" ></span>"); |
|
338 | + if ($visible === false) |
|
339 | + $this->client()->replaceContent($this->_control, "<span id=\"" . $this->_control->getClientID() . "\" style=\"display:none\" ></span>"); |
|
340 | 340 | else |
341 | - $this->client()->replaceContent($this->_control,$this->_control); |
|
341 | + $this->client()->replaceContent($this->_control, $this->_control); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | protected function updateEnabled($enable) |
349 | 349 | { |
350 | - $this->client()->setAttribute($this->_control, 'disabled', $enable===false); |
|
350 | + $this->client()->setAttribute($this->_control, 'disabled', $enable === false); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | */ |
357 | 357 | protected function updateStyle($style) |
358 | 358 | { |
359 | - if($style['CssClass']!==null) |
|
359 | + if ($style['CssClass'] !== null) |
|
360 | 360 | $this->client()->setAttribute($this->_control, 'class', $style['CssClass']); |
361 | - if(count($style['Style']) > 0) |
|
361 | + if (count($style['Style']) > 0) |
|
362 | 362 | $this->client()->setStyle($this->_control, $style['Style']); |
363 | 363 | } |
364 | 364 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | protected function updateAttributes($attributes) |
370 | 370 | { |
371 | - foreach($attributes as $name => $value) |
|
371 | + foreach ($attributes as $name => $value) |
|
372 | 372 | $this->client()->setAttribute($this->_control, $name, $value); |
373 | 373 | } |
374 | 374 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | public function getDifference() |
432 | 432 | { |
433 | - if(gettype($this->_new) === gettype($this->_old) |
|
433 | + if (gettype($this->_new) === gettype($this->_old) |
|
434 | 434 | && $this->_new === $this->_old) |
435 | 435 | return $this->_null; |
436 | 436 | else |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | */ |
456 | 456 | protected function getCombinedStyle($obj) |
457 | 457 | { |
458 | - if(!($obj instanceof TStyle)) |
|
458 | + if (!($obj instanceof TStyle)) |
|
459 | 459 | return array(); |
460 | 460 | $style = $obj->getStyleFields(); |
461 | - $style = array_merge($style,$this->getStyleFromString($obj->getCustomStyle())); |
|
462 | - if($obj->hasFont()) |
|
461 | + $style = array_merge($style, $this->getStyleFromString($obj->getCustomStyle())); |
|
462 | + if ($obj->hasFont()) |
|
463 | 463 | $style = array_merge($style, $this->getStyleFromString($obj->getFont()->toString())); |
464 | 464 | return $style; |
465 | 465 | } |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | protected function getStyleFromString($string) |
472 | 472 | { |
473 | 473 | $style = array(); |
474 | - if(!is_string($string)) return $style; |
|
474 | + if (!is_string($string)) return $style; |
|
475 | 475 | |
476 | - foreach(explode(';',$string) as $sub) |
|
476 | + foreach (explode(';', $string) as $sub) |
|
477 | 477 | { |
478 | - $arr=explode(':',$sub); |
|
479 | - if(isset($arr[1]) && trim($arr[0])!=='') |
|
478 | + $arr = explode(':', $sub); |
|
479 | + if (isset($arr[1]) && trim($arr[0]) !== '') |
|
480 | 480 | $style[trim($arr[0])] = trim($arr[1]); |
481 | 481 | } |
482 | 482 | return $style; |
@@ -487,9 +487,9 @@ discard block |
||
487 | 487 | */ |
488 | 488 | protected function getCssClassDiff() |
489 | 489 | { |
490 | - if($this->_old===null) |
|
490 | + if ($this->_old === null) |
|
491 | 491 | { |
492 | - return ($this->_new!==null) && $this->_new->hasCssClass() |
|
492 | + return ($this->_new !== null) && $this->_new->hasCssClass() |
|
493 | 493 | ? $this->_new->getCssClass() : null; |
494 | 494 | } |
495 | 495 | else |
@@ -515,13 +515,13 @@ discard block |
||
515 | 515 | */ |
516 | 516 | public function getDifference() |
517 | 517 | { |
518 | - if($this->_new===null) |
|
518 | + if ($this->_new === null) |
|
519 | 519 | return $this->_null; |
520 | 520 | else |
521 | 521 | { |
522 | 522 | $css = $this->getCssClassDiff(); |
523 | 523 | $style = $this->getStyleDiff(); |
524 | - if(($css!==null) || ($style!==null)) |
|
524 | + if (($css !== null) || ($style !== null)) |
|
525 | 525 | return array('CssClass' => $css, 'Style' => $style); |
526 | 526 | else |
527 | 527 | $this->_null; |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public function getDifference() |
547 | 547 | { |
548 | - if($this->_old===null) |
|
548 | + if ($this->_old === null) |
|
549 | 549 | { |
550 | - return ($this->_new!==null) ? $this->_new->toArray() : $this->_null; |
|
550 | + return ($this->_new !== null) ? $this->_new->toArray() : $this->_null; |
|
551 | 551 | } |
552 | 552 | else |
553 | 553 | { |
@@ -78,8 +78,8 @@ |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | - * Publish the ajax script |
|
82 | - */ |
|
81 | + * Publish the ajax script |
|
82 | + */ |
|
83 | 83 | public function onPreRender($param) |
84 | 84 | { |
85 | 85 | parent::onPreRender($param); |
@@ -72,8 +72,7 @@ discard block |
||
72 | 72 | $this->_activeControlType = 'TBaseActiveCallbackControl'; |
73 | 73 | else |
74 | 74 | $this->_activeControlType = 'TBaseActiveControl'; |
75 | - } |
|
76 | - else |
|
75 | + } else |
|
77 | 76 | $this->_activeControlType = $type; |
78 | 77 | } |
79 | 78 | |
@@ -289,8 +288,9 @@ discard block |
||
289 | 288 | */ |
290 | 289 | public function respondToChanges() |
291 | 290 | { |
292 | - foreach($this->getChanges() as $change) |
|
293 | - call_user_func_array($change[0], $change[1]); |
|
291 | + foreach($this->getChanges() as $change) { |
|
292 | + call_user_func_array($change[0], $change[1]); |
|
293 | + } |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -368,8 +368,9 @@ discard block |
||
368 | 368 | */ |
369 | 369 | protected function updateAttributes($attributes) |
370 | 370 | { |
371 | - foreach($attributes as $name => $value) |
|
372 | - $this->client()->setAttribute($this->_control, $name, $value); |
|
371 | + foreach($attributes as $name => $value) { |
|
372 | + $this->client()->setAttribute($this->_control, $name, $value); |
|
373 | + } |
|
373 | 374 | } |
374 | 375 | } |
375 | 376 | |
@@ -491,8 +492,7 @@ discard block |
||
491 | 492 | { |
492 | 493 | return ($this->_new!==null) && $this->_new->hasCssClass() |
493 | 494 | ? $this->_new->getCssClass() : null; |
494 | - } |
|
495 | - else |
|
495 | + } else |
|
496 | 496 | { |
497 | 497 | return $this->_old->getCssClass() !== $this->_new->getCssClass() ? |
498 | 498 | $this->_new->getCssClass() : null; |
@@ -548,8 +548,7 @@ discard block |
||
548 | 548 | if($this->_old===null) |
549 | 549 | { |
550 | 550 | return ($this->_new!==null) ? $this->_new->toArray() : $this->_null; |
551 | - } |
|
552 | - else |
|
551 | + } else |
|
553 | 552 | { |
554 | 553 | $new = $this->_new->toArray(); |
555 | 554 | $old = $this->_old->toArray(); |
@@ -252,7 +252,7 @@ |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * @return boolean true to observe changes. |
|
255 | + * @return boolean|string true to observe changes. |
|
256 | 256 | */ |
257 | 257 | public function getObserveChanges() |
258 | 258 | { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | // it could have been changed by the clientside validation. |
109 | 109 | |
110 | 110 | parent::setIsValid($value); |
111 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
111 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
112 | 112 | { |
113 | 113 | $client = $this->getPage()->getCallbackClient(); |
114 | 114 | $func = 'Prado.Validation.updateActiveCustomValidator'; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function getClientScriptOptions() |
136 | 136 | { |
137 | - $options=TBaseValidator::getClientScriptOptions(); |
|
137 | + $options = TBaseValidator::getClientScriptOptions(); |
|
138 | 138 | $options['EventTarget'] = $this->getUniqueID(); |
139 | 139 | return $options; |
140 | 140 | } |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function setErrorMessage($value) |
147 | 147 | { |
148 | - if(parent::getErrorMessage() === $value) |
|
148 | + if (parent::getErrorMessage() === $value) |
|
149 | 149 | return; |
150 | 150 | |
151 | 151 | |
152 | 152 | parent::setErrorMessage($value); |
153 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
153 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
154 | 154 | { |
155 | 155 | $client = $this->getPage()->getCallbackClient(); |
156 | 156 | $func = 'Prado.Validation.setErrorMessage'; |
@@ -264,6 +264,6 @@ discard block |
||
264 | 264 | public function getObserveChanges() |
265 | 265 | { |
266 | 266 | $changes = $this->getOption('ObserveChanges'); |
267 | - return ($changes===null) ? true : $changes; |
|
267 | + return ($changes === null) ? true : $changes; |
|
268 | 268 | } |
269 | 269 | } |
@@ -66,7 +66,7 @@ |
||
66 | 66 | /** |
67 | 67 | * No client class for this control. |
68 | 68 | * This method overrides the parent implementation. |
69 | - * @return null no javascript class name. |
|
69 | + * @return string no javascript class name. |
|
70 | 70 | */ |
71 | 71 | protected function getClientClassName() |
72 | 72 | { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | protected function createListItemCollection() |
84 | 84 | { |
85 | - $collection = new TActiveListItemCollection; |
|
85 | + $collection = new TActiveListItemCollection; |
|
86 | 86 | $collection->setControl($this); |
87 | 87 | return $collection; |
88 | 88 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | protected function addAttributesToRender($writer) |
103 | 103 | { |
104 | 104 | parent::addAttributesToRender($writer); |
105 | - $writer->addAttribute('id',$this->getClientID()); |
|
105 | + $writer->addAttribute('id', $this->getClientID()); |
|
106 | 106 | if ($this->getAutoPostBack()) |
107 | 107 | $this->getActiveControl()->registerCallbackClientScript( |
108 | 108 | $this->getClientClassName(), $this->getPostBackOptions()); |
@@ -79,6 +79,7 @@ |
||
79 | 79 | |
80 | 80 | /** |
81 | 81 | * @param string the URL of the image file |
82 | + * @param string $value |
|
82 | 83 | */ |
83 | 84 | public function setImageUrl($value) |
84 | 85 | { |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setAlternateText($value) |
60 | 60 | { |
61 | - if(parent::getAlternateText() === $value) |
|
61 | + if (parent::getAlternateText() === $value) |
|
62 | 62 | return; |
63 | 63 | |
64 | 64 | parent::setAlternateText($value); |
65 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
65 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
66 | 66 | $this->getPage()->getCallbackClient()->setAttribute($this, 'alt', $value); |
67 | 67 | } |
68 | 68 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function setImageAlign($value) |
77 | 77 | { |
78 | - if(parent::getImageAlign() === $value) |
|
78 | + if (parent::getImageAlign() === $value) |
|
79 | 79 | return; |
80 | 80 | |
81 | 81 | parent::setImageAlign($value); |
82 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
82 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
83 | 83 | $this->getPage()->getCallbackClient()->setAttribute($this, 'align', $value); |
84 | 84 | } |
85 | 85 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function setImageUrl($value) |
90 | 90 | { |
91 | - if(parent::getImageUrl() === $value) |
|
91 | + if (parent::getImageUrl() === $value) |
|
92 | 92 | return; |
93 | 93 | |
94 | 94 | parent::setImageUrl($value); |
95 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
95 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
96 | 96 | $this->getPage()->getCallbackClient()->setAttribute($this, 'src', $value); |
97 | 97 | } |
98 | 98 | |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function setDescriptionUrl($value) |
103 | 103 | { |
104 | - if(parent::getDescriptionUrl() === $value) |
|
104 | + if (parent::getDescriptionUrl() === $value) |
|
105 | 105 | return; |
106 | 106 | |
107 | 107 | parent::setDescriptionUrl($value); |
108 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
108 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
109 | 109 | $this->getPage()->getCallbackClient()->setAttribute($this, 'longdesc', $value); |
110 | 110 | } |
111 | 111 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | protected function addAttributesToRender($writer) |
152 | 152 | { |
153 | 153 | parent::addAttributesToRender($writer); |
154 | - $writer->addAttribute('id',$this->getClientID()); |
|
154 | + $writer->addAttribute('id', $this->getClientID()); |
|
155 | 155 | $this->getActiveControl()->registerCallbackClientScript( |
156 | 156 | $this->getClientClassName(), $this->getPostBackOptions()); |
157 | 157 | } |