@@ -238,90 +238,90 @@ |
||
238 | 238 | parent::initRecursive($namingContainer); |
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Function to update view controls with data in a given AR object. |
|
243 | - * View controls and AR object need to have the same name in IDs and Attrs respectively. |
|
244 | - * @param TActiveRecord $arObj |
|
245 | - * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
246 | - * @author Daniel Sampedro <[email protected]> |
|
247 | - */ |
|
248 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
249 | - { |
|
250 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | - foreach (array_keys($objAttrs) as $key) |
|
252 | - { |
|
253 | - try |
|
254 | - { |
|
255 | - if ($key != "RELATIONS") |
|
256 | - { |
|
257 | - $control = $this->{$key}; |
|
258 | - if ($control instanceof TTextBox) |
|
259 | - $control->Text = $arObj->{$key}; |
|
260 | - elseif ($control instanceof TCheckBox) |
|
261 | - $control->Checked = (boolean) $arObj->{$key}; |
|
262 | - elseif ($control instanceof TDatePicker) |
|
263 | - $control->Date = $arObj->{$key}; |
|
264 | - } |
|
265 | - else |
|
266 | - { |
|
267 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | - { |
|
269 | - $relControl = $this->{$relKey}; |
|
270 | - switch ($relValues[0]) |
|
271 | - { |
|
272 | - case TActiveRecord::BELONGS_TO: |
|
273 | - case TActiveRecord::HAS_ONE: |
|
274 | - $relControl->Text = $arObj->{$relKey}; |
|
275 | - break; |
|
276 | - case TActiveRecord::HAS_MANY: |
|
277 | - if ($relControl instanceof TListControl) |
|
278 | - { |
|
279 | - $relControl->DataSource = $arObj->{$relKey}; |
|
280 | - $relControl->dataBind(); |
|
281 | - } |
|
282 | - break; |
|
283 | - } |
|
284 | - } |
|
285 | - break; |
|
286 | - } |
|
287 | - } |
|
288 | - catch (Exception $ex) |
|
289 | - { |
|
290 | - if ($throwExceptions) |
|
291 | - throw $ex; |
|
292 | - } |
|
293 | - } |
|
294 | - } |
|
241 | + /** |
|
242 | + * Function to update view controls with data in a given AR object. |
|
243 | + * View controls and AR object need to have the same name in IDs and Attrs respectively. |
|
244 | + * @param TActiveRecord $arObj |
|
245 | + * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
246 | + * @author Daniel Sampedro <[email protected]> |
|
247 | + */ |
|
248 | + public function tryToUpdateView($arObj, $throwExceptions = false) |
|
249 | + { |
|
250 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | + foreach (array_keys($objAttrs) as $key) |
|
252 | + { |
|
253 | + try |
|
254 | + { |
|
255 | + if ($key != "RELATIONS") |
|
256 | + { |
|
257 | + $control = $this->{$key}; |
|
258 | + if ($control instanceof TTextBox) |
|
259 | + $control->Text = $arObj->{$key}; |
|
260 | + elseif ($control instanceof TCheckBox) |
|
261 | + $control->Checked = (boolean) $arObj->{$key}; |
|
262 | + elseif ($control instanceof TDatePicker) |
|
263 | + $control->Date = $arObj->{$key}; |
|
264 | + } |
|
265 | + else |
|
266 | + { |
|
267 | + foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | + { |
|
269 | + $relControl = $this->{$relKey}; |
|
270 | + switch ($relValues[0]) |
|
271 | + { |
|
272 | + case TActiveRecord::BELONGS_TO: |
|
273 | + case TActiveRecord::HAS_ONE: |
|
274 | + $relControl->Text = $arObj->{$relKey}; |
|
275 | + break; |
|
276 | + case TActiveRecord::HAS_MANY: |
|
277 | + if ($relControl instanceof TListControl) |
|
278 | + { |
|
279 | + $relControl->DataSource = $arObj->{$relKey}; |
|
280 | + $relControl->dataBind(); |
|
281 | + } |
|
282 | + break; |
|
283 | + } |
|
284 | + } |
|
285 | + break; |
|
286 | + } |
|
287 | + } |
|
288 | + catch (Exception $ex) |
|
289 | + { |
|
290 | + if ($throwExceptions) |
|
291 | + throw $ex; |
|
292 | + } |
|
293 | + } |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * Function to try to update an AR object with data in view controls. |
|
298 | - * @param TActiveRecord $arObj |
|
299 | - * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
300 | - * @author Daniel Sampedro <[email protected]> |
|
301 | - */ |
|
302 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
303 | - { |
|
304 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | - foreach (array_keys($objAttrs) as $key) |
|
306 | - { |
|
307 | - try |
|
308 | - { |
|
309 | - if ($key == "RELATIONS") |
|
310 | - break; |
|
311 | - $control = $this->{$key}; |
|
312 | - if ($control instanceof TTextBox) |
|
313 | - $arObj->{$key} = $control->Text; |
|
314 | - elseif ($control instanceof TCheckBox) |
|
315 | - $arObj->{$key} = $control->Checked; |
|
316 | - elseif ($control instanceof TDatePicker) |
|
317 | - $arObj->{$key} = $control->Date; |
|
318 | - } |
|
319 | - catch (Exception $ex) |
|
320 | - { |
|
321 | - if ($throwExceptions) |
|
322 | - throw $ex; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
296 | + /** |
|
297 | + * Function to try to update an AR object with data in view controls. |
|
298 | + * @param TActiveRecord $arObj |
|
299 | + * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
300 | + * @author Daniel Sampedro <[email protected]> |
|
301 | + */ |
|
302 | + public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
303 | + { |
|
304 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | + foreach (array_keys($objAttrs) as $key) |
|
306 | + { |
|
307 | + try |
|
308 | + { |
|
309 | + if ($key == "RELATIONS") |
|
310 | + break; |
|
311 | + $control = $this->{$key}; |
|
312 | + if ($control instanceof TTextBox) |
|
313 | + $arObj->{$key} = $control->Text; |
|
314 | + elseif ($control instanceof TCheckBox) |
|
315 | + $arObj->{$key} = $control->Checked; |
|
316 | + elseif ($control instanceof TDatePicker) |
|
317 | + $arObj->{$key} = $control->Date; |
|
318 | + } |
|
319 | + catch (Exception $ex) |
|
320 | + { |
|
321 | + if ($throwExceptions) |
|
322 | + throw $ex; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | 326 | } |
327 | 327 |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | if(!isset(self::$_template[$class])) |
70 | 70 | self::$_template[$class]=$this->loadTemplate(); |
71 | 71 | return self::$_template[$class]; |
72 | - } |
|
73 | - else |
|
72 | + } else |
|
74 | 73 | return $this->_localTemplate; |
75 | 74 | } |
76 | 75 | |
@@ -205,8 +204,7 @@ discard block |
||
205 | 204 | $controls=$placeholder->getParent()->getControls(); |
206 | 205 | $loc=$controls->remove($placeholder); |
207 | 206 | $controls->insertAt($loc,$content); |
208 | - } |
|
209 | - else |
|
207 | + } else |
|
210 | 208 | throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
211 | 209 | } |
212 | 210 | |
@@ -232,8 +230,7 @@ discard block |
||
232 | 230 | $master->ensureChildControls(); |
233 | 231 | foreach($this->_contents as $id=>$content) |
234 | 232 | $master->injectContent($id,$content); |
235 | - } |
|
236 | - else if(!empty($this->_contents)) |
|
233 | + } else if(!empty($this->_contents)) |
|
237 | 234 | throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
238 | 235 | parent::initRecursive($namingContainer); |
239 | 236 | } |
@@ -261,8 +258,7 @@ discard block |
||
261 | 258 | $control->Checked = (boolean) $arObj->{$key}; |
262 | 259 | elseif ($control instanceof TDatePicker) |
263 | 260 | $control->Date = $arObj->{$key}; |
264 | - } |
|
265 | - else |
|
261 | + } else |
|
266 | 262 | { |
267 | 263 | foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
268 | 264 | { |
@@ -284,8 +280,7 @@ discard block |
||
284 | 280 | } |
285 | 281 | break; |
286 | 282 | } |
287 | - } |
|
288 | - catch (Exception $ex) |
|
283 | + } catch (Exception $ex) |
|
289 | 284 | { |
290 | 285 | if ($throwExceptions) |
291 | 286 | throw $ex; |
@@ -315,8 +310,7 @@ discard block |
||
315 | 310 | $arObj->{$key} = $control->Checked; |
316 | 311 | elseif ($control instanceof TDatePicker) |
317 | 312 | $arObj->{$key} = $control->Date; |
318 | - } |
|
319 | - catch (Exception $ex) |
|
313 | + } catch (Exception $ex) |
|
320 | 314 | { |
321 | 315 | if ($throwExceptions) |
322 | 316 | throw $ex; |
@@ -146,6 +146,7 @@ discard block |
||
146 | 146 | * Registers a content control. |
147 | 147 | * @param string ID of the content |
148 | 148 | * @param TContent |
149 | + * @param string $id |
|
149 | 150 | */ |
150 | 151 | public function registerContent($id,TContent $object) |
151 | 152 | { |
@@ -160,6 +161,7 @@ discard block |
||
160 | 161 | * This method should only be used by framework and control developers. |
161 | 162 | * @param string placeholder ID |
162 | 163 | * @param TContentPlaceHolder placeholder control |
164 | + * @param string $id |
|
163 | 165 | */ |
164 | 166 | public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
165 | 167 | { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function loadTemplate() |
119 | 119 | { |
120 | - Prado::trace("Loading template ".get_class($this),'\Prado\Web\UI\TTemplateControl'); |
|
120 | + Prado::trace("Loading template ".get_class($this), '\Prado\Web\UI\TTemplateControl'); |
|
121 | 121 | $template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
122 | 122 | return $template; |
123 | 123 | } |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | foreach($tpl->getDirective() as $name=>$value) |
135 | 135 | { |
136 | 136 | if(is_string($value)) |
137 | - $this->setSubProperty($name,$value); |
|
137 | + $this->setSubProperty($name, $value); |
|
138 | 138 | else |
139 | - throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name); |
|
139 | + throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name); |
|
140 | 140 | } |
141 | 141 | $tpl->instantiateIn($this); |
142 | 142 | } |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | * @param string ID of the content |
148 | 148 | * @param TContent |
149 | 149 | */ |
150 | - public function registerContent($id,TContent $object) |
|
150 | + public function registerContent($id, TContent $object) |
|
151 | 151 | { |
152 | 152 | if(isset($this->_contents[$id])) |
153 | - throw new TConfigurationException('templatecontrol_contentid_duplicated',$id); |
|
153 | + throw new TConfigurationException('templatecontrol_contentid_duplicated', $id); |
|
154 | 154 | else |
155 | 155 | $this->_contents[$id]=$object; |
156 | 156 | } |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | * @param string placeholder ID |
162 | 162 | * @param TContentPlaceHolder placeholder control |
163 | 163 | */ |
164 | - public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
|
164 | + public function registerContentPlaceHolder($id, TContentPlaceHolder $object) |
|
165 | 165 | { |
166 | 166 | if(isset($this->_placeholders[$id])) |
167 | - throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id); |
|
167 | + throw new TConfigurationException('templatecontrol_placeholderid_duplicated', $id); |
|
168 | 168 | else |
169 | 169 | $this->_placeholders[$id]=$object; |
170 | 170 | } |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | * @param string ID of the content control |
200 | 200 | * @param TContent the content to be injected |
201 | 201 | */ |
202 | - public function injectContent($id,$content) |
|
202 | + public function injectContent($id, $content) |
|
203 | 203 | { |
204 | 204 | if(isset($this->_placeholders[$id])) |
205 | 205 | { |
206 | 206 | $placeholder=$this->_placeholders[$id]; |
207 | 207 | $controls=$placeholder->getParent()->getControls(); |
208 | 208 | $loc=$controls->remove($placeholder); |
209 | - $controls->insertAt($loc,$content); |
|
209 | + $controls->insertAt($loc, $content); |
|
210 | 210 | } |
211 | 211 | else |
212 | - throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
|
212 | + throw new TConfigurationException('templatecontrol_placeholder_inexistent', $id); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | $this->getControls()->add($master); |
234 | 234 | $master->ensureChildControls(); |
235 | 235 | foreach($this->_contents as $id=>$content) |
236 | - $master->injectContent($id,$content); |
|
236 | + $master->injectContent($id, $content); |
|
237 | 237 | } |
238 | 238 | else if(!empty($this->_contents)) |
239 | - throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
|
239 | + throw new TConfigurationException('templatecontrol_mastercontrol_required', get_class($this)); |
|
240 | 240 | parent::initRecursive($namingContainer); |
241 | 241 | } |
242 | 242 | |
@@ -247,38 +247,38 @@ discard block |
||
247 | 247 | * @param Boolean $throwExceptions Wheter or not to throw exceptions |
248 | 248 | * @author Daniel Sampedro <[email protected]> |
249 | 249 | */ |
250 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
250 | + public function tryToUpdateView($arObj, $throwExceptions=false) |
|
251 | 251 | { |
252 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
253 | - foreach (array_keys($objAttrs) as $key) |
|
252 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
253 | + foreach(array_keys($objAttrs) as $key) |
|
254 | 254 | { |
255 | 255 | try |
256 | 256 | { |
257 | - if ($key != "RELATIONS") |
|
257 | + if($key!="RELATIONS") |
|
258 | 258 | { |
259 | - $control = $this->{$key}; |
|
260 | - if ($control instanceof TTextBox) |
|
261 | - $control->Text = $arObj->{$key}; |
|
262 | - elseif ($control instanceof TCheckBox) |
|
263 | - $control->Checked = (boolean) $arObj->{$key}; |
|
264 | - elseif ($control instanceof TDatePicker) |
|
265 | - $control->Date = $arObj->{$key}; |
|
259 | + $control=$this->{$key}; |
|
260 | + if($control instanceof TTextBox) |
|
261 | + $control->Text=$arObj->{$key}; |
|
262 | + elseif($control instanceof TCheckBox) |
|
263 | + $control->Checked=(boolean) $arObj->{$key}; |
|
264 | + elseif($control instanceof TDatePicker) |
|
265 | + $control->Date=$arObj->{$key}; |
|
266 | 266 | } |
267 | 267 | else |
268 | 268 | { |
269 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
269 | + foreach($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
270 | 270 | { |
271 | - $relControl = $this->{$relKey}; |
|
272 | - switch ($relValues[0]) |
|
271 | + $relControl=$this->{$relKey}; |
|
272 | + switch($relValues[0]) |
|
273 | 273 | { |
274 | 274 | case TActiveRecord::BELONGS_TO: |
275 | 275 | case TActiveRecord::HAS_ONE: |
276 | - $relControl->Text = $arObj->{$relKey}; |
|
276 | + $relControl->Text=$arObj->{$relKey}; |
|
277 | 277 | break; |
278 | 278 | case TActiveRecord::HAS_MANY: |
279 | - if ($relControl instanceof TListControl) |
|
279 | + if($relControl instanceof TListControl) |
|
280 | 280 | { |
281 | - $relControl->DataSource = $arObj->{$relKey}; |
|
281 | + $relControl->DataSource=$arObj->{$relKey}; |
|
282 | 282 | $relControl->dataBind(); |
283 | 283 | } |
284 | 284 | break; |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | break; |
288 | 288 | } |
289 | 289 | } |
290 | - catch (Exception $ex) |
|
290 | + catch(Exception $ex) |
|
291 | 291 | { |
292 | - if ($throwExceptions) |
|
292 | + if($throwExceptions) |
|
293 | 293 | throw $ex; |
294 | 294 | } |
295 | 295 | } |
@@ -301,26 +301,26 @@ discard block |
||
301 | 301 | * @param Boolean $throwExceptions Wheter or not to throw exceptions |
302 | 302 | * @author Daniel Sampedro <[email protected]> |
303 | 303 | */ |
304 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
304 | + public function tryToUpdateAR($arObj, $throwExceptions=false) |
|
305 | 305 | { |
306 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
307 | - foreach (array_keys($objAttrs) as $key) |
|
306 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
307 | + foreach(array_keys($objAttrs) as $key) |
|
308 | 308 | { |
309 | 309 | try |
310 | 310 | { |
311 | - if ($key == "RELATIONS") |
|
311 | + if($key=="RELATIONS") |
|
312 | 312 | break; |
313 | - $control = $this->{$key}; |
|
314 | - if ($control instanceof TTextBox) |
|
315 | - $arObj->{$key} = $control->Text; |
|
316 | - elseif ($control instanceof TCheckBox) |
|
317 | - $arObj->{$key} = $control->Checked; |
|
318 | - elseif ($control instanceof TDatePicker) |
|
319 | - $arObj->{$key} = $control->Date; |
|
313 | + $control=$this->{$key}; |
|
314 | + if($control instanceof TTextBox) |
|
315 | + $arObj->{$key}=$control->Text; |
|
316 | + elseif($control instanceof TCheckBox) |
|
317 | + $arObj->{$key}=$control->Checked; |
|
318 | + elseif($control instanceof TDatePicker) |
|
319 | + $arObj->{$key}=$control->Date; |
|
320 | 320 | } |
321 | - catch (Exception $ex) |
|
321 | + catch(Exception $ex) |
|
322 | 322 | { |
323 | - if ($throwExceptions) |
|
323 | + if($throwExceptions) |
|
324 | 324 | throw $ex; |
325 | 325 | } |
326 | 326 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * It reads the CacheModule property. |
51 | 51 | * @param TXmlElement module configuration |
52 | 52 | */ |
53 | - public function init($config) |
|
54 | - { |
|
53 | + public function init($config) |
|
54 | + { |
|
55 | 55 | if($this->_cacheModuleID==='') |
56 | 56 | throw new TConfigurationException('cachesession_cachemoduleid_required'); |
57 | 57 | else if(($cache=$this->getApplication()->getModule($this->_cacheModuleID))===null) |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | throw new TConfigurationException('cachesession_cachemodule_invalid',$this->_cacheModuleID); |
63 | 63 | $this->setUseCustomStorage(true); |
64 | 64 | parent::init($config); |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @return string the ID of the cache module. |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function _read($id) |
97 | 97 | { |
98 | - return $this->_cache->get($this->calculateKey($id)); |
|
98 | + return $this->_cache->get($this->calculateKey($id)); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function _destroy($id) |
119 | 119 | { |
120 | - return $this->_cache->delete($this->calculateKey($id)); |
|
120 | + return $this->_cache->delete($this->calculateKey($id)); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getKeyPrefix() |
127 | 127 | { |
128 | - return $this->_prefix; |
|
128 | + return $this->_prefix; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * @param string prefix of session variable name to avoid conflict with other cache data |
|
133 | - */ |
|
132 | + * @param string prefix of session variable name to avoid conflict with other cache data |
|
133 | + */ |
|
134 | 134 | public function setKeyPrefix($value) |
135 | 135 | { |
136 | - $this->_prefix=$value; |
|
136 | + $this->_prefix=$value; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | protected function calculateKey($id) |
144 | 144 | { |
145 | - return $this->_prefix.':'.$id; |
|
145 | + return $this->_prefix.':'.$id; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | if($this->_cacheModuleID==='') |
56 | 56 | throw new TConfigurationException('cachesession_cachemoduleid_required'); |
57 | 57 | else if(($cache=$this->getApplication()->getModule($this->_cacheModuleID))===null) |
58 | - throw new TConfigurationException('cachesession_cachemodule_inexistent',$this->_cacheModuleID); |
|
58 | + throw new TConfigurationException('cachesession_cachemodule_inexistent', $this->_cacheModuleID); |
|
59 | 59 | else if($cache instanceof ICache) |
60 | 60 | $this->_cache=$cache; |
61 | 61 | else |
62 | - throw new TConfigurationException('cachesession_cachemodule_invalid',$this->_cacheModuleID); |
|
62 | + throw new TConfigurationException('cachesession_cachemodule_invalid', $this->_cacheModuleID); |
|
63 | 63 | $this->setUseCustomStorage(true); |
64 | 64 | parent::init($config); |
65 | 65 | } |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * @param string session data |
105 | 105 | * @return boolean whether session write is successful |
106 | 106 | */ |
107 | - public function _write($id,$data) |
|
107 | + public function _write($id, $data) |
|
108 | 108 | { |
109 | - return $this->_cache->set($this->calculateKey($id),$data,$this->getTimeout()); |
|
109 | + return $this->_cache->set($this->calculateKey($id), $data, $this->getTimeout()); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -602,7 +602,7 @@ |
||
602 | 602 | |
603 | 603 | /** |
604 | 604 | * @param string the application configuration type. 'xml' and 'php' are valid values |
605 | - */ |
|
605 | + */ |
|
606 | 606 | public function setConfigurationType($value) |
607 | 607 | { |
608 | 608 | $this->_configType = $value; |
@@ -325,6 +325,7 @@ discard block |
||
325 | 325 | * to determine the application configuration file, |
326 | 326 | * application root path and the runtime path. |
327 | 327 | * @param string the application root path or the application configuration file |
328 | + * @param string $basePath |
|
328 | 329 | * @see setBasePath |
329 | 330 | * @see setRuntimePath |
330 | 331 | * @see setConfigurationFile |
@@ -423,6 +424,7 @@ discard block |
||
423 | 424 | * A global value is one that is persistent across users sessions and requests. |
424 | 425 | * @param string the name of the value to be returned |
425 | 426 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
427 | + * @param integer $defaultValue |
|
426 | 428 | * @return mixed the global value corresponding to $key |
427 | 429 | */ |
428 | 430 | public function getGlobalState($key,$defaultValue=null) |
@@ -439,6 +441,7 @@ discard block |
||
439 | 441 | * @param mixed the global value to be set |
440 | 442 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
441 | 443 | * @param boolean wheter to force an immediate GlobalState save. defaults to false |
444 | + * @param string $key |
|
442 | 445 | */ |
443 | 446 | public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false) |
444 | 447 | { |
@@ -553,6 +556,7 @@ discard block |
||
553 | 556 | |
554 | 557 | /** |
555 | 558 | * @param string the directory containing the application configuration file |
559 | + * @param string $value |
|
556 | 560 | */ |
557 | 561 | public function setBasePath($value) |
558 | 562 | { |
@@ -569,6 +573,7 @@ discard block |
||
569 | 573 | |
570 | 574 | /** |
571 | 575 | * @param string the application configuration file (absolute path) |
576 | + * @param string $value |
|
572 | 577 | */ |
573 | 578 | public function setConfigurationFile($value) |
574 | 579 | { |
@@ -585,6 +590,7 @@ discard block |
||
585 | 590 | |
586 | 591 | /** |
587 | 592 | * @param string the application configuration type. 'xml' and 'php' are valid values |
593 | + * @param string $value |
|
588 | 594 | */ |
589 | 595 | public function setConfigurationType($value) |
590 | 596 | { |
@@ -640,6 +646,7 @@ discard block |
||
640 | 646 | |
641 | 647 | /** |
642 | 648 | * @param string the directory storing cache data and application-level persistent data. (absolute path) |
649 | + * @param string $value |
|
643 | 650 | */ |
644 | 651 | public function setRuntimePath($value) |
645 | 652 | { |
@@ -1071,6 +1078,7 @@ discard block |
||
1071 | 1078 | * The service instance will be created. Its properties will be initialized |
1072 | 1079 | * and the configurations will be applied, if any. |
1073 | 1080 | * @param string service ID |
1081 | + * @param string $serviceID |
|
1074 | 1082 | */ |
1075 | 1083 | public function startService($serviceID) |
1076 | 1084 | { |
@@ -1109,6 +1117,7 @@ discard block |
||
1109 | 1117 | * This method is invoked when an exception is raised during the lifecycles |
1110 | 1118 | * of the application. |
1111 | 1119 | * @param mixed event parameter |
1120 | + * @param \Exception $param |
|
1112 | 1121 | */ |
1113 | 1122 | public function onError($param) |
1114 | 1123 | { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * Configuration file type, application.xml and config.xml |
118 | 118 | */ |
119 | - const CONFIG_TYPE_XML = 'xml'; |
|
119 | + const CONFIG_TYPE_XML='xml'; |
|
120 | 120 | /** |
121 | 121 | * Application configuration file name |
122 | 122 | */ |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * Configuration file type, application.php and config.php |
130 | 130 | */ |
131 | - const CONFIG_TYPE_PHP = 'php'; |
|
131 | + const CONFIG_TYPE_PHP='php'; |
|
132 | 132 | /** |
133 | 133 | * Runtime directory name |
134 | 134 | */ |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | /** |
282 | 282 | * @var string Customizable page service ID |
283 | 283 | */ |
284 | - private $_pageServiceID = self::PAGE_SERVICE_ID; |
|
284 | + private $_pageServiceID=self::PAGE_SERVICE_ID; |
|
285 | 285 | |
286 | 286 | /** |
287 | 287 | * Constructor. |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param boolean whether to cache application configuration. Defaults to true. |
302 | 302 | * @throws TConfigurationException if configuration file cannot be read or the runtime path is invalid. |
303 | 303 | */ |
304 | - public function __construct($basePath='protected',$cacheConfig=true, $configType=self::CONFIG_TYPE_XML) |
|
304 | + public function __construct($basePath='protected', $cacheConfig=true, $configType=self::CONFIG_TYPE_XML) |
|
305 | 305 | { |
306 | 306 | // register application as a singleton |
307 | 307 | Prado::setApplication($this); |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | // generates unique ID by hashing the runtime path |
315 | 315 | $this->_uniqueID=md5($this->_runtimePath); |
316 | 316 | $this->_parameters=new \Prado\Collections\TMap; |
317 | - $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
|
317 | + $this->_services=array($this->getPageServiceID()=>array('TPageService', array(), null)); |
|
318 | 318 | |
319 | - Prado::setPathOfAlias('Application',$this->_basePath); |
|
319 | + Prado::setPathOfAlias('Application', $this->_basePath); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | { |
334 | 334 | // determine configuration path and file |
335 | 335 | if(empty($basePath) || ($basePath=realpath($basePath))===false) |
336 | - throw new TConfigurationException('application_basepath_invalid',$basePath); |
|
336 | + throw new TConfigurationException('application_basepath_invalid', $basePath); |
|
337 | 337 | if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName())) |
338 | 338 | $configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName(); |
339 | 339 | else if(is_file($basePath)) |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | if(!is_dir($runtimePath)) |
355 | 355 | { |
356 | 356 | if(@mkdir($runtimePath)===false) |
357 | - throw new TConfigurationException('application_runtimepath_failed',$runtimePath); |
|
357 | + throw new TConfigurationException('application_runtimepath_failed', $runtimePath); |
|
358 | 358 | @chmod($runtimePath, PRADO_CHMOD); //make it deletable |
359 | 359 | } |
360 | 360 | $this->setConfigurationFile($configFile); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $this->setRuntimePath($runtimePath); |
364 | 364 | } |
365 | 365 | else |
366 | - throw new TConfigurationException('application_runtimepath_invalid',$runtimePath); |
|
366 | + throw new TConfigurationException('application_runtimepath_invalid', $runtimePath); |
|
367 | 367 | |
368 | 368 | } |
369 | 369 | |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | $n=count(self::$_steps); |
381 | 381 | $this->_step=0; |
382 | 382 | $this->_requestCompleted=false; |
383 | - while($this->_step<$n) |
|
383 | + while($this->_step < $n) |
|
384 | 384 | { |
385 | 385 | if($this->_mode===self::STATE_OFF) |
386 | - throw new THttpException(503,'application_unavailable'); |
|
386 | + throw new THttpException(503, 'application_unavailable'); |
|
387 | 387 | if($this->_requestCompleted) |
388 | 388 | break; |
389 | 389 | $method=self::$_steps[$this->_step]; |
390 | - Prado::trace("Executing $method()",'Prado\TApplication'); |
|
390 | + Prado::trace("Executing $method()", 'Prado\TApplication'); |
|
391 | 391 | $this->$method(); |
392 | 392 | $this->_step++; |
393 | 393 | } |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
426 | 426 | * @return mixed the global value corresponding to $key |
427 | 427 | */ |
428 | - public function getGlobalState($key,$defaultValue=null) |
|
428 | + public function getGlobalState($key, $defaultValue=null) |
|
429 | 429 | { |
430 | - return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue; |
|
430 | + return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue; |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
441 | 441 | * @param boolean wheter to force an immediate GlobalState save. defaults to false |
442 | 442 | */ |
443 | - public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false) |
|
443 | + public function setGlobalState($key, $value, $defaultValue=null, $forceSave=false) |
|
444 | 444 | { |
445 | 445 | $this->_stateChanged=true; |
446 | 446 | if($value===$defaultValue) |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | */ |
541 | 541 | public function setMode($value) |
542 | 542 | { |
543 | - $this->_mode=TPropertyValue::ensureEnum($value,'\Prado\TApplicationMode'); |
|
543 | + $this->_mode=TPropertyValue::ensureEnum($value, '\Prado\TApplicationMode'); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | */ |
589 | 589 | public function setConfigurationType($value) |
590 | 590 | { |
591 | - $this->_configType = $value; |
|
591 | + $this->_configType=$value; |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -601,10 +601,10 @@ discard block |
||
601 | 601 | switch($this->_configType) |
602 | 602 | { |
603 | 603 | case TApplication::CONFIG_TYPE_PHP: |
604 | - $this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP; |
|
604 | + $this->_configFileExt=TApplication::CONFIG_FILE_EXT_PHP; |
|
605 | 605 | break; |
606 | 606 | default: |
607 | - $this->_configFileExt = TApplication::CONFIG_FILE_EXT_XML; |
|
607 | + $this->_configFileExt=TApplication::CONFIG_FILE_EXT_XML; |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | return $this->_configFileExt; |
@@ -616,15 +616,15 @@ discard block |
||
616 | 616 | public function getConfigurationFileName() |
617 | 617 | { |
618 | 618 | static $fileName; |
619 | - if($fileName == null) |
|
619 | + if($fileName==null) |
|
620 | 620 | { |
621 | 621 | switch($this->_configType) |
622 | 622 | { |
623 | 623 | case TApplication::CONFIG_TYPE_PHP: |
624 | - $fileName = TApplication::CONFIG_FILE_PHP; |
|
624 | + $fileName=TApplication::CONFIG_FILE_PHP; |
|
625 | 625 | break; |
626 | 626 | default: |
627 | - $fileName = TApplication::CONFIG_FILE_XML; |
|
627 | + $fileName=TApplication::CONFIG_FILE_XML; |
|
628 | 628 | } |
629 | 629 | } |
630 | 630 | return $fileName; |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | public function setModule($id, IModule $module=null) |
676 | 676 | { |
677 | 677 | if(isset($this->_modules[$id])) |
678 | - throw new TConfigurationException('application_moduleid_duplicated',$id); |
|
678 | + throw new TConfigurationException('application_moduleid_duplicated', $id); |
|
679 | 679 | else |
680 | 680 | $this->_modules[$id]=$module; |
681 | 681 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | // force loading of a lazy module |
692 | 692 | if($this->_modules[$id]===null) |
693 | 693 | { |
694 | - $module = $this->internalLoadModule($id, true); |
|
694 | + $module=$this->internalLoadModule($id, true); |
|
695 | 695 | $module[0]->init($module[1]); |
696 | 696 | } |
697 | 697 | |
@@ -940,37 +940,37 @@ discard block |
||
940 | 940 | list($moduleClass, $initProperties, $configElement)=$this->_lazyModules[$id]; |
941 | 941 | if(isset($initProperties['lazy']) && $initProperties['lazy'] && !$force) |
942 | 942 | { |
943 | - Prado::trace("Postponed loading of lazy module $id ({$moduleClass})",'\Prado\TApplication'); |
|
943 | + Prado::trace("Postponed loading of lazy module $id ({$moduleClass})", '\Prado\TApplication'); |
|
944 | 944 | $this->setModule($id, null); |
945 | 945 | return null; |
946 | 946 | } |
947 | 947 | |
948 | - Prado::trace("Loading module $id ({$moduleClass})",'\Prado\TApplication'); |
|
948 | + Prado::trace("Loading module $id ({$moduleClass})", '\Prado\TApplication'); |
|
949 | 949 | $module=Prado::createComponent($moduleClass); |
950 | 950 | foreach($initProperties as $name=>$value) |
951 | 951 | { |
952 | 952 | if($name==='lazy') continue; |
953 | - $module->setSubProperty($name,$value); |
|
953 | + $module->setSubProperty($name, $value); |
|
954 | 954 | } |
955 | - $this->setModule($id,$module); |
|
955 | + $this->setModule($id, $module); |
|
956 | 956 | // keep the key to avoid reuse of the old module id |
957 | 957 | $this->_lazyModules[$id]=null; |
958 | 958 | |
959 | - return array($module,$configElement); |
|
959 | + return array($module, $configElement); |
|
960 | 960 | } |
961 | 961 | /** |
962 | 962 | * Applies an application configuration. |
963 | 963 | * @param TApplicationConfiguration the configuration |
964 | 964 | * @param boolean whether the configuration is specified within a service. |
965 | 965 | */ |
966 | - public function applyConfiguration($config,$withinService=false) |
|
966 | + public function applyConfiguration($config, $withinService=false) |
|
967 | 967 | { |
968 | 968 | if($config->getIsEmpty()) |
969 | 969 | return; |
970 | 970 | |
971 | 971 | // set path aliases and using namespaces |
972 | 972 | foreach($config->getAliases() as $alias=>$path) |
973 | - Prado::setPathOfAlias($alias,$path); |
|
973 | + Prado::setPathOfAlias($alias, $path); |
|
974 | 974 | foreach($config->getUsings() as $using) |
975 | 975 | Prado::using($using); |
976 | 976 | |
@@ -978,11 +978,11 @@ discard block |
||
978 | 978 | if(!$withinService) |
979 | 979 | { |
980 | 980 | foreach($config->getProperties() as $name=>$value) |
981 | - $this->setSubProperty($name,$value); |
|
981 | + $this->setSubProperty($name, $value); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | if(empty($this->_services)) |
985 | - $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
|
985 | + $this->_services=array($this->getPageServiceID()=>array('TPageService', array(), null)); |
|
986 | 986 | |
987 | 987 | // load parameters |
988 | 988 | foreach($config->getParameters() as $id=>$parameter) |
@@ -991,11 +991,11 @@ discard block |
||
991 | 991 | { |
992 | 992 | $component=Prado::createComponent($parameter[0]); |
993 | 993 | foreach($parameter[1] as $name=>$value) |
994 | - $component->setSubProperty($name,$value); |
|
995 | - $this->_parameters->add($id,$component); |
|
994 | + $component->setSubProperty($name, $value); |
|
995 | + $this->_parameters->add($id, $component); |
|
996 | 996 | } |
997 | 997 | else |
998 | - $this->_parameters->add($id,$parameter); |
|
998 | + $this->_parameters->add($id, $parameter); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | // load and init modules specified in app config |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | if(!is_string($id)) |
1006 | 1006 | $id='_module'.count($this->_lazyModules); |
1007 | 1007 | $this->_lazyModules[$id]=$moduleConfig; |
1008 | - if($module = $this->internalLoadModule($id)) |
|
1008 | + if($module=$this->internalLoadModule($id)) |
|
1009 | 1009 | $modules[]=$module; |
1010 | 1010 | } |
1011 | 1011 | foreach($modules as $module) |
@@ -1022,12 +1022,12 @@ discard block |
||
1022 | 1022 | $condition=$this->evaluateExpression($condition); |
1023 | 1023 | if($condition) |
1024 | 1024 | { |
1025 | - if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path)) |
|
1026 | - throw new TConfigurationException('application_includefile_invalid',$filePath); |
|
1025 | + if(($path=Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt()))===null || !is_file($path)) |
|
1026 | + throw new TConfigurationException('application_includefile_invalid', $filePath); |
|
1027 | 1027 | $cn=$this->getApplicationConfigurationClass(); |
1028 | 1028 | $c=new $cn; |
1029 | 1029 | $c->loadFromFile($path); |
1030 | - $this->applyConfiguration($c,$withinService); |
|
1030 | + $this->applyConfiguration($c, $withinService); |
|
1031 | 1031 | } |
1032 | 1032 | } |
1033 | 1033 | } |
@@ -1043,21 +1043,21 @@ discard block |
||
1043 | 1043 | */ |
1044 | 1044 | protected function initApplication() |
1045 | 1045 | { |
1046 | - Prado::trace('Initializing application','Prado\TApplication'); |
|
1046 | + Prado::trace('Initializing application', 'Prado\TApplication'); |
|
1047 | 1047 | |
1048 | 1048 | if($this->_configFile!==null) |
1049 | 1049 | { |
1050 | - if($this->_cacheFile===null || @filemtime($this->_cacheFile)<filemtime($this->_configFile)) |
|
1050 | + if($this->_cacheFile===null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) |
|
1051 | 1051 | { |
1052 | 1052 | $config=new TApplicationConfiguration; |
1053 | 1053 | $config->loadFromFile($this->_configFile); |
1054 | 1054 | if($this->_cacheFile!==null) |
1055 | - file_put_contents($this->_cacheFile,serialize($config),LOCK_EX); |
|
1055 | + file_put_contents($this->_cacheFile, serialize($config), LOCK_EX); |
|
1056 | 1056 | } |
1057 | 1057 | else |
1058 | 1058 | $config=unserialize(file_get_contents($this->_cacheFile)); |
1059 | 1059 | |
1060 | - $this->applyConfiguration($config,false); |
|
1060 | + $this->applyConfiguration($config, false); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null) |
@@ -1076,32 +1076,32 @@ discard block |
||
1076 | 1076 | { |
1077 | 1077 | if(isset($this->_services[$serviceID])) |
1078 | 1078 | { |
1079 | - list($serviceClass,$initProperties,$configElement)=$this->_services[$serviceID]; |
|
1079 | + list($serviceClass, $initProperties, $configElement)=$this->_services[$serviceID]; |
|
1080 | 1080 | $service=Prado::createComponent($serviceClass); |
1081 | 1081 | if(!($service instanceof IService)) |
1082 | - throw new THttpException(500,'application_service_invalid',$serviceClass); |
|
1082 | + throw new THttpException(500, 'application_service_invalid', $serviceClass); |
|
1083 | 1083 | if(!$service->getEnabled()) |
1084 | - throw new THttpException(500,'application_service_unavailable',$serviceClass); |
|
1084 | + throw new THttpException(500, 'application_service_unavailable', $serviceClass); |
|
1085 | 1085 | $service->setID($serviceID); |
1086 | 1086 | $this->setService($service); |
1087 | 1087 | |
1088 | 1088 | foreach($initProperties as $name=>$value) |
1089 | - $service->setSubProperty($name,$value); |
|
1089 | + $service->setSubProperty($name, $value); |
|
1090 | 1090 | |
1091 | 1091 | if($configElement!==null) |
1092 | 1092 | { |
1093 | 1093 | $config=new TApplicationConfiguration; |
1094 | 1094 | if($this->getConfigurationType()==self::CONFIG_TYPE_PHP) |
1095 | - $config->loadFromPhp($configElement,$this->getBasePath()); |
|
1095 | + $config->loadFromPhp($configElement, $this->getBasePath()); |
|
1096 | 1096 | else |
1097 | - $config->loadFromXml($configElement,$this->getBasePath()); |
|
1098 | - $this->applyConfiguration($config,true); |
|
1097 | + $config->loadFromXml($configElement, $this->getBasePath()); |
|
1098 | + $this->applyConfiguration($config, true); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | $service->init($configElement); |
1102 | 1102 | } |
1103 | 1103 | else |
1104 | - throw new THttpException(500,'application_service_unknown',$serviceID); |
|
1104 | + throw new THttpException(500, 'application_service_unknown', $serviceID); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | /** |
@@ -1112,9 +1112,9 @@ discard block |
||
1112 | 1112 | */ |
1113 | 1113 | public function onError($param) |
1114 | 1114 | { |
1115 | - Prado::log($param->getMessage(),TLogger::ERROR,'Prado\TApplication'); |
|
1116 | - $this->raiseEvent('OnError',$this,$param); |
|
1117 | - $this->getErrorHandler()->handleError($this,$param); |
|
1115 | + Prado::log($param->getMessage(), TLogger::ERROR, 'Prado\TApplication'); |
|
1116 | + $this->raiseEvent('OnError', $this, $param); |
|
1117 | + $this->getErrorHandler()->handleError($this, $param); |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | /** |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | */ |
1127 | 1127 | public function onBeginRequest() |
1128 | 1128 | { |
1129 | - $this->raiseEvent('OnBeginRequest',$this,null); |
|
1129 | + $this->raiseEvent('OnBeginRequest', $this, null); |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | /** |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | */ |
1136 | 1136 | public function onAuthentication() |
1137 | 1137 | { |
1138 | - $this->raiseEvent('OnAuthentication',$this,null); |
|
1138 | + $this->raiseEvent('OnAuthentication', $this, null); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | /** |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | */ |
1145 | 1145 | public function onAuthenticationComplete() |
1146 | 1146 | { |
1147 | - $this->raiseEvent('OnAuthenticationComplete',$this,null); |
|
1147 | + $this->raiseEvent('OnAuthenticationComplete', $this, null); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | /** |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | */ |
1154 | 1154 | public function onAuthorization() |
1155 | 1155 | { |
1156 | - $this->raiseEvent('OnAuthorization',$this,null); |
|
1156 | + $this->raiseEvent('OnAuthorization', $this, null); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | /** |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | */ |
1163 | 1163 | public function onAuthorizationComplete() |
1164 | 1164 | { |
1165 | - $this->raiseEvent('OnAuthorizationComplete',$this,null); |
|
1165 | + $this->raiseEvent('OnAuthorizationComplete', $this, null); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | /** |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | public function onLoadState() |
1173 | 1173 | { |
1174 | 1174 | $this->loadGlobals(); |
1175 | - $this->raiseEvent('OnLoadState',$this,null); |
|
1175 | + $this->raiseEvent('OnLoadState', $this, null); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | /** |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | */ |
1182 | 1182 | public function onLoadStateComplete() |
1183 | 1183 | { |
1184 | - $this->raiseEvent('OnLoadStateComplete',$this,null); |
|
1184 | + $this->raiseEvent('OnLoadStateComplete', $this, null); |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | /** |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | */ |
1191 | 1191 | public function onPreRunService() |
1192 | 1192 | { |
1193 | - $this->raiseEvent('OnPreRunService',$this,null); |
|
1193 | + $this->raiseEvent('OnPreRunService', $this, null); |
|
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | /** |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | public function onSaveState() |
1210 | 1210 | { |
1211 | - $this->raiseEvent('OnSaveState',$this,null); |
|
1211 | + $this->raiseEvent('OnSaveState', $this, null); |
|
1212 | 1212 | $this->saveGlobals(); |
1213 | 1213 | } |
1214 | 1214 | |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | */ |
1219 | 1219 | public function onSaveStateComplete() |
1220 | 1220 | { |
1221 | - $this->raiseEvent('OnSaveStateComplete',$this,null); |
|
1221 | + $this->raiseEvent('OnSaveStateComplete', $this, null); |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | /** |
@@ -1227,14 +1227,14 @@ discard block |
||
1227 | 1227 | */ |
1228 | 1228 | public function onPreFlushOutput() |
1229 | 1229 | { |
1230 | - $this->raiseEvent('OnPreFlushOutput',$this,null); |
|
1230 | + $this->raiseEvent('OnPreFlushOutput', $this, null); |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | /** |
1234 | 1234 | * Flushes output to client side. |
1235 | 1235 | * @param boolean whether to continue buffering after flush if buffering was active |
1236 | 1236 | */ |
1237 | - public function flushOutput($continueBuffering = true) |
|
1237 | + public function flushOutput($continueBuffering=true) |
|
1238 | 1238 | { |
1239 | 1239 | $this->getResponse()->flush($continueBuffering); |
1240 | 1240 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | public function onEndRequest() |
1247 | 1247 | { |
1248 | 1248 | $this->flushOutput(false); // flush all remaining content in the buffer |
1249 | - $this->saveGlobals(); // save global state |
|
1250 | - $this->raiseEvent('OnEndRequest',$this,null); |
|
1249 | + $this->saveGlobals(); // save global state |
|
1250 | + $this->raiseEvent('OnEndRequest', $this, null); |
|
1251 | 1251 | } |
1252 | 1252 | } |
@@ -340,8 +340,7 @@ discard block |
||
340 | 340 | { |
341 | 341 | $configFile=$basePath; |
342 | 342 | $basePath=dirname($configFile); |
343 | - } |
|
344 | - else |
|
343 | + } else |
|
345 | 344 | $configFile=null; |
346 | 345 | |
347 | 346 | // determine runtime path |
@@ -361,8 +360,7 @@ discard block |
||
361 | 360 | } |
362 | 361 | $this->setBasePath($basePath); |
363 | 362 | $this->setRuntimePath($runtimePath); |
364 | - } |
|
365 | - else |
|
363 | + } else |
|
366 | 364 | throw new TConfigurationException('application_runtimepath_invalid',$runtimePath); |
367 | 365 | |
368 | 366 | } |
@@ -391,8 +389,7 @@ discard block |
||
391 | 389 | $this->$method(); |
392 | 390 | $this->_step++; |
393 | 391 | } |
394 | - } |
|
395 | - catch(\Exception $e) |
|
392 | + } catch(\Exception $e) |
|
396 | 393 | { |
397 | 394 | $this->onError($e); |
398 | 395 | } |
@@ -993,8 +990,7 @@ discard block |
||
993 | 990 | foreach($parameter[1] as $name=>$value) |
994 | 991 | $component->setSubProperty($name,$value); |
995 | 992 | $this->_parameters->add($id,$component); |
996 | - } |
|
997 | - else |
|
993 | + } else |
|
998 | 994 | $this->_parameters->add($id,$parameter); |
999 | 995 | } |
1000 | 996 | |
@@ -1053,8 +1049,7 @@ discard block |
||
1053 | 1049 | $config->loadFromFile($this->_configFile); |
1054 | 1050 | if($this->_cacheFile!==null) |
1055 | 1051 | file_put_contents($this->_cacheFile,serialize($config),LOCK_EX); |
1056 | - } |
|
1057 | - else |
|
1052 | + } else |
|
1058 | 1053 | $config=unserialize(file_get_contents($this->_cacheFile)); |
1059 | 1054 | |
1060 | 1055 | $this->applyConfiguration($config,false); |
@@ -1099,8 +1094,7 @@ discard block |
||
1099 | 1094 | } |
1100 | 1095 | |
1101 | 1096 | $service->init($configElement); |
1102 | - } |
|
1103 | - else |
|
1097 | + } else |
|
1104 | 1098 | throw new THttpException(500,'application_service_unknown',$serviceID); |
1105 | 1099 | } |
1106 | 1100 |
@@ -90,10 +90,10 @@ |
||
90 | 90 | private $_association_columns=array(); |
91 | 91 | |
92 | 92 | /** |
93 | - * Get the foreign key index values from the results and make calls to the |
|
94 | - * database to find the corresponding foreign objects using association table. |
|
95 | - * @param array original results. |
|
96 | - */ |
|
93 | + * Get the foreign key index values from the results and make calls to the |
|
94 | + * database to find the corresponding foreign objects using association table. |
|
95 | + * @param array original results. |
|
96 | + */ |
|
97 | 97 | protected function collectForeignObjects(&$results) |
98 | 98 | { |
99 | 99 | list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys(); |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function collectForeignObjects(&$results) |
98 | 98 | { |
99 | - list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys(); |
|
100 | - $properties = array_values($sourceKeys); |
|
101 | - $indexValues = $this->getIndexValues($properties, $results); |
|
102 | - $this->fetchForeignObjects($results, $foreignKeys,$indexValues,$sourceKeys); |
|
99 | + list($sourceKeys, $foreignKeys)=$this->getRelationForeignKeys(); |
|
100 | + $properties=array_values($sourceKeys); |
|
101 | + $indexValues=$this->getIndexValues($properties, $results); |
|
102 | + $this->fetchForeignObjects($results, $foreignKeys, $indexValues, $sourceKeys); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getRelationForeignKeys() |
109 | 109 | { |
110 | - $association = $this->getAssociationTable(); |
|
111 | - $sourceKeys = $this->findForeignKeys($association, $this->getSourceRecord(), true); |
|
112 | - $fkObject = $this->getContext()->getForeignRecordFinder(); |
|
113 | - $foreignKeys = $this->findForeignKeys($association, $fkObject); |
|
110 | + $association=$this->getAssociationTable(); |
|
111 | + $sourceKeys=$this->findForeignKeys($association, $this->getSourceRecord(), true); |
|
112 | + $fkObject=$this->getContext()->getForeignRecordFinder(); |
|
113 | + $foreignKeys=$this->findForeignKeys($association, $fkObject); |
|
114 | 114 | return array($sourceKeys, $foreignKeys); |
115 | 115 | } |
116 | 116 | |
@@ -121,16 +121,16 @@ discard block |
||
121 | 121 | { |
122 | 122 | if($this->_association===null) |
123 | 123 | { |
124 | - $gateway = $this->getSourceRecord()->getRecordGateway(); |
|
125 | - $conn = $this->getSourceRecord()->getDbConnection(); |
|
124 | + $gateway=$this->getSourceRecord()->getRecordGateway(); |
|
125 | + $conn=$this->getSourceRecord()->getDbConnection(); |
|
126 | 126 | //table name may include the fk column name separated with a dot. |
127 | - $table = explode('.', $this->getContext()->getAssociationTable()); |
|
128 | - if(count($table)>1) |
|
127 | + $table=explode('.', $this->getContext()->getAssociationTable()); |
|
128 | + if(count($table) > 1) |
|
129 | 129 | { |
130 | - $columns = preg_replace('/^\((.*)\)/', '\1', $table[1]); |
|
131 | - $this->_association_columns = preg_split('/\s*[, ]\*/',$columns); |
|
130 | + $columns=preg_replace('/^\((.*)\)/', '\1', $table[1]); |
|
131 | + $this->_association_columns=preg_split('/\s*[, ]\*/', $columns); |
|
132 | 132 | } |
133 | - $this->_association = $gateway->getTableInfo($conn, $table[0]); |
|
133 | + $this->_association=$gateway->getTableInfo($conn, $table[0]); |
|
134 | 134 | } |
135 | 135 | return $this->_association; |
136 | 136 | } |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | { |
143 | 143 | if($this->_sourceTable===null) |
144 | 144 | { |
145 | - $gateway = $this->getSourceRecord()->getRecordGateway(); |
|
146 | - $this->_sourceTable = $gateway->getRecordTableInfo($this->getSourceRecord()); |
|
145 | + $gateway=$this->getSourceRecord()->getRecordGateway(); |
|
146 | + $this->_sourceTable=$gateway->getRecordTableInfo($this->getSourceRecord()); |
|
147 | 147 | } |
148 | 148 | return $this->_sourceTable; |
149 | 149 | } |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | { |
156 | 156 | if($this->_foreignTable===null) |
157 | 157 | { |
158 | - $gateway = $this->getSourceRecord()->getRecordGateway(); |
|
159 | - $fkObject = $this->getContext()->getForeignRecordFinder(); |
|
160 | - $this->_foreignTable = $gateway->getRecordTableInfo($fkObject); |
|
158 | + $gateway=$this->getSourceRecord()->getRecordGateway(); |
|
159 | + $fkObject=$this->getContext()->getForeignRecordFinder(); |
|
160 | + $this->_foreignTable=$gateway->getRecordTableInfo($fkObject); |
|
161 | 161 | } |
162 | 162 | return $this->_foreignTable; |
163 | 163 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function getForeignCommandBuilder() |
177 | 177 | { |
178 | - $obj = $this->getContext()->getForeignRecordFinder(); |
|
178 | + $obj=$this->getContext()->getForeignRecordFinder(); |
|
179 | 179 | return $this->getSourceRecord()->getRecordGateway()->getCommand($obj); |
180 | 180 | } |
181 | 181 | |
@@ -185,21 +185,21 @@ discard block |
||
185 | 185 | * @param array field names |
186 | 186 | * @param array foreign key index values. |
187 | 187 | */ |
188 | - protected function fetchForeignObjects(&$results,$foreignKeys,$indexValues,$sourceKeys) |
|
188 | + protected function fetchForeignObjects(&$results, $foreignKeys, $indexValues, $sourceKeys) |
|
189 | 189 | { |
190 | - $criteria = $this->getCriteria(); |
|
191 | - $finder = $this->getContext()->getForeignRecordFinder(); |
|
192 | - $type = get_class($finder); |
|
193 | - $command = $this->createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys); |
|
194 | - $srcProps = array_keys($sourceKeys); |
|
190 | + $criteria=$this->getCriteria(); |
|
191 | + $finder=$this->getContext()->getForeignRecordFinder(); |
|
192 | + $type=get_class($finder); |
|
193 | + $command=$this->createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys); |
|
194 | + $srcProps=array_keys($sourceKeys); |
|
195 | 195 | $collections=array(); |
196 | 196 | foreach($this->getCommandBuilder()->onExecuteCommand($command, $command->query()) as $row) |
197 | 197 | { |
198 | - $hash = $this->getObjectHash($row, $srcProps); |
|
198 | + $hash=$this->getObjectHash($row, $srcProps); |
|
199 | 199 | foreach($srcProps as $column) |
200 | 200 | unset($row[$column]); |
201 | - $obj = $this->createFkObject($type,$row,$foreignKeys); |
|
202 | - $collections[$hash][] = $obj; |
|
201 | + $obj=$this->createFkObject($type, $row, $foreignKeys); |
|
202 | + $collections[$hash][]=$obj; |
|
203 | 203 | } |
204 | 204 | $this->setResultCollection($results, $collections, array_values($sourceKeys)); |
205 | 205 | } |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * @param array foreign key column names |
211 | 211 | * @return TActiveRecord |
212 | 212 | */ |
213 | - protected function createFkObject($type,$row,$foreignKeys) |
|
213 | + protected function createFkObject($type, $row, $foreignKeys) |
|
214 | 214 | { |
215 | - $obj = TActiveRecord::createRecord($type, $row); |
|
215 | + $obj=TActiveRecord::createRecord($type, $row); |
|
216 | 216 | if(count($this->_association_columns) > 0) |
217 | 217 | { |
218 | 218 | $i=0; |
@@ -228,22 +228,22 @@ discard block |
||
228 | 228 | * @param array field names |
229 | 229 | * @param array field values |
230 | 230 | */ |
231 | - public function createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys) |
|
231 | + public function createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys) |
|
232 | 232 | { |
233 | - $innerJoin = $this->getAssociationJoin($foreignKeys,$indexValues,$sourceKeys); |
|
234 | - $fkTable = $this->getForeignTable()->getTableFullName(); |
|
235 | - $srcColumns = $this->getSourceColumns($sourceKeys); |
|
233 | + $innerJoin=$this->getAssociationJoin($foreignKeys, $indexValues, $sourceKeys); |
|
234 | + $fkTable=$this->getForeignTable()->getTableFullName(); |
|
235 | + $srcColumns=$this->getSourceColumns($sourceKeys); |
|
236 | 236 | if(($where=$criteria->getCondition())===null) |
237 | 237 | $where='1=1'; |
238 | - $sql = "SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}"; |
|
238 | + $sql="SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}"; |
|
239 | 239 | |
240 | - $parameters = $criteria->getParameters()->toArray(); |
|
241 | - $ordering = $criteria->getOrdersBy(); |
|
242 | - $limit = $criteria->getLimit(); |
|
243 | - $offset = $criteria->getOffset(); |
|
240 | + $parameters=$criteria->getParameters()->toArray(); |
|
241 | + $ordering=$criteria->getOrdersBy(); |
|
242 | + $limit=$criteria->getLimit(); |
|
243 | + $offset=$criteria->getOffset(); |
|
244 | 244 | |
245 | - $builder = $this->getForeignCommandBuilder()->getBuilder(); |
|
246 | - $command = $builder->applyCriterias($sql,$parameters,$ordering,$limit,$offset); |
|
245 | + $builder=$this->getForeignCommandBuilder()->getBuilder(); |
|
246 | + $command=$builder->applyCriterias($sql, $parameters, $ordering, $limit, $offset); |
|
247 | 247 | $this->getCommandBuilder()->onCreateCommand($command, $criteria); |
248 | 248 | return $command; |
249 | 249 | } |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | protected function getSourceColumns($sourceKeys) |
256 | 256 | { |
257 | 257 | $columns=array(); |
258 | - $table = $this->getAssociationTable(); |
|
259 | - $tableName = $table->getTableFullName(); |
|
260 | - $columnNames = array_merge(array_keys($sourceKeys),$this->_association_columns); |
|
258 | + $table=$this->getAssociationTable(); |
|
259 | + $tableName=$table->getTableFullName(); |
|
260 | + $columnNames=array_merge(array_keys($sourceKeys), $this->_association_columns); |
|
261 | 261 | foreach($columnNames as $name) |
262 | - $columns[] = $tableName.'.'.$table->getColumn($name)->getColumnName(); |
|
262 | + $columns[]=$tableName.'.'.$table->getColumn($name)->getColumnName(); |
|
263 | 263 | return implode(', ', $columns); |
264 | 264 | } |
265 | 265 | |
@@ -270,28 +270,28 @@ discard block |
||
270 | 270 | * @param array source table column names. |
271 | 271 | * @return string inner join condition for M-N relationship via association table. |
272 | 272 | */ |
273 | - protected function getAssociationJoin($foreignKeys,$indexValues,$sourceKeys) |
|
273 | + protected function getAssociationJoin($foreignKeys, $indexValues, $sourceKeys) |
|
274 | 274 | { |
275 | - $refInfo= $this->getAssociationTable(); |
|
276 | - $fkInfo = $this->getForeignTable(); |
|
275 | + $refInfo=$this->getAssociationTable(); |
|
276 | + $fkInfo=$this->getForeignTable(); |
|
277 | 277 | |
278 | - $refTable = $refInfo->getTableFullName(); |
|
279 | - $fkTable = $fkInfo->getTableFullName(); |
|
278 | + $refTable=$refInfo->getTableFullName(); |
|
279 | + $fkTable=$fkInfo->getTableFullName(); |
|
280 | 280 | |
281 | - $joins = array(); |
|
282 | - $hasAssociationColumns = count($this->_association_columns) > 0; |
|
281 | + $joins=array(); |
|
282 | + $hasAssociationColumns=count($this->_association_columns) > 0; |
|
283 | 283 | $i=0; |
284 | 284 | foreach($foreignKeys as $ref=>$fk) |
285 | 285 | { |
286 | 286 | if($hasAssociationColumns) |
287 | - $refField = $refInfo->getColumn($this->_association_columns[$i++])->getColumnName(); |
|
287 | + $refField=$refInfo->getColumn($this->_association_columns[$i++])->getColumnName(); |
|
288 | 288 | else |
289 | - $refField = $refInfo->getColumn($ref)->getColumnName(); |
|
290 | - $fkField = $fkInfo->getColumn($fk)->getColumnName(); |
|
291 | - $joins[] = "{$fkTable}.{$fkField} = {$refTable}.{$refField}"; |
|
289 | + $refField=$refInfo->getColumn($ref)->getColumnName(); |
|
290 | + $fkField=$fkInfo->getColumn($fk)->getColumnName(); |
|
291 | + $joins[]="{$fkTable}.{$fkField} = {$refTable}.{$refField}"; |
|
292 | 292 | } |
293 | - $joinCondition = implode(' AND ', $joins); |
|
294 | - $index = $this->getCommandBuilder()->getIndexKeyCondition($refInfo,array_keys($sourceKeys), $indexValues); |
|
293 | + $joinCondition=implode(' AND ', $joins); |
|
294 | + $index=$this->getCommandBuilder()->getIndexKeyCondition($refInfo, array_keys($sourceKeys), $indexValues); |
|
295 | 295 | return "INNER JOIN {$refTable} ON ({$joinCondition}) AND {$index}"; |
296 | 296 | } |
297 | 297 | |
@@ -301,15 +301,15 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function updateAssociatedRecords() |
303 | 303 | { |
304 | - $obj = $this->getContext()->getSourceRecord(); |
|
305 | - $fkObjects = &$obj->{$this->getContext()->getProperty()}; |
|
304 | + $obj=$this->getContext()->getSourceRecord(); |
|
305 | + $fkObjects=&$obj->{$this->getContext()->getProperty()}; |
|
306 | 306 | $success=true; |
307 | - if(($total = count($fkObjects))> 0) |
|
307 | + if(($total=count($fkObjects)) > 0) |
|
308 | 308 | { |
309 | - $source = $this->getSourceRecord(); |
|
310 | - $builder = $this->getAssociationTableCommandBuilder(); |
|
311 | - for($i=0;$i<$total;$i++) |
|
312 | - $success = $fkObjects[$i]->save() && $success; |
|
309 | + $source=$this->getSourceRecord(); |
|
310 | + $builder=$this->getAssociationTableCommandBuilder(); |
|
311 | + for($i=0; $i < $total; $i++) |
|
312 | + $success=$fkObjects[$i]->save() && $success; |
|
313 | 313 | return $this->updateAssociationTable($obj, $fkObjects, $builder) && $success; |
314 | 314 | } |
315 | 315 | return $success; |
@@ -320,57 +320,57 @@ discard block |
||
320 | 320 | */ |
321 | 321 | protected function getAssociationTableCommandBuilder() |
322 | 322 | { |
323 | - $conn = $this->getContext()->getSourceRecord()->getDbConnection(); |
|
323 | + $conn=$this->getContext()->getSourceRecord()->getDbConnection(); |
|
324 | 324 | return $this->getAssociationTable()->createCommandBuilder($conn); |
325 | 325 | } |
326 | 326 | |
327 | - private function hasAssociationData($builder,$data) |
|
327 | + private function hasAssociationData($builder, $data) |
|
328 | 328 | { |
329 | 329 | $condition=array(); |
330 | - $table = $this->getAssociationTable(); |
|
330 | + $table=$this->getAssociationTable(); |
|
331 | 331 | foreach($data as $name=>$value) |
332 | - $condition[] = $table->getColumn($name)->getColumnName().' = ?'; |
|
333 | - $command = $builder->createCountCommand(implode(' AND ', $condition),array_values($data)); |
|
334 | - $result = $this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar())); |
|
332 | + $condition[]=$table->getColumn($name)->getColumnName().' = ?'; |
|
333 | + $command=$builder->createCountCommand(implode(' AND ', $condition), array_values($data)); |
|
334 | + $result=$this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar())); |
|
335 | 335 | return intval($result) > 0; |
336 | 336 | } |
337 | 337 | |
338 | - private function addAssociationData($builder,$data) |
|
338 | + private function addAssociationData($builder, $data) |
|
339 | 339 | { |
340 | - $command = $builder->createInsertCommand($data); |
|
340 | + $command=$builder->createInsertCommand($data); |
|
341 | 341 | return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0; |
342 | 342 | } |
343 | 343 | |
344 | - private function updateAssociationTable($obj,$fkObjects, $builder) |
|
344 | + private function updateAssociationTable($obj, $fkObjects, $builder) |
|
345 | 345 | { |
346 | - $source = $this->getSourceRecordValues($obj); |
|
347 | - $foreignKeys = $this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]); |
|
346 | + $source=$this->getSourceRecordValues($obj); |
|
347 | + $foreignKeys=$this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]); |
|
348 | 348 | $success=true; |
349 | 349 | foreach($fkObjects as $fkObject) |
350 | 350 | { |
351 | - $data = array_merge($source, $this->getForeignObjectValues($foreignKeys,$fkObject)); |
|
352 | - if(!$this->hasAssociationData($builder,$data)) |
|
353 | - $success = $this->addAssociationData($builder,$data) && $success; |
|
351 | + $data=array_merge($source, $this->getForeignObjectValues($foreignKeys, $fkObject)); |
|
352 | + if(!$this->hasAssociationData($builder, $data)) |
|
353 | + $success=$this->addAssociationData($builder, $data) && $success; |
|
354 | 354 | } |
355 | 355 | return $success; |
356 | 356 | } |
357 | 357 | |
358 | 358 | private function getSourceRecordValues($obj) |
359 | 359 | { |
360 | - $sourceKeys = $this->findForeignKeys($this->getAssociationTable(), $obj); |
|
361 | - $indexValues = $this->getIndexValues(array_values($sourceKeys), $obj); |
|
362 | - $data = array(); |
|
360 | + $sourceKeys=$this->findForeignKeys($this->getAssociationTable(), $obj); |
|
361 | + $indexValues=$this->getIndexValues(array_values($sourceKeys), $obj); |
|
362 | + $data=array(); |
|
363 | 363 | $i=0; |
364 | 364 | foreach($sourceKeys as $name=>$srcKey) |
365 | - $data[$name] = $indexValues[0][$i++]; |
|
365 | + $data[$name]=$indexValues[0][$i++]; |
|
366 | 366 | return $data; |
367 | 367 | } |
368 | 368 | |
369 | - private function getForeignObjectValues($foreignKeys,$fkObject) |
|
369 | + private function getForeignObjectValues($foreignKeys, $fkObject) |
|
370 | 370 | { |
371 | 371 | $data=array(); |
372 | 372 | foreach($foreignKeys as $name=>$fKey) |
373 | - $data[$name] = $fkObject->getColumnValue($fKey); |
|
373 | + $data[$name]=$fkObject->getColumnValue($fKey); |
|
374 | 374 | return $data; |
375 | 375 | } |
376 | 376 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | - * @return TDataGatewayCommand |
|
168 | + * @return \Prado\Data\DataGateway\TDataGatewayCommand |
|
169 | 169 | */ |
170 | 170 | protected function getCommandBuilder() |
171 | 171 | { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @return TDataGatewayCommand |
|
176 | + * @return \Prado\Data\DataGateway\TDataGatewayCommand |
|
177 | 177 | */ |
178 | 178 | protected function getForeignCommandBuilder() |
179 | 179 | { |
@@ -210,6 +210,7 @@ discard block |
||
210 | 210 | * @param string active record class name. |
211 | 211 | * @param array row data |
212 | 212 | * @param array foreign key column names |
213 | + * @param string $type |
|
213 | 214 | * @return TActiveRecord |
214 | 215 | */ |
215 | 216 | protected function createFkObject($type,$row,$foreignKeys) |
@@ -343,6 +344,9 @@ discard block |
||
343 | 344 | return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0; |
344 | 345 | } |
345 | 346 | |
347 | + /** |
|
348 | + * @param TActiveRecord $obj |
|
349 | + */ |
|
346 | 350 | private function updateAssociationTable($obj,$fkObjects, $builder) |
347 | 351 | { |
348 | 352 | $source = $this->getSourceRecordValues($obj); |
@@ -189,11 +189,11 @@ |
||
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
192 | - /** |
|
193 | - * Returns all table names in the database. |
|
194 | - * @param string $schema the schema of the tables. This is not used for sqlite database. |
|
195 | - * @return array all table names in the database. |
|
196 | - */ |
|
192 | + /** |
|
193 | + * Returns all table names in the database. |
|
194 | + * @param string $schema the schema of the tables. This is not used for sqlite database. |
|
195 | + * @return array all table names in the database. |
|
196 | + */ |
|
197 | 197 | public function findTableNames($schema='') |
198 | 198 | { |
199 | 199 | $sql="SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'"; |
@@ -69,30 +69,30 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected function createTableInfo($tableName) |
71 | 71 | { |
72 | - $tableName = str_replace("'",'',$tableName); |
|
72 | + $tableName=str_replace("'", '', $tableName); |
|
73 | 73 | $this->getDbConnection()->setActive(true); |
74 | - $table = $this->getDbConnection()->quoteString($tableName); |
|
75 | - $sql = "PRAGMA table_info({$table})"; |
|
76 | - $command = $this->getDbConnection()->createCommand($sql); |
|
77 | - $foreign = $this->getForeignKeys($table); |
|
74 | + $table=$this->getDbConnection()->quoteString($tableName); |
|
75 | + $sql="PRAGMA table_info({$table})"; |
|
76 | + $command=$this->getDbConnection()->createCommand($sql); |
|
77 | + $foreign=$this->getForeignKeys($table); |
|
78 | 78 | $index=0; |
79 | 79 | $columns=array(); |
80 | 80 | $primary=array(); |
81 | 81 | foreach($command->query() as $col) |
82 | 82 | { |
83 | - $col['index'] = $index++; |
|
84 | - $column = $this->processColumn($col, $foreign); |
|
85 | - $columns[$col['name']] = $column; |
|
83 | + $col['index']=$index++; |
|
84 | + $column=$this->processColumn($col, $foreign); |
|
85 | + $columns[$col['name']]=$column; |
|
86 | 86 | if($column->getIsPrimaryKey()) |
87 | - $primary[] = $col['name']; |
|
87 | + $primary[]=$col['name']; |
|
88 | 88 | } |
89 | - $info['TableName'] = $tableName; |
|
89 | + $info['TableName']=$tableName; |
|
90 | 90 | if($this->getIsView($tableName)) |
91 | - $info['IsView'] = true; |
|
91 | + $info['IsView']=true; |
|
92 | 92 | if(count($columns)===0) |
93 | 93 | throw new TDbException('dbmetadata_invalid_table_view', $tableName); |
94 | - $class = $this->getTableInfoClass(); |
|
95 | - $tableInfo = new $class($info,$primary,$foreign); |
|
94 | + $class=$this->getTableInfoClass(); |
|
95 | + $tableInfo=new $class($info, $primary, $foreign); |
|
96 | 96 | $tableInfo->getColumns()->copyFrom($columns); |
97 | 97 | return $tableInfo; |
98 | 98 | } |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function getIsView($tableName) |
105 | 105 | { |
106 | - $sql = 'SELECT count(*) FROM sqlite_master WHERE type="view" AND name= :table'; |
|
106 | + $sql='SELECT count(*) FROM sqlite_master WHERE type="view" AND name= :table'; |
|
107 | 107 | $this->getDbConnection()->setActive(true); |
108 | - $command = $this->getDbConnection()->createCommand($sql); |
|
108 | + $command=$this->getDbConnection()->createCommand($sql); |
|
109 | 109 | $command->bindValue(':table', $tableName); |
110 | - return intval($command->queryScalar()) === 1; |
|
110 | + return intval($command->queryScalar())===1; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function processColumn($col, $foreign) |
119 | 119 | { |
120 | - $columnId = $col['name']; //use column name as column Id |
|
120 | + $columnId=$col['name']; //use column name as column Id |
|
121 | 121 | |
122 | - $info['ColumnName'] = '"'.$columnId.'"'; //quote the column names! |
|
123 | - $info['ColumnId'] = $columnId; |
|
124 | - $info['ColumnIndex'] = $col['index']; |
|
122 | + $info['ColumnName']='"'.$columnId.'"'; //quote the column names! |
|
123 | + $info['ColumnId']=$columnId; |
|
124 | + $info['ColumnIndex']=$col['index']; |
|
125 | 125 | |
126 | 126 | if($col['notnull']!=='99') |
127 | - $info['AllowNull'] = true; |
|
127 | + $info['AllowNull']=true; |
|
128 | 128 | |
129 | 129 | if($col['pk']==='1') |
130 | - $info['IsPrimaryKey'] = true; |
|
130 | + $info['IsPrimaryKey']=true; |
|
131 | 131 | if($this->isForeignKeyColumn($columnId, $foreign)) |
132 | - $info['IsForeignKey'] = true; |
|
132 | + $info['IsForeignKey']=true; |
|
133 | 133 | |
134 | 134 | if($col['dflt_value']!==null) |
135 | - $info['DefaultValue'] = $col['dflt_value']; |
|
135 | + $info['DefaultValue']=$col['dflt_value']; |
|
136 | 136 | |
137 | - $type = strtolower($col['type']); |
|
138 | - $info['AutoIncrement'] = $type==='integer' && $col['pk']==='1'; |
|
137 | + $type=strtolower($col['type']); |
|
138 | + $info['AutoIncrement']=$type==='integer' && $col['pk']==='1'; |
|
139 | 139 | |
140 | - $info['DbType'] = $type; |
|
140 | + $info['DbType']=$type; |
|
141 | 141 | $match=array(); |
142 | 142 | if(is_int($pos=strpos($type, '(')) && preg_match('/\((.*)\)/', $type, $match)) |
143 | 143 | { |
144 | - $ps = explode(',', $match[1]); |
|
144 | + $ps=explode(',', $match[1]); |
|
145 | 145 | if(count($ps)===2) |
146 | 146 | { |
147 | - $info['NumericPrecision'] = intval($ps[0]); |
|
148 | - $info['NumericScale'] = intval($ps[1]); |
|
147 | + $info['NumericPrecision']=intval($ps[0]); |
|
148 | + $info['NumericScale']=intval($ps[1]); |
|
149 | 149 | } |
150 | 150 | else |
151 | 151 | $info['ColumnSize']=intval($match[1]); |
152 | - $info['DbType'] = substr($type,0,$pos); |
|
152 | + $info['DbType']=substr($type, 0, $pos); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | return new TSqliteTableColumn($info); |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function getForeignKeys($table) |
165 | 165 | { |
166 | - $sql = "PRAGMA foreign_key_list({$table})"; |
|
167 | - $command = $this->getDbConnection()->createCommand($sql); |
|
168 | - $fkeys = array(); |
|
166 | + $sql="PRAGMA foreign_key_list({$table})"; |
|
167 | + $command=$this->getDbConnection()->createCommand($sql); |
|
168 | + $fkeys=array(); |
|
169 | 169 | foreach($command->query() as $col) |
170 | 170 | { |
171 | - $fkeys[$col['table']]['keys'][$col['from']] = $col['to']; |
|
172 | - $fkeys[$col['table']]['table'] = $col['table']; |
|
171 | + $fkeys[$col['table']]['keys'][$col['from']]=$col['to']; |
|
172 | + $fkeys[$col['table']]['table']=$col['table']; |
|
173 | 173 | } |
174 | 174 | return count($fkeys) > 0 ? array_values($fkeys) : $fkeys; |
175 | 175 | } |
@@ -158,8 +158,7 @@ |
||
158 | 158 | $e->setAttribute('maxOccurs','unbounded'); |
159 | 159 | $sequence->appendChild($e); |
160 | 160 | $complexType->appendChild($sequence); |
161 | - } |
|
162 | - else |
|
161 | + } else |
|
163 | 162 | { |
164 | 163 | $all = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:all'); |
165 | 164 | foreach($elements as $elem) |
@@ -36,46 +36,46 @@ |
||
36 | 36 | class TWsatService extends TPageService |
37 | 37 | { |
38 | 38 | |
39 | - private $_pass = ''; |
|
39 | + private $_pass = ''; |
|
40 | 40 | |
41 | - public function init($config) |
|
42 | - { |
|
43 | - if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
44 | - throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
|
41 | + public function init($config) |
|
42 | + { |
|
43 | + if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
44 | + throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
|
45 | 45 | |
46 | - if (empty($this->_pass)) |
|
47 | - throw new TConfigurationException("You need to specify the Password attribute."); |
|
46 | + if (empty($this->_pass)) |
|
47 | + throw new TConfigurationException("You need to specify the Password attribute."); |
|
48 | 48 | |
49 | - $this->setDefaultPage("TWsatHome"); |
|
50 | - $this->_startThemeManager(); |
|
51 | - parent::init($config); |
|
52 | - } |
|
49 | + $this->setDefaultPage("TWsatHome"); |
|
50 | + $this->_startThemeManager(); |
|
51 | + parent::init($config); |
|
52 | + } |
|
53 | 53 | |
54 | - public function getBasePath() |
|
55 | - { |
|
56 | - $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); |
|
57 | - return realpath($basePath); |
|
58 | - } |
|
54 | + public function getBasePath() |
|
55 | + { |
|
56 | + $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); |
|
57 | + return realpath($basePath); |
|
58 | + } |
|
59 | 59 | |
60 | - private function _startThemeManager() |
|
61 | - { |
|
62 | - $themeManager = new TThemeManager; |
|
63 | - $themeManager->BasePath = "System.Wsat.themes"; |
|
64 | - $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
65 | - $themeManager->BaseUrl = "$url/themes"; |
|
60 | + private function _startThemeManager() |
|
61 | + { |
|
62 | + $themeManager = new TThemeManager; |
|
63 | + $themeManager->BasePath = "System.Wsat.themes"; |
|
64 | + $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
65 | + $themeManager->BaseUrl = "$url/themes"; |
|
66 | 66 | |
67 | - $themeManager->init(null); |
|
68 | - $this->setThemeManager($themeManager); |
|
69 | - } |
|
67 | + $themeManager->init(null); |
|
68 | + $this->setThemeManager($themeManager); |
|
69 | + } |
|
70 | 70 | |
71 | - public function getPassword() |
|
72 | - { |
|
73 | - return $this->_pass; |
|
74 | - } |
|
71 | + public function getPassword() |
|
72 | + { |
|
73 | + return $this->_pass; |
|
74 | + } |
|
75 | 75 | |
76 | - public function setPassword($_pass) |
|
77 | - { |
|
78 | - $this->_pass = $_pass; |
|
79 | - } |
|
76 | + public function setPassword($_pass) |
|
77 | + { |
|
78 | + $this->_pass = $_pass; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | class TWsatService extends TPageService |
37 | 37 | { |
38 | 38 | |
39 | - private $_pass = ''; |
|
39 | + private $_pass=''; |
|
40 | 40 | |
41 | 41 | public function init($config) |
42 | 42 | { |
43 | - if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
43 | + if($this->getApplication()->getMode()===TApplicationMode::Performance || $this->getApplication()->getMode()===TApplicationMode::Normal) |
|
44 | 44 | throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
45 | 45 | |
46 | - if (empty($this->_pass)) |
|
46 | + if(empty($this->_pass)) |
|
47 | 47 | throw new TConfigurationException("You need to specify the Password attribute."); |
48 | 48 | |
49 | 49 | $this->setDefaultPage("TWsatHome"); |
@@ -53,16 +53,16 @@ discard block |
||
53 | 53 | |
54 | 54 | public function getBasePath() |
55 | 55 | { |
56 | - $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); |
|
56 | + $basePath=Prado::getPathOfNamespace("System.Wsat.pages"); |
|
57 | 57 | return realpath($basePath); |
58 | 58 | } |
59 | 59 | |
60 | 60 | private function _startThemeManager() |
61 | 61 | { |
62 | - $themeManager = new TThemeManager; |
|
63 | - $themeManager->BasePath = "System.Wsat.themes"; |
|
64 | - $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
65 | - $themeManager->BaseUrl = "$url/themes"; |
|
62 | + $themeManager=new TThemeManager; |
|
63 | + $themeManager->BasePath="System.Wsat.themes"; |
|
64 | + $url=Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
65 | + $themeManager->BaseUrl="$url/themes"; |
|
66 | 66 | |
67 | 67 | $themeManager->init(null); |
68 | 68 | $this->setThemeManager($themeManager); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function setPassword($_pass) |
77 | 77 | { |
78 | - $this->_pass = $_pass; |
|
78 | + $this->_pass=$_pass; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -14,69 +14,69 @@ |
||
14 | 14 | class TWsatBaseGenerator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @return TDbMetaData for retrieving metadata information, such as |
|
19 | - * table and columns information, from a database connection. |
|
20 | - */ |
|
21 | - protected $_dbMetaData; |
|
17 | + /** |
|
18 | + * @return TDbMetaData for retrieving metadata information, such as |
|
19 | + * table and columns information, from a database connection. |
|
20 | + */ |
|
21 | + protected $_dbMetaData; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Output folder where AR classes will be saved. |
|
25 | - */ |
|
26 | - protected $_opFile; |
|
23 | + /** |
|
24 | + * Output folder where AR classes will be saved. |
|
25 | + */ |
|
26 | + protected $_opFile; |
|
27 | 27 | |
28 | - function __construct() |
|
29 | - { |
|
30 | - if (!class_exists("TActiveRecordManager", false)) |
|
31 | - throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
|
32 | - $ar_manager = TActiveRecordManager::getInstance(); |
|
33 | - $_conn = $ar_manager->getDbConnection(); |
|
34 | - $_conn->Active = true; |
|
35 | - $this->_dbMetaData = TDbMetaData::getInstance($_conn); |
|
36 | - } |
|
28 | + function __construct() |
|
29 | + { |
|
30 | + if (!class_exists("TActiveRecordManager", false)) |
|
31 | + throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
|
32 | + $ar_manager = TActiveRecordManager::getInstance(); |
|
33 | + $_conn = $ar_manager->getDbConnection(); |
|
34 | + $_conn->Active = true; |
|
35 | + $this->_dbMetaData = TDbMetaData::getInstance($_conn); |
|
36 | + } |
|
37 | 37 | |
38 | - public function setOpFile($op_file_namespace) |
|
39 | - { |
|
40 | - $op_file = Prado::getPathOfNamespace($op_file_namespace); |
|
41 | - if (empty($op_file)) |
|
42 | - throw new Exception("You need to fix your output folder namespace."); |
|
43 | - if (!is_dir($op_file)) |
|
44 | - mkdir($op_file, 0777, true); |
|
45 | - $this->_opFile = $op_file; |
|
46 | - } |
|
38 | + public function setOpFile($op_file_namespace) |
|
39 | + { |
|
40 | + $op_file = Prado::getPathOfNamespace($op_file_namespace); |
|
41 | + if (empty($op_file)) |
|
42 | + throw new Exception("You need to fix your output folder namespace."); |
|
43 | + if (!is_dir($op_file)) |
|
44 | + mkdir($op_file, 0777, true); |
|
45 | + $this->_opFile = $op_file; |
|
46 | + } |
|
47 | 47 | |
48 | - public function renderAllTablesInformation() |
|
49 | - { |
|
50 | - foreach ($this->getAllTableNames() as $table_name) |
|
51 | - { |
|
52 | - echo $table_name . "<br>"; |
|
53 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
54 | - echo "Table info:" . "<br>"; |
|
55 | - echo "<pre>"; |
|
56 | - print_r($tableInfo); |
|
57 | - echo "</pre>"; |
|
58 | - } |
|
59 | - } |
|
48 | + public function renderAllTablesInformation() |
|
49 | + { |
|
50 | + foreach ($this->getAllTableNames() as $table_name) |
|
51 | + { |
|
52 | + echo $table_name . "<br>"; |
|
53 | + $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
54 | + echo "Table info:" . "<br>"; |
|
55 | + echo "<pre>"; |
|
56 | + print_r($tableInfo); |
|
57 | + echo "</pre>"; |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | - public function getAllTableNames() |
|
62 | - { |
|
63 | - $tableNames = $this->_dbMetaData->findTableNames(); |
|
64 | - $index = array_search('pradocache', $tableNames); |
|
65 | - if ($index) |
|
66 | - array_splice($tableNames, $index, 1); |
|
67 | - return $tableNames; |
|
68 | - } |
|
61 | + public function getAllTableNames() |
|
62 | + { |
|
63 | + $tableNames = $this->_dbMetaData->findTableNames(); |
|
64 | + $index = array_search('pradocache', $tableNames); |
|
65 | + if ($index) |
|
66 | + array_splice($tableNames, $index, 1); |
|
67 | + return $tableNames; |
|
68 | + } |
|
69 | 69 | |
70 | - public static function pr($data) |
|
71 | - { |
|
72 | - echo "<pre>"; |
|
73 | - print_r($data); |
|
74 | - echo "</pre>"; |
|
75 | - } |
|
70 | + public static function pr($data) |
|
71 | + { |
|
72 | + echo "<pre>"; |
|
73 | + print_r($data); |
|
74 | + echo "</pre>"; |
|
75 | + } |
|
76 | 76 | |
77 | - protected function eq($data) |
|
78 | - { |
|
79 | - return '"' . $data . '"'; |
|
80 | - } |
|
77 | + protected function eq($data) |
|
78 | + { |
|
79 | + return '"' . $data . '"'; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
@@ -27,31 +27,31 @@ discard block |
||
27 | 27 | |
28 | 28 | function __construct() |
29 | 29 | { |
30 | - if (!class_exists("TActiveRecordManager", false)) |
|
30 | + if(!class_exists("TActiveRecordManager", false)) |
|
31 | 31 | throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
32 | - $ar_manager = TActiveRecordManager::getInstance(); |
|
33 | - $_conn = $ar_manager->getDbConnection(); |
|
34 | - $_conn->Active = true; |
|
35 | - $this->_dbMetaData = TDbMetaData::getInstance($_conn); |
|
32 | + $ar_manager=TActiveRecordManager::getInstance(); |
|
33 | + $_conn=$ar_manager->getDbConnection(); |
|
34 | + $_conn->Active=true; |
|
35 | + $this->_dbMetaData=TDbMetaData::getInstance($_conn); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function setOpFile($op_file_namespace) |
39 | 39 | { |
40 | - $op_file = Prado::getPathOfNamespace($op_file_namespace); |
|
41 | - if (empty($op_file)) |
|
40 | + $op_file=Prado::getPathOfNamespace($op_file_namespace); |
|
41 | + if(empty($op_file)) |
|
42 | 42 | throw new Exception("You need to fix your output folder namespace."); |
43 | - if (!is_dir($op_file)) |
|
43 | + if(!is_dir($op_file)) |
|
44 | 44 | mkdir($op_file, 0777, true); |
45 | - $this->_opFile = $op_file; |
|
45 | + $this->_opFile=$op_file; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function renderAllTablesInformation() |
49 | 49 | { |
50 | - foreach ($this->getAllTableNames() as $table_name) |
|
50 | + foreach($this->getAllTableNames() as $table_name) |
|
51 | 51 | { |
52 | - echo $table_name . "<br>"; |
|
53 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
54 | - echo "Table info:" . "<br>"; |
|
52 | + echo $table_name."<br>"; |
|
53 | + $tableInfo=$this->_dbMetaData->getTableInfo($table_name); |
|
54 | + echo "Table info:"."<br>"; |
|
55 | 55 | echo "<pre>"; |
56 | 56 | print_r($tableInfo); |
57 | 57 | echo "</pre>"; |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | |
61 | 61 | public function getAllTableNames() |
62 | 62 | { |
63 | - $tableNames = $this->_dbMetaData->findTableNames(); |
|
64 | - $index = array_search('pradocache', $tableNames); |
|
65 | - if ($index) |
|
63 | + $tableNames=$this->_dbMetaData->findTableNames(); |
|
64 | + $index=array_search('pradocache', $tableNames); |
|
65 | + if($index) |
|
66 | 66 | array_splice($tableNames, $index, 1); |
67 | 67 | return $tableNames; |
68 | 68 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | protected function eq($data) |
78 | 78 | { |
79 | - return '"' . $data . '"'; |
|
79 | + return '"'.$data.'"'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | } |
@@ -14,59 +14,59 @@ |
||
14 | 14 | class TWsatScaffolding extends TPage |
15 | 15 | { |
16 | 16 | |
17 | - public function onInit($param) |
|
18 | - { |
|
19 | - parent::onInit($param); |
|
20 | - $this->startVisual(); |
|
21 | - } |
|
17 | + public function onInit($param) |
|
18 | + { |
|
19 | + parent::onInit($param); |
|
20 | + $this->startVisual(); |
|
21 | + } |
|
22 | 22 | |
23 | - private function startVisual() |
|
24 | - { |
|
25 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
26 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
27 | - { |
|
28 | - $dynChb = new TCheckBox(); |
|
29 | - $dynChb->ID = "cb_$tableName"; |
|
30 | - $dynChb->Text = ucfirst($tableName); |
|
31 | - $dynChb->Checked = true; |
|
32 | - $this->registerObject("cb_$tableName", $dynChb); |
|
33 | - $this->tableNames->getControls()->add($dynChb); |
|
34 | - $this->tableNames->getControls()->add("</br>"); |
|
35 | - } |
|
36 | - } |
|
23 | + private function startVisual() |
|
24 | + { |
|
25 | + $scf_generator = new TWsatScaffoldingGenerator(); |
|
26 | + foreach ($scf_generator->getAllTableNames() as $tableName) |
|
27 | + { |
|
28 | + $dynChb = new TCheckBox(); |
|
29 | + $dynChb->ID = "cb_$tableName"; |
|
30 | + $dynChb->Text = ucfirst($tableName); |
|
31 | + $dynChb->Checked = true; |
|
32 | + $this->registerObject("cb_$tableName", $dynChb); |
|
33 | + $this->tableNames->getControls()->add($dynChb); |
|
34 | + $this->tableNames->getControls()->add("</br>"); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Generate Scaffolding code for selected tables |
|
40 | - * @param type $sender |
|
41 | - */ |
|
42 | - public function generate($sender) |
|
43 | - { |
|
44 | - if ($this->IsValid) |
|
45 | - { |
|
46 | - try |
|
47 | - { |
|
48 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
49 | - $scf_generator->setOpFile($this->output_folder->Text); |
|
50 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
51 | - { |
|
52 | - $id = "cb_$tableName"; |
|
53 | - $obj = $this->tableNames->findControl($id); |
|
54 | - if($obj!==null && $obj->Checked) |
|
55 | - { |
|
56 | - $scf_generator->generateCRUD($tableName); |
|
57 | - } |
|
58 | - } |
|
38 | + /** |
|
39 | + * Generate Scaffolding code for selected tables |
|
40 | + * @param type $sender |
|
41 | + */ |
|
42 | + public function generate($sender) |
|
43 | + { |
|
44 | + if ($this->IsValid) |
|
45 | + { |
|
46 | + try |
|
47 | + { |
|
48 | + $scf_generator = new TWsatScaffoldingGenerator(); |
|
49 | + $scf_generator->setOpFile($this->output_folder->Text); |
|
50 | + foreach ($scf_generator->getAllTableNames() as $tableName) |
|
51 | + { |
|
52 | + $id = "cb_$tableName"; |
|
53 | + $obj = $this->tableNames->findControl($id); |
|
54 | + if($obj!==null && $obj->Checked) |
|
55 | + { |
|
56 | + $scf_generator->generateCRUD($tableName); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - $this->feedback_panel->CssClass = "green_panel"; |
|
61 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
62 | - } catch (Exception $ex) |
|
63 | - { |
|
64 | - $this->feedback_panel->CssClass = "red_panel"; |
|
65 | - $this->generation_msg->Text = $ex->getMessage(); |
|
66 | - } |
|
67 | - $this->feedback_panel->Visible = true; |
|
68 | - } |
|
60 | + $this->feedback_panel->CssClass = "green_panel"; |
|
61 | + $this->generation_msg->Text = "The code has been generated successfully."; |
|
62 | + } catch (Exception $ex) |
|
63 | + { |
|
64 | + $this->feedback_panel->CssClass = "red_panel"; |
|
65 | + $this->generation_msg->Text = $ex->getMessage(); |
|
66 | + } |
|
67 | + $this->feedback_panel->Visible = true; |
|
68 | + } |
|
69 | 69 | |
70 | - // $scf_generator->renderAllTablesInformation(); |
|
71 | - } |
|
70 | + // $scf_generator->renderAllTablesInformation(); |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | |
23 | 23 | private function startVisual() |
24 | 24 | { |
25 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
26 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
25 | + $scf_generator=new TWsatScaffoldingGenerator(); |
|
26 | + foreach($scf_generator->getAllTableNames() as $tableName) |
|
27 | 27 | { |
28 | - $dynChb = new TCheckBox(); |
|
29 | - $dynChb->ID = "cb_$tableName"; |
|
30 | - $dynChb->Text = ucfirst($tableName); |
|
31 | - $dynChb->Checked = true; |
|
28 | + $dynChb=new TCheckBox(); |
|
29 | + $dynChb->ID="cb_$tableName"; |
|
30 | + $dynChb->Text=ucfirst($tableName); |
|
31 | + $dynChb->Checked=true; |
|
32 | 32 | $this->registerObject("cb_$tableName", $dynChb); |
33 | 33 | $this->tableNames->getControls()->add($dynChb); |
34 | 34 | $this->tableNames->getControls()->add("</br>"); |
@@ -41,30 +41,30 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function generate($sender) |
43 | 43 | { |
44 | - if ($this->IsValid) |
|
44 | + if($this->IsValid) |
|
45 | 45 | { |
46 | 46 | try |
47 | 47 | { |
48 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
48 | + $scf_generator=new TWsatScaffoldingGenerator(); |
|
49 | 49 | $scf_generator->setOpFile($this->output_folder->Text); |
50 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
50 | + foreach($scf_generator->getAllTableNames() as $tableName) |
|
51 | 51 | { |
52 | - $id = "cb_$tableName"; |
|
53 | - $obj = $this->tableNames->findControl($id); |
|
52 | + $id="cb_$tableName"; |
|
53 | + $obj=$this->tableNames->findControl($id); |
|
54 | 54 | if($obj!==null && $obj->Checked) |
55 | 55 | { |
56 | 56 | $scf_generator->generateCRUD($tableName); |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - $this->feedback_panel->CssClass = "green_panel"; |
|
61 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
62 | - } catch (Exception $ex) |
|
60 | + $this->feedback_panel->CssClass="green_panel"; |
|
61 | + $this->generation_msg->Text="The code has been generated successfully."; |
|
62 | + } catch(Exception $ex) |
|
63 | 63 | { |
64 | - $this->feedback_panel->CssClass = "red_panel"; |
|
65 | - $this->generation_msg->Text = $ex->getMessage(); |
|
64 | + $this->feedback_panel->CssClass="red_panel"; |
|
65 | + $this->generation_msg->Text=$ex->getMessage(); |
|
66 | 66 | } |
67 | - $this->feedback_panel->Visible = true; |
|
67 | + $this->feedback_panel->Visible=true; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // $scf_generator->renderAllTablesInformation(); |
@@ -8,29 +8,29 @@ |
||
8 | 8 | class TWsatLayout extends TTemplateControl |
9 | 9 | { |
10 | 10 | |
11 | - public function onLoad($param) |
|
12 | - { |
|
13 | - parent::onLoad($param); |
|
14 | - $this->validateSecurity(); |
|
15 | - } |
|
11 | + public function onLoad($param) |
|
12 | + { |
|
13 | + parent::onLoad($param); |
|
14 | + $this->validateSecurity(); |
|
15 | + } |
|
16 | 16 | |
17 | - private function validateSecurity() |
|
18 | - { |
|
19 | - if ($this->Session["wsat_password"] !== $this->getService()->getPassword()) |
|
20 | - { |
|
21 | - if (!$this->getPage() instanceof TWsatLogin) |
|
22 | - { |
|
23 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
24 | - $this->Response->redirect($url); |
|
25 | - } |
|
26 | - } |
|
27 | - } |
|
17 | + private function validateSecurity() |
|
18 | + { |
|
19 | + if ($this->Session["wsat_password"] !== $this->getService()->getPassword()) |
|
20 | + { |
|
21 | + if (!$this->getPage() instanceof TWsatLogin) |
|
22 | + { |
|
23 | + $url = $this->Service->constructUrl('TWsatLogin'); |
|
24 | + $this->Response->redirect($url); |
|
25 | + } |
|
26 | + } |
|
27 | + } |
|
28 | 28 | |
29 | - public function logout() |
|
30 | - { |
|
31 | - $this->Session["wsat_password"] = ""; |
|
32 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
33 | - $this->Response->redirect($url); |
|
34 | - } |
|
29 | + public function logout() |
|
30 | + { |
|
31 | + $this->Session["wsat_password"] = ""; |
|
32 | + $url = $this->Service->constructUrl('TWsatLogin'); |
|
33 | + $this->Response->redirect($url); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | \ No newline at end of file |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | |
17 | 17 | private function validateSecurity() |
18 | 18 | { |
19 | - if ($this->Session["wsat_password"] !== $this->getService()->getPassword()) |
|
19 | + if($this->Session["wsat_password"]!==$this->getService()->getPassword()) |
|
20 | 20 | { |
21 | - if (!$this->getPage() instanceof TWsatLogin) |
|
21 | + if(!$this->getPage() instanceof TWsatLogin) |
|
22 | 22 | { |
23 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
23 | + $url=$this->Service->constructUrl('TWsatLogin'); |
|
24 | 24 | $this->Response->redirect($url); |
25 | 25 | } |
26 | 26 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | public function logout() |
30 | 30 | { |
31 | - $this->Session["wsat_password"] = ""; |
|
32 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
31 | + $this->Session["wsat_password"]=""; |
|
32 | + $url=$this->Service->constructUrl('TWsatLogin'); |
|
33 | 33 | $this->Response->redirect($url); |
34 | 34 | } |
35 | 35 |