@@ -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 | } |
@@ -225,8 +225,7 @@ discard block |
||
225 | 225 | $year = "{$date['year']}"; |
226 | 226 | $month = $date['mon']; |
227 | 227 | $day = $date['mday']; |
228 | - } |
|
229 | - else |
|
228 | + } else |
|
230 | 229 | { |
231 | 230 | $year = null; |
232 | 231 | $month = null; |
@@ -262,8 +261,7 @@ discard block |
||
262 | 261 | $year = $iYear + 2000; |
263 | 262 | } |
264 | 263 | $year = (int)$year; |
265 | - } |
|
266 | - elseif($token=='MM' || $token=='M') |
|
264 | + } elseif($token=='MM' || $token=='M') |
|
267 | 265 | { |
268 | 266 | $month=$this->getInteger($value,$i_val, |
269 | 267 | $this->length($token),2); |
@@ -273,8 +271,7 @@ discard block |
||
273 | 271 | //throw new TInvalidDataValueException('Invalid month', $value); |
274 | 272 | $i_val += strlen($month); |
275 | 273 | $month = $iMonth; |
276 | - } |
|
277 | - elseif ($token=='dd' || $token=='d') |
|
274 | + } elseif ($token=='dd' || $token=='d') |
|
278 | 275 | { |
279 | 276 | $day = $this->getInteger($value,$i_val, |
280 | 277 | $this->length($token), 2); |
@@ -284,8 +281,7 @@ discard block |
||
284 | 281 | //throw new TInvalidDataValueException('Invalid day', $value); |
285 | 282 | $i_val += strlen($day); |
286 | 283 | $day = $iDay; |
287 | - } |
|
288 | - else |
|
284 | + } else |
|
289 | 285 | { |
290 | 286 | if($this->substring($value, $i_val, $this->length($token)) != $token) |
291 | 287 | return null; |
@@ -65,6 +65,7 @@ discard block |
||
65 | 65 | * Constructor, create a new date time formatter. |
66 | 66 | * @param string formatting pattern. |
67 | 67 | * @param string pattern and value charset |
68 | + * @param string $pattern |
|
68 | 69 | */ |
69 | 70 | public function __construct($pattern, $charset='UTF-8') |
70 | 71 | { |
@@ -98,6 +99,7 @@ discard block |
||
98 | 99 | |
99 | 100 | /** |
100 | 101 | * @param string formatting charset. |
102 | + * @param string $charset |
|
101 | 103 | */ |
102 | 104 | public function setCharset($charset) |
103 | 105 | { |
@@ -172,7 +174,7 @@ discard block |
||
172 | 174 | /** |
173 | 175 | * Gets the time stamp from string or integer. |
174 | 176 | * @param string|int date to parse |
175 | - * @return array date info array |
|
177 | + * @return \DateTime date info array |
|
176 | 178 | */ |
177 | 179 | private function getDate($value) |
178 | 180 | { |
@@ -324,6 +326,7 @@ discard block |
||
324 | 326 | |
325 | 327 | /** |
326 | 328 | * Calculate the length of a string, may be consider iconv_strlen? |
329 | + * @param string $string |
|
327 | 330 | */ |
328 | 331 | private function length($string) |
329 | 332 | { |
@@ -349,6 +352,9 @@ discard block |
||
349 | 352 | |
350 | 353 | /** |
351 | 354 | * Returns true if char at position equals a particular char. |
355 | + * @param string $string |
|
356 | + * @param integer $pos |
|
357 | + * @param string $char |
|
352 | 358 | */ |
353 | 359 | private function charEqual($string, $pos, $char) |
354 | 360 | { |
@@ -361,6 +367,10 @@ discard block |
||
361 | 367 | * @param int starting position |
362 | 368 | * @param int minimum integer length |
363 | 369 | * @param int maximum integer length |
370 | + * @param string $str |
|
371 | + * @param integer $i |
|
372 | + * @param integer|null $minlength |
|
373 | + * @param integer|null $maxlength |
|
364 | 374 | * @return string integer portion of the string, null otherwise |
365 | 375 | */ |
366 | 376 | private function getInteger($str,$i,$minlength,$maxlength) |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * Charset, default is 'UTF-8' |
60 | 60 | * @var string |
61 | 61 | */ |
62 | - private $charset = 'UTF-8'; |
|
62 | + private $charset='UTF-8'; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Constructor, create a new date time formatter. |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function setPattern($pattern) |
87 | 87 | { |
88 | - $this->pattern = $pattern; |
|
88 | + $this->pattern=$pattern; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function setCharset($charset) |
103 | 103 | { |
104 | - $this->charset = $charset; |
|
104 | + $this->charset=$charset; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,17 +111,17 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function format($value) |
113 | 113 | { |
114 | - $dt = $this->getDate($value); |
|
115 | - $bits['yyyy'] = $dt->format('Y'); |
|
116 | - $bits['yy'] = $dt->format('y'); |
|
114 | + $dt=$this->getDate($value); |
|
115 | + $bits['yyyy']=$dt->format('Y'); |
|
116 | + $bits['yy']=$dt->format('y'); |
|
117 | 117 | |
118 | - $bits['MM'] = $dt->format('m'); |
|
119 | - $bits['M'] = $dt->format('n'); |
|
118 | + $bits['MM']=$dt->format('m'); |
|
119 | + $bits['M']=$dt->format('n'); |
|
120 | 120 | |
121 | - $bits['dd'] = $dt->format('d'); |
|
122 | - $bits['d'] = $dt->format('j'); |
|
121 | + $bits['dd']=$dt->format('d'); |
|
122 | + $bits['d']=$dt->format('j'); |
|
123 | 123 | |
124 | - $pattern = preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
124 | + $pattern=preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
125 | 125 | return str_replace(array_keys($bits), $bits, $pattern); |
126 | 126 | } |
127 | 127 | |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | |
159 | 159 | public function getDayMonthYearOrdering() |
160 | 160 | { |
161 | - $ordering = array(); |
|
162 | - if(is_int($day= strpos($this->pattern, 'd'))) |
|
163 | - $ordering['day'] = $day; |
|
164 | - if(is_int($month= strpos($this->pattern, 'M'))) |
|
165 | - $ordering['month'] = $month; |
|
166 | - if(is_int($year= strpos($this->pattern, 'yy'))) |
|
167 | - $ordering['year'] = $year; |
|
161 | + $ordering=array(); |
|
162 | + if(is_int($day=strpos($this->pattern, 'd'))) |
|
163 | + $ordering['day']=$day; |
|
164 | + if(is_int($month=strpos($this->pattern, 'M'))) |
|
165 | + $ordering['month']=$month; |
|
166 | + if(is_int($year=strpos($this->pattern, 'yy'))) |
|
167 | + $ordering['year']=$year; |
|
168 | 168 | asort($ordering); |
169 | 169 | return array_keys($ordering); |
170 | 170 | } |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | { |
179 | 179 | if(is_numeric($value)) |
180 | 180 | { |
181 | - $date = new \DateTime; |
|
181 | + $date=new \DateTime; |
|
182 | 182 | $date->setTimeStamp($value); |
183 | 183 | } else { |
184 | - $date = new \DateTime($value); |
|
184 | + $date=new \DateTime($value); |
|
185 | 185 | } |
186 | 186 | return $date; |
187 | 187 | } |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function isValidDate($value) |
193 | 193 | { |
194 | - if($value === null) { |
|
194 | + if($value===null) { |
|
195 | 195 | return false; |
196 | 196 | } else { |
197 | - return $this->parse($value, false) !== null; |
|
197 | + return $this->parse($value, false)!==null; |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return int date time stamp |
205 | 205 | * @throws TInvalidDataValueException if date string is malformed. |
206 | 206 | */ |
207 | - public function parse($value,$defaultToCurrentTime=true) |
|
207 | + public function parse($value, $defaultToCurrentTime=true) |
|
208 | 208 | { |
209 | 209 | if(is_int($value) || is_float($value)) |
210 | 210 | return $value; |
@@ -213,111 +213,111 @@ discard block |
||
213 | 213 | |
214 | 214 | if(empty($this->pattern)) return time(); |
215 | 215 | |
216 | - $date = time(); |
|
216 | + $date=time(); |
|
217 | 217 | |
218 | 218 | if($this->length(trim($value)) < 1) |
219 | 219 | return $defaultToCurrentTime ? $date : null; |
220 | 220 | |
221 | - $pattern = $this->pattern; |
|
221 | + $pattern=$this->pattern; |
|
222 | 222 | |
223 | - $i_val = 0; |
|
224 | - $i_format = 0; |
|
225 | - $pattern_length = $this->length($pattern); |
|
226 | - $c = ''; |
|
223 | + $i_val=0; |
|
224 | + $i_format=0; |
|
225 | + $pattern_length=$this->length($pattern); |
|
226 | + $c=''; |
|
227 | 227 | $token=''; |
228 | 228 | $x=null; $y=null; |
229 | 229 | |
230 | 230 | |
231 | 231 | if($defaultToCurrentTime) |
232 | 232 | { |
233 | - $year = "{$date['year']}"; |
|
234 | - $month = $date['mon']; |
|
235 | - $day = $date['mday']; |
|
233 | + $year="{$date['year']}"; |
|
234 | + $month=$date['mon']; |
|
235 | + $day=$date['mday']; |
|
236 | 236 | } |
237 | 237 | else |
238 | 238 | { |
239 | - $year = null; |
|
240 | - $month = null; |
|
241 | - $day = null; |
|
239 | + $year=null; |
|
240 | + $month=null; |
|
241 | + $day=null; |
|
242 | 242 | } |
243 | 243 | |
244 | - while ($i_format < $pattern_length) |
|
244 | + while($i_format < $pattern_length) |
|
245 | 245 | { |
246 | - $c = $this->charAt($pattern,$i_format); |
|
246 | + $c=$this->charAt($pattern, $i_format); |
|
247 | 247 | $token=''; |
248 | - while ($this->charEqual($pattern, $i_format, $c) |
|
248 | + while($this->charEqual($pattern, $i_format, $c) |
|
249 | 249 | && ($i_format < $pattern_length)) |
250 | 250 | { |
251 | - $token .= $this->charAt($pattern, $i_format++); |
|
251 | + $token.=$this->charAt($pattern, $i_format++); |
|
252 | 252 | } |
253 | 253 | |
254 | - if ($token=='yyyy' || $token=='yy' || $token=='y') |
|
254 | + if($token=='yyyy' || $token=='yy' || $token=='y') |
|
255 | 255 | { |
256 | - if ($token=='yyyy') { $x=4;$y=4; } |
|
257 | - if ($token=='yy') { $x=2;$y=2; } |
|
258 | - if ($token=='y') { $x=2;$y=4; } |
|
259 | - $year = $this->getInteger($value,$i_val,$x,$y); |
|
260 | - if($year === null) |
|
256 | + if($token=='yyyy') { $x=4; $y=4; } |
|
257 | + if($token=='yy') { $x=2; $y=2; } |
|
258 | + if($token=='y') { $x=2; $y=4; } |
|
259 | + $year=$this->getInteger($value, $i_val, $x, $y); |
|
260 | + if($year===null) |
|
261 | 261 | return null; |
262 | 262 | //throw new TInvalidDataValueException('Invalid year', $value); |
263 | - $i_val += strlen($year); |
|
264 | - if(strlen($year) == 2) |
|
263 | + $i_val+=strlen($year); |
|
264 | + if(strlen($year)==2) |
|
265 | 265 | { |
266 | - $iYear = (int)$year; |
|
266 | + $iYear=(int) $year; |
|
267 | 267 | if($iYear > 70) |
268 | - $year = $iYear + 1900; |
|
268 | + $year=$iYear + 1900; |
|
269 | 269 | else |
270 | - $year = $iYear + 2000; |
|
270 | + $year=$iYear + 2000; |
|
271 | 271 | } |
272 | - $year = (int)$year; |
|
272 | + $year=(int) $year; |
|
273 | 273 | } |
274 | 274 | elseif($token=='MM' || $token=='M') |
275 | 275 | { |
276 | - $month=$this->getInteger($value,$i_val, |
|
277 | - $this->length($token),2); |
|
278 | - $iMonth = (int)$month; |
|
279 | - if($month === null || $iMonth < 1 || $iMonth > 12 ) |
|
276 | + $month=$this->getInteger($value, $i_val, |
|
277 | + $this->length($token), 2); |
|
278 | + $iMonth=(int) $month; |
|
279 | + if($month===null || $iMonth < 1 || $iMonth > 12) |
|
280 | 280 | return null; |
281 | 281 | //throw new TInvalidDataValueException('Invalid month', $value); |
282 | - $i_val += strlen($month); |
|
283 | - $month = $iMonth; |
|
282 | + $i_val+=strlen($month); |
|
283 | + $month=$iMonth; |
|
284 | 284 | } |
285 | - elseif ($token=='dd' || $token=='d') |
|
285 | + elseif($token=='dd' || $token=='d') |
|
286 | 286 | { |
287 | - $day = $this->getInteger($value,$i_val, |
|
287 | + $day=$this->getInteger($value, $i_val, |
|
288 | 288 | $this->length($token), 2); |
289 | - $iDay = (int)$day; |
|
290 | - if($day === null || $iDay < 1 || $iDay >31) |
|
289 | + $iDay=(int) $day; |
|
290 | + if($day===null || $iDay < 1 || $iDay > 31) |
|
291 | 291 | return null; |
292 | 292 | //throw new TInvalidDataValueException('Invalid day', $value); |
293 | - $i_val += strlen($day); |
|
294 | - $day = $iDay; |
|
293 | + $i_val+=strlen($day); |
|
294 | + $day=$iDay; |
|
295 | 295 | } |
296 | 296 | else |
297 | 297 | { |
298 | - if($this->substring($value, $i_val, $this->length($token)) != $token) |
|
298 | + if($this->substring($value, $i_val, $this->length($token))!=$token) |
|
299 | 299 | return null; |
300 | 300 | //throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value); |
301 | 301 | else |
302 | - $i_val += $this->length($token); |
|
302 | + $i_val+=$this->length($token); |
|
303 | 303 | } |
304 | 304 | } |
305 | - if ($i_val != $this->length($value)) |
|
305 | + if($i_val!=$this->length($value)) |
|
306 | 306 | return null; |
307 | 307 | //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); |
308 | - if(!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) |
|
308 | + if(!$defaultToCurrentTime && ($month===null || $day===null || $year===null)) |
|
309 | 309 | return null; |
310 | 310 | else |
311 | 311 | { |
312 | 312 | if(empty($year)) { |
313 | - $year = date('Y'); |
|
313 | + $year=date('Y'); |
|
314 | 314 | } |
315 | - $day = (int)$day <= 0 ? 1 : (int)$day; |
|
316 | - $month = (int)$month <= 0 ? 1 : (int)$month; |
|
315 | + $day=(int) $day <= 0 ? 1 : (int) $day; |
|
316 | + $month=(int) $month <= 0 ? 1 : (int) $month; |
|
317 | 317 | |
318 | - $s = new \DateTime; |
|
318 | + $s=new \DateTime; |
|
319 | 319 | $s->setDate($year, $month, $day); |
320 | - $s->setTime(0, 0 , 0); |
|
320 | + $s->setTime(0, 0, 0); |
|
321 | 321 | return $s->getTimeStamp(); |
322 | 322 | } |
323 | 323 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | private function charEqual($string, $pos, $char) |
354 | 354 | { |
355 | - return $this->charAt($string, $pos) == $char; |
|
355 | + return $this->charAt($string, $pos)==$char; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -363,15 +363,15 @@ discard block |
||
363 | 363 | * @param int maximum integer length |
364 | 364 | * @return string integer portion of the string, null otherwise |
365 | 365 | */ |
366 | - private function getInteger($str,$i,$minlength,$maxlength) |
|
366 | + private function getInteger($str, $i, $minlength, $maxlength) |
|
367 | 367 | { |
368 | 368 | //match for digits backwards |
369 | - for ($x = $maxlength; $x >= $minlength; $x--) |
|
369 | + for($x=$maxlength; $x >= $minlength; $x--) |
|
370 | 370 | { |
371 | - $token= $this->substring($str, $i,$x); |
|
372 | - if ($this->length($token) < $minlength) |
|
371 | + $token=$this->substring($str, $i, $x); |
|
372 | + if($this->length($token) < $minlength) |
|
373 | 373 | return null; |
374 | - if (preg_match('/^\d+$/', $token)) |
|
374 | + if(preg_match('/^\d+$/', $token)) |
|
375 | 375 | return $token; |
376 | 376 | } |
377 | 377 | return null; |
@@ -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 | } |
@@ -123,8 +123,7 @@ discard block |
||
123 | 123 | $user=Prado::createComponent($this->_userClass,$this); |
124 | 124 | $user->setIsGuest(true); |
125 | 125 | return $user; |
126 | - } |
|
127 | - else |
|
126 | + } else |
|
128 | 127 | return $this->_userFactory->createUser($username); |
129 | 128 | } |
130 | 129 | |
@@ -175,8 +174,7 @@ discard block |
||
175 | 174 | return $conn->getDbConnection(); |
176 | 175 | else |
177 | 176 | throw new TConfigurationException('dbusermanager_connectionid_invalid',$connectionID); |
178 | - } |
|
179 | - else |
|
177 | + } else |
|
180 | 178 | throw new TConfigurationException('dbusermanager_connectionid_required'); |
181 | 179 | } |
182 | 180 |
@@ -162,7 +162,8 @@ |
||
162 | 162 | /** |
163 | 163 | * Creates the DB connection. |
164 | 164 | * @param string the module ID for TDataSourceConfig |
165 | - * @return TDbConnection the created DB connection |
|
165 | + * @param string $connectionID |
|
166 | + * @return \Prado\Data\TDbConnection the created DB connection |
|
166 | 167 | * @throws TConfigurationException if module ID is invalid or empty |
167 | 168 | */ |
168 | 169 | protected function createDbConnection($connectionID) |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | { |
63 | 63 | if($this->_userClass==='') |
64 | 64 | throw new TConfigurationException('dbusermanager_userclass_required'); |
65 | - $this->_userFactory=Prado::createComponent($this->_userClass,$this); |
|
65 | + $this->_userFactory=Prado::createComponent($this->_userClass, $this); |
|
66 | 66 | if(!($this->_userFactory instanceof TDbUser)) |
67 | - throw new TInvalidDataTypeException('dbusermanager_userclass_invalid',$this->_userClass); |
|
67 | + throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param string password |
106 | 106 | * @return boolean true if validation is successful, false otherwise. |
107 | 107 | */ |
108 | - public function validateUser($username,$password) |
|
108 | + public function validateUser($username, $password) |
|
109 | 109 | { |
110 | - return $this->_userFactory->validateUser($username,$password); |
|
110 | + return $this->_userFactory->validateUser($username, $password); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | { |
120 | 120 | if($username===null) |
121 | 121 | { |
122 | - $user=Prado::createComponent($this->_userClass,$this); |
|
122 | + $user=Prado::createComponent($this->_userClass, $this); |
|
123 | 123 | $user->setIsGuest(true); |
124 | 124 | return $user; |
125 | 125 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | if($conn instanceof TDataSourceConfig) |
174 | 174 | return $conn->getDbConnection(); |
175 | 175 | else |
176 | - throw new TConfigurationException('dbusermanager_connectionid_invalid',$connectionID); |
|
176 | + throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID); |
|
177 | 177 | } |
178 | 178 | else |
179 | 179 | throw new TConfigurationException('dbusermanager_connectionid_required'); |
@@ -80,8 +80,7 @@ |
||
80 | 80 | // i-prefix, such as i-cherokee |
81 | 81 | if(count($codes)>1) |
82 | 82 | $lang = $codes[1]; |
83 | - } |
|
84 | - else |
|
83 | + } else |
|
85 | 84 | { |
86 | 85 | for($i = 0, $k = count($codes); $i<$k; ++$i) |
87 | 86 | { |
@@ -53,24 +53,24 @@ discard block |
||
53 | 53 | $this->languages = array(); |
54 | 54 | |
55 | 55 | if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
56 | - return $this->languages; |
|
56 | + return $this->languages; |
|
57 | 57 | |
58 | 58 | $info = new CultureInfo(); |
59 | 59 | |
60 | 60 | foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) |
61 | 61 | { |
62 | - // Cut off any q-value that might come after a semi-colon |
|
63 | - if ($pos = strpos($lang, ';')) |
|
64 | - $lang = trim(substr($lang, 0, $pos)); |
|
62 | + // Cut off any q-value that might come after a semi-colon |
|
63 | + if ($pos = strpos($lang, ';')) |
|
64 | + $lang = trim(substr($lang, 0, $pos)); |
|
65 | 65 | |
66 | 66 | if (strstr($lang, '-')) |
67 | 67 | { |
68 | 68 | $codes = explode('-',$lang); |
69 | 69 | if($codes[0] == 'i') |
70 | 70 | { |
71 | - // Language not listed in ISO 639 that are not variants |
|
72 | - // of any listed language, which can be registerd with the |
|
73 | - // i-prefix, such as i-cherokee |
|
71 | + // Language not listed in ISO 639 that are not variants |
|
72 | + // of any listed language, which can be registerd with the |
|
73 | + // i-prefix, such as i-cherokee |
|
74 | 74 | if(count($codes)>1) |
75 | 75 | $lang = $codes[1]; |
76 | 76 | } |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | $lang .= '_'.strtoupper($codes[$i]); |
85 | 85 | } |
86 | 86 | } |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | 91 | if($info->validCulture($lang)) |
92 | 92 | $this->languages[] = $lang; |
93 | - } |
|
93 | + } |
|
94 | 94 | |
95 | 95 | return $this->languages; |
96 | 96 | } |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getCharsets() |
103 | 103 | { |
104 | - if($this->charsets !== null) { |
|
104 | + if($this->charsets !== null) { |
|
105 | 105 | return $this->charsets; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $this->charsets = array(); |
109 | 109 | |
110 | 110 | if (!isset($_SERVER['HTTP_ACCEPT_CHARSET'])) |
111 | - return $this->charsets; |
|
111 | + return $this->charsets; |
|
112 | 112 | |
113 | 113 | foreach (explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset) |
114 | 114 | { |
115 | - if (!empty($charset)) |
|
116 | - $this->charsets[] = preg_replace('/;.*/', '', $charset); |
|
117 | - } |
|
115 | + if (!empty($charset)) |
|
116 | + $this->charsets[] = preg_replace('/;.*/', '', $charset); |
|
117 | + } |
|
118 | 118 | |
119 | 119 | return $this->charsets; |
120 | 120 | } |
@@ -46,42 +46,42 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function getLanguages() |
48 | 48 | { |
49 | - if($this->languages !== null) { |
|
49 | + if($this->languages!==null) { |
|
50 | 50 | return $this->languages; |
51 | 51 | } |
52 | 52 | |
53 | - $this->languages = array(); |
|
53 | + $this->languages=array(); |
|
54 | 54 | |
55 | - if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
55 | + if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
56 | 56 | return $this->languages; |
57 | 57 | |
58 | - $info = new CultureInfo(); |
|
58 | + $info=new CultureInfo(); |
|
59 | 59 | |
60 | 60 | foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) |
61 | 61 | { |
62 | 62 | // Cut off any q-value that might come after a semi-colon |
63 | - if ($pos = strpos($lang, ';')) |
|
64 | - $lang = trim(substr($lang, 0, $pos)); |
|
63 | + if($pos=strpos($lang, ';')) |
|
64 | + $lang=trim(substr($lang, 0, $pos)); |
|
65 | 65 | |
66 | - if (strstr($lang, '-')) |
|
66 | + if(strstr($lang, '-')) |
|
67 | 67 | { |
68 | - $codes = explode('-',$lang); |
|
69 | - if($codes[0] == 'i') |
|
68 | + $codes=explode('-', $lang); |
|
69 | + if($codes[0]=='i') |
|
70 | 70 | { |
71 | 71 | // Language not listed in ISO 639 that are not variants |
72 | 72 | // of any listed language, which can be registerd with the |
73 | 73 | // i-prefix, such as i-cherokee |
74 | - if(count($codes)>1) |
|
75 | - $lang = $codes[1]; |
|
74 | + if(count($codes) > 1) |
|
75 | + $lang=$codes[1]; |
|
76 | 76 | } |
77 | 77 | else |
78 | 78 | { |
79 | - for($i = 0, $k = count($codes); $i<$k; ++$i) |
|
79 | + for($i=0, $k=count($codes); $i < $k; ++$i) |
|
80 | 80 | { |
81 | - if($i == 0) |
|
82 | - $lang = strtolower($codes[0]); |
|
81 | + if($i==0) |
|
82 | + $lang=strtolower($codes[0]); |
|
83 | 83 | else |
84 | - $lang .= '_'.strtoupper($codes[$i]); |
|
84 | + $lang.='_'.strtoupper($codes[$i]); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | |
91 | 91 | if($info->validCulture($lang)) |
92 | - $this->languages[] = $lang; |
|
92 | + $this->languages[]=$lang; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $this->languages; |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getCharsets() |
103 | 103 | { |
104 | - if($this->charsets !== null) { |
|
104 | + if($this->charsets!==null) { |
|
105 | 105 | return $this->charsets; |
106 | 106 | } |
107 | 107 | |
108 | - $this->charsets = array(); |
|
108 | + $this->charsets=array(); |
|
109 | 109 | |
110 | - if (!isset($_SERVER['HTTP_ACCEPT_CHARSET'])) |
|
110 | + if(!isset($_SERVER['HTTP_ACCEPT_CHARSET'])) |
|
111 | 111 | return $this->charsets; |
112 | 112 | |
113 | - foreach (explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset) |
|
113 | + foreach(explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset) |
|
114 | 114 | { |
115 | - if (!empty($charset)) |
|
116 | - $this->charsets[] = preg_replace('/;.*/', '', $charset); |
|
115 | + if(!empty($charset)) |
|
116 | + $this->charsets[]=preg_replace('/;.*/', '', $charset); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | return $this->charsets; |
@@ -112,8 +112,7 @@ |
||
112 | 112 | && strlen($datetime[1]) == 1) |
113 | 113 | { |
114 | 114 | $pattern = $datetime; |
115 | - } |
|
116 | - else //no subpattern, try the presets |
|
115 | + } else //no subpattern, try the presets |
|
117 | 116 | $pattern = $this->getPreset($string); |
118 | 117 | |
119 | 118 | //no presets found, use the string as the pattern |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * A set of pattern presets and their respective formatting shorthand. |
71 | 71 | * @var array |
72 | 72 | */ |
73 | - static private $_patternPresets = array( |
|
74 | - 'fulldate'=>'P','full'=>'P', |
|
75 | - 'longdate'=>'D','long'=>'d', |
|
76 | - 'mediumdate'=>'p','medium'=>'p', |
|
77 | - 'shortdate'=>'d','short'=>'d', |
|
73 | + static private $_patternPresets=array( |
|
74 | + 'fulldate'=>'P', 'full'=>'P', |
|
75 | + 'longdate'=>'D', 'long'=>'d', |
|
76 | + 'mediumdate'=>'p', 'medium'=>'p', |
|
77 | + 'shortdate'=>'d', 'short'=>'d', |
|
78 | 78 | 'fulltime'=>'Q', 'longtime'=>'T', |
79 | 79 | 'mediumtime'=>'q', 'shorttime'=>'t'); |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function setPattern($value) |
86 | 86 | { |
87 | - $this->setViewState('Pattern',$value,''); |
|
87 | + $this->setViewState('Pattern', $value, ''); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -93,35 +93,35 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getPattern() |
95 | 95 | { |
96 | - $string = $this->getViewState('Pattern',''); |
|
96 | + $string=$this->getViewState('Pattern', ''); |
|
97 | 97 | |
98 | - $pattern = null; |
|
98 | + $pattern=null; |
|
99 | 99 | |
100 | 100 | //try the subpattern of "date time" presets |
101 | - $subpatterns = explode(' ',$string,2); |
|
102 | - $datetime = array(); |
|
101 | + $subpatterns=explode(' ', $string, 2); |
|
102 | + $datetime=array(); |
|
103 | 103 | if(count($subpatterns)==2) |
104 | 104 | { |
105 | - $datetime[] = $this->getPreset($subpatterns[0]); |
|
106 | - $datetime[] = $this->getPreset($subpatterns[1]); |
|
105 | + $datetime[]=$this->getPreset($subpatterns[0]); |
|
106 | + $datetime[]=$this->getPreset($subpatterns[1]); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //we have a good subpattern |
110 | - if(count($datetime) == 2 |
|
111 | - && strlen($datetime[0]) == 1 |
|
112 | - && strlen($datetime[1]) == 1) |
|
110 | + if(count($datetime)==2 |
|
111 | + && strlen($datetime[0])==1 |
|
112 | + && strlen($datetime[1])==1) |
|
113 | 113 | { |
114 | - $pattern = $datetime; |
|
114 | + $pattern=$datetime; |
|
115 | 115 | } |
116 | 116 | else //no subpattern, try the presets |
117 | - $pattern = $this->getPreset($string); |
|
117 | + $pattern=$this->getPreset($string); |
|
118 | 118 | |
119 | 119 | //no presets found, use the string as the pattern |
120 | 120 | //and let the DateFormat handle it. |
121 | 121 | if($pattern===null) |
122 | - $pattern = $string; |
|
123 | - if (!is_array($pattern) && strlen($pattern) == 0) |
|
124 | - $pattern = null; |
|
122 | + $pattern=$string; |
|
123 | + if(!is_array($pattern) && strlen($pattern)==0) |
|
124 | + $pattern=null; |
|
125 | 125 | return $pattern; |
126 | 126 | } |
127 | 127 | |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function getPreset($string) |
134 | 134 | { |
135 | - $string = strtolower($string); |
|
135 | + $string=strtolower($string); |
|
136 | 136 | foreach(self::$_patternPresets as $pattern => $preset) |
137 | 137 | { |
138 | - if($string == $pattern) |
|
138 | + if($string==$pattern) |
|
139 | 139 | return $preset; |
140 | 140 | } |
141 | 141 | } |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getValue() |
148 | 148 | { |
149 | - $value = $this->getViewState('Value',''); |
|
149 | + $value=$this->getViewState('Value', ''); |
|
150 | 150 | if(empty($value)) |
151 | 151 | { |
152 | - $defaultText = $this->getDefaultText(); |
|
152 | + $defaultText=$this->getDefaultText(); |
|
153 | 153 | if(empty($defaultText)) |
154 | 154 | return time(); |
155 | 155 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function setValue($value) |
164 | 164 | { |
165 | - $this->setViewState('Value',$value,''); |
|
165 | + $this->setViewState('Value', $value, ''); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function getDefaultText() |
173 | 173 | { |
174 | - return $this->getViewState('DefaultText',''); |
|
174 | + return $this->getViewState('DefaultText', ''); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function setDefaultText($value) |
182 | 182 | { |
183 | - $this->setViewState('DefaultText',$value,''); |
|
183 | + $this->setViewState('DefaultText', $value, ''); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -217,29 +217,29 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function getFormattedDate() |
219 | 219 | { |
220 | - $value = $this->getValue(); |
|
221 | - $defaultText = $this->getDefaultText(); |
|
220 | + $value=$this->getValue(); |
|
221 | + $defaultText=$this->getDefaultText(); |
|
222 | 222 | if(empty($value) && !empty($defaultText)) |
223 | 223 | return $this->getDefaultText(); |
224 | 224 | |
225 | - $app = $this->getApplication()->getGlobalization(); |
|
225 | + $app=$this->getApplication()->getGlobalization(); |
|
226 | 226 | |
227 | 227 | //initialized the default class wide formatter |
228 | 228 | if(self::$formatter===null) |
229 | - self::$formatter = new DateFormat($app->getCulture()); |
|
229 | + self::$formatter=new DateFormat($app->getCulture()); |
|
230 | 230 | |
231 | - $culture = $this->getCulture(); |
|
231 | + $culture=$this->getCulture(); |
|
232 | 232 | |
233 | 233 | //return the specific cultural formatted date time |
234 | - if(strlen($culture) && $app->getCulture() !== $culture) |
|
234 | + if(strlen($culture) && $app->getCulture()!==$culture) |
|
235 | 235 | { |
236 | - $formatter = new DateFormat($culture); |
|
236 | + $formatter=new DateFormat($culture); |
|
237 | 237 | return $formatter->format($value, |
238 | 238 | $this->getPattern(), |
239 | 239 | $this->getCharset()); |
240 | 240 | } |
241 | 241 | //return the application wide culture formatted date time. |
242 | - $result = self::$formatter->format($value, |
|
242 | + $result=self::$formatter->format($value, |
|
243 | 243 | $this->getPattern(), |
244 | 244 | $this->getCharset()); |
245 | 245 | return $result; |
@@ -120,11 +120,9 @@ |
||
120 | 120 | { |
121 | 121 | $this->setChecked(true); |
122 | 122 | return true; |
123 | - } |
|
124 | - else |
|
123 | + } else |
|
125 | 124 | return false; |
126 | - } |
|
127 | - else if($this->getChecked()) |
|
125 | + } else if($this->getChecked()) |
|
128 | 126 | $this->setChecked(false); |
129 | 127 | return false; |
130 | 128 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function __construct() |
77 | 77 | { |
78 | 78 | parent::__construct(); |
79 | - $this->_globalID = self::$_buttonCount++; |
|
79 | + $this->_globalID=self::$_buttonCount++; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | * @param array the input data collection |
109 | 109 | * @return boolean whether the data of the control has been changed |
110 | 110 | */ |
111 | - public function loadPostData($key,$values) |
|
111 | + public function loadPostData($key, $values) |
|
112 | 112 | { |
113 | 113 | $uniqueGroupName=$this->getUniqueGroupName(); |
114 | - $value=isset($values[$uniqueGroupName])?$values[$uniqueGroupName]:null; |
|
114 | + $value=isset($values[$uniqueGroupName]) ? $values[$uniqueGroupName] : null; |
|
115 | 115 | if($value!==null && $value===$this->getValueAttribute()) |
116 | 116 | { |
117 | 117 | if(!$this->getChecked()) |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function getGroupName() |
134 | 134 | { |
135 | - return $this->getViewState('GroupName',''); |
|
135 | + return $this->getViewState('GroupName', ''); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function setGroupName($value) |
145 | 145 | { |
146 | - $this->setViewState('GroupName',$value,''); |
|
146 | + $this->setViewState('GroupName', $value, ''); |
|
147 | 147 | $this->_uniqueGroupName=null; |
148 | 148 | } |
149 | 149 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function getUniqueGroupName() |
154 | 154 | { |
155 | - if(($groupName=$this->getViewState('UniqueGroupName',''))!=='') |
|
155 | + if(($groupName=$this->getViewState('UniqueGroupName', ''))!=='') |
|
156 | 156 | return $groupName; |
157 | 157 | else if(($uniqueID=$this->getUniqueID())!==$this->_previousUniqueID || $this->_uniqueGroupName===null) |
158 | 158 | { |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | $this->_previousUniqueID=$uniqueID; |
161 | 161 | if($uniqueID!=='') |
162 | 162 | { |
163 | - if(($pos=strrpos($uniqueID,\Prado\Web\UI\TControl::ID_SEPARATOR))!==false) |
|
163 | + if(($pos=strrpos($uniqueID, \Prado\Web\UI\TControl::ID_SEPARATOR))!==false) |
|
164 | 164 | { |
165 | 165 | if($groupName!=='') |
166 | - $groupName=substr($uniqueID,0,$pos+1).$groupName; |
|
166 | + $groupName=substr($uniqueID, 0, $pos + 1).$groupName; |
|
167 | 167 | else if($this->getNamingContainer() instanceof TRadioButtonList) |
168 | - $groupName=substr($uniqueID,0,$pos); |
|
168 | + $groupName=substr($uniqueID, 0, $pos); |
|
169 | 169 | } |
170 | 170 | if($groupName==='') |
171 | 171 | $groupName=$uniqueID; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function setUniqueGroupName($value) |
195 | 195 | { |
196 | - $this->setViewState('UniqueGroupName',$value,''); |
|
196 | + $this->setViewState('UniqueGroupName', $value, ''); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -204,12 +204,12 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function getRadioButtonsInGroup() |
206 | 206 | { |
207 | - $group = $this->getUniqueGroupName(); |
|
208 | - $buttons = array(); |
|
207 | + $group=$this->getUniqueGroupName(); |
|
208 | + $buttons=array(); |
|
209 | 209 | foreach(self::$_activeButtons as $control) |
210 | 210 | { |
211 | - if($control->getUniqueGroupName() === $group) |
|
212 | - $buttons[] = $control; |
|
211 | + if($control->getUniqueGroupName()===$group) |
|
212 | + $buttons[]=$control; |
|
213 | 213 | } |
214 | 214 | return $buttons; |
215 | 215 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function getEnableClientScript() |
232 | 232 | { |
233 | - return $this->getViewState('EnableClientScript',true); |
|
233 | + return $this->getViewState('EnableClientScript', true); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function setEnableClientScript($value) |
240 | 240 | { |
241 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
241 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -247,19 +247,19 @@ discard block |
||
247 | 247 | * @param string checkbox id |
248 | 248 | * @param string onclick js |
249 | 249 | */ |
250 | - protected function renderInputTag($writer,$clientID,$onclick) |
|
250 | + protected function renderInputTag($writer, $clientID, $onclick) |
|
251 | 251 | { |
252 | 252 | if($clientID!=='') |
253 | - $writer->addAttribute('id',$clientID); |
|
254 | - $writer->addAttribute('type','radio'); |
|
255 | - $writer->addAttribute('name',$this->getUniqueGroupName()); |
|
256 | - $writer->addAttribute('value',$this->getValueAttribute()); |
|
253 | + $writer->addAttribute('id', $clientID); |
|
254 | + $writer->addAttribute('type', 'radio'); |
|
255 | + $writer->addAttribute('name', $this->getUniqueGroupName()); |
|
256 | + $writer->addAttribute('value', $this->getValueAttribute()); |
|
257 | 257 | if(!empty($onclick)) |
258 | - $writer->addAttribute('onclick',$onclick); |
|
258 | + $writer->addAttribute('onclick', $onclick); |
|
259 | 259 | if($this->getChecked()) |
260 | - $writer->addAttribute('checked','checked'); |
|
260 | + $writer->addAttribute('checked', 'checked'); |
|
261 | 261 | if(!$this->getEnabled(true)) |
262 | - $writer->addAttribute('disabled','disabled'); |
|
262 | + $writer->addAttribute('disabled', 'disabled'); |
|
263 | 263 | |
264 | 264 | $page=$this->getPage(); |
265 | 265 | if($this->getEnabled(true) |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | if(($accesskey=$this->getAccessKey())!=='') |
274 | - $writer->addAttribute('accesskey',$accesskey); |
|
275 | - if(($tabindex=$this->getTabIndex())>0) |
|
276 | - $writer->addAttribute('tabindex',"$tabindex"); |
|
277 | - if($attributes=$this->getViewState('InputAttributes',null)) |
|
274 | + $writer->addAttribute('accesskey', $accesskey); |
|
275 | + if(($tabindex=$this->getTabIndex()) > 0) |
|
276 | + $writer->addAttribute('tabindex', "$tabindex"); |
|
277 | + if($attributes=$this->getViewState('InputAttributes', null)) |
|
278 | 278 | $writer->addAttributes($attributes); |
279 | 279 | $writer->renderBeginTag('input'); |
280 | 280 | $writer->renderEndTag(); |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | */ |
286 | 286 | protected function renderClientControlScript($writer) |
287 | 287 | { |
288 | - $cs = $this->getPage()->getClientScript(); |
|
289 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
288 | + $cs=$this->getPage()->getClientScript(); |
|
289 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |