@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected function addAttributesToRender($writer) |
45 | 45 | { |
46 | - $writer->addAttribute('id',$this->getClientID()); |
|
47 | - $writer->addAttribute('method',$this->getMethod()); |
|
46 | + $writer->addAttribute('id', $this->getClientID()); |
|
47 | + $writer->addAttribute('method', $this->getMethod()); |
|
48 | 48 | $uri=$this->getRequest()->getRequestURI(); |
49 | - $writer->addAttribute('action',str_replace('&','&',str_replace('&','&',$uri))); |
|
49 | + $writer->addAttribute('action', str_replace('&', '&', str_replace('&', '&', $uri))); |
|
50 | 50 | if(($enctype=$this->getEnctype())!=='') |
51 | - $writer->addAttribute('enctype',$enctype); |
|
51 | + $writer->addAttribute('enctype', $enctype); |
|
52 | 52 | |
53 | 53 | $attributes=$this->getAttributes(); |
54 | 54 | $attributes->remove('action'); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if(($button=$this->findControl($butt))!==null) |
60 | 60 | $this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
61 | 61 | else |
62 | - throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt); |
|
62 | + throw new TInvalidDataValueException('form_defaultbutton_invalid', $butt); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getDefaultButton() |
110 | 110 | { |
111 | - return $this->getViewState('DefaultButton',''); |
|
111 | + return $this->getViewState('DefaultButton', ''); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function setDefaultButton($value) |
121 | 121 | { |
122 | - $this->setViewState('DefaultButton',$value,''); |
|
122 | + $this->setViewState('DefaultButton', $value, ''); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getMethod() |
129 | 129 | { |
130 | - return $this->getViewState('Method','post'); |
|
130 | + return $this->getViewState('Method', 'post'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function setMethod($value) |
137 | 137 | { |
138 | - $this->setViewState('Method',TPropertyValue::ensureEnum($value,'post','get'),'post'); |
|
138 | + $this->setViewState('Method', TPropertyValue::ensureEnum($value, 'post', 'get'), 'post'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function getEnctype() |
145 | 145 | { |
146 | - return $this->getViewState('Enctype',''); |
|
146 | + return $this->getViewState('Enctype', ''); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function setEnctype($value) |
157 | 157 | { |
158 | - $this->setViewState('Enctype',$value,''); |
|
158 | + $this->setViewState('Enctype', $value, ''); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | public function setWriter($writer) |
90 | 90 | { |
91 | - $this->_writer = $writer; |
|
91 | + $this->_writer=$writer; |
|
92 | 92 | } |
93 | 93 | /** |
94 | 94 | * Adds a list of attributes to be rendered. |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string name of the attribute |
106 | 106 | * @param string value of the attribute |
107 | 107 | */ |
108 | - public function addAttribute($name,$value) |
|
108 | + public function addAttribute($name, $value) |
|
109 | 109 | { |
110 | 110 | $this->_attributes[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
111 | 111 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param string stylesheet attribute name |
135 | 135 | * @param string stylesheet attribute value |
136 | 136 | */ |
137 | - public function addStyleAttribute($name,$value) |
|
137 | + public function addStyleAttribute($name, $value) |
|
138 | 138 | { |
139 | 139 | $this->_styles[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
140 | 140 | } |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | if(isset(self::$_simpleTags[$tagName])) |
204 | 204 | { |
205 | 205 | $str.=' />'; |
206 | - $this->_openTags[] = ''; |
|
206 | + $this->_openTags[]=''; |
|
207 | 207 | } |
208 | 208 | else |
209 | 209 | { |
210 | 210 | $str.='>'; |
211 | - $this->_openTags[] = $tagName; |
|
211 | + $this->_openTags[]=$tagName; |
|
212 | 212 | } |
213 | 213 | $this->_writer->write($str); |
214 | 214 | $this->_attributes=array(); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function createChildControls() |
45 | 45 | { |
46 | - if(null === ($_template = $this->getTemplate())) { |
|
46 | + if(null===($_template=$this->getTemplate())) { |
|
47 | 47 | return $this->doCreateChildControlsFor(get_class($this)); |
48 | 48 | } |
49 | 49 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function doCreateChildControlsFor($parentClass) |
68 | 68 | { |
69 | - if(false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) { |
|
69 | + if(false!==($_parentClass=get_parent_class($parentClass)) && 'TTemplateControl'!=$_parentClass) { |
|
70 | 70 | $this->doCreateChildControlsFor($_parentClass); |
71 | 71 | } |
72 | 72 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function doTemplateForClass($parentClass) |
84 | 84 | { |
85 | - if(null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
85 | + if(null!==($_template=$this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
86 | 86 | foreach($_template->getDirective() as $_name => $_value) { |
87 | 87 | if(!is_string($_value)) { |
88 | 88 | throw new TConfigurationException('templatecontrol_directive_invalid', get_class(this), $_name); |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getIsSourceTemplateControl() |
107 | 107 | { |
108 | - if(null !== ($_template = $this->getTemplate())) { |
|
108 | + if(null!==($_template=$this->getTemplate())) { |
|
109 | 109 | return $_template->getIsSourceTemplate(); |
110 | 110 | } |
111 | 111 | |
112 | - return ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName(get_parent_class($this))) |
|
112 | + return ($_template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_parent_class($this))) |
|
113 | 113 | ? $_template->getIsSourceTemplate() |
114 | 114 | : false; |
115 | 115 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function save($state) |
52 | 52 | { |
53 | - $this->_page->setClientState(TPageStateFormatter::serialize($this->_page,$state)); |
|
53 | + $this->_page->setClientState(TPageStateFormatter::serialize($this->_page, $state)); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function load() |
62 | 62 | { |
63 | - if(($data=TPageStateFormatter::unserialize($this->_page,$this->_page->getRequestClientState()))!==null) |
|
63 | + if(($data=TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState()))!==null) |
|
64 | 64 | return $data; |
65 | 65 | else |
66 | - throw new THttpException(400,'pagestatepersister_pagestate_corrupted'); |
|
66 | + throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class THttpUtility |
20 | 20 | { |
21 | - private static $_encodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
22 | - private static $_decodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
23 | - private static $_stripTable=array('<'=>'','>'=>'','"'=>''); |
|
21 | + private static $_encodeTable=array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
22 | + private static $_decodeTable=array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
23 | + private static $_stripTable=array('<'=>'', '>'=>'', '"'=>''); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * HTML-encodes a string. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function htmlEncode($s) |
34 | 34 | { |
35 | - return strtr($s,self::$_encodeTable); |
|
35 | + return strtr($s, self::$_encodeTable); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function htmlDecode($s) |
45 | 45 | { |
46 | - return strtr($s,self::$_decodeTable); |
|
46 | + return strtr($s, self::$_decodeTable); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public static function htmlStrip($s) |
56 | 56 | { |
57 | - return strtr($s,self::$_stripTable); |
|
57 | + return strtr($s, self::$_stripTable); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class TDateTimeStamp |
27 | 27 | { |
28 | - protected static $_month_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); |
|
29 | - protected static $_month_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); |
|
28 | + protected static $_month_normal=array("", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
29 | + protected static $_month_leaf=array("", 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Returns the day of the week (0=Sunday, 1=Monday, .. 6=Saturday) |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getDayofWeek($year, $month, $day) |
38 | 38 | { |
39 | - $dt = new DateTime(); |
|
39 | + $dt=new DateTime(); |
|
40 | 40 | $dt->setDate($year, $month, $day); |
41 | 41 | return (int) $dt->format('w'); |
42 | 42 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function isLeapYear($year) |
51 | 51 | { |
52 | - $year = $this->digitCheck($year); |
|
53 | - $dt = new DateTime(); |
|
52 | + $year=$this->digitCheck($year); |
|
53 | + $dt=new DateTime(); |
|
54 | 54 | $dt->setDate($year, 1, 1); |
55 | 55 | return (bool) $dt->format('L'); |
56 | 56 | } |
@@ -62,22 +62,22 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected function digitCheck($y) |
64 | 64 | { |
65 | - if ($y < 100){ |
|
66 | - $yr = (integer) date("Y"); |
|
67 | - $century = (integer) ($yr /100); |
|
65 | + if($y < 100) { |
|
66 | + $yr=(integer) date("Y"); |
|
67 | + $century=(integer) ($yr / 100); |
|
68 | 68 | |
69 | - if ($yr%100 > 50) { |
|
70 | - $c1 = $century + 1; |
|
71 | - $c0 = $century; |
|
69 | + if($yr % 100 > 50) { |
|
70 | + $c1=$century + 1; |
|
71 | + $c0=$century; |
|
72 | 72 | } else { |
73 | - $c1 = $century; |
|
74 | - $c0 = $century - 1; |
|
73 | + $c1=$century; |
|
74 | + $c0=$century - 1; |
|
75 | 75 | } |
76 | - $c1 *= 100; |
|
76 | + $c1*=100; |
|
77 | 77 | // if 2-digit year is less than 30 years in future, set it to this century |
78 | 78 | // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. |
79 | - if (($y + $c1) < $yr+30) $y = $y + $c1; |
|
80 | - else $y = $y + $c0*100; |
|
79 | + if(($y + $c1) < $yr + 30) $y=$y + $c1; |
|
80 | + else $y=$y + $c0 * 100; |
|
81 | 81 | } |
82 | 82 | return $y; |
83 | 83 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getGMTDiff($ts=false) |
94 | 94 | { |
95 | - $dt = new DateTime(); |
|
95 | + $dt=new DateTime(); |
|
96 | 96 | if($ts) |
97 | 97 | $dt->setTimeStamp($ts); |
98 | 98 | else |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | function parseDate($txt=false) |
108 | 108 | { |
109 | - if ($txt === false) return getdate(); |
|
109 | + if($txt===false) return getdate(); |
|
110 | 110 | |
111 | - $dt = new DateTime($txt); |
|
111 | + $dt=new DateTime($txt); |
|
112 | 112 | |
113 | 113 | return array( |
114 | 114 | 'seconds' => (int) $dt->format('s'), |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * @return array an array with date info. |
130 | 130 | */ |
131 | - function getDate($d=false,$fast=false) |
|
131 | + function getDate($d=false, $fast=false) |
|
132 | 132 | { |
133 | - if ($d === false) return getdate(); |
|
133 | + if($d===false) return getdate(); |
|
134 | 134 | |
135 | - $dt = new DateTime(); |
|
135 | + $dt=new DateTime(); |
|
136 | 136 | $dt->setTimestamp($d); |
137 | 137 | |
138 | 138 | return array( |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * @return boolean true if valid date, semantic check only. |
155 | 155 | */ |
156 | - public function isValidDate($y,$m,$d) |
|
156 | + public function isValidDate($y, $m, $d) |
|
157 | 157 | { |
158 | - if ($this->isLeapYear($y)) |
|
159 | - $marr =& self::$_month_leaf; |
|
158 | + if($this->isLeapYear($y)) |
|
159 | + $marr=& self::$_month_leaf; |
|
160 | 160 | else |
161 | - $marr =& self::$_month_normal; |
|
161 | + $marr=& self::$_month_normal; |
|
162 | 162 | |
163 | - if ($m > 12 || $m < 1) return false; |
|
163 | + if($m > 12 || $m < 1) return false; |
|
164 | 164 | |
165 | - if ($d > 31 || $d < 1) return false; |
|
165 | + if($d > 31 || $d < 1) return false; |
|
166 | 166 | |
167 | - if ($marr[$m] < $d) return false; |
|
167 | + if($marr[$m] < $d) return false; |
|
168 | 168 | |
169 | - if ($y < 1000 && $y > 3000) return false; |
|
169 | + if($y < 1000 && $y > 3000) return false; |
|
170 | 170 | |
171 | 171 | return true; |
172 | 172 | } |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @return string formatted date based on timestamp $d |
176 | 176 | */ |
177 | - function formatDate($fmt,$ts=false,$is_gmt=false) |
|
177 | + function formatDate($fmt, $ts=false, $is_gmt=false) |
|
178 | 178 | { |
179 | - $dt = new DateTime(); |
|
179 | + $dt=new DateTime(); |
|
180 | 180 | if($is_gmt) |
181 | 181 | $dt->setTimeZone(new DateTimeZone('UTC')); |
182 | 182 | $dt->setTimestamp($ts); |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | /** |
188 | 188 | * @return integer|float a timestamp given a local time |
189 | 189 | */ |
190 | - function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false) |
|
190 | + function getTimeStamp($hr, $min, $sec, $mon=false, $day=false, $year=false, $is_gmt=false) |
|
191 | 191 | { |
192 | - $dt = new DateTime(); |
|
192 | + $dt=new DateTime(); |
|
193 | 193 | if($is_gmt) |
194 | 194 | $dt->setTimeZone(new DateTimeZone('UTC')); |
195 | 195 | $dt->setDate($year!==false ? $year : date('Y'), |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * the object and method name as string |
45 | 45 | * @param array The array of arguments to the function call chain |
46 | 46 | */ |
47 | - public function addCall($method,$args) |
|
47 | + public function addCall($method, $args) |
|
48 | 48 | { |
49 | - $this->add(array($method,$args)); |
|
49 | + $this->add(array($method, $args)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $args=func_get_args(); |
94 | 94 | if($this->getCount()===0) |
95 | - return isset($args[0])?$args[0]:null; |
|
95 | + return isset($args[0]) ? $args[0] : null; |
|
96 | 96 | |
97 | 97 | if(!$this->_iterator) |
98 | 98 | { |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | do { |
104 | 104 | $handler=$this->_iterator->current(); |
105 | 105 | $this->_iterator->next(); |
106 | - if(is_array($handler[0])&&$handler[0][0] instanceof IClassBehavior) |
|
107 | - array_splice($handler[1],1,count($args),$args); |
|
106 | + if(is_array($handler[0]) && $handler[0][0] instanceof IClassBehavior) |
|
107 | + array_splice($handler[1], 1, count($args), $args); |
|
108 | 108 | else |
109 | - array_splice($handler[1],0,count($args),$args); |
|
109 | + array_splice($handler[1], 0, count($args), $args); |
|
110 | 110 | $handler[1][]=$this; |
111 | - $result=call_user_func_array($handler[0],$handler[1]); |
|
111 | + $result=call_user_func_array($handler[0], $handler[1]); |
|
112 | 112 | } while($this->_iterator->valid()); |
113 | 113 | else |
114 | - $result = $args[0]; |
|
114 | + $result=$args[0]; |
|
115 | 115 | return $result; |
116 | 116 | } |
117 | 117 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @param string method name of the unspecified object method |
138 | 138 | * @param array arguments to the unspecified object method |
139 | 139 | */ |
140 | - public function __dycall($method,$args) |
|
140 | + public function __dycall($method, $args) |
|
141 | 141 | { |
142 | 142 | if($this->_method==$method) |
143 | - return call_user_func_array(array($this,'call'),$args); |
|
143 | + return call_user_func_array(array($this, 'call'), $args); |
|
144 | 144 | return null; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return mixed value at the specified field |
49 | 49 | * @throws TInvalidDataValueException if field or data is invalid |
50 | 50 | */ |
51 | - public static function getDataFieldValue($data,$field) |
|
51 | + public static function getDataFieldValue($data, $field) |
|
52 | 52 | { |
53 | 53 | try |
54 | 54 | { |
@@ -57,33 +57,33 @@ discard block |
||
57 | 57 | if(isset($data[$field])) |
58 | 58 | return $data[$field]; |
59 | 59 | |
60 | - $tmp = $data; |
|
61 | - foreach (explode(".", $field) as $f) |
|
62 | - $tmp = $tmp[$f]; |
|
60 | + $tmp=$data; |
|
61 | + foreach(explode(".", $field) as $f) |
|
62 | + $tmp=$tmp[$f]; |
|
63 | 63 | return $tmp; |
64 | 64 | } |
65 | 65 | else if(is_object($data)) |
66 | 66 | { |
67 | - if(strpos($field,'.')===false) // simple field |
|
67 | + if(strpos($field, '.')===false) // simple field |
|
68 | 68 | { |
69 | 69 | if(method_exists($data, 'get'.$field)) |
70 | - return call_user_func(array($data,'get'.$field)); |
|
70 | + return call_user_func(array($data, 'get'.$field)); |
|
71 | 71 | else |
72 | 72 | return $data->{$field}; |
73 | 73 | } |
74 | 74 | else // field in the format of xxx.yyy.zzz |
75 | 75 | { |
76 | 76 | $object=$data; |
77 | - foreach(explode('.',$field) as $f) |
|
78 | - $object = TDataFieldAccessor::getDataFieldValue($object, $f); |
|
77 | + foreach(explode('.', $field) as $f) |
|
78 | + $object=TDataFieldAccessor::getDataFieldValue($object, $f); |
|
79 | 79 | return $object; |
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
83 | 83 | catch(Exception $e) |
84 | 84 | { |
85 | - throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid',$field,$e->getMessage()); |
|
85 | + throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid', $field, $e->getMessage()); |
|
86 | 86 | } |
87 | - throw new TInvalidDataValueException('datafieldaccessor_data_invalid',$field); |
|
87 | + throw new TInvalidDataValueException('datafieldaccessor_data_invalid', $field); |
|
88 | 88 | } |
89 | 89 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | $this->_owner=$owner; |
45 | 45 | foreach($this->events() as $event=>$handler) |
46 | - $owner->attachEventHandler($event,array($this,$handler)); |
|
46 | + $owner->attachEventHandler($event, array($this, $handler)); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function detach($owner) |
57 | 57 | { |
58 | 58 | foreach($this->events() as $event=>$handler) |
59 | - $owner->detachEventHandler($event,array($this,$handler)); |
|
59 | + $owner->detachEventHandler($event, array($this, $handler)); |
|
60 | 60 | $this->_owner=null; |
61 | 61 | } |
62 | 62 |