@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | case 'datetime': case 'timestamp': |
34 | 34 | return $this->createDateTimeControl($container, $column, $record); |
35 | 35 | default: |
36 | - return $this->createDefaultControl($container,$column, $record); |
|
36 | + return $this->createDefaultControl($container, $column, $record); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | case 'time': |
51 | 51 | return $this->getTimeValue($container, $column, $record); |
52 | 52 | case 'datetime': case 'timestamp': |
53 | - return $this->getDateTimeValue($container,$column, $record); |
|
53 | + return $this->getDateTimeValue($container, $column, $record); |
|
54 | 54 | default: |
55 | - return $this->getDefaultControlValue($container,$column, $record); |
|
55 | + return $this->getDefaultControlValue($container, $column, $record); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | protected function createDateControl($container, $column, $record) |
60 | 60 | { |
61 | - $control = parent::createDateControl($container, $column, $record); |
|
62 | - $value = $this->getRecordPropertyValue($column, $record); |
|
61 | + $control=parent::createDateControl($container, $column, $record); |
|
62 | + $value=$this->getRecordPropertyValue($column, $record); |
|
63 | 63 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
64 | 64 | $control->setTimestamp(intval($value)); |
65 | 65 | return $control; |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | |
68 | 68 | protected function createDateTimeControl($container, $column, $record) |
69 | 69 | { |
70 | - $value = $this->getRecordPropertyValue($column, $record); |
|
71 | - $time = parent::createDateTimeControl($container, $column, $record); |
|
70 | + $value=$this->getRecordPropertyValue($column, $record); |
|
71 | + $time=parent::createDateTimeControl($container, $column, $record); |
|
72 | 72 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
73 | 73 | { |
74 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
75 | - $date = $s->getDate(intval($value)); |
|
74 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
75 | + $date=$s->getDate(intval($value)); |
|
76 | 76 | $time[1]->setSelectedValue($date['hours']); |
77 | 77 | $time[2]->setSelectedValue($date['minutes']); |
78 | 78 | $time[3]->setSelectedValue($date['seconds']); |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | { |
85 | 85 | if(preg_match('/timestamp/i', $column->getDbType())) |
86 | 86 | { |
87 | - $time = $container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
88 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
89 | - $date = $s->getDate($time); |
|
90 | - $hour = $container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
91 | - $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); |
|
92 | - $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
93 | - return $s->getTimeStamp($hour,$mins,$secs,$date['mon'],$date['mday'],$date['year']); |
|
87 | + $time=$container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
88 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
89 | + $date=$s->getDate($time); |
|
90 | + $hour=$container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
91 | + $mins=$container->findControl('scaffold_time_min')->getSelectedValue(); |
|
92 | + $secs=$container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
93 | + return $s->getTimeStamp($hour, $mins, $secs, $date['mon'], $date['mday'], $date['year']); |
|
94 | 94 | } |
95 | 95 | else |
96 | 96 | return parent::getDateTimeValue($container, $column, $record); |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | $object = $object[$prop]; |
62 | 62 | else |
63 | 63 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
64 | - } |
|
65 | - else if(is_object($object)) |
|
64 | + } else if(is_object($object)) |
|
66 | 65 | { |
67 | 66 | $getter = 'get'.$prop; |
68 | 67 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | $object = $object->{$prop}; |
74 | 73 | else |
75 | 74 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
76 | - } |
|
77 | - else |
|
75 | + } else |
|
78 | 76 | throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
79 | 77 | } |
80 | 78 | return $object; |
@@ -98,8 +96,7 @@ discard block |
||
98 | 96 | $object = $object[$prop]; |
99 | 97 | else |
100 | 98 | return false; |
101 | - } |
|
102 | - else if(is_object($object)) |
|
99 | + } else if(is_object($object)) |
|
103 | 100 | { |
104 | 101 | $getter = 'get'.$prop; |
105 | 102 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
@@ -110,8 +107,7 @@ discard block |
||
110 | 107 | $object = $object->{$prop}; |
111 | 108 | else |
112 | 109 | return false; |
113 | - } |
|
114 | - else |
|
110 | + } else |
|
115 | 111 | return false; |
116 | 112 | } |
117 | 113 | return true; |
@@ -136,16 +132,14 @@ discard block |
||
136 | 132 | if(is_array($object) || $object instanceof ArrayAccess) |
137 | 133 | { |
138 | 134 | $object[$prop] = $value; |
139 | - } |
|
140 | - else if(is_object($object)) |
|
135 | + } else if(is_object($object)) |
|
141 | 136 | { |
142 | 137 | $setter = 'set'.$prop; |
143 | 138 | if (method_exists($object, $setter) && is_callable(array($object, $setter))) |
144 | 139 | $object->{$setter}($value); |
145 | 140 | else |
146 | 141 | $object->{$prop} = $value; |
147 | - } |
|
148 | - else |
|
142 | + } else |
|
149 | 143 | throw new TInvalidPropertyException('sqlmap_invalid_property_type',$path); |
150 | 144 | } |
151 | 145 |
@@ -48,34 +48,34 @@ discard block |
||
48 | 48 | * @return mixed property value. |
49 | 49 | * @throws TInvalidDataValueException if property path is invalid. |
50 | 50 | */ |
51 | - public static function get($object,$path) |
|
51 | + public static function get($object, $path) |
|
52 | 52 | { |
53 | 53 | if(!is_array($object) && !is_object($object)) |
54 | 54 | return $object; |
55 | - $properties = explode('.', $path); |
|
55 | + $properties=explode('.', $path); |
|
56 | 56 | foreach($properties as $prop) |
57 | 57 | { |
58 | 58 | if(is_array($object) || $object instanceof ArrayAccess) |
59 | 59 | { |
60 | 60 | if(array_key_exists($prop, $object)) |
61 | - $object = $object[$prop]; |
|
61 | + $object=$object[$prop]; |
|
62 | 62 | else |
63 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
63 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
64 | 64 | } |
65 | 65 | else if(is_object($object)) |
66 | 66 | { |
67 | - $getter = 'get'.$prop; |
|
67 | + $getter='get'.$prop; |
|
68 | 68 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
69 | - $object = $object->{$getter}(); |
|
69 | + $object=$object->{$getter}(); |
|
70 | 70 | else if(in_array($prop, array_keys(get_object_vars($object)))) |
71 | - $object = $object->{$prop}; |
|
71 | + $object=$object->{$prop}; |
|
72 | 72 | elseif(method_exists($object, '__get') && is_callable(array($object, '__get'))) |
73 | - $object = $object->{$prop}; |
|
73 | + $object=$object->{$prop}; |
|
74 | 74 | else |
75 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
75 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
76 | 76 | } |
77 | 77 | else |
78 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
78 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
79 | 79 | } |
80 | 80 | return $object; |
81 | 81 | } |
@@ -89,25 +89,25 @@ discard block |
||
89 | 89 | { |
90 | 90 | if(!is_array($object) && !is_object($object)) |
91 | 91 | return false; |
92 | - $properties = explode('.', $path); |
|
92 | + $properties=explode('.', $path); |
|
93 | 93 | foreach($properties as $prop) |
94 | 94 | { |
95 | 95 | if(is_array($object) || $object instanceof ArrayAccess) |
96 | 96 | { |
97 | 97 | if(array_key_exists($prop, $object)) |
98 | - $object = $object[$prop]; |
|
98 | + $object=$object[$prop]; |
|
99 | 99 | else |
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | else if(is_object($object)) |
103 | 103 | { |
104 | - $getter = 'get'.$prop; |
|
104 | + $getter='get'.$prop; |
|
105 | 105 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
106 | - $object = $object->{$getter}(); |
|
106 | + $object=$object->{$getter}(); |
|
107 | 107 | else if(in_array($prop, array_keys(get_object_vars($object)))) |
108 | - $object = $object->{$prop}; |
|
108 | + $object=$object->{$prop}; |
|
109 | 109 | elseif(method_exists($object, '__get') && is_callable(array($object, '__get'))) |
110 | - $object = $object->{$prop}; |
|
110 | + $object=$object->{$prop}; |
|
111 | 111 | else |
112 | 112 | return false; |
113 | 113 | } |
@@ -126,27 +126,27 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public static function set(&$originalObject, $path, $value) |
128 | 128 | { |
129 | - $properties = explode('.', $path); |
|
130 | - $prop = array_pop($properties); |
|
129 | + $properties=explode('.', $path); |
|
130 | + $prop=array_pop($properties); |
|
131 | 131 | if(count($properties) > 0) |
132 | - $object = self::get($originalObject, implode('.',$properties)); |
|
132 | + $object=self::get($originalObject, implode('.', $properties)); |
|
133 | 133 | else |
134 | - $object = &$originalObject; |
|
134 | + $object=&$originalObject; |
|
135 | 135 | |
136 | 136 | if(is_array($object) || $object instanceof ArrayAccess) |
137 | 137 | { |
138 | - $object[$prop] = $value; |
|
138 | + $object[$prop]=$value; |
|
139 | 139 | } |
140 | 140 | else if(is_object($object)) |
141 | 141 | { |
142 | - $setter = 'set'.$prop; |
|
143 | - if (method_exists($object, $setter) && is_callable(array($object, $setter))) |
|
142 | + $setter='set'.$prop; |
|
143 | + if(method_exists($object, $setter) && is_callable(array($object, $setter))) |
|
144 | 144 | $object->{$setter}($value); |
145 | 145 | else |
146 | - $object->{$prop} = $value; |
|
146 | + $object->{$prop}=$value; |
|
147 | 147 | } |
148 | 148 | else |
149 | - throw new TInvalidPropertyException('sqlmap_invalid_property_type',$path); |
|
149 | + throw new TInvalidPropertyException('sqlmap_invalid_property_type', $path); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } |
@@ -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 | } |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -30,12 +30,12 @@ |
||
30 | 30 | */ |
31 | 31 | public function applyLimitOffset($sql, $limit=-1, $offset=-1) |
32 | 32 | { |
33 | - $limit = $limit!==null ? intval($limit) : -1; |
|
34 | - $offset = $offset!==null ? intval($offset) : -1; |
|
33 | + $limit=$limit!==null ? intval($limit) : -1; |
|
34 | + $offset=$offset!==null ? intval($offset) : -1; |
|
35 | 35 | if($limit > 0 || $offset > 0) |
36 | 36 | { |
37 | - $limitStr = ' LIMIT '.$limit; |
|
38 | - $offsetStr = $offset >= 0 ? ' OFFSET '.$offset : ''; |
|
37 | + $limitStr=' LIMIT '.$limit; |
|
38 | + $offsetStr=$offset >= 0 ? ' OFFSET '.$offset : ''; |
|
39 | 39 | return $sql.$limitStr.$offsetStr; |
40 | 40 | } |
41 | 41 | else |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TSqliteCommandBuilder class file. |
|
4 | - * |
|
5 | - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Data.Common |
|
10 | - */ |
|
3 | + * TSqliteCommandBuilder class file. |
|
4 | + * |
|
5 | + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Data.Common |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | Prado::using('System.Data.Common.TDbCommandBuilder'); |
13 | 13 |
@@ -199,8 +199,7 @@ discard block |
||
199 | 199 | $this -> _createCheck = true; |
200 | 200 | $this -> getApplication() -> setGlobalState($key, time()); |
201 | 201 | } |
202 | - } |
|
203 | - catch(Exception $e) |
|
202 | + } catch(Exception $e) |
|
204 | 203 | { |
205 | 204 | // DB table not exists |
206 | 205 | if($this->_autoCreate) |
@@ -223,8 +222,7 @@ discard block |
||
223 | 222 | |
224 | 223 | $this -> _createCheck = true; |
225 | 224 | $this -> getApplication() -> setGlobalState($key, time()); |
226 | - } |
|
227 | - else |
|
225 | + } else |
|
228 | 226 | throw new TConfigurationException('db_cachetable_inexistent',$this->_cacheTable); |
229 | 227 | } |
230 | 228 | $this->_cacheInitialized = true; |
@@ -293,8 +291,7 @@ discard block |
||
293 | 291 | return $config->getDbConnection(); |
294 | 292 | else |
295 | 293 | throw new TConfigurationException('dbcache_connectionid_invalid',$this->_connID); |
296 | - } |
|
297 | - else |
|
294 | + } else |
|
298 | 295 | { |
299 | 296 | $db=new TDbConnection; |
300 | 297 | if($this->_connectionString!=='') |
@@ -304,8 +301,7 @@ discard block |
||
304 | 301 | $db->setUsername($this->_username); |
305 | 302 | if($this->_password!=='') |
306 | 303 | $db->setPassword($this->_password); |
307 | - } |
|
308 | - else |
|
304 | + } else |
|
309 | 305 | { |
310 | 306 | // default to SQLite3 database |
311 | 307 | $dbFile=$this->getApplication()->getRuntimePath().'/sqlite3.cache'; |
@@ -462,8 +458,7 @@ discard block |
||
462 | 458 | $sql='SELECT value FROM '.$this->_cacheTable.' WHERE itemkey=\''.$key.'\' AND (expire=0 OR expire>'.time().') ORDER BY expire DESC'; |
463 | 459 | $command=$this->getDbConnection()->createCommand($sql); |
464 | 460 | return unserialize($command->queryScalar()); |
465 | - } |
|
466 | - catch(Exception $e) |
|
461 | + } catch(Exception $e) |
|
467 | 462 | { |
468 | 463 | $this->initializeCache(true); |
469 | 464 | return unserialize($command->queryScalar()); |
@@ -506,16 +501,14 @@ discard block |
||
506 | 501 | $command->bindValue(':value',serialize($value),PDO::PARAM_LOB); |
507 | 502 | $command->execute(); |
508 | 503 | return true; |
509 | - } |
|
510 | - catch(Exception $e) |
|
504 | + } catch(Exception $e) |
|
511 | 505 | { |
512 | 506 | try |
513 | 507 | { |
514 | 508 | $this->initializeCache(true); |
515 | 509 | $command->execute(); |
516 | 510 | return true; |
517 | - } |
|
518 | - catch(Exception $e) |
|
511 | + } catch(Exception $e) |
|
519 | 512 | { |
520 | 513 | return false; |
521 | 514 | } |
@@ -537,8 +530,7 @@ discard block |
||
537 | 530 | $command->bindValue(':key',$key,PDO::PARAM_STR); |
538 | 531 | $command->execute(); |
539 | 532 | return true; |
540 | - } |
|
541 | - catch(Exception $e) |
|
533 | + } catch(Exception $e) |
|
542 | 534 | { |
543 | 535 | $this->initializeCache(true); |
544 | 536 | $command->execute(); |
@@ -557,16 +549,14 @@ discard block |
||
557 | 549 | { |
558 | 550 | $command = $this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
559 | 551 | $command->execute(); |
560 | - } |
|
561 | - catch(Exception $e) |
|
552 | + } catch(Exception $e) |
|
562 | 553 | { |
563 | 554 | try |
564 | 555 | { |
565 | 556 | $this->initializeCache(true); |
566 | 557 | $command->execute(); |
567 | 558 | return true; |
568 | - } |
|
569 | - catch(Exception $e) |
|
559 | + } catch(Exception $e) |
|
570 | 560 | { |
571 | 561 | return false; |
572 | 562 | } |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @var boolean |
107 | 107 | */ |
108 | - private $_cacheInitialized = false; |
|
108 | + private $_cacheInitialized=false; |
|
109 | 109 | /** |
110 | 110 | * @var boolean |
111 | 111 | */ |
112 | - private $_createCheck= false; |
|
112 | + private $_createCheck=false; |
|
113 | 113 | /** |
114 | 114 | * @var boolean whether the cache DB table should be created automatically |
115 | 115 | */ |
@@ -183,20 +183,20 @@ discard block |
||
183 | 183 | $db=$this->getDbConnection(); |
184 | 184 | try |
185 | 185 | { |
186 | - $key = 'TDbCache:' . $this->_cacheTable . ':created'; |
|
186 | + $key='TDbCache:'.$this->_cacheTable.':created'; |
|
187 | 187 | if($force) |
188 | - $this -> _createCheck = false; |
|
188 | + $this -> _createCheck=false; |
|
189 | 189 | else |
190 | - $this -> _createCheck = $this -> getApplication() -> getGlobalState($key, 0); |
|
190 | + $this -> _createCheck=$this -> getApplication() -> getGlobalState($key, 0); |
|
191 | 191 | |
192 | 192 | if($this->_autoCreate && !$this -> _createCheck) { |
193 | 193 | |
194 | - Prado::trace(($force ? 'Force initializing: ' : 'Initializing: ') . $this -> id . ', ' . $this->_cacheTable, 'System.Caching.TDbCache'); |
|
194 | + Prado::trace(($force ? 'Force initializing: ' : 'Initializing: ').$this -> id.', '.$this->_cacheTable, 'System.Caching.TDbCache'); |
|
195 | 195 | |
196 | 196 | $sql='SELECT 1 FROM '.$this->_cacheTable.' WHERE 0=1'; |
197 | 197 | $db->createCommand($sql)->queryScalar(); |
198 | 198 | |
199 | - $this -> _createCheck = true; |
|
199 | + $this -> _createCheck=true; |
|
200 | 200 | $this -> getApplication() -> setGlobalState($key, time()); |
201 | 201 | } |
202 | 202 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // DB table not exists |
206 | 206 | if($this->_autoCreate) |
207 | 207 | { |
208 | - Prado::trace('Autocreate: ' . $this->_cacheTable, 'System.Caching.TDbCache'); |
|
208 | + Prado::trace('Autocreate: '.$this->_cacheTable, 'System.Caching.TDbCache'); |
|
209 | 209 | |
210 | 210 | $driver=$db->getDriverName(); |
211 | 211 | if($driver==='mysql') |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | $sql='CREATE TABLE '.$this->_cacheTable." (itemkey CHAR(128) PRIMARY KEY, value $blob, expire INTEGER)"; |
219 | 219 | $db->createCommand($sql)->execute(); |
220 | 220 | |
221 | - $sql='CREATE INDEX IX_expire ON ' . $this->_cacheTable . ' (expire)'; |
|
221 | + $sql='CREATE INDEX IX_expire ON '.$this->_cacheTable.' (expire)'; |
|
222 | 222 | $db->createCommand($sql)->execute(); |
223 | 223 | |
224 | - $this -> _createCheck = true; |
|
224 | + $this -> _createCheck=true; |
|
225 | 225 | $this -> getApplication() -> setGlobalState($key, time()); |
226 | 226 | } |
227 | 227 | else |
228 | - throw new TConfigurationException('db_cachetable_inexistent',$this->_cacheTable); |
|
228 | + throw new TConfigurationException('db_cachetable_inexistent', $this->_cacheTable); |
|
229 | 229 | } |
230 | - $this->_cacheInitialized = true; |
|
230 | + $this->_cacheInitialized=true; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function flushCacheExpired($force=false) |
240 | 240 | { |
241 | - $interval = $this -> getFlushInterval(); |
|
242 | - if(!$force && $interval === 0) return; |
|
241 | + $interval=$this -> getFlushInterval(); |
|
242 | + if(!$force && $interval===0) return; |
|
243 | 243 | |
244 | - $key = 'TDbCache:' . $this->_cacheTable . ':flushed'; |
|
245 | - $now = time(); |
|
246 | - $next = $interval + (integer)$this -> getApplication() -> getGlobalState($key, 0); |
|
244 | + $key='TDbCache:'.$this->_cacheTable.':flushed'; |
|
245 | + $now=time(); |
|
246 | + $next=$interval + (integer) $this -> getApplication() -> getGlobalState($key, 0); |
|
247 | 247 | |
248 | 248 | if($force || $next <= $now) |
249 | 249 | { |
250 | 250 | if(!$this->_cacheInitialized) $this->initializeCache(); |
251 | - Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ') . $this -> id . ', ' . $this->_cacheTable, 'System.Caching.TDbCache'); |
|
251 | + Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ').$this -> id.', '.$this->_cacheTable, 'System.Caching.TDbCache'); |
|
252 | 252 | $sql='DELETE FROM '.$this->_cacheTable.' WHERE expire<>0 AND expire<'.$now; |
253 | 253 | $this->getDbConnection()->createCommand($sql)->execute(); |
254 | 254 | $this -> getApplication() -> setGlobalState($key, $now); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function setFlushInterval($value) |
277 | 277 | { |
278 | - $this->_flushInterval = (integer) $value; |
|
278 | + $this->_flushInterval=(integer) $value; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | if($config instanceof TDataSourceConfig) |
293 | 293 | return $config->getDbConnection(); |
294 | 294 | else |
295 | - throw new TConfigurationException('dbcache_connectionid_invalid',$this->_connID); |
|
295 | + throw new TConfigurationException('dbcache_connectionid_invalid', $this->_connID); |
|
296 | 296 | } |
297 | 297 | else |
298 | 298 | { |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
480 | 480 | * @return boolean true if the value is successfully stored into cache, false otherwise |
481 | 481 | */ |
482 | - protected function setValue($key,$value,$expire) |
|
482 | + protected function setValue($key, $value, $expire) |
|
483 | 483 | { |
484 | 484 | $this->deleteValue($key); |
485 | - return $this->addValue($key,$value,$expire); |
|
485 | + return $this->addValue($key, $value, $expire); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -494,16 +494,16 @@ discard block |
||
494 | 494 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
495 | 495 | * @return boolean true if the value is successfully stored into cache, false otherwise |
496 | 496 | */ |
497 | - protected function addValue($key,$value,$expire) |
|
497 | + protected function addValue($key, $value, $expire) |
|
498 | 498 | { |
499 | 499 | if(!$this->_cacheInitialized) $this->initializeCache(); |
500 | - $expire=($expire<=0)?0:time()+$expire; |
|
500 | + $expire=($expire <= 0) ? 0 : time() + $expire; |
|
501 | 501 | $sql="INSERT INTO {$this->_cacheTable} (itemkey,value,expire) VALUES(:key,:value,$expire)"; |
502 | 502 | try |
503 | 503 | { |
504 | 504 | $command=$this->getDbConnection()->createCommand($sql); |
505 | - $command->bindValue(':key',$key,PDO::PARAM_STR); |
|
506 | - $command->bindValue(':value',serialize($value),PDO::PARAM_LOB); |
|
505 | + $command->bindValue(':key', $key, PDO::PARAM_STR); |
|
506 | + $command->bindValue(':value', serialize($value), PDO::PARAM_LOB); |
|
507 | 507 | $command->execute(); |
508 | 508 | return true; |
509 | 509 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | try |
535 | 535 | { |
536 | 536 | $command=$this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable} WHERE itemkey=:key"); |
537 | - $command->bindValue(':key',$key,PDO::PARAM_STR); |
|
537 | + $command->bindValue(':key', $key, PDO::PARAM_STR); |
|
538 | 538 | $command->execute(); |
539 | 539 | return true; |
540 | 540 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | if(!$this->_cacheInitialized) $this->initializeCache(); |
556 | 556 | try |
557 | 557 | { |
558 | - $command = $this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
|
558 | + $command=$this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
|
559 | 559 | $command->execute(); |
560 | 560 | } |
561 | 561 | catch(Exception $e) |
@@ -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 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
113 | 113 | { |
114 | - $userFile = include $this->_userFile; |
|
114 | + $userFile=include $this->_userFile; |
|
115 | 115 | $this->loadUserDataFromPhp($userFile); |
116 | 116 | } |
117 | 117 | else |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | { |
147 | 147 | foreach($config['users'] as $user) |
148 | 148 | { |
149 | - $name = trim(strtolower(isset($user['name'])?$user['name']:'')); |
|
150 | - $password = isset($user['password'])?$user['password']:''; |
|
151 | - $this->_users[$name] = $password; |
|
152 | - $roles = isset($user['roles'])?$user['roles']:''; |
|
149 | + $name=trim(strtolower(isset($user['name']) ? $user['name'] : '')); |
|
150 | + $password=isset($user['password']) ? $user['password'] : ''; |
|
151 | + $this->_users[$name]=$password; |
|
152 | + $roles=isset($user['roles']) ? $user['roles'] : ''; |
|
153 | 153 | if($roles!=='') |
154 | 154 | { |
155 | - foreach(explode(',',$roles) as $role) |
|
155 | + foreach(explode(',', $roles) as $role) |
|
156 | 156 | { |
157 | 157 | if(($role=trim($role))!=='') |
158 | 158 | $this->_roles[$name][]=$role; |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | { |
165 | 165 | foreach($config['roles'] as $role) |
166 | 166 | { |
167 | - $name = isset($role['name'])?$role['name']:''; |
|
168 | - $users = isset($role['users'])?$role['users']:''; |
|
169 | - foreach(explode(',',$users) as $user) |
|
167 | + $name=isset($role['name']) ? $role['name'] : ''; |
|
168 | + $users=isset($role['users']) ? $role['users'] : ''; |
|
169 | + foreach(explode(',', $users) as $user) |
|
170 | 170 | { |
171 | 171 | if(($user=trim($user))!=='') |
172 | 172 | $this->_roles[strtolower($user)][]=$name; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $this->_users[$name]=$node->getAttribute('password'); |
188 | 188 | if(($roles=trim($node->getAttribute('roles')))!=='') |
189 | 189 | { |
190 | - foreach(explode(',',$roles) as $role) |
|
190 | + foreach(explode(',', $roles) as $role) |
|
191 | 191 | { |
192 | 192 | if(($role=trim($role))!=='') |
193 | 193 | $this->_roles[$name][]=$role; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | foreach($xmlNode->getElementsByTagName('role') as $node) |
198 | 198 | { |
199 | - foreach(explode(',',$node->getAttribute('users')) as $user) |
|
199 | + foreach(explode(',', $node->getAttribute('users')) as $user) |
|
200 | 200 | { |
201 | 201 | if(($user=trim($user))!=='') |
202 | 202 | $this->_roles[strtolower($user)][]=$node->getAttribute('name'); |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | { |
247 | 247 | if($this->_initialized) |
248 | 248 | throw new TInvalidOperationException('usermanager_userfile_unchangeable'); |
249 | - else if(($this->_userFile=Prado::getPathOfNamespace($value,self::USER_FILE_EXT))===null || !is_file($this->_userFile)) |
|
250 | - throw new TConfigurationException('usermanager_userfile_invalid',$value); |
|
249 | + else if(($this->_userFile=Prado::getPathOfNamespace($value, self::USER_FILE_EXT))===null || !is_file($this->_userFile)) |
|
250 | + throw new TConfigurationException('usermanager_userfile_invalid', $value); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function setPasswordMode($value) |
281 | 281 | { |
282 | - $this->_passwordMode=TPropertyValue::ensureEnum($value,'TUserManagerPasswordMode'); |
|
282 | + $this->_passwordMode=TPropertyValue::ensureEnum($value, 'TUserManagerPasswordMode'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param string password |
289 | 289 | * @return boolean true if validation is successful, false otherwise. |
290 | 290 | */ |
291 | - public function validateUser($username,$password) |
|
291 | + public function validateUser($username, $password) |
|
292 | 292 | { |
293 | 293 | if($this->_passwordMode===TUserManagerPasswordMode::MD5) |
294 | 294 | $password=md5($password); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | $data=unserialize($data); |
342 | 342 | if(is_array($data) && count($data)===2) |
343 | 343 | { |
344 | - list($username,$token)=$data; |
|
344 | + list($username, $token)=$data; |
|
345 | 345 | if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username])) |
346 | 346 | return $this->getUser($username); |
347 | 347 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $username=strtolower($user->getName()); |
361 | 361 | if(isset($this->_users[$username])) |
362 | 362 | { |
363 | - $data=array($username,md5($username.$this->_users[$username])); |
|
363 | + $data=array($username, md5($username.$this->_users[$username])); |
|
364 | 364 | $cookie->setValue(serialize($data)); |
365 | 365 | } |
366 | 366 | } |
@@ -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; |
@@ -283,8 +283,7 @@ discard block |
||
283 | 283 | closedir($dir); |
284 | 284 | if($cacheValid) |
285 | 285 | $this->_skins=$skins; |
286 | - } |
|
287 | - else |
|
286 | + } else |
|
288 | 287 | { |
289 | 288 | $cacheValid=true; |
290 | 289 | $this->_cssFiles=$cssFiles; |
@@ -461,20 +460,16 @@ discard block |
||
461 | 460 | { |
462 | 461 | $setter='set'.$name; |
463 | 462 | $control->$setter($value); |
464 | - } |
|
465 | - else |
|
463 | + } else |
|
466 | 464 | throw new TConfigurationException('theme_property_readonly',$type,$name); |
467 | - } |
|
468 | - else |
|
465 | + } else |
|
469 | 466 | throw new TConfigurationException('theme_property_undefined',$type,$name); |
470 | - } |
|
471 | - else // complex property |
|
467 | + } else // complex property |
|
472 | 468 | $control->setSubProperty($name,$value); |
473 | 469 | } |
474 | 470 | } |
475 | 471 | return true; |
476 | - } |
|
477 | - else |
|
472 | + } else |
|
478 | 473 | return false; |
479 | 474 | } |
480 | 475 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * default theme class |
48 | 48 | */ |
49 | - const DEFAULT_THEMECLASS = 'TTheme'; |
|
49 | + const DEFAULT_THEMECLASS='TTheme'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function getTheme($name) |
89 | 89 | { |
90 | 90 | $themePath=$this->getBasePath().DIRECTORY_SEPARATOR.$name; |
91 | - $themeUrl=rtrim($this->getBaseUrl(),'/').'/'.$name; |
|
91 | + $themeUrl=rtrim($this->getBaseUrl(), '/').'/'.$name; |
|
92 | 92 | return Prado::createComponent($this->getThemeClass(), $themePath, $themeUrl); |
93 | 93 | } |
94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param string|null $class Theme class name in namespace format |
97 | 97 | */ |
98 | 98 | public function setThemeClass($class) { |
99 | - $this->_themeClass = $class===null ? self::DEFAULT_THEMECLASS : (string)$class; |
|
99 | + $this->_themeClass=$class===null ? self::DEFAULT_THEMECLASS : (string) $class; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | $this->_basePath=dirname($this->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
135 | 135 | if(($basePath=realpath($this->_basePath))===false || !is_dir($basePath)) |
136 | - throw new TConfigurationException('thememanager_basepath_invalid2',$this->_basePath); |
|
136 | + throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
|
137 | 137 | $this->_basePath=$basePath; |
138 | 138 | } |
139 | 139 | return $this->_basePath; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | $this->_basePath=Prado::getPathOfNamespace($value); |
153 | 153 | if($this->_basePath===null || !is_dir($this->_basePath)) |
154 | - throw new TInvalidDataValueException('thememanager_basepath_invalid',$value); |
|
154 | + throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | { |
166 | 166 | $appPath=dirname($this->getRequest()->getApplicationFilePath()); |
167 | 167 | $basePath=$this->getBasePath(); |
168 | - if(strpos($basePath,$appPath)===false) |
|
168 | + if(strpos($basePath, $appPath)===false) |
|
169 | 169 | throw new TConfigurationException('thememanager_baseurl_required'); |
170 | - $appUrl=rtrim(dirname($this->getRequest()->getApplicationUrl()),'/\\'); |
|
171 | - $this->_baseUrl=$appUrl.strtr(substr($basePath,strlen($appPath)),'\\','/'); |
|
170 | + $appUrl=rtrim(dirname($this->getRequest()->getApplicationUrl()), '/\\'); |
|
171 | + $this->_baseUrl=$appUrl.strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
|
172 | 172 | } |
173 | 173 | return $this->_baseUrl; |
174 | 174 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function setBaseUrl($value) |
180 | 180 | { |
181 | - $this->_baseUrl=rtrim($value,'/'); |
|
181 | + $this->_baseUrl=rtrim($value, '/'); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param string theme URL |
249 | 249 | * @throws TConfigurationException if theme path does not exist or any parsing error of the skin files |
250 | 250 | */ |
251 | - public function __construct($themePath,$themeUrl) |
|
251 | + public function __construct($themePath, $themeUrl) |
|
252 | 252 | { |
253 | 253 | $this->_themeUrl=$themeUrl; |
254 | 254 | $this->_themePath=realpath($themePath); |
@@ -260,21 +260,21 @@ discard block |
||
260 | 260 | $array=$cache->get(self::THEME_CACHE_PREFIX.$themePath); |
261 | 261 | if(is_array($array)) |
262 | 262 | { |
263 | - list($skins,$cssFiles,$jsFiles,$timestamp)=$array; |
|
263 | + list($skins, $cssFiles, $jsFiles, $timestamp)=$array; |
|
264 | 264 | if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
265 | 265 | { |
266 | 266 | if(($dir=opendir($themePath))===false) |
267 | - throw new TIOException('theme_path_inexistent',$themePath); |
|
267 | + throw new TIOException('theme_path_inexistent', $themePath); |
|
268 | 268 | $cacheValid=true; |
269 | 269 | while(($file=readdir($dir))!==false) |
270 | 270 | { |
271 | 271 | if($file==='.' || $file==='..') |
272 | 272 | continue; |
273 | - else if(basename($file,'.css')!==$file) |
|
273 | + else if(basename($file, '.css')!==$file) |
|
274 | 274 | $this->_cssFiles[]=$themeUrl.'/'.$file; |
275 | - else if(basename($file,'.js')!==$file) |
|
275 | + else if(basename($file, '.js')!==$file) |
|
276 | 276 | $this->_jsFiles[]=$themeUrl.'/'.$file; |
277 | - else if(basename($file,self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file)>$timestamp) |
|
277 | + else if(basename($file, self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file) > $timestamp) |
|
278 | 278 | { |
279 | 279 | $cacheValid=false; |
280 | 280 | break; |
@@ -299,29 +299,29 @@ discard block |
||
299 | 299 | $this->_jsFiles=array(); |
300 | 300 | $this->_skins=array(); |
301 | 301 | if(($dir=opendir($themePath))===false) |
302 | - throw new TIOException('theme_path_inexistent',$themePath); |
|
302 | + throw new TIOException('theme_path_inexistent', $themePath); |
|
303 | 303 | while(($file=readdir($dir))!==false) |
304 | 304 | { |
305 | 305 | if($file==='.' || $file==='..') |
306 | 306 | continue; |
307 | - else if(basename($file,'.css')!==$file) |
|
307 | + else if(basename($file, '.css')!==$file) |
|
308 | 308 | $this->_cssFiles[]=$themeUrl.'/'.$file; |
309 | - else if(basename($file,'.js')!==$file) |
|
309 | + else if(basename($file, '.js')!==$file) |
|
310 | 310 | $this->_jsFiles[]=$themeUrl.'/'.$file; |
311 | - else if(basename($file,self::SKIN_FILE_EXT)!==$file) |
|
311 | + else if(basename($file, self::SKIN_FILE_EXT)!==$file) |
|
312 | 312 | { |
313 | - $template=new TTemplate(file_get_contents($themePath.'/'.$file),$themePath,$themePath.'/'.$file); |
|
313 | + $template=new TTemplate(file_get_contents($themePath.'/'.$file), $themePath, $themePath.'/'.$file); |
|
314 | 314 | foreach($template->getItems() as $skin) |
315 | 315 | { |
316 | 316 | if(!isset($skin[2])) // a text string, ignored |
317 | 317 | continue; |
318 | 318 | else if($skin[0]!==-1) |
319 | - throw new TConfigurationException('theme_control_nested',$skin[1],dirname($themePath)); |
|
319 | + throw new TConfigurationException('theme_control_nested', $skin[1], dirname($themePath)); |
|
320 | 320 | $type=$skin[1]; |
321 | - $id=isset($skin[2]['skinid'])?$skin[2]['skinid']:0; |
|
321 | + $id=isset($skin[2]['skinid']) ? $skin[2]['skinid'] : 0; |
|
322 | 322 | unset($skin[2]['skinid']); |
323 | 323 | if(isset($this->_skins[$type][$id])) |
324 | - throw new TConfigurationException('theme_skinid_duplicated',$type,$id,dirname($themePath)); |
|
324 | + throw new TConfigurationException('theme_skinid_duplicated', $type, $id, dirname($themePath)); |
|
325 | 325 | /* |
326 | 326 | foreach($skin[2] as $name=>$value) |
327 | 327 | { |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | sort($this->_cssFiles); |
338 | 338 | sort($this->_jsFiles); |
339 | 339 | if($cache!==null) |
340 | - $cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,$this->_jsFiles,time())); |
|
340 | + $cache->set(self::THEME_CACHE_PREFIX.$themePath, array($this->_skins, $this->_cssFiles, $this->_jsFiles, time())); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | protected function setName($value) |
356 | 356 | { |
357 | - $this->_name = $value; |
|
357 | + $this->_name=$value; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | protected function setBaseUrl($value) |
372 | 372 | { |
373 | - $this->_themeUrl=rtrim($value,'/'); |
|
373 | + $this->_themeUrl=rtrim($value, '/'); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | protected function setSkins($value) |
404 | 404 | { |
405 | - $this->_skins = $value; |
|
405 | + $this->_skins=$value; |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | { |
424 | 424 | foreach($this->_skins[$type][$id] as $name=>$value) |
425 | 425 | { |
426 | - Prado::trace("Applying skin $name to $type",'System.Web.UI.TThemeManager'); |
|
426 | + Prado::trace("Applying skin $name to $type", 'System.Web.UI.TThemeManager'); |
|
427 | 427 | if(is_array($value)) |
428 | 428 | { |
429 | 429 | switch($value[0]) |
@@ -432,28 +432,28 @@ discard block |
||
432 | 432 | $value=$this->evaluateExpression($value[1]); |
433 | 433 | break; |
434 | 434 | case TTemplate::CONFIG_ASSET: |
435 | - $value=$this->_themeUrl.'/'.ltrim($value[1],'/'); |
|
435 | + $value=$this->_themeUrl.'/'.ltrim($value[1], '/'); |
|
436 | 436 | break; |
437 | 437 | case TTemplate::CONFIG_DATABIND: |
438 | - $control->bindProperty($name,$value[1]); |
|
438 | + $control->bindProperty($name, $value[1]); |
|
439 | 439 | break; |
440 | 440 | case TTemplate::CONFIG_PARAMETER: |
441 | - $control->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1])); |
|
441 | + $control->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1])); |
|
442 | 442 | break; |
443 | 443 | case TTemplate::CONFIG_TEMPLATE: |
444 | - $control->setSubProperty($name,$value[1]); |
|
444 | + $control->setSubProperty($name, $value[1]); |
|
445 | 445 | break; |
446 | 446 | case TTemplate::CONFIG_LOCALIZATION: |
447 | - $control->setSubProperty($name,Prado::localize($value[1])); |
|
447 | + $control->setSubProperty($name, Prado::localize($value[1])); |
|
448 | 448 | break; |
449 | 449 | default: |
450 | - throw new TConfigurationException('theme_tag_unexpected',$name,$value[0]); |
|
450 | + throw new TConfigurationException('theme_tag_unexpected', $name, $value[0]); |
|
451 | 451 | break; |
452 | 452 | } |
453 | 453 | } |
454 | 454 | if(!is_array($value)) |
455 | 455 | { |
456 | - if(strpos($name,'.')===false) // is simple property or custom attribute |
|
456 | + if(strpos($name, '.')===false) // is simple property or custom attribute |
|
457 | 457 | { |
458 | 458 | if($control->hasProperty($name)) |
459 | 459 | { |
@@ -463,13 +463,13 @@ discard block |
||
463 | 463 | $control->$setter($value); |
464 | 464 | } |
465 | 465 | else |
466 | - throw new TConfigurationException('theme_property_readonly',$type,$name); |
|
466 | + throw new TConfigurationException('theme_property_readonly', $type, $name); |
|
467 | 467 | } |
468 | 468 | else |
469 | - throw new TConfigurationException('theme_property_undefined',$type,$name); |
|
469 | + throw new TConfigurationException('theme_property_undefined', $type, $name); |
|
470 | 470 | } |
471 | 471 | else // complex property |
472 | - $control->setSubProperty($name,$value); |
|
472 | + $control->setSubProperty($name, $value); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | return true; |
@@ -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 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function __construct() |
79 | 79 | { |
80 | 80 | parent::__construct(); |
81 | - $this->_globalID = self::$_buttonCount++; |
|
81 | + $this->_globalID=self::$_buttonCount++; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * @param array the input data collection |
111 | 111 | * @return boolean whether the data of the control has been changed |
112 | 112 | */ |
113 | - public function loadPostData($key,$values) |
|
113 | + public function loadPostData($key, $values) |
|
114 | 114 | { |
115 | 115 | $uniqueGroupName=$this->getUniqueGroupName(); |
116 | - $value=isset($values[$uniqueGroupName])?$values[$uniqueGroupName]:null; |
|
116 | + $value=isset($values[$uniqueGroupName]) ? $values[$uniqueGroupName] : null; |
|
117 | 117 | if($value!==null && $value===$this->getValueAttribute()) |
118 | 118 | { |
119 | 119 | if(!$this->getChecked()) |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function getGroupName() |
136 | 136 | { |
137 | - return $this->getViewState('GroupName',''); |
|
137 | + return $this->getViewState('GroupName', ''); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function setGroupName($value) |
147 | 147 | { |
148 | - $this->setViewState('GroupName',$value,''); |
|
148 | + $this->setViewState('GroupName', $value, ''); |
|
149 | 149 | $this->_uniqueGroupName=null; |
150 | 150 | } |
151 | 151 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function getUniqueGroupName() |
156 | 156 | { |
157 | - if(($groupName=$this->getViewState('UniqueGroupName',''))!=='') |
|
157 | + if(($groupName=$this->getViewState('UniqueGroupName', ''))!=='') |
|
158 | 158 | return $groupName; |
159 | 159 | else if(($uniqueID=$this->getUniqueID())!==$this->_previousUniqueID || $this->_uniqueGroupName===null) |
160 | 160 | { |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | $this->_previousUniqueID=$uniqueID; |
163 | 163 | if($uniqueID!=='') |
164 | 164 | { |
165 | - if(($pos=strrpos($uniqueID,TControl::ID_SEPARATOR))!==false) |
|
165 | + if(($pos=strrpos($uniqueID, TControl::ID_SEPARATOR))!==false) |
|
166 | 166 | { |
167 | 167 | if($groupName!=='') |
168 | - $groupName=substr($uniqueID,0,$pos+1).$groupName; |
|
168 | + $groupName=substr($uniqueID, 0, $pos + 1).$groupName; |
|
169 | 169 | else if(is_a($this->getNamingContainer(), 'TRadioButtonList')) |
170 | - $groupName=substr($uniqueID,0,$pos); |
|
170 | + $groupName=substr($uniqueID, 0, $pos); |
|
171 | 171 | } |
172 | 172 | if($groupName==='') |
173 | 173 | $groupName=$uniqueID; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function setUniqueGroupName($value) |
197 | 197 | { |
198 | - $this->setViewState('UniqueGroupName',$value,''); |
|
198 | + $this->setViewState('UniqueGroupName', $value, ''); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function getRadioButtonsInGroup() |
208 | 208 | { |
209 | - $group = $this->getUniqueGroupName(); |
|
210 | - $buttons = array(); |
|
209 | + $group=$this->getUniqueGroupName(); |
|
210 | + $buttons=array(); |
|
211 | 211 | foreach(self::$_activeButtons as $control) |
212 | 212 | { |
213 | - if($control->getUniqueGroupName() === $group) |
|
214 | - $buttons[] = $control; |
|
213 | + if($control->getUniqueGroupName()===$group) |
|
214 | + $buttons[]=$control; |
|
215 | 215 | } |
216 | 216 | return $buttons; |
217 | 217 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function getEnableClientScript() |
234 | 234 | { |
235 | - return $this->getViewState('EnableClientScript',true); |
|
235 | + return $this->getViewState('EnableClientScript', true); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function setEnableClientScript($value) |
242 | 242 | { |
243 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
243 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -249,19 +249,19 @@ discard block |
||
249 | 249 | * @param string checkbox id |
250 | 250 | * @param string onclick js |
251 | 251 | */ |
252 | - protected function renderInputTag($writer,$clientID,$onclick) |
|
252 | + protected function renderInputTag($writer, $clientID, $onclick) |
|
253 | 253 | { |
254 | 254 | if($clientID!=='') |
255 | - $writer->addAttribute('id',$clientID); |
|
256 | - $writer->addAttribute('type','radio'); |
|
257 | - $writer->addAttribute('name',$this->getUniqueGroupName()); |
|
258 | - $writer->addAttribute('value',$this->getValueAttribute()); |
|
255 | + $writer->addAttribute('id', $clientID); |
|
256 | + $writer->addAttribute('type', 'radio'); |
|
257 | + $writer->addAttribute('name', $this->getUniqueGroupName()); |
|
258 | + $writer->addAttribute('value', $this->getValueAttribute()); |
|
259 | 259 | if(!empty($onclick)) |
260 | - $writer->addAttribute('onclick',$onclick); |
|
260 | + $writer->addAttribute('onclick', $onclick); |
|
261 | 261 | if($this->getChecked()) |
262 | - $writer->addAttribute('checked','checked'); |
|
262 | + $writer->addAttribute('checked', 'checked'); |
|
263 | 263 | if(!$this->getEnabled(true)) |
264 | - $writer->addAttribute('disabled','disabled'); |
|
264 | + $writer->addAttribute('disabled', 'disabled'); |
|
265 | 265 | |
266 | 266 | $page=$this->getPage(); |
267 | 267 | if($this->getEnabled(true) |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | if(($accesskey=$this->getAccessKey())!=='') |
276 | - $writer->addAttribute('accesskey',$accesskey); |
|
277 | - if(($tabindex=$this->getTabIndex())>0) |
|
278 | - $writer->addAttribute('tabindex',"$tabindex"); |
|
279 | - if($attributes=$this->getViewState('InputAttributes',null)) |
|
276 | + $writer->addAttribute('accesskey', $accesskey); |
|
277 | + if(($tabindex=$this->getTabIndex()) > 0) |
|
278 | + $writer->addAttribute('tabindex', "$tabindex"); |
|
279 | + if($attributes=$this->getViewState('InputAttributes', null)) |
|
280 | 280 | $writer->addAttributes($attributes); |
281 | 281 | $writer->renderBeginTag('input'); |
282 | 282 | $writer->renderEndTag(); |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function renderClientControlScript($writer) |
289 | 289 | { |
290 | - $cs = $this->getPage()->getClientScript(); |
|
291 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
290 | + $cs=$this->getPage()->getClientScript(); |
|
291 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |