@@ -93,6 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | /** |
95 | 95 | * @param boolean whether the keys are case-sensitive. |
96 | + * @param boolean $value |
|
96 | 97 | */ |
97 | 98 | public function setCaseSensitive($value) |
98 | 99 | { |
@@ -126,6 +127,7 @@ discard block |
||
126 | 127 | * Removes an item from the map by its key. |
127 | 128 | * This overrides the parent implementation by converting the key to lower case first if CaseSensitive is false. |
128 | 129 | * @param mixed the key of the item to be removed |
130 | + * @param string $key |
|
129 | 131 | * @return mixed the removed value, null if no such key exists. |
130 | 132 | */ |
131 | 133 | public function remove($key) |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | protected function _getZappableSleepProps(&$exprops) |
52 | 52 | { |
53 | 53 | parent::_getZappableSleepProps($exprops); |
54 | - if ($this->_caseSensitive===false) |
|
55 | - $exprops[] = "\0Prado\Collections\TAttributeCollection\0_caseSensitive"; |
|
54 | + if($this->_caseSensitive===false) |
|
55 | + $exprops[]="\0Prado\Collections\TAttributeCollection\0_caseSensitive"; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function __get($name) |
67 | 67 | { |
68 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
68 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @param mixed the property value or event handler |
77 | 77 | * @throws TInvalidOperationException If the property is not defined or read-only. |
78 | 78 | */ |
79 | - public function __set($name,$value) |
|
79 | + public function __set($name, $value) |
|
80 | 80 | { |
81 | - $this->add($name,$value); |
|
81 | + $this->add($name, $value); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function itemAt($key) |
107 | 107 | { |
108 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
108 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | * @param mixed key |
116 | 116 | * @param mixed value |
117 | 117 | */ |
118 | - public function add($key,$value) |
|
118 | + public function add($key, $value) |
|
119 | 119 | { |
120 | - parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
|
120 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function remove($key) |
130 | 130 | { |
131 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
131 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function contains($key) |
141 | 141 | { |
142 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
142 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -90,7 +90,7 @@ |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * @return string default culture |
|
93 | + * @return boolean default culture |
|
94 | 94 | */ |
95 | 95 | public function getTranslateDefaultCulture() |
96 | 96 | { |
@@ -212,8 +212,7 @@ discard block |
||
212 | 212 | $config['source']); |
213 | 213 | chmod($config['source'], PRADO_CHMOD); //make it deletable |
214 | 214 | } |
215 | - } |
|
216 | - else |
|
215 | + } else |
|
217 | 216 | { |
218 | 217 | throw new TConfigurationException("invalid source dir '{$config['source']}'"); |
219 | 218 | } |
@@ -228,8 +227,7 @@ discard block |
||
228 | 227 | $config['cache']); |
229 | 228 | chmod($config['cache'], PRADO_CHMOD); //make it deletable |
230 | 229 | } |
231 | - } |
|
232 | - else |
|
230 | + } else |
|
233 | 231 | { |
234 | 232 | unset($config['cache']); |
235 | 233 | } |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | * Default character set is 'UTF-8'. |
34 | 34 | * @var string |
35 | 35 | */ |
36 | - private $_defaultCharset = 'UTF-8'; |
|
36 | + private $_defaultCharset='UTF-8'; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Default culture is 'en'. |
40 | 40 | * @var string |
41 | 41 | */ |
42 | - private $_defaultCulture = 'en'; |
|
42 | + private $_defaultCulture='en'; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * The current charset. |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | if($config!==null) |
82 | 82 | { |
83 | 83 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
84 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
84 | + $translation=isset($config['translate']) ? $config['translate'] : null; |
|
85 | 85 | else |
86 | 86 | { |
87 | - $t = $config->getElementByTagName('translation'); |
|
88 | - $translation = ($t)?$t->getAttributes():null; |
|
87 | + $t=$config->getElementByTagName('translation'); |
|
88 | + $translation=($t) ? $t->getAttributes() : null; |
|
89 | 89 | } |
90 | 90 | if($translation) |
91 | 91 | $this->setTranslationConfiguration($translation); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function setTranslateDefaultCulture($value) |
108 | 108 | { |
109 | - $this->_translateDefaultCulture = TPropertyValue::ensureBoolean($value); |
|
109 | + $this->_translateDefaultCulture=TPropertyValue::ensureBoolean($value); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function setDefaultCulture($culture) |
124 | 124 | { |
125 | - $this->_defaultCulture = str_replace('-','_',$culture); |
|
125 | + $this->_defaultCulture=str_replace('-', '_', $culture); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function setDefaultCharset($charset) |
140 | 140 | { |
141 | - $this->_defaultCharset = $charset; |
|
141 | + $this->_defaultCharset=$charset; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function setCulture($culture) |
156 | 156 | { |
157 | - $this->_culture = str_replace('-','_',$culture); |
|
157 | + $this->_culture=str_replace('-', '_', $culture); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function setCharset($charset) |
172 | 172 | { |
173 | - $this->_charset = $charset; |
|
173 | + $this->_charset=$charset; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getTranslationConfiguration() |
180 | 180 | { |
181 | - return (!$this->_translateDefaultCulture && ($this->getDefaultCulture() == $this->getCulture())) |
|
181 | + return (!$this->_translateDefaultCulture && ($this->getDefaultCulture()==$this->getCulture())) |
|
182 | 182 | ? null |
183 | 183 | : $this->_translation; |
184 | 184 | } |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function setTranslationConfiguration($config) |
202 | 202 | { |
203 | - if($config['type'] == 'XLIFF' || $config['type'] == 'gettext' || $config['type'] == 'PHP') |
|
203 | + if($config['type']=='XLIFF' || $config['type']=='gettext' || $config['type']=='PHP') |
|
204 | 204 | { |
205 | 205 | if($config['source']) |
206 | 206 | { |
207 | - $config['source'] = Prado::getPathOfNamespace($config['source']); |
|
207 | + $config['source']=Prado::getPathOfNamespace($config['source']); |
|
208 | 208 | if(!is_dir($config['source'])) |
209 | 209 | { |
210 | 210 | if(@mkdir($config['source'])===false) |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | if(isset($config['cache']) && TPropertyValue::ensureBoolean($config['cache'])) |
222 | 222 | { |
223 | - $config['cache'] = $this->getApplication()->getRunTimePath().'/i18n'; |
|
223 | + $config['cache']=$this->getApplication()->getRunTimePath().'/i18n'; |
|
224 | 224 | if(!is_dir($config['cache'])) |
225 | 225 | { |
226 | 226 | if(@mkdir($config['cache'])===false) |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | unset($config['cache']); |
235 | 235 | } |
236 | - $this->_translation = $config; |
|
236 | + $this->_translation=$config; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function setTranslationCatalogue($value) |
251 | 251 | { |
252 | - $this->_translation['catalogue'] = $value; |
|
252 | + $this->_translation['catalogue']=$value; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function getCultureVariants($culture=null) |
262 | 262 | { |
263 | - if($culture===null) $culture = $this->getCulture(); |
|
264 | - $variants = explode('_', $culture); |
|
265 | - $result = array(); |
|
263 | + if($culture===null) $culture=$this->getCulture(); |
|
264 | + $variants=explode('_', $culture); |
|
265 | + $result=array(); |
|
266 | 266 | for(; count($variants) > 0; array_pop($variants)) |
267 | - $result[] = implode('_', $variants); |
|
267 | + $result[]=implode('_', $variants); |
|
268 | 268 | return $result; |
269 | 269 | } |
270 | 270 | |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | * @param string culture string, null to use current culture |
288 | 288 | * @return array list of possible localized resource files. |
289 | 289 | */ |
290 | - public function getLocalizedResource($file,$culture=null) |
|
290 | + public function getLocalizedResource($file, $culture=null) |
|
291 | 291 | { |
292 | - $files = array(); |
|
293 | - $variants = $this->getCultureVariants($culture); |
|
294 | - $path = pathinfo($file); |
|
292 | + $files=array(); |
|
293 | + $variants=$this->getCultureVariants($culture); |
|
294 | + $path=pathinfo($file); |
|
295 | 295 | foreach($variants as $variant) |
296 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
297 | - $filename = substr($path['basename'],0,strrpos($path['basename'],'.')); |
|
296 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
297 | + $filename=substr($path['basename'], 0, strrpos($path['basename'], '.')); |
|
298 | 298 | foreach($variants as $variant) |
299 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
300 | - $files[] = $file; |
|
299 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
300 | + $files[]=$file; |
|
301 | 301 | return $files; |
302 | 302 | } |
303 | 303 |
@@ -73,6 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @param string username |
76 | + * @param string $value |
|
76 | 77 | */ |
77 | 78 | public function setName($value) |
78 | 79 | { |
@@ -89,6 +90,7 @@ discard block |
||
89 | 90 | |
90 | 91 | /** |
91 | 92 | * @param boolean if the user is a guest |
93 | + * @param boolean $value |
|
92 | 94 | */ |
93 | 95 | public function setIsGuest($value) |
94 | 96 | { |
@@ -170,6 +172,7 @@ discard block |
||
170 | 172 | * |
171 | 173 | * @param string variable name |
172 | 174 | * @param mixed default value |
175 | + * @param string $key |
|
173 | 176 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 177 | * @see setState |
175 | 178 | */ |
@@ -190,6 +193,7 @@ discard block |
||
190 | 193 | * @param string variable name |
191 | 194 | * @param mixed variable value |
192 | 195 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
196 | + * @param string $key |
|
193 | 197 | * @see getState |
194 | 198 | */ |
195 | 199 | protected function setState($key,$value,$defaultValue=null) |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getName() |
70 | 70 | { |
71 | - return $this->getState('Name',''); |
|
71 | + return $this->getState('Name', ''); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setName($value) |
78 | 78 | { |
79 | - $this->setState('Name',$value,''); |
|
79 | + $this->setState('Name', $value, ''); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getIsGuest() |
86 | 86 | { |
87 | - return $this->getState('IsGuest',true); |
|
87 | + return $this->getState('IsGuest', true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $this->setName($this->_manager->getGuestName()); |
98 | 98 | $this->setRoles(array()); |
99 | 99 | } |
100 | - $this->setState('IsGuest',$isGuest); |
|
100 | + $this->setState('IsGuest', $isGuest); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getRoles() |
107 | 107 | { |
108 | - return $this->getState('Roles',array()); |
|
108 | + return $this->getState('Roles', array()); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | public function setRoles($value) |
115 | 115 | { |
116 | 116 | if(is_array($value)) |
117 | - $this->setState('Roles',$value,array()); |
|
117 | + $this->setState('Roles', $value, array()); |
|
118 | 118 | else |
119 | 119 | { |
120 | 120 | $roles=array(); |
121 | - foreach(explode(',',$value) as $role) |
|
121 | + foreach(explode(',', $value) as $role) |
|
122 | 122 | { |
123 | 123 | if(($role=trim($role))!=='') |
124 | 124 | $roles[]=$role; |
125 | 125 | } |
126 | - $this->setState('Roles',$roles,array()); |
|
126 | + $this->setState('Roles', $roles, array()); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function isInRole($role) |
135 | 135 | { |
136 | 136 | foreach($this->getRoles() as $r) |
137 | - if(strcasecmp($role,$r)===0) |
|
137 | + if(strcasecmp($role, $r)===0) |
|
138 | 138 | return true; |
139 | 139 | return false; |
140 | 140 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 174 | * @see setState |
175 | 175 | */ |
176 | - protected function getState($key,$defaultValue=null) |
|
176 | + protected function getState($key, $defaultValue=null) |
|
177 | 177 | { |
178 | - return isset($this->_state[$key])?$this->_state[$key]:$defaultValue; |
|
178 | + return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
193 | 193 | * @see getState |
194 | 194 | */ |
195 | - protected function setState($key,$value,$defaultValue=null) |
|
195 | + protected function setState($key, $value, $defaultValue=null) |
|
196 | 196 | { |
197 | 197 | if($value===$defaultValue) |
198 | 198 | unset($this->_state[$key]); |
@@ -215,6 +215,7 @@ discard block |
||
215 | 215 | * This method does not perform any publishing. It merely tells you |
216 | 216 | * if the file path is published, what the URL will be to access it. |
217 | 217 | * @param string directory or file path being published |
218 | + * @param string $path |
|
218 | 219 | * @return string the published URL for the file path |
219 | 220 | */ |
220 | 221 | public function getPublishedUrl($path) |
@@ -230,6 +231,7 @@ discard block |
||
230 | 231 | * Generate a CRC32 hash for the directory path. Collisions are higher |
231 | 232 | * than MD5 but generates a much smaller hash string. |
232 | 233 | * @param string string to be hashed. |
234 | + * @param string $dir |
|
233 | 235 | * @return string hashed string. |
234 | 236 | */ |
235 | 237 | protected function hash($dir) |
@@ -243,6 +245,8 @@ discard block |
||
243 | 245 | * or has an older file modification time. |
244 | 246 | * @param string source file path |
245 | 247 | * @param string destination directory (if not exists, it will be created) |
248 | + * @param string $src |
|
249 | + * @param string $dst |
|
246 | 250 | */ |
247 | 251 | protected function copyFile($src,$dst) |
248 | 252 | { |
@@ -265,6 +269,8 @@ discard block |
||
265 | 269 | * File modification time is used to ensure the copied files are latest. |
266 | 270 | * @param string the source directory |
267 | 271 | * @param string the destination directory |
272 | + * @param string $src |
|
273 | + * @param string $dst |
|
268 | 274 | * @todo a generic solution to ignore certain directories and files |
269 | 275 | */ |
270 | 276 | public function copyDirectory($src,$dst) |
@@ -306,6 +312,8 @@ discard block |
||
306 | 312 | * @param string tar filename |
307 | 313 | * @param string MD5 checksum for the corresponding tar file. |
308 | 314 | * @param boolean Wether or not to check the time stamp of the file for publishing. Defaults to false. |
315 | + * @param string $tarfile |
|
316 | + * @param string $md5sum |
|
309 | 317 | * @return string URL path to the directory where the tar file was extracted. |
310 | 318 | */ |
311 | 319 | public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false) |
@@ -336,6 +344,7 @@ discard block |
||
336 | 344 | * N.B Tar file must not be compressed. |
337 | 345 | * @param string tar file |
338 | 346 | * @param string path where the contents of tar file are to be extracted |
347 | + * @param string $destination |
|
339 | 348 | * @return boolean true if extract successful, false otherwise. |
340 | 349 | */ |
341 | 350 | protected function deployTarFile($path,$destination) |
@@ -163,8 +163,7 @@ discard block |
||
163 | 163 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
164 | 164 | $this->copyFile($fullpath,$dst); |
165 | 165 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
166 | - } |
|
167 | - else |
|
166 | + } else |
|
168 | 167 | { |
169 | 168 | $dir=$this->hash($fullpath); |
170 | 169 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
@@ -287,8 +286,7 @@ discard block |
||
287 | 286 | @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
288 | 287 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
289 | 288 | } |
290 | - } |
|
291 | - else |
|
289 | + } else |
|
292 | 290 | $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
293 | 291 | } |
294 | 292 | closedir($folder); |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | if($this->_basePath===null) |
92 | 92 | $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
93 | 93 | if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
94 | - throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath); |
|
94 | + throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
|
95 | 95 | if($this->_baseUrl===null) |
96 | - $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH; |
|
96 | + $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\').'/'.self::DEFAULT_BASEPATH; |
|
97 | 97 | $application->setAssetManager($this); |
98 | 98 | $this->_initialized=true; |
99 | 99 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $this->_basePath=Prado::getPathOfNamespace($value); |
122 | 122 | if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
123 | - throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value); |
|
123 | + throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | if($this->_initialized) |
142 | 142 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
143 | 143 | else |
144 | - $this->_baseUrl=rtrim($value,'/'); |
|
144 | + $this->_baseUrl=rtrim($value, '/'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -158,19 +158,19 @@ discard block |
||
158 | 158 | * @throws TInvalidDataValueException if the file path to be published is |
159 | 159 | * invalid |
160 | 160 | */ |
161 | - public function publishFilePath($path,$checkTimestamp=false) |
|
161 | + public function publishFilePath($path, $checkTimestamp=false) |
|
162 | 162 | { |
163 | 163 | if(isset($this->_published[$path])) |
164 | 164 | return $this->_published[$path]; |
165 | 165 | else if(empty($path) || ($fullpath=realpath($path))===false) |
166 | - throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path); |
|
166 | + throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
|
167 | 167 | else if(is_file($fullpath)) |
168 | 168 | { |
169 | 169 | $dir=$this->hash(dirname($fullpath)); |
170 | 170 | $fileName=basename($fullpath); |
171 | 171 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
172 | 172 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
173 | - $this->copyFile($fullpath,$dst); |
|
173 | + $this->copyFile($fullpath, $dst); |
|
174 | 174 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
175 | 175 | } |
176 | 176 | else |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | $dir=$this->hash($fullpath); |
179 | 179 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
180 | 180 | { |
181 | - Prado::trace("Publishing directory $fullpath",'Prado\Web\TAssetManager'); |
|
182 | - $this->copyDirectory($fullpath,$this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
181 | + Prado::trace("Publishing directory $fullpath", 'Prado\Web\TAssetManager'); |
|
182 | + $this->copyDirectory($fullpath, $this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
183 | 183 | } |
184 | 184 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
185 | 185 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function setPublished($values=array()) |
202 | 202 | { |
203 | - $this->_published = $values; |
|
203 | + $this->_published=$values; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function hash($dir) |
245 | 245 | { |
246 | - return sprintf('%x',crc32($dir.Prado::getVersion())); |
|
246 | + return sprintf('%x', crc32($dir.Prado::getVersion())); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param string source file path |
254 | 254 | * @param string destination directory (if not exists, it will be created) |
255 | 255 | */ |
256 | - protected function copyFile($src,$dst) |
|
256 | + protected function copyFile($src, $dst) |
|
257 | 257 | { |
258 | 258 | if(!is_dir($dst)) |
259 | 259 | { |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | @chmod($dst, PRADO_CHMOD); |
262 | 262 | } |
263 | 263 | $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
264 | - if(@filemtime($dstFile)<@filemtime($src)) |
|
264 | + if(@filemtime($dstFile) < @filemtime($src)) |
|
265 | 265 | { |
266 | - Prado::trace("Publishing file $src to $dstFile",'Prado\Web\TAssetManager'); |
|
267 | - @copy($src,$dstFile); |
|
266 | + Prado::trace("Publishing file $src to $dstFile", 'Prado\Web\TAssetManager'); |
|
267 | + @copy($src, $dstFile); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param string the destination directory |
277 | 277 | * @todo a generic solution to ignore certain directories and files |
278 | 278 | */ |
279 | - public function copyDirectory($src,$dst) |
|
279 | + public function copyDirectory($src, $dst) |
|
280 | 280 | { |
281 | 281 | if(!is_dir($dst)) |
282 | 282 | { |
@@ -291,14 +291,14 @@ discard block |
||
291 | 291 | continue; |
292 | 292 | else if(is_file($src.DIRECTORY_SEPARATOR.$file)) |
293 | 293 | { |
294 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
294 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$file) < @filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
295 | 295 | { |
296 | - @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
296 | + @copy($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
297 | 297 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
298 | 298 | } |
299 | 299 | } |
300 | 300 | else |
301 | - $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
301 | + $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
302 | 302 | } |
303 | 303 | closedir($folder); |
304 | 304 | } else { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | if(isset($this->_published[$md5sum])) |
323 | 323 | return $this->_published[$md5sum]; |
324 | 324 | else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
325 | - throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum); |
|
325 | + throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
|
326 | 326 | else |
327 | 327 | { |
328 | 328 | $dir=$this->hash(dirname($fullpath)); |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
331 | 331 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
332 | 332 | { |
333 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName)<@filemtime($fullpath)) |
|
333 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName) < @filemtime($fullpath)) |
|
334 | 334 | { |
335 | - $this->copyFile($fullpath,$dst); |
|
336 | - $this->deployTarFile($tarfile,$dst); |
|
335 | + $this->copyFile($fullpath, $dst); |
|
336 | + $this->deployTarFile($tarfile, $dst); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | * @param string path where the contents of tar file are to be extracted |
348 | 348 | * @return boolean true if extract successful, false otherwise. |
349 | 349 | */ |
350 | - protected function deployTarFile($path,$destination) |
|
350 | + protected function deployTarFile($path, $destination) |
|
351 | 351 | { |
352 | 352 | if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
353 | - throw new TIOException('assetmanager_tarfile_invalid',$path); |
|
353 | + throw new TIOException('assetmanager_tarfile_invalid', $path); |
|
354 | 354 | else |
355 | 355 | { |
356 | - $tar = new TTarFileExtractor($fullpath); |
|
356 | + $tar=new TTarFileExtractor($fullpath); |
|
357 | 357 | return $tar->extract($destination); |
358 | 358 | } |
359 | 359 | } |
@@ -416,8 +416,7 @@ |
||
416 | 416 | { |
417 | 417 | $useArgs = !is_array($parameters) && is_array($args); |
418 | 418 | return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
419 | - } |
|
420 | - else if($criteria instanceof TSqlCriteria) |
|
419 | + } else if($criteria instanceof TSqlCriteria) |
|
421 | 420 | return $criteria; |
422 | 421 | else |
423 | 422 | throw new TDbException('dbtablegateway_invalid_criteria'); |
@@ -103,6 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @param TDbTableInfo table or view information. |
106 | + * @param TDbTableInfo $tableInfo |
|
106 | 107 | */ |
107 | 108 | protected function setTableInfo($tableInfo) |
108 | 109 | { |
@@ -113,6 +114,7 @@ discard block |
||
113 | 114 | /** |
114 | 115 | * Sets up the command builder for the given table. |
115 | 116 | * @param string table or view name. |
117 | + * @param string $tableName |
|
116 | 118 | */ |
117 | 119 | protected function setTableName($tableName) |
118 | 120 | { |
@@ -224,6 +226,7 @@ discard block |
||
224 | 226 | * |
225 | 227 | * @param string|TSqlCriteria SQL condition or criteria object. |
226 | 228 | * @param mixed parameter values. |
229 | + * @param TSqlCriteria $criteria |
|
227 | 230 | * @return array matching record object. |
228 | 231 | */ |
229 | 232 | public function find($criteria, $parameters=array()) |
@@ -237,6 +240,7 @@ discard block |
||
237 | 240 | * Accepts same parameters as find(), but returns TDbDataReader instead. |
238 | 241 | * @param string|TSqlCriteria SQL condition or criteria object. |
239 | 242 | * @param mixed parameter values. |
243 | + * @param TSqlCriteria $criteria |
|
240 | 244 | * @return TDbDataReader matching records. |
241 | 245 | */ |
242 | 246 | public function findAll($criteria=null, $parameters=array()) |
@@ -299,6 +303,7 @@ discard block |
||
299 | 303 | * </code> |
300 | 304 | * @param string delete condition. |
301 | 305 | * @param array condition parameters. |
306 | + * @param TSqlCriteria $criteria |
|
302 | 307 | * @return integer number of records deleted. |
303 | 308 | */ |
304 | 309 | public function deleteAll($criteria, $parameters=array()) |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string|TDbTableInfo table or view name or table information. |
91 | 91 | * @param TDbConnection database connection. |
92 | 92 | */ |
93 | - public function __construct($table,$connection) |
|
93 | + public function __construct($table, $connection) |
|
94 | 94 | { |
95 | 95 | $this->_connection=$connection; |
96 | 96 | if(is_string($table)) |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function setTableInfo($tableInfo) |
108 | 108 | { |
109 | - $builder = $tableInfo->createCommandBuilder($this->getDbConnection()); |
|
109 | + $builder=$tableInfo->createCommandBuilder($this->getDbConnection()); |
|
110 | 110 | $this->initCommandBuilder($builder); |
111 | 111 | } |
112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function setTableName($tableName) |
118 | 118 | { |
119 | - $meta = TDbMetaData::getInstance($this->getDbConnection()); |
|
119 | + $meta=TDbMetaData::getInstance($this->getDbConnection()); |
|
120 | 120 | $this->initCommandBuilder($meta->createCommandBuilder($tableName)); |
121 | 121 | } |
122 | 122 | |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | */ |
136 | 136 | protected function initCommandBuilder($builder) |
137 | 137 | { |
138 | - $this->_command = new TDataGatewayCommand($builder); |
|
139 | - $this->_command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
140 | - $this->_command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
138 | + $this->_command=new TDataGatewayCommand($builder); |
|
139 | + $this->_command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
140 | + $this->_command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function findBySql($sql, $parameters=array()) |
193 | 193 | { |
194 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
195 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
194 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
195 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
196 | 196 | return $this->getCommand()->findBySql($criteria); |
197 | 197 | } |
198 | 198 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function findAllBySql($sql, $parameters=array()) |
206 | 206 | { |
207 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
208 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
207 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
208 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
209 | 209 | return $this->getCommand()->findAllBySql($criteria); |
210 | 210 | } |
211 | 211 | |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function find($criteria, $parameters=array()) |
230 | 230 | { |
231 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
232 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
231 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
232 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
233 | 233 | return $this->getCommand()->find($criteria); |
234 | 234 | } |
235 | 235 | |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function findAll($criteria=null, $parameters=array()) |
243 | 243 | { |
244 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
244 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
245 | 245 | if($criteria!==null) |
246 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
246 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
247 | 247 | return $this->getCommand()->findAll($criteria); |
248 | 248 | } |
249 | 249 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | public function findByPk($keys) |
263 | 263 | { |
264 | 264 | if(func_num_args() > 1) |
265 | - $keys = func_get_args(); |
|
265 | + $keys=func_get_args(); |
|
266 | 266 | return $this->getCommand()->findByPk($keys); |
267 | 267 | } |
268 | 268 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public function findAllByPks($keys) |
287 | 287 | { |
288 | 288 | if(func_num_args() > 1) |
289 | - $keys = func_get_args(); |
|
289 | + $keys=func_get_args(); |
|
290 | 290 | return $this->getCommand()->findAllByPk($keys); |
291 | 291 | } |
292 | 292 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function deleteAll($criteria, $parameters=array()) |
305 | 305 | { |
306 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
307 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
306 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
307 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
308 | 308 | return $this->getCommand()->delete($criteria); |
309 | 309 | } |
310 | 310 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | public function deleteByPk($keys) |
335 | 335 | { |
336 | 336 | if(func_num_args() > 1) |
337 | - $keys = func_get_args(); |
|
337 | + $keys=func_get_args(); |
|
338 | 338 | return $this->getCommand()->deleteByPk($keys); |
339 | 339 | } |
340 | 340 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | public function deleteAllByPks($keys) |
345 | 345 | { |
346 | 346 | if(func_num_args() > 1) |
347 | - $keys = func_get_args(); |
|
347 | + $keys=func_get_args(); |
|
348 | 348 | return $this->deleteByPk($keys); |
349 | 349 | } |
350 | 350 | |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | * @param mixed parameter values. |
355 | 355 | * @return int number of records. |
356 | 356 | */ |
357 | - public function count($criteria=null,$parameters=array()) |
|
357 | + public function count($criteria=null, $parameters=array()) |
|
358 | 358 | { |
359 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
359 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
360 | 360 | if($criteria!==null) |
361 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
361 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
362 | 362 | return $this->getCommand()->count($criteria); |
363 | 363 | } |
364 | 364 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | */ |
379 | 379 | public function update($data, $criteria, $parameters=array()) |
380 | 380 | { |
381 | - $args = func_num_args() > 2 ? array_slice(func_get_args(),2) : null; |
|
382 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
381 | + $args=func_num_args() > 2 ? array_slice(func_get_args(), 2) : null; |
|
382 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
383 | 383 | return $this->getCommand()->update($data, $criteria); |
384 | 384 | } |
385 | 385 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | { |
417 | 417 | if(is_string($criteria)) |
418 | 418 | { |
419 | - $useArgs = !is_array($parameters) && is_array($args); |
|
420 | - return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
|
419 | + $useArgs=!is_array($parameters) && is_array($args); |
|
420 | + return new TSqlCriteria($criteria, $useArgs ? $args : $parameters); |
|
421 | 421 | } |
422 | 422 | else if($criteria instanceof TSqlCriteria) |
423 | 423 | return $criteria; |
@@ -454,21 +454,21 @@ discard block |
||
454 | 454 | * @return mixed single record if method name starts with "findBy", 0 or more records |
455 | 455 | * if method name starts with "findAllBy" |
456 | 456 | */ |
457 | - public function __call($method,$args) |
|
457 | + public function __call($method, $args) |
|
458 | 458 | { |
459 | - $delete =false; |
|
460 | - if($findOne = substr(strtolower($method),0,6)==='findby') |
|
461 | - $condition = $method[6]==='_' ? substr($method,7) : substr($method,6); |
|
462 | - else if(substr(strtolower($method),0,9)==='findallby') |
|
463 | - $condition = $method[9]==='_' ? substr($method,10) : substr($method,9); |
|
464 | - else if($delete = substr(strtolower($method),0,8)==='deleteby') |
|
465 | - $condition = $method[8]==='_' ? substr($method,9) : substr($method,8); |
|
466 | - else if($delete = substr(strtolower($method),0,11)==='deleteallby') |
|
467 | - $condition = $method[11]==='_' ? substr($method,12) : substr($method,11); |
|
459 | + $delete=false; |
|
460 | + if($findOne=substr(strtolower($method), 0, 6)==='findby') |
|
461 | + $condition=$method[6]==='_' ? substr($method, 7) : substr($method, 6); |
|
462 | + else if(substr(strtolower($method), 0, 9)==='findallby') |
|
463 | + $condition=$method[9]==='_' ? substr($method, 10) : substr($method, 9); |
|
464 | + else if($delete=substr(strtolower($method), 0, 8)==='deleteby') |
|
465 | + $condition=$method[8]==='_' ? substr($method, 9) : substr($method, 8); |
|
466 | + else if($delete=substr(strtolower($method), 0, 11)==='deleteallby') |
|
467 | + $condition=$method[11]==='_' ? substr($method, 12) : substr($method, 11); |
|
468 | 468 | else |
469 | 469 | return null; |
470 | 470 | |
471 | - $criteria = $this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
471 | + $criteria=$this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
472 | 472 | if($delete) |
473 | 473 | return $this->deleteAll($criteria); |
474 | 474 | else |
@@ -115,8 +115,7 @@ discard block |
||
115 | 115 | $columns = $this->getTableInfo()->getColumns(); |
116 | 116 | $this->getInputRepeater()->setDataSource($columns); |
117 | 117 | $this->getInputRepeater()->dataBind(); |
118 | - } |
|
119 | - else |
|
118 | + } else |
|
120 | 119 | { |
121 | 120 | if($this->_editRenderer===null) |
122 | 121 | $this->createEditRenderer($record, $classPath); |
@@ -140,8 +139,7 @@ discard block |
||
140 | 139 | $index = $this->getControls()->remove($this->getInputRepeater()); |
141 | 140 | $this->getControls()->insertAt($index,$this->_editRenderer); |
142 | 141 | $this->_editRenderer->setData($record); |
143 | - } |
|
144 | - else |
|
142 | + } else |
|
145 | 143 | { |
146 | 144 | throw new TConfigurationException( |
147 | 145 | 'scaffold_invalid_edit_renderer', $this->getID(), get_class($record)); |
@@ -204,15 +202,13 @@ discard block |
||
204 | 202 | $column = $table->getColumn($item->getCustomData()); |
205 | 203 | $builder->loadScaffoldInput($this, $item, $column, $record); |
206 | 204 | } |
207 | - } |
|
208 | - else |
|
205 | + } else |
|
209 | 206 | { |
210 | 207 | $this->_editRenderer->updateRecord($record); |
211 | 208 | } |
212 | 209 | $record->save(); |
213 | 210 | return true; |
214 | - } |
|
215 | - else if($this->_editRenderer!==null) |
|
211 | + } else if($this->_editRenderer!==null) |
|
216 | 212 | { |
217 | 213 | //preserve the form data. |
218 | 214 | $this->_editRenderer->updateRecord($this->getCurrentRecord()); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | - * @return TActiveRecord current Active Record instance |
|
106 | + * @return \Prado\Data\ActiveRecord\TActiveRecord current Active Record instance |
|
107 | 107 | */ |
108 | 108 | protected function getCurrentRecord() |
109 | 109 | { |
@@ -136,6 +136,8 @@ discard block |
||
136 | 136 | * Instantiate the external edit renderer. |
137 | 137 | * @param TActiveRecord record to be edited |
138 | 138 | * @param string external edit renderer class name. |
139 | + * @param \Prado\Data\ActiveRecord\TActiveRecord $record |
|
140 | + * @param string $classPath |
|
139 | 141 | * @throws TConfigurationException raised when renderer is not an |
140 | 142 | * instance of IScaffoldEditRenderer. |
141 | 143 | */ |
@@ -267,6 +269,7 @@ discard block |
||
267 | 269 | /** |
268 | 270 | * Create the default scaffold editor control factory. |
269 | 271 | * @param TActiveRecord record instance. |
272 | + * @param \Prado\Data\ActiveRecord\TActiveRecord $record |
|
270 | 273 | * @return TScaffoldInputBase scaffold editor control factory. |
271 | 274 | */ |
272 | 275 | protected function getScaffoldInputBuilder($record) |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * xxx is the property name). |
50 | 50 | * |
51 | 51 | * @author Wei Zhuo <weizho[at]gmail[dot]com> |
52 | - * @package Prado\Data\ActiveRecord\Scaffold |
|
52 | + * @package Prado\Data\ActiveRecord\Scaffold |
|
53 | 53 | * @since 3.1 |
54 | 54 | */ |
55 | 55 | class TScaffoldEditView extends TScaffoldBase |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function setRecordPk($value) |
91 | 91 | { |
92 | 92 | $this->clearRecordObject(); |
93 | - $val = TPropertyValue::ensureArray($value); |
|
93 | + $val=TPropertyValue::ensureArray($value); |
|
94 | 94 | $this->setViewState('PK', count($val) > 0 ? $val : null); |
95 | 95 | } |
96 | 96 | |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function initializeEditForm() |
117 | 117 | { |
118 | - $record = $this->getCurrentRecord(); |
|
119 | - $classPath = $this->getEditRenderer(); |
|
120 | - if($classPath === '') |
|
118 | + $record=$this->getCurrentRecord(); |
|
119 | + $classPath=$this->getEditRenderer(); |
|
120 | + if($classPath==='') |
|
121 | 121 | { |
122 | - $columns = $this->getTableInfo()->getColumns(); |
|
122 | + $columns=$this->getTableInfo()->getColumns(); |
|
123 | 123 | $this->getInputRepeater()->setDataSource($columns); |
124 | 124 | $this->getInputRepeater()->dataBind(); |
125 | 125 | } |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function createEditRenderer($record, $classPath) |
143 | 143 | { |
144 | - $this->_editRenderer = Prado::createComponent($classPath); |
|
144 | + $this->_editRenderer=Prado::createComponent($classPath); |
|
145 | 145 | if($this->_editRenderer instanceof IScaffoldEditRenderer) |
146 | 146 | { |
147 | - $index = $this->getControls()->remove($this->getInputRepeater()); |
|
148 | - $this->getControls()->insertAt($index,$this->_editRenderer); |
|
147 | + $index=$this->getControls()->remove($this->getInputRepeater()); |
|
148 | + $this->getControls()->insertAt($index, $this->_editRenderer); |
|
149 | 149 | $this->_editRenderer->setData($record); |
150 | 150 | } |
151 | 151 | else |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | */ |
161 | 161 | protected function createRepeaterEditItem($sender, $param) |
162 | 162 | { |
163 | - $type = $param->getItem()->getItemType(); |
|
163 | + $type=$param->getItem()->getItemType(); |
|
164 | 164 | if($type==TListItemType::Item || $type==TListItemType::AlternatingItem) |
165 | 165 | { |
166 | - $item = $param->getItem(); |
|
167 | - $column = $item->getData(); |
|
166 | + $item=$param->getItem(); |
|
167 | + $column=$item->getData(); |
|
168 | 168 | if($column===null) |
169 | 169 | return; |
170 | 170 | |
171 | - $record = $this->getCurrentRecord(); |
|
172 | - $builder = $this->getScaffoldInputBuilder($record); |
|
171 | + $record=$this->getCurrentRecord(); |
|
172 | + $builder=$this->getScaffoldInputBuilder($record); |
|
173 | 173 | $builder->createScaffoldInput($this, $item, $column, $record); |
174 | 174 | } |
175 | 175 | } |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | { |
202 | 202 | if($this->getPage()->getIsValid()) |
203 | 203 | { |
204 | - $record = $this->getCurrentRecord(); |
|
204 | + $record=$this->getCurrentRecord(); |
|
205 | 205 | if($this->_editRenderer===null) |
206 | 206 | { |
207 | - $table = $this->getTableInfo(); |
|
208 | - $builder = $this->getScaffoldInputBuilder($record); |
|
207 | + $table=$this->getTableInfo(); |
|
208 | + $builder=$this->getScaffoldInputBuilder($record); |
|
209 | 209 | foreach($this->getInputRepeater()->getItems() as $item) |
210 | 210 | { |
211 | - $column = $table->getColumn($item->getCustomData()); |
|
211 | + $column=$table->getColumn($item->getCustomData()); |
|
212 | 212 | $builder->loadScaffoldInput($this, $item, $column, $record); |
213 | 213 | } |
214 | 214 | } |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | protected function getScaffoldInputBuilder($record) |
273 | 273 | { |
274 | 274 | static $_builders=array(); |
275 | - $class = get_class($record); |
|
275 | + $class=get_class($record); |
|
276 | 276 | if(!isset($_builders[$class])) |
277 | 277 | { |
278 | - $_builders[$class] = TScaffoldInputBase::createInputBuilder($record); |
|
278 | + $_builders[$class]=TScaffoldInputBase::createInputBuilder($record); |
|
279 | 279 | } |
280 | 280 | return $_builders[$class]; |
281 | 281 | } |
@@ -67,16 +67,14 @@ |
||
67 | 67 | throw new TActiveRecordException('ar_invalid_tablename_property', |
68 | 68 | get_class($record),self::TABLE_CONST); |
69 | 69 | return $value; |
70 | - } |
|
71 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
70 | + } elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
72 | 71 | { |
73 | 72 | $value = $record->{self::TABLE_METHOD}(); |
74 | 73 | if(empty($value)) |
75 | 74 | throw new TActiveRecordException('ar_invalid_tablename_method', |
76 | 75 | get_class($record),self::TABLE_METHOD); |
77 | 76 | return $value; |
78 | - } |
|
79 | - else |
|
77 | + } else |
|
80 | 78 | return strtolower(get_class($record)); |
81 | 79 | } |
82 | 80 |
@@ -236,6 +236,7 @@ discard block |
||
236 | 236 | * Return record data from sql query. |
237 | 237 | * @param TActiveRecord active record finder instance. |
238 | 238 | * @param TActiveRecordCriteria sql query |
239 | + * @param TSqlCriteria $criteria |
|
239 | 240 | * @return array result. |
240 | 241 | */ |
241 | 242 | public function findRecordBySql(TActiveRecord $record, $criteria) |
@@ -247,6 +248,7 @@ discard block |
||
247 | 248 | * Return record data from sql query. |
248 | 249 | * @param TActiveRecord active record finder instance. |
249 | 250 | * @param TActiveRecordCriteria sql query |
251 | + * @param TSqlCriteria $criteria |
|
250 | 252 | * @return TDbDataReader result iterator. |
251 | 253 | */ |
252 | 254 | public function findRecordsBySql(TActiveRecord $record, $criteria) |
@@ -288,6 +290,7 @@ discard block |
||
288 | 290 | /** |
289 | 291 | * Sets the last insert ID to the corresponding property of the record if available. |
290 | 292 | * @param TActiveRecord record for insertion |
293 | + * @param TActiveRecord $record |
|
291 | 294 | */ |
292 | 295 | protected function updatePostInsert($record) |
293 | 296 | { |
@@ -405,6 +408,7 @@ discard block |
||
405 | 408 | * Delete multiple records by criteria. |
406 | 409 | * @param TActiveRecord active record finder instance. |
407 | 410 | * @param TActiveRecordCriteria search criteria |
411 | + * @param TSqlCriteria $criteria |
|
408 | 412 | * @return int number of records. |
409 | 413 | */ |
410 | 414 | public function deleteRecordsByCriteria(TActiveRecord $record, $criteria) |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function getRecordTableName(TActiveRecord $record) |
72 | 72 | { |
73 | - $class = new ReflectionClass($record); |
|
73 | + $class=new ReflectionClass($record); |
|
74 | 74 | if($class->hasConstant(self::TABLE_CONST)) |
75 | 75 | { |
76 | - $value = $class->getConstant(self::TABLE_CONST); |
|
76 | + $value=$class->getConstant(self::TABLE_CONST); |
|
77 | 77 | if(empty($value)) |
78 | 78 | throw new TActiveRecordException('ar_invalid_tablename_property', |
79 | - get_class($record),self::TABLE_CONST); |
|
79 | + get_class($record), self::TABLE_CONST); |
|
80 | 80 | return $value; |
81 | 81 | } |
82 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
82 | + elseif($class->hasMethod(self::TABLE_METHOD)) |
|
83 | 83 | { |
84 | - $value = $record->{self::TABLE_METHOD}(); |
|
84 | + $value=$record->{self::TABLE_METHOD}(); |
|
85 | 85 | if(empty($value)) |
86 | 86 | throw new TActiveRecordException('ar_invalid_tablename_method', |
87 | - get_class($record),self::TABLE_METHOD); |
|
87 | + get_class($record), self::TABLE_METHOD); |
|
88 | 88 | return $value; |
89 | 89 | } |
90 | 90 | else |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function getRecordTableInfo(TActiveRecord $record) |
100 | 100 | { |
101 | - $tableName = $this->getRecordTableName($record); |
|
101 | + $tableName=$this->getRecordTableName($record); |
|
102 | 102 | return $this->getTableInfo($record->getDbConnection(), $tableName); |
103 | 103 | } |
104 | 104 | |
@@ -110,27 +110,27 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function getTableInfo(TDbConnection $connection, $tableName) |
112 | 112 | { |
113 | - $connStr = $connection->getConnectionString(); |
|
114 | - $key = $connStr.$tableName; |
|
113 | + $connStr=$connection->getConnectionString(); |
|
114 | + $key=$connStr.$tableName; |
|
115 | 115 | if(!isset($this->_tables[$key])) |
116 | 116 | { |
117 | 117 | //call this first to ensure that unserializing the cache |
118 | 118 | //will find the correct driver dependent classes. |
119 | 119 | if(!isset($this->_meta[$connStr])) |
120 | 120 | { |
121 | - $this->_meta[$connStr] = TDbMetaData::getInstance($connection); |
|
121 | + $this->_meta[$connStr]=TDbMetaData::getInstance($connection); |
|
122 | 122 | } |
123 | 123 | |
124 | - $tableInfo = null; |
|
124 | + $tableInfo=null; |
|
125 | 125 | if(($cache=$this->getManager()->getCache())!==null) |
126 | - $tableInfo = $cache->get($key); |
|
126 | + $tableInfo=$cache->get($key); |
|
127 | 127 | if(empty($tableInfo)) |
128 | 128 | { |
129 | - $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName); |
|
129 | + $tableInfo=$this->_meta[$connStr]->getTableInfo($tableName); |
|
130 | 130 | if($cache!==null) |
131 | 131 | $cache->set($key, $tableInfo); |
132 | 132 | } |
133 | - $this->_tables[$key] = $tableInfo; |
|
133 | + $this->_tables[$key]=$tableInfo; |
|
134 | 134 | } |
135 | 135 | return $this->_tables[$key]; |
136 | 136 | } |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function getCommand(TActiveRecord $record) |
143 | 143 | { |
144 | - $conn = $record->getDbConnection(); |
|
145 | - $connStr = $conn->getConnectionString(); |
|
146 | - $tableInfo = $this->getRecordTableInfo($record); |
|
144 | + $conn=$record->getDbConnection(); |
|
145 | + $connStr=$conn->getConnectionString(); |
|
146 | + $tableInfo=$this->getRecordTableInfo($record); |
|
147 | 147 | if(!isset($this->_commandBuilders[$connStr])) |
148 | 148 | { |
149 | - $builder = $tableInfo->createCommandBuilder($record->getDbConnection()); |
|
150 | - $command = new TDataGatewayCommand($builder); |
|
151 | - $command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
152 | - $command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
153 | - $this->_commandBuilders[$connStr] = $command; |
|
149 | + $builder=$tableInfo->createCommandBuilder($record->getDbConnection()); |
|
150 | + $command=new TDataGatewayCommand($builder); |
|
151 | + $command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
152 | + $command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
153 | + $this->_commandBuilders[$connStr]=$command; |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo); |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * @param array primary name value pairs |
201 | 201 | * @return array record data |
202 | 202 | */ |
203 | - public function findRecordByPK(TActiveRecord $record,$keys) |
|
203 | + public function findRecordByPK(TActiveRecord $record, $keys) |
|
204 | 204 | { |
205 | - $command = $this->getCommand($record); |
|
205 | + $command=$this->getCommand($record); |
|
206 | 206 | return $command->findByPk($keys); |
207 | 207 | } |
208 | 208 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false) |
230 | 230 | { |
231 | - $command = $this->getCommand($record); |
|
231 | + $command=$this->getCommand($record); |
|
232 | 232 | return $iterator ? $command->findAll($criteria) : $command->find($criteria); |
233 | 233 | } |
234 | 234 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values) |
258 | 258 | { |
259 | - return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values); |
|
259 | + return $this->getCommand($record)->findAllByIndex($criteria, $fields, $values); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | public function insert(TActiveRecord $record) |
279 | 279 | { |
280 | 280 | //$this->updateAssociatedRecords($record,true); |
281 | - $result = $this->getCommand($record)->insert($this->getInsertValues($record)); |
|
281 | + $result=$this->getCommand($record)->insert($this->getInsertValues($record)); |
|
282 | 282 | if($result) |
283 | 283 | $this->updatePostInsert($record); |
284 | 284 | //$this->updateAssociatedRecords($record); |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | */ |
292 | 292 | protected function updatePostInsert($record) |
293 | 293 | { |
294 | - $command = $this->getCommand($record); |
|
295 | - $tableInfo = $command->getTableInfo(); |
|
294 | + $command=$this->getCommand($record); |
|
295 | + $tableInfo=$command->getTableInfo(); |
|
296 | 296 | foreach($tableInfo->getColumns() as $name => $column) |
297 | 297 | { |
298 | 298 | if($column->hasSequence()) |
299 | - $record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName())); |
|
299 | + $record->setColumnValue($name, $command->getLastInsertID($column->getSequenceName())); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -307,20 +307,20 @@ discard block |
||
307 | 307 | protected function getInsertValues(TActiveRecord $record) |
308 | 308 | { |
309 | 309 | $values=array(); |
310 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
310 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
311 | 311 | foreach($tableInfo->getColumns() as $name=>$column) |
312 | 312 | { |
313 | 313 | if($column->getIsExcluded()) |
314 | 314 | continue; |
315 | - $value = $record->getColumnValue($name); |
|
316 | - if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
315 | + $value=$record->getColumnValue($name); |
|
316 | + if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
317 | 317 | { |
318 | 318 | throw new TActiveRecordException( |
319 | 319 | 'ar_value_must_not_be_null', get_class($record), |
320 | 320 | $tableInfo->getTableFullName(), $name); |
321 | 321 | } |
322 | 322 | if($value!==null) |
323 | - $values[$name] = $value; |
|
323 | + $values[$name]=$value; |
|
324 | 324 | } |
325 | 325 | return $values; |
326 | 326 | } |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | public function update(TActiveRecord $record) |
334 | 334 | { |
335 | 335 | //$this->updateAssociatedRecords($record,true); |
336 | - list($data, $keys) = $this->getUpdateValues($record); |
|
337 | - $result = $this->getCommand($record)->updateByPk($data, $keys); |
|
336 | + list($data, $keys)=$this->getUpdateValues($record); |
|
337 | + $result=$this->getCommand($record)->updateByPk($data, $keys); |
|
338 | 338 | //$this->updateAssociatedRecords($record); |
339 | 339 | return $result; |
340 | 340 | } |
@@ -342,30 +342,30 @@ discard block |
||
342 | 342 | protected function getUpdateValues(TActiveRecord $record) |
343 | 343 | { |
344 | 344 | $values=array(); |
345 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
345 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
346 | 346 | $primary=array(); |
347 | 347 | foreach($tableInfo->getColumns() as $name=>$column) |
348 | 348 | { |
349 | 349 | if($column->getIsExcluded()) |
350 | 350 | continue; |
351 | - $value = $record->getColumnValue($name); |
|
352 | - if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
351 | + $value=$record->getColumnValue($name); |
|
352 | + if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
353 | 353 | { |
354 | 354 | throw new TActiveRecordException( |
355 | 355 | 'ar_value_must_not_be_null', get_class($record), |
356 | 356 | $tableInfo->getTableFullName(), $name); |
357 | 357 | } |
358 | 358 | if($column->getIsPrimaryKey()) |
359 | - $primary[$name] = $value; |
|
359 | + $primary[$name]=$value; |
|
360 | 360 | else |
361 | - $values[$name] = $value; |
|
361 | + $values[$name]=$value; |
|
362 | 362 | } |
363 | - return array($values,$primary); |
|
363 | + return array($values, $primary); |
|
364 | 364 | } |
365 | 365 | |
366 | - protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false) |
|
366 | + protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo=false) |
|
367 | 367 | { |
368 | - $context = new TActiveRecordRelationContext($record); |
|
368 | + $context=new TActiveRecordRelationContext($record); |
|
369 | 369 | return $context->updateAssociatedRecords($updateBelongsTo); |
370 | 370 | } |
371 | 371 | |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | |
382 | 382 | protected function getPrimaryKeyValues(TActiveRecord $record) |
383 | 383 | { |
384 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
384 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
385 | 385 | $primary=array(); |
386 | 386 | foreach($tableInfo->getColumns() as $name=>$column) |
387 | 387 | { |
388 | 388 | if($column->getIsPrimaryKey()) |
389 | - $primary[$name] = $record->getColumnValue($name); |
|
389 | + $primary[$name]=$record->getColumnValue($name); |
|
390 | 390 | } |
391 | 391 | return $primary; |
392 | 392 | } |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | * @param TActiveRecord active record |
420 | 420 | * @param TActiveRecordCriteria data for the command. |
421 | 421 | */ |
422 | - protected function raiseCommandEvent($event,$command,$record,$criteria) |
|
422 | + protected function raiseCommandEvent($event, $command, $record, $criteria) |
|
423 | 423 | { |
424 | 424 | if(!($criteria instanceof TSqlCriteria)) |
425 | - $criteria = new TActiveRecordCriteria(null,$criteria); |
|
426 | - $param = new TActiveRecordEventParameter($command,$record,$criteria); |
|
427 | - $manager = $record->getRecordManager(); |
|
425 | + $criteria=new TActiveRecordCriteria(null, $criteria); |
|
426 | + $param=new TActiveRecordEventParameter($command, $record, $criteria); |
|
427 | + $manager=$record->getRecordManager(); |
|
428 | 428 | $manager->{$event}($param); |
429 | 429 | $record->{$event}($param); |
430 | 430 | } |
@@ -164,8 +164,7 @@ |
||
164 | 164 | return $handler->createNewInstance(); |
165 | 165 | else |
166 | 166 | return $registry->createInstanceOf($this->getClass()); |
167 | - } |
|
168 | - catch (TSqlMapException $e) |
|
167 | + } catch (TSqlMapException $e) |
|
169 | 168 | { |
170 | 169 | throw new TSqlMapException( |
171 | 170 | 'sqlmap_unable_to_create_new_instance', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function setClass($value) |
83 | 83 | { |
84 | - $this->_class = $value; |
|
84 | + $this->_class=$value; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function setExtends($value) |
107 | 107 | { |
108 | - $this->_extends = $value; |
|
108 | + $this->_extends=$value; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function setGroupBy($value) |
123 | 123 | { |
124 | - $this->_groupBy = $value; |
|
124 | + $this->_groupBy=$value; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function setDiscriminator(TDiscriminator $value) |
139 | 139 | { |
140 | - $this->_discriminator = $value; |
|
140 | + $this->_discriminator=$value; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function addResultProperty(TResultProperty $property) |
148 | 148 | { |
149 | - $this->_columns[$property->getProperty()] = $property; |
|
149 | + $this->_columns[$property->getProperty()]=$property; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function createInstanceOfResult($registry) |
159 | 159 | { |
160 | - $handler = $registry->getTypeHandler($this->getClass()); |
|
160 | + $handler=$registry->getTypeHandler($this->getClass()); |
|
161 | 161 | try |
162 | 162 | { |
163 | 163 | if($handler!==null) |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | else |
166 | 166 | return $registry->createInstanceOf($this->getClass()); |
167 | 167 | } |
168 | - catch (TSqlMapException $e) |
|
168 | + catch(TSqlMapException $e) |
|
169 | 169 | { |
170 | 170 | throw new TSqlMapException( |
171 | 171 | 'sqlmap_unable_to_create_new_instance', |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | * @param array row data. |
180 | 180 | * @return TResultMap result sub-map. |
181 | 181 | */ |
182 | - public function resolveSubMap($registry,$row) |
|
182 | + public function resolveSubMap($registry, $row) |
|
183 | 183 | { |
184 | - $subMap = $this; |
|
185 | - if(($disc = $this->getDiscriminator())!==null) |
|
184 | + $subMap=$this; |
|
185 | + if(($disc=$this->getDiscriminator())!==null) |
|
186 | 186 | { |
187 | - $value = $disc->getMapping()->getPropertyValue($registry,$row); |
|
188 | - $subMap = $disc->getSubMap((string)$value); |
|
187 | + $value=$disc->getMapping()->getPropertyValue($registry, $row); |
|
188 | + $subMap=$disc->getSubMap((string) $value); |
|
189 | 189 | |
190 | 190 | if($subMap===null) |
191 | - $subMap = $this; |
|
192 | - else if($subMap !== $this) |
|
193 | - $subMap = $subMap->resolveSubMap($registry,$row); |
|
191 | + $subMap=$this; |
|
192 | + else if($subMap!==$this) |
|
193 | + $subMap=$subMap->resolveSubMap($registry, $row); |
|
194 | 194 | } |
195 | 195 | return $subMap; |
196 | 196 | } |
@@ -113,8 +113,7 @@ discard block |
||
113 | 113 | { |
114 | 114 | $userFile = include $this->_userFile; |
115 | 115 | $this->loadUserDataFromPhp($userFile); |
116 | - } |
|
117 | - else |
|
116 | + } else |
|
118 | 117 | { |
119 | 118 | $dom=new TXmlDocument; |
120 | 119 | $dom->loadFromFile($this->_userFile); |
@@ -310,8 +309,7 @@ discard block |
||
310 | 309 | $user=new TUser($this); |
311 | 310 | $user->setIsGuest(true); |
312 | 311 | return $user; |
313 | - } |
|
314 | - else |
|
312 | + } else |
|
315 | 313 | { |
316 | 314 | $username=strtolower($username); |
317 | 315 | if(isset($this->_users[$username])) |
@@ -322,8 +320,7 @@ discard block |
||
322 | 320 | if(isset($this->_roles[$username])) |
323 | 321 | $user->setRoles($this->_roles[$username]); |
324 | 322 | return $user; |
325 | - } |
|
326 | - else |
|
323 | + } else |
|
327 | 324 | return null; |
328 | 325 | } |
329 | 326 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | { |
115 | 115 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
116 | 116 | { |
117 | - $userFile = include $this->_userFile; |
|
117 | + $userFile=include $this->_userFile; |
|
118 | 118 | $this->loadUserDataFromPhp($userFile); |
119 | 119 | } |
120 | 120 | else |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | { |
150 | 150 | foreach($config['users'] as $user) |
151 | 151 | { |
152 | - $name = trim(strtolower(isset($user['name'])?$user['name']:'')); |
|
153 | - $password = isset($user['password'])?$user['password']:''; |
|
154 | - $this->_users[$name] = $password; |
|
155 | - $roles = isset($user['roles'])?$user['roles']:''; |
|
152 | + $name=trim(strtolower(isset($user['name']) ? $user['name'] : '')); |
|
153 | + $password=isset($user['password']) ? $user['password'] : ''; |
|
154 | + $this->_users[$name]=$password; |
|
155 | + $roles=isset($user['roles']) ? $user['roles'] : ''; |
|
156 | 156 | if($roles!=='') |
157 | 157 | { |
158 | - foreach(explode(',',$roles) as $role) |
|
158 | + foreach(explode(',', $roles) as $role) |
|
159 | 159 | { |
160 | 160 | if(($role=trim($role))!=='') |
161 | 161 | $this->_roles[$name][]=$role; |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | { |
168 | 168 | foreach($config['roles'] as $role) |
169 | 169 | { |
170 | - $name = isset($role['name'])?$role['name']:''; |
|
171 | - $users = isset($role['users'])?$role['users']:''; |
|
172 | - foreach(explode(',',$users) as $user) |
|
170 | + $name=isset($role['name']) ? $role['name'] : ''; |
|
171 | + $users=isset($role['users']) ? $role['users'] : ''; |
|
172 | + foreach(explode(',', $users) as $user) |
|
173 | 173 | { |
174 | 174 | if(($user=trim($user))!=='') |
175 | 175 | $this->_roles[strtolower($user)][]=$name; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $this->_users[$name]=$node->getAttribute('password'); |
191 | 191 | if(($roles=trim($node->getAttribute('roles')))!=='') |
192 | 192 | { |
193 | - foreach(explode(',',$roles) as $role) |
|
193 | + foreach(explode(',', $roles) as $role) |
|
194 | 194 | { |
195 | 195 | if(($role=trim($role))!=='') |
196 | 196 | $this->_roles[$name][]=$role; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | foreach($xmlNode->getElementsByTagName('role') as $node) |
201 | 201 | { |
202 | - foreach(explode(',',$node->getAttribute('users')) as $user) |
|
202 | + foreach(explode(',', $node->getAttribute('users')) as $user) |
|
203 | 203 | { |
204 | 204 | if(($user=trim($user))!=='') |
205 | 205 | $this->_roles[strtolower($user)][]=$node->getAttribute('name'); |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | { |
250 | 250 | if($this->_initialized) |
251 | 251 | throw new TInvalidOperationException('usermanager_userfile_unchangeable'); |
252 | - else if(($this->_userFile=Prado::getPathOfNamespace($value,self::USER_FILE_EXT))===null || !is_file($this->_userFile)) |
|
253 | - throw new TConfigurationException('usermanager_userfile_invalid',$value); |
|
252 | + else if(($this->_userFile=Prado::getPathOfNamespace($value, self::USER_FILE_EXT))===null || !is_file($this->_userFile)) |
|
253 | + throw new TConfigurationException('usermanager_userfile_invalid', $value); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function setPasswordMode($value) |
284 | 284 | { |
285 | - $this->_passwordMode=TPropertyValue::ensureEnum($value,'Prado\\Security\\TUserManagerPasswordMode'); |
|
285 | + $this->_passwordMode=TPropertyValue::ensureEnum($value, 'Prado\\Security\\TUserManagerPasswordMode'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param string password |
292 | 292 | * @return boolean true if validation is successful, false otherwise. |
293 | 293 | */ |
294 | - public function validateUser($username,$password) |
|
294 | + public function validateUser($username, $password) |
|
295 | 295 | { |
296 | 296 | if($this->_passwordMode===TUserManagerPasswordMode::MD5) |
297 | 297 | $password=md5($password); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | $data=unserialize($data); |
345 | 345 | if(is_array($data) && count($data)===2) |
346 | 346 | { |
347 | - list($username,$token)=$data; |
|
347 | + list($username, $token)=$data; |
|
348 | 348 | if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username])) |
349 | 349 | return $this->getUser($username); |
350 | 350 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $username=strtolower($user->getName()); |
364 | 364 | if(isset($this->_users[$username])) |
365 | 365 | { |
366 | - $data=array($username,md5($username.$this->_users[$username])); |
|
366 | + $data=array($username, md5($username.$this->_users[$username])); |
|
367 | 367 | $cookie->setValue(serialize($data)); |
368 | 368 | } |
369 | 369 | } |