@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Clears all existing selections on the client side. |
|
125 | - */ |
|
126 | - public function clearSelection() |
|
127 | - { |
|
123 | + /** |
|
124 | + * Clears all existing selections on the client side. |
|
125 | + */ |
|
126 | + public function clearSelection() |
|
127 | + { |
|
128 | 128 | if($this->canUpdateClientSide()) |
129 | 129 | { |
130 | 130 | $this->updateListItems(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $this->getPage()->getCallbackClient()->select($this->getControl(), 'Clear'); |
138 | 138 | } |
139 | 139 | } |
140 | - } |
|
140 | + } |
|
141 | 141 | |
142 | 142 | /** |
143 | 143 | * Update the client-side list options. |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | if($this->canUpdateClientSide()) |
71 | 71 | { |
72 | 72 | $this->updateListItems(); |
73 | - $n = $this->getControl()->getItemCount(); |
|
73 | + $n=$this->getControl()->getItemCount(); |
|
74 | 74 | |
75 | 75 | $promptValue=$this->getControl()->getPromptValue(); |
76 | 76 | if($promptValue==='') |
77 | 77 | $promptValue=$this->getControl()->getPromptText(); |
78 | 78 | |
79 | - $list = array(); |
|
79 | + $list=array(); |
|
80 | 80 | foreach($indices as $index) |
81 | 81 | { |
82 | - $index = intval($index); |
|
82 | + $index=intval($index); |
|
83 | 83 | if($promptValue!=='') |
84 | 84 | $index++; |
85 | 85 | if($index >= 0 && $index <= $n) |
86 | - $list[] = $index; |
|
86 | + $list[]=$index; |
|
87 | 87 | } |
88 | 88 | if(count($list) > 0) |
89 | 89 | $this->getPage()->getCallbackClient()->select( |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | if($this->canUpdateClientSide()) |
115 | 115 | { |
116 | 116 | $this->updateListItems(); |
117 | - $list = array(); |
|
117 | + $list=array(); |
|
118 | 118 | foreach($values as $value) |
119 | - $list[] = $value; |
|
119 | + $list[]=$value; |
|
120 | 120 | if(count($list) > 0) |
121 | 121 | $this->getPage()->getCallbackClient()->select( |
122 | 122 | $this->getControl(), 'Values', $list); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | if($this->canUpdateClientSide()) |
151 | 151 | { |
152 | - $items = $this->getControl()->getItems(); |
|
152 | + $items=$this->getControl()->getItems(); |
|
153 | 153 | if($items instanceof TActiveListItemCollection |
154 | 154 | && $items->getListHasChanged()) |
155 | 155 | { |
@@ -173,15 +173,15 @@ |
||
173 | 173 | { |
174 | 174 | if(($forControl=$this->getForControl())==='') |
175 | 175 | throw new TConfigurationException('keyboard_forcontrol_required'); |
176 | - if(($target=$this->findControl($forControl))===null) |
|
177 | - throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl); |
|
176 | + if(($target=$this->findControl($forControl))===null) |
|
177 | + throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl); |
|
178 | 178 | |
179 | - $options['ID'] = $this->getClientID(); |
|
180 | - $options['ForControl'] = $target->getClientID(); |
|
181 | - $options['AutoHide'] = $this->getAutoHide(); |
|
182 | - $options['CssClass'] = $this->getKeyboardCssClass(); |
|
179 | + $options['ID'] = $this->getClientID(); |
|
180 | + $options['ForControl'] = $target->getClientID(); |
|
181 | + $options['AutoHide'] = $this->getAutoHide(); |
|
182 | + $options['CssClass'] = $this->getKeyboardCssClass(); |
|
183 | 183 | |
184 | - return $options; |
|
184 | + return $options; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function getForControl() |
44 | 44 | { |
45 | - return $this->getViewState('ForControl',''); |
|
45 | + return $this->getViewState('ForControl', ''); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | { |
132 | 132 | parent::addAttributesToRender($writer); |
133 | 133 | if($this->getPage()->getClientSupportsJavaScript()) |
134 | - $writer->addAttribute('id',$this->getClientID()); |
|
134 | + $writer->addAttribute('id', $this->getClientID()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | { |
144 | 144 | if(($url=$this->getCssUrl())==='') |
145 | 145 | $url=$this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'keyboard.css'); |
146 | - $this->getPage()->getClientScript()->registerStyleSheetFile($url,$url); |
|
146 | + $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | if(($forControl=$this->getForControl())==='') |
175 | 175 | throw new TConfigurationException('keyboard_forcontrol_required'); |
176 | 176 | if(($target=$this->findControl($forControl))===null) |
177 | - throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl); |
|
177 | + throw new TConfigurationException('keyboard_forcontrol_invalid', $forControl); |
|
178 | 178 | |
179 | - $options['ID'] = $this->getClientID(); |
|
180 | - $options['ForControl'] = $target->getClientID(); |
|
181 | - $options['AutoHide'] = $this->getAutoHide(); |
|
182 | - $options['CssClass'] = $this->getKeyboardCssClass(); |
|
179 | + $options['ID']=$this->getClientID(); |
|
180 | + $options['ForControl']=$target->getClientID(); |
|
181 | + $options['AutoHide']=$this->getAutoHide(); |
|
182 | + $options['CssClass']=$this->getKeyboardCssClass(); |
|
183 | 183 | |
184 | 184 | return $options; |
185 | 185 | } |
@@ -101,7 +101,7 @@ |
||
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Sets the horizontal alignment of the contents within the panel. |
104 | - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' |
|
104 | + * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' |
|
105 | 105 | * @param string the horizontal alignment |
106 | 106 | */ |
107 | 107 | public function setHorizontalAlign($value) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | parent::addAttributesToRender($writer); |
73 | 73 | if(($butt=$this->getDefaultButton())!=='') |
74 | - $writer->addAttribute('id',$this->getClientID()); |
|
74 | + $writer->addAttribute('id', $this->getClientID()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function getGroupingText() |
170 | 170 | { |
171 | - return $this->getViewState('GroupingText',''); |
|
171 | + return $this->getViewState('GroupingText', ''); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function setGroupingText($value) |
178 | 178 | { |
179 | - $this->setViewState('GroupingText',$value,''); |
|
179 | + $this->setViewState('GroupingText', $value, ''); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | if(($butt=$this->getDefaultButton())!=='') |
231 | 231 | { |
232 | 232 | if(($button=$this->findControl($butt))===null) |
233 | - throw new TInvalidDataValueException('panel_defaultbutton_invalid',$butt); |
|
233 | + throw new TInvalidDataValueException('panel_defaultbutton_invalid', $butt); |
|
234 | 234 | else |
235 | 235 | $this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
236 | 236 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * Creates a new callback control, sets the adapter to |
|
72 | - * TActiveControlAdapter. |
|
73 | - */ |
|
71 | + * Creates a new callback control, sets the adapter to |
|
72 | + * TActiveControlAdapter. |
|
73 | + */ |
|
74 | 74 | public function __construct() { |
75 | 75 | parent::__construct(); |
76 | 76 | $this->setAdapter(new TActiveControlAdapter($this)); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $value container tag |
112 | 112 | */ |
113 | 113 | public function setSurroundingTag($value) { |
114 | - $this->_surroundingTag=TPropertyValue::ensureString($value); |
|
114 | + $this->_surroundingTag=TPropertyValue::ensureString($value); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | parent::setDataSource($value); |
90 | 90 | if($this->getActiveControl()->canUpdateClientSide()) { |
91 | 91 | $this->renderPager(); |
92 | - $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter()); |
|
92 | + $this->getPage()->getAdapter()->registerControlToRender($this, $this->getResponse()->createHtmlWriter()); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param string CommandParameter corresponding to the OnCommand event of the button |
132 | 132 | * @return mixed the button instance |
133 | 133 | */ |
134 | - protected function createPagerButton($pager,$buttonType,$enabled,$text,$commandName,$commandParameter) { |
|
134 | + protected function createPagerButton($pager, $buttonType, $enabled, $text, $commandName, $commandParameter) { |
|
135 | 135 | if($buttonType===TDataGridPagerButtonType::LinkButton) { |
136 | 136 | if($enabled) |
137 | 137 | $button=new TActiveLinkButton; |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | public function render($writer) { |
175 | 175 | if($this->getHasPreRendered()) { |
176 | 176 | $this->renderDataGrid($writer); |
177 | - if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(),$writer); |
|
177 | + if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(), $writer); |
|
178 | 178 | } |
179 | 179 | else { |
180 | - $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
|
180 | + $this->getPage()->getAdapter()->registerControlToRender($this, $writer); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | foreach($pager as $item) { |
192 | 192 | if($item->ControlToPaginate==$this->ID) { |
193 | 193 | $writer=$this->getResponse()->createHtmlWriter(); |
194 | - $this->getPage()->getAdapter()->registerControlToRender($item,$writer); |
|
194 | + $this->getPage()->getAdapter()->registerControlToRender($item, $writer); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param THtmlWriter writer for the rendering purpose |
204 | 204 | */ |
205 | 205 | private function renderDataGrid($writer) { |
206 | - $writer->addAttribute('id',$this->getSurroundingTagID()); |
|
206 | + $writer->addAttribute('id', $this->getSurroundingTagID()); |
|
207 | 207 | $writer->renderBeginTag($this->getSurroundingTag()); |
208 | 208 | parent::render($writer); |
209 | 209 | $writer->renderEndTag(); |
@@ -140,8 +140,7 @@ discard block |
||
140 | 140 | $button->setText($text); |
141 | 141 | return $button; |
142 | 142 | } |
143 | - } |
|
144 | - else { |
|
143 | + } else { |
|
145 | 144 | $button=new TActiveButton; |
146 | 145 | if(!$enabled) |
147 | 146 | $button->setEnabled(false); |
@@ -175,8 +174,7 @@ discard block |
||
175 | 174 | if($this->getHasPreRendered()) { |
176 | 175 | $this->renderDataGrid($writer); |
177 | 176 | if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(),$writer); |
178 | - } |
|
179 | - else { |
|
177 | + } else { |
|
180 | 178 | $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
181 | 179 | } |
182 | 180 | } |
@@ -93,6 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | /** |
95 | 95 | * @param boolean whether the keys are case-sensitive. |
96 | + * @param boolean $value |
|
96 | 97 | */ |
97 | 98 | public function setCaseSensitive($value) |
98 | 99 | { |
@@ -126,6 +127,7 @@ discard block |
||
126 | 127 | * Removes an item from the map by its key. |
127 | 128 | * This overrides the parent implementation by converting the key to lower case first if CaseSensitive is false. |
128 | 129 | * @param mixed the key of the item to be removed |
130 | + * @param string $key |
|
129 | 131 | * @return mixed the removed value, null if no such key exists. |
130 | 132 | */ |
131 | 133 | public function remove($key) |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | protected function _getZappableSleepProps(&$exprops) |
52 | 52 | { |
53 | 53 | parent::_getZappableSleepProps($exprops); |
54 | - if ($this->_caseSensitive===false) |
|
55 | - $exprops[] = "\0Prado\Collections\TAttributeCollection\0_caseSensitive"; |
|
54 | + if($this->_caseSensitive===false) |
|
55 | + $exprops[]="\0Prado\Collections\TAttributeCollection\0_caseSensitive"; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function __get($name) |
67 | 67 | { |
68 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
68 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @param mixed the property value or event handler |
77 | 77 | * @throws TInvalidOperationException If the property is not defined or read-only. |
78 | 78 | */ |
79 | - public function __set($name,$value) |
|
79 | + public function __set($name, $value) |
|
80 | 80 | { |
81 | - $this->add($name,$value); |
|
81 | + $this->add($name, $value); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function itemAt($key) |
107 | 107 | { |
108 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
108 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | * @param mixed key |
116 | 116 | * @param mixed value |
117 | 117 | */ |
118 | - public function add($key,$value) |
|
118 | + public function add($key, $value) |
|
119 | 119 | { |
120 | - parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
|
120 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function remove($key) |
130 | 130 | { |
131 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
131 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function contains($key) |
141 | 141 | { |
142 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
142 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -87,6 +87,7 @@ discard block |
||
87 | 87 | * Initialize a new DateFormat. |
88 | 88 | * @param mixed either, null, a CultureInfo instance, |
89 | 89 | * a DateTimeFormatInfo instance, or a locale. |
90 | + * @param string $formatInfo |
|
90 | 91 | * @return DateFormat instance |
91 | 92 | */ |
92 | 93 | function __construct($formatInfo=null) |
@@ -106,6 +107,7 @@ discard block |
||
106 | 107 | /** |
107 | 108 | * Format a date according to the pattern. |
108 | 109 | * @param mixed the time as integer or string in strtotime format. |
110 | + * @param string $time |
|
109 | 111 | * @return string formatted date time. |
110 | 112 | */ |
111 | 113 | public function format($time, $pattern='F', $charset='UTF-8') |
@@ -179,6 +181,7 @@ discard block |
||
179 | 181 | * DateTimeFormatInfo::formatDateTime |
180 | 182 | * See the tutorial documentation for futher details on the patterns. |
181 | 183 | * @param mixed a pattern. |
184 | + * @param string $pattern |
|
182 | 185 | * @return string a pattern. |
183 | 186 | * @see DateTimeFormatInfo::formatDateTime() |
184 | 187 | */ |
@@ -269,6 +272,7 @@ discard block |
||
269 | 272 | * Any substrings, starting and ending with a single quote (') |
270 | 273 | * will be treated as a single token. |
271 | 274 | * @param string pattern. |
275 | + * @param string $pattern |
|
272 | 276 | * @return array string tokens in an array. |
273 | 277 | */ |
274 | 278 | protected function getTokens($pattern) |
@@ -134,12 +134,10 @@ discard block |
||
134 | 134 | { |
135 | 135 | $sub = preg_replace('/(^\')|(\'$)/','',$pattern); |
136 | 136 | $tokens[$i] = str_replace('``````','\'',$sub); |
137 | - } |
|
138 | - else if($pattern == '``````') |
|
137 | + } else if($pattern == '``````') |
|
139 | 138 | { |
140 | 139 | $tokens[$i] = '\''; |
141 | - } |
|
142 | - else |
|
140 | + } else |
|
143 | 141 | { |
144 | 142 | $function = $this->getFunctionName($pattern); |
145 | 143 | if($function != null) |
@@ -149,8 +147,7 @@ discard block |
||
149 | 147 | { |
150 | 148 | $rs = $this->$fName($date, $pattern); |
151 | 149 | $tokens[$i] = $rs; |
152 | - } |
|
153 | - else |
|
150 | + } else |
|
154 | 151 | throw new |
155 | 152 | Exception('function '.$function.' not found.'); |
156 | 153 | } |
@@ -285,8 +282,7 @@ discard block |
||
285 | 282 | if($char==null || $pattern{$i} == $char || $text) |
286 | 283 | { |
287 | 284 | $token .= $pattern{$i}; |
288 | - } |
|
289 | - else |
|
285 | + } else |
|
290 | 286 | { |
291 | 287 | $tokens[] = str_replace("","'",$token); |
292 | 288 | $token = $pattern{$i}; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | /** |
84 | 84 | * The DateTimeFormatInfo, containing culture specific patterns and names. |
85 | - * @var DateTimeFormatInfo |
|
85 | + * @var DateTimeFormatInfo |
|
86 | 86 | */ |
87 | 87 | protected $formatInfo; |
88 | 88 | |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Get the year. |
313 | - * "yy" will return the last two digits of year. |
|
314 | - * "yyyy" will return the full integer year. |
|
313 | + * "yy" will return the last two digits of year. |
|
314 | + * "yyyy" will return the full integer year. |
|
315 | 315 | * @param array getdate format. |
316 | 316 | * @param string a pattern. |
317 | 317 | * @return string year |
@@ -331,10 +331,10 @@ discard block |
||
331 | 331 | |
332 | 332 | /** |
333 | 333 | * Get the month. |
334 | - * "M" will return integer 1 through 12 |
|
335 | - * "MM" will return the narrow month name, e.g. "J" |
|
336 | - * "MMM" will return the abrreviated month name, e.g. "Jan" |
|
337 | - * "MMMM" will return the month name, e.g. "January" |
|
334 | + * "M" will return integer 1 through 12 |
|
335 | + * "MM" will return the narrow month name, e.g. "J" |
|
336 | + * "MMM" will return the abrreviated month name, e.g. "Jan" |
|
337 | + * "MMMM" will return the month name, e.g. "January" |
|
338 | 338 | * @param array getdate format. |
339 | 339 | * @param string a pattern. |
340 | 340 | * @return string month name |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | /** |
360 | 360 | * Get the day of the week. |
361 | - * "E" will return integer 0 (for Sunday) through 6 (for Saturday). |
|
362 | - * "EE" will return the narrow day of the week, e.g. "M" |
|
363 | - * "EEE" will return the abrreviated day of the week, e.g. "Mon" |
|
364 | - * "EEEE" will return the day of the week, e.g. "Monday" |
|
361 | + * "E" will return integer 0 (for Sunday) through 6 (for Saturday). |
|
362 | + * "EE" will return the narrow day of the week, e.g. "M" |
|
363 | + * "EEE" will return the abrreviated day of the week, e.g. "Mon" |
|
364 | + * "EEEE" will return the day of the week, e.g. "Monday" |
|
365 | 365 | * @param array getdate format. |
366 | 366 | * @param string a pattern. |
367 | 367 | * @return string day of the week. |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Get the day of the month. |
389 | - * "d" for non-padding, "dd" will always return 2 characters. |
|
389 | + * "d" for non-padding, "dd" will always return 2 characters. |
|
390 | 390 | * @param array getdate format. |
391 | 391 | * @param string a pattern. |
392 | 392 | * @return string day of the month |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | protected function getDayInMonth($date, $pattern='FF') |
559 | 559 | { |
560 | 560 | switch ($pattern) { |
561 | - case 'F': |
|
562 | - return $date->format('j'); |
|
563 | - case 'FF': |
|
564 | - return $date->format('d'); |
|
565 | - default: |
|
566 | - throw new Exception('The pattern for day in month is "F" or "FF".'); |
|
561 | + case 'F': |
|
562 | + return $date->format('j'); |
|
563 | + case 'FF': |
|
564 | + return $date->format('d'); |
|
565 | + default: |
|
566 | + throw new Exception('The pattern for day in month is "F" or "FF".'); |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * A list of tokens and their function call. |
55 | 55 | * @var array |
56 | 56 | */ |
57 | - protected $tokens = array( |
|
57 | + protected $tokens=array( |
|
58 | 58 | 'G'=>'Era', |
59 | 59 | 'y'=>'Year', |
60 | 60 | 'M'=>'Month', |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * A list of methods, to be used by the token function calls. |
79 | 79 | * @var array |
80 | 80 | */ |
81 | - protected $methods = array(); |
|
81 | + protected $methods=array(); |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * The DateTimeFormatInfo, containing culture specific patterns and names. |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | */ |
95 | 95 | function __construct($formatInfo=null) |
96 | 96 | { |
97 | - if($formatInfo === null) |
|
98 | - $this->formatInfo = DateTimeFormatInfo::getInvariantInfo(); |
|
97 | + if($formatInfo===null) |
|
98 | + $this->formatInfo=DateTimeFormatInfo::getInvariantInfo(); |
|
99 | 99 | else if($formatInfo instanceof CultureInfo) |
100 | - $this->formatInfo = $formatInfo->DateTimeFormat; |
|
100 | + $this->formatInfo=$formatInfo->DateTimeFormat; |
|
101 | 101 | else if($formatInfo instanceof DateTimeFormatInfo) |
102 | - $this->formatInfo = $formatInfo; |
|
102 | + $this->formatInfo=$formatInfo; |
|
103 | 103 | else |
104 | - $this->formatInfo = DateTimeFormatInfo::getInstance($formatInfo); |
|
104 | + $this->formatInfo=DateTimeFormatInfo::getInstance($formatInfo); |
|
105 | 105 | |
106 | - $this->methods = get_class_methods($this); |
|
106 | + $this->methods=get_class_methods($this); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,44 +113,44 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function format($time, $pattern='F', $charset='UTF-8') |
115 | 115 | { |
116 | - if (is_numeric($time)) //assumes unix epoch |
|
117 | - $time = floatval($time); |
|
116 | + if(is_numeric($time)) //assumes unix epoch |
|
117 | + $time=floatval($time); |
|
118 | 118 | else if(is_string($time)) |
119 | - $time = @strtotime($time); |
|
119 | + $time=@strtotime($time); |
|
120 | 120 | |
121 | - if($pattern === null) |
|
122 | - $pattern = 'F'; |
|
121 | + if($pattern===null) |
|
122 | + $pattern='F'; |
|
123 | 123 | |
124 | - $date = new \DateTime; |
|
124 | + $date=new \DateTime; |
|
125 | 125 | $date->setTimestamp($time); |
126 | 126 | |
127 | - $pattern = $this->getPattern($pattern); |
|
127 | + $pattern=$this->getPattern($pattern); |
|
128 | 128 | |
129 | - $tokens = $this->getTokens($pattern); |
|
129 | + $tokens=$this->getTokens($pattern); |
|
130 | 130 | |
131 | - for($i = 0, $k = count($tokens); $i<$k; ++$i) |
|
131 | + for($i=0, $k=count($tokens); $i < $k; ++$i) |
|
132 | 132 | { |
133 | - $pattern = $tokens[$i]; |
|
134 | - if($pattern{0} == "'" |
|
135 | - && $pattern{strlen($pattern)-1} == "'") |
|
133 | + $pattern=$tokens[$i]; |
|
134 | + if($pattern{0}=="'" |
|
135 | + && $pattern{strlen($pattern) - 1}=="'") |
|
136 | 136 | { |
137 | - $sub = preg_replace('/(^\')|(\'$)/','',$pattern); |
|
138 | - $tokens[$i] = str_replace('``````','\'',$sub); |
|
137 | + $sub=preg_replace('/(^\')|(\'$)/', '', $pattern); |
|
138 | + $tokens[$i]=str_replace('``````', '\'', $sub); |
|
139 | 139 | } |
140 | - else if($pattern == '``````') |
|
140 | + else if($pattern=='``````') |
|
141 | 141 | { |
142 | - $tokens[$i] = '\''; |
|
142 | + $tokens[$i]='\''; |
|
143 | 143 | } |
144 | 144 | else |
145 | 145 | { |
146 | - $function = $this->getFunctionName($pattern); |
|
147 | - if($function != null) |
|
146 | + $function=$this->getFunctionName($pattern); |
|
147 | + if($function!=null) |
|
148 | 148 | { |
149 | - $fName = 'get'.$function; |
|
149 | + $fName='get'.$function; |
|
150 | 150 | if(in_array($fName, $this->methods)) |
151 | 151 | { |
152 | - $rs = $this->$fName($date, $pattern); |
|
153 | - $tokens[$i] = $rs; |
|
152 | + $rs=$this->$fName($date, $pattern); |
|
153 | + $tokens[$i]=$rs; |
|
154 | 154 | } |
155 | 155 | else |
156 | 156 | throw new |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - return I18N_toEncoding(implode('',$tokens), $charset); |
|
162 | + return I18N_toEncoding(implode('', $tokens), $charset); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function getPattern($pattern) |
188 | 188 | { |
189 | - if(is_array($pattern) && count($pattern) == 2) |
|
189 | + if(is_array($pattern) && count($pattern)==2) |
|
190 | 190 | { |
191 | 191 | return $this->formatInfo->formatDateTime( |
192 | 192 | $this->getPattern($pattern[0]), |
@@ -275,36 +275,36 @@ discard block |
||
275 | 275 | */ |
276 | 276 | protected function getTokens($pattern) |
277 | 277 | { |
278 | - $char = null; |
|
279 | - $tokens = array(); |
|
280 | - $token = null; |
|
278 | + $char=null; |
|
279 | + $tokens=array(); |
|
280 | + $token=null; |
|
281 | 281 | |
282 | - $text = false; |
|
283 | - $pattern = preg_replace("/''/", '``````', $pattern); |
|
282 | + $text=false; |
|
283 | + $pattern=preg_replace("/''/", '``````', $pattern); |
|
284 | 284 | |
285 | - for($i = 0; $i < strlen($pattern); $i++) |
|
285 | + for($i=0; $i < strlen($pattern); $i++) |
|
286 | 286 | { |
287 | - if($char==null || $pattern{$i} == $char || $text) |
|
287 | + if($char==null || $pattern{$i}==$char || $text) |
|
288 | 288 | { |
289 | - $token .= $pattern{$i}; |
|
289 | + $token.=$pattern{$i}; |
|
290 | 290 | } |
291 | 291 | else |
292 | 292 | { |
293 | - $tokens[] = str_replace("","'",$token); |
|
294 | - $token = $pattern{$i}; |
|
293 | + $tokens[]=str_replace("", "'", $token); |
|
294 | + $token=$pattern{$i}; |
|
295 | 295 | } |
296 | 296 | |
297 | - if($pattern{$i} == "'" && $text == false) |
|
298 | - $text = true; |
|
299 | - else if($text && $pattern{$i} == "'" && $char == "'") |
|
300 | - $text = true; |
|
301 | - else if($text && $char != "'" && $pattern{$i} == "'") |
|
302 | - $text = false; |
|
297 | + if($pattern{$i}=="'" && $text==false) |
|
298 | + $text=true; |
|
299 | + else if($text && $pattern{$i}=="'" && $char=="'") |
|
300 | + $text=true; |
|
301 | + else if($text && $char!="'" && $pattern{$i}=="'") |
|
302 | + $text=false; |
|
303 | 303 | |
304 | - $char = $pattern{$i}; |
|
304 | + $char=$pattern{$i}; |
|
305 | 305 | |
306 | 306 | } |
307 | - $tokens[] = $token; |
|
307 | + $tokens[]=$token; |
|
308 | 308 | return $tokens; |
309 | 309 | } |
310 | 310 | |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | case 'MM': |
349 | 349 | return $date->format('m'); |
350 | 350 | case 'MMM': |
351 | - return $this->formatInfo->AbbreviatedMonthNames[$date->format('n')-1]; |
|
351 | + return $this->formatInfo->AbbreviatedMonthNames[$date->format('n') - 1]; |
|
352 | 352 | case 'MMMM': |
353 | - return $this->formatInfo->MonthNames[$date->format('n')-1]; |
|
353 | + return $this->formatInfo->MonthNames[$date->format('n') - 1]; |
|
354 | 354 | default: |
355 | 355 | throw new Exception('The pattern for month is "M", "MM", "MMM", or "MMMM".'); |
356 | 356 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | protected function getDayInWeek($date, $pattern='EEEE') |
370 | 370 | { |
371 | - $day = $date->format('w'); |
|
371 | + $day=$date->format('w'); |
|
372 | 372 | switch($pattern) |
373 | 373 | { |
374 | 374 | case 'E': |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | */ |
415 | 415 | protected function getEra($date, $pattern='G') |
416 | 416 | { |
417 | - if($pattern != 'G') |
|
417 | + if($pattern!='G') |
|
418 | 418 | throw new Exception('The pattern for era is "G".'); |
419 | 419 | |
420 | - $year = $date->format('Y'); |
|
420 | + $year=$date->format('Y'); |
|
421 | 421 | if($year > 0) |
422 | 422 | return $this->formatInfo->getEra(1); |
423 | 423 | else |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | */ |
453 | 453 | protected function getAMPM($date, $pattern='a') |
454 | 454 | { |
455 | - if($pattern != 'a') |
|
455 | + if($pattern!='a') |
|
456 | 456 | throw new Exception('The pattern for AM/PM marker is "a".'); |
457 | 457 | |
458 | - $hour = $date->format('G'); |
|
459 | - $ampm = (int)($hour/12); |
|
458 | + $hour=$date->format('G'); |
|
459 | + $ampm=(int) ($hour / 12); |
|
460 | 460 | return $this->formatInfo->AMPMMarkers[$ampm]; |
461 | 461 | } |
462 | 462 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | */ |
530 | 530 | protected function getTimeZone($date, $pattern='z') |
531 | 531 | { |
532 | - if($pattern != 'z') |
|
532 | + if($pattern!='z') |
|
533 | 533 | throw new Exception('The pattern for time zone is "z".'); |
534 | 534 | |
535 | 535 | return $date->format('T'); |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | */ |
544 | 544 | protected function getDayInYear($date, $pattern='D') |
545 | 545 | { |
546 | - if($pattern != 'D') |
|
546 | + if($pattern!='D') |
|
547 | 547 | throw new Exception('The pattern for day in year is "D".'); |
548 | 548 | |
549 | 549 | return $date->format('z'); |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | */ |
558 | 558 | protected function getDayInMonth($date, $pattern='FF') |
559 | 559 | { |
560 | - switch ($pattern) { |
|
560 | + switch($pattern) { |
|
561 | 561 | case 'F': |
562 | 562 | return $date->format('j'); |
563 | 563 | case 'FF': |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | */ |
576 | 576 | protected function getWeekInYear($date, $pattern='w') |
577 | 577 | { |
578 | - if($pattern != 'w') |
|
578 | + if($pattern!='w') |
|
579 | 579 | throw new Exception('The pattern for week in year is "w".'); |
580 | 580 | |
581 | 581 | return $date->format('W'); |
@@ -588,10 +588,10 @@ discard block |
||
588 | 588 | */ |
589 | 589 | protected function getWeekInMonth($date, $pattern='W') |
590 | 590 | { |
591 | - if($pattern != 'W') |
|
591 | + if($pattern!='W') |
|
592 | 592 | throw new Exception('The pattern for week in month is "W".'); |
593 | 593 | |
594 | - $firstInMonth = clone($date); |
|
594 | + $firstInMonth=clone($date); |
|
595 | 595 | $firstInMonth->setDate($firstInMonth->format('Y'), $firstInMonth->format('m'), 1); |
596 | 596 | return $date->format('W') - $firstInMonth->format('W'); |
597 | 597 | } |
@@ -604,10 +604,10 @@ discard block |
||
604 | 604 | */ |
605 | 605 | protected function getHourInDay($date, $pattern='k') |
606 | 606 | { |
607 | - if($pattern != 'k') |
|
607 | + if($pattern!='k') |
|
608 | 608 | throw new Exception('The pattern for hour in day is "k".'); |
609 | 609 | |
610 | - return $date->format('G')+1; |
|
610 | + return $date->format('G') + 1; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -618,9 +618,9 @@ discard block |
||
618 | 618 | */ |
619 | 619 | protected function getHourInAMPM($date, $pattern='K') |
620 | 620 | { |
621 | - if($pattern != 'K') |
|
621 | + if($pattern!='K') |
|
622 | 622 | throw new Exception('The pattern for hour in AM/PM is "K".'); |
623 | 623 | |
624 | - return $date->format('g')+1; |
|
624 | + return $date->format('g') + 1; |
|
625 | 625 | } |
626 | 626 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * @return string default culture |
|
93 | + * @return boolean default culture |
|
94 | 94 | */ |
95 | 95 | public function getTranslateDefaultCulture() |
96 | 96 | { |
@@ -212,8 +212,7 @@ discard block |
||
212 | 212 | $config['source']); |
213 | 213 | chmod($config['source'], PRADO_CHMOD); //make it deletable |
214 | 214 | } |
215 | - } |
|
216 | - else |
|
215 | + } else |
|
217 | 216 | { |
218 | 217 | throw new TConfigurationException("invalid source dir '{$config['source']}'"); |
219 | 218 | } |
@@ -228,8 +227,7 @@ discard block |
||
228 | 227 | $config['cache']); |
229 | 228 | chmod($config['cache'], PRADO_CHMOD); //make it deletable |
230 | 229 | } |
231 | - } |
|
232 | - else |
|
230 | + } else |
|
233 | 231 | { |
234 | 232 | unset($config['cache']); |
235 | 233 | } |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | * Default character set is 'UTF-8'. |
34 | 34 | * @var string |
35 | 35 | */ |
36 | - private $_defaultCharset = 'UTF-8'; |
|
36 | + private $_defaultCharset='UTF-8'; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Default culture is 'en'. |
40 | 40 | * @var string |
41 | 41 | */ |
42 | - private $_defaultCulture = 'en'; |
|
42 | + private $_defaultCulture='en'; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * The current charset. |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | if($config!==null) |
82 | 82 | { |
83 | 83 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
84 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
84 | + $translation=isset($config['translate']) ? $config['translate'] : null; |
|
85 | 85 | else |
86 | 86 | { |
87 | - $t = $config->getElementByTagName('translation'); |
|
88 | - $translation = ($t)?$t->getAttributes():null; |
|
87 | + $t=$config->getElementByTagName('translation'); |
|
88 | + $translation=($t) ? $t->getAttributes() : null; |
|
89 | 89 | } |
90 | 90 | if($translation) |
91 | 91 | $this->setTranslationConfiguration($translation); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function setTranslateDefaultCulture($value) |
108 | 108 | { |
109 | - $this->_translateDefaultCulture = TPropertyValue::ensureBoolean($value); |
|
109 | + $this->_translateDefaultCulture=TPropertyValue::ensureBoolean($value); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function setDefaultCulture($culture) |
124 | 124 | { |
125 | - $this->_defaultCulture = str_replace('-','_',$culture); |
|
125 | + $this->_defaultCulture=str_replace('-', '_', $culture); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function setDefaultCharset($charset) |
140 | 140 | { |
141 | - $this->_defaultCharset = $charset; |
|
141 | + $this->_defaultCharset=$charset; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function setCulture($culture) |
156 | 156 | { |
157 | - $this->_culture = str_replace('-','_',$culture); |
|
157 | + $this->_culture=str_replace('-', '_', $culture); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function setCharset($charset) |
172 | 172 | { |
173 | - $this->_charset = $charset; |
|
173 | + $this->_charset=$charset; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getTranslationConfiguration() |
180 | 180 | { |
181 | - return (!$this->_translateDefaultCulture && ($this->getDefaultCulture() == $this->getCulture())) |
|
181 | + return (!$this->_translateDefaultCulture && ($this->getDefaultCulture()==$this->getCulture())) |
|
182 | 182 | ? null |
183 | 183 | : $this->_translation; |
184 | 184 | } |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function setTranslationConfiguration($config) |
202 | 202 | { |
203 | - if($config['type'] == 'XLIFF' || $config['type'] == 'gettext' || $config['type'] == 'PHP') |
|
203 | + if($config['type']=='XLIFF' || $config['type']=='gettext' || $config['type']=='PHP') |
|
204 | 204 | { |
205 | 205 | if($config['source']) |
206 | 206 | { |
207 | - $config['source'] = Prado::getPathOfNamespace($config['source']); |
|
207 | + $config['source']=Prado::getPathOfNamespace($config['source']); |
|
208 | 208 | if(!is_dir($config['source'])) |
209 | 209 | { |
210 | 210 | if(@mkdir($config['source'])===false) |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | if(isset($config['cache']) && TPropertyValue::ensureBoolean($config['cache'])) |
222 | 222 | { |
223 | - $config['cache'] = $this->getApplication()->getRunTimePath().'/i18n'; |
|
223 | + $config['cache']=$this->getApplication()->getRunTimePath().'/i18n'; |
|
224 | 224 | if(!is_dir($config['cache'])) |
225 | 225 | { |
226 | 226 | if(@mkdir($config['cache'])===false) |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | unset($config['cache']); |
235 | 235 | } |
236 | - $this->_translation = $config; |
|
236 | + $this->_translation=$config; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function setTranslationCatalogue($value) |
251 | 251 | { |
252 | - $this->_translation['catalogue'] = $value; |
|
252 | + $this->_translation['catalogue']=$value; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function getCultureVariants($culture=null) |
262 | 262 | { |
263 | - if($culture===null) $culture = $this->getCulture(); |
|
264 | - $variants = explode('_', $culture); |
|
265 | - $result = array(); |
|
263 | + if($culture===null) $culture=$this->getCulture(); |
|
264 | + $variants=explode('_', $culture); |
|
265 | + $result=array(); |
|
266 | 266 | for(; count($variants) > 0; array_pop($variants)) |
267 | - $result[] = implode('_', $variants); |
|
267 | + $result[]=implode('_', $variants); |
|
268 | 268 | return $result; |
269 | 269 | } |
270 | 270 | |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | * @param string culture string, null to use current culture |
288 | 288 | * @return array list of possible localized resource files. |
289 | 289 | */ |
290 | - public function getLocalizedResource($file,$culture=null) |
|
290 | + public function getLocalizedResource($file, $culture=null) |
|
291 | 291 | { |
292 | - $files = array(); |
|
293 | - $variants = $this->getCultureVariants($culture); |
|
294 | - $path = pathinfo($file); |
|
292 | + $files=array(); |
|
293 | + $variants=$this->getCultureVariants($culture); |
|
294 | + $path=pathinfo($file); |
|
295 | 295 | foreach($variants as $variant) |
296 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
297 | - $filename = substr($path['basename'],0,strrpos($path['basename'],'.')); |
|
296 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
297 | + $filename=substr($path['basename'], 0, strrpos($path['basename'], '.')); |
|
298 | 298 | foreach($variants as $variant) |
299 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
300 | - $files[] = $file; |
|
299 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
300 | + $files[]=$file; |
|
301 | 301 | return $files; |
302 | 302 | } |
303 | 303 |
@@ -73,6 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @param string username |
76 | + * @param string $value |
|
76 | 77 | */ |
77 | 78 | public function setName($value) |
78 | 79 | { |
@@ -89,6 +90,7 @@ discard block |
||
89 | 90 | |
90 | 91 | /** |
91 | 92 | * @param boolean if the user is a guest |
93 | + * @param boolean $value |
|
92 | 94 | */ |
93 | 95 | public function setIsGuest($value) |
94 | 96 | { |
@@ -170,6 +172,7 @@ discard block |
||
170 | 172 | * |
171 | 173 | * @param string variable name |
172 | 174 | * @param mixed default value |
175 | + * @param string $key |
|
173 | 176 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 177 | * @see setState |
175 | 178 | */ |
@@ -190,6 +193,7 @@ discard block |
||
190 | 193 | * @param string variable name |
191 | 194 | * @param mixed variable value |
192 | 195 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
196 | + * @param string $key |
|
193 | 197 | * @see getState |
194 | 198 | */ |
195 | 199 | protected function setState($key,$value,$defaultValue=null) |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getName() |
70 | 70 | { |
71 | - return $this->getState('Name',''); |
|
71 | + return $this->getState('Name', ''); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setName($value) |
78 | 78 | { |
79 | - $this->setState('Name',$value,''); |
|
79 | + $this->setState('Name', $value, ''); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getIsGuest() |
86 | 86 | { |
87 | - return $this->getState('IsGuest',true); |
|
87 | + return $this->getState('IsGuest', true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $this->setName($this->_manager->getGuestName()); |
98 | 98 | $this->setRoles(array()); |
99 | 99 | } |
100 | - $this->setState('IsGuest',$isGuest); |
|
100 | + $this->setState('IsGuest', $isGuest); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getRoles() |
107 | 107 | { |
108 | - return $this->getState('Roles',array()); |
|
108 | + return $this->getState('Roles', array()); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | public function setRoles($value) |
115 | 115 | { |
116 | 116 | if(is_array($value)) |
117 | - $this->setState('Roles',$value,array()); |
|
117 | + $this->setState('Roles', $value, array()); |
|
118 | 118 | else |
119 | 119 | { |
120 | 120 | $roles=array(); |
121 | - foreach(explode(',',$value) as $role) |
|
121 | + foreach(explode(',', $value) as $role) |
|
122 | 122 | { |
123 | 123 | if(($role=trim($role))!=='') |
124 | 124 | $roles[]=$role; |
125 | 125 | } |
126 | - $this->setState('Roles',$roles,array()); |
|
126 | + $this->setState('Roles', $roles, array()); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function isInRole($role) |
135 | 135 | { |
136 | 136 | foreach($this->getRoles() as $r) |
137 | - if(strcasecmp($role,$r)===0) |
|
137 | + if(strcasecmp($role, $r)===0) |
|
138 | 138 | return true; |
139 | 139 | return false; |
140 | 140 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 174 | * @see setState |
175 | 175 | */ |
176 | - protected function getState($key,$defaultValue=null) |
|
176 | + protected function getState($key, $defaultValue=null) |
|
177 | 177 | { |
178 | - return isset($this->_state[$key])?$this->_state[$key]:$defaultValue; |
|
178 | + return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
193 | 193 | * @see getState |
194 | 194 | */ |
195 | - protected function setState($key,$value,$defaultValue=null) |
|
195 | + protected function setState($key, $value, $defaultValue=null) |
|
196 | 196 | { |
197 | 197 | if($value===$defaultValue) |
198 | 198 | unset($this->_state[$key]); |
@@ -215,6 +215,7 @@ discard block |
||
215 | 215 | * This method does not perform any publishing. It merely tells you |
216 | 216 | * if the file path is published, what the URL will be to access it. |
217 | 217 | * @param string directory or file path being published |
218 | + * @param string $path |
|
218 | 219 | * @return string the published URL for the file path |
219 | 220 | */ |
220 | 221 | public function getPublishedUrl($path) |
@@ -230,6 +231,7 @@ discard block |
||
230 | 231 | * Generate a CRC32 hash for the directory path. Collisions are higher |
231 | 232 | * than MD5 but generates a much smaller hash string. |
232 | 233 | * @param string string to be hashed. |
234 | + * @param string $dir |
|
233 | 235 | * @return string hashed string. |
234 | 236 | */ |
235 | 237 | protected function hash($dir) |
@@ -243,6 +245,8 @@ discard block |
||
243 | 245 | * or has an older file modification time. |
244 | 246 | * @param string source file path |
245 | 247 | * @param string destination directory (if not exists, it will be created) |
248 | + * @param string $src |
|
249 | + * @param string $dst |
|
246 | 250 | */ |
247 | 251 | protected function copyFile($src,$dst) |
248 | 252 | { |
@@ -265,6 +269,8 @@ discard block |
||
265 | 269 | * File modification time is used to ensure the copied files are latest. |
266 | 270 | * @param string the source directory |
267 | 271 | * @param string the destination directory |
272 | + * @param string $src |
|
273 | + * @param string $dst |
|
268 | 274 | * @todo a generic solution to ignore certain directories and files |
269 | 275 | */ |
270 | 276 | public function copyDirectory($src,$dst) |
@@ -306,6 +312,8 @@ discard block |
||
306 | 312 | * @param string tar filename |
307 | 313 | * @param string MD5 checksum for the corresponding tar file. |
308 | 314 | * @param boolean Wether or not to check the time stamp of the file for publishing. Defaults to false. |
315 | + * @param string $tarfile |
|
316 | + * @param string $md5sum |
|
309 | 317 | * @return string URL path to the directory where the tar file was extracted. |
310 | 318 | */ |
311 | 319 | public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false) |
@@ -336,6 +344,7 @@ discard block |
||
336 | 344 | * N.B Tar file must not be compressed. |
337 | 345 | * @param string tar file |
338 | 346 | * @param string path where the contents of tar file are to be extracted |
347 | + * @param string $destination |
|
339 | 348 | * @return boolean true if extract successful, false otherwise. |
340 | 349 | */ |
341 | 350 | protected function deployTarFile($path,$destination) |
@@ -163,8 +163,7 @@ discard block |
||
163 | 163 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
164 | 164 | $this->copyFile($fullpath,$dst); |
165 | 165 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
166 | - } |
|
167 | - else |
|
166 | + } else |
|
168 | 167 | { |
169 | 168 | $dir=$this->hash($fullpath); |
170 | 169 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
@@ -287,8 +286,7 @@ discard block |
||
287 | 286 | @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
288 | 287 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
289 | 288 | } |
290 | - } |
|
291 | - else |
|
289 | + } else |
|
292 | 290 | $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
293 | 291 | } |
294 | 292 | closedir($folder); |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | if($this->_basePath===null) |
92 | 92 | $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
93 | 93 | if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
94 | - throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath); |
|
94 | + throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
|
95 | 95 | if($this->_baseUrl===null) |
96 | - $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH; |
|
96 | + $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\').'/'.self::DEFAULT_BASEPATH; |
|
97 | 97 | $application->setAssetManager($this); |
98 | 98 | $this->_initialized=true; |
99 | 99 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $this->_basePath=Prado::getPathOfNamespace($value); |
122 | 122 | if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
123 | - throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value); |
|
123 | + throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | if($this->_initialized) |
142 | 142 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
143 | 143 | else |
144 | - $this->_baseUrl=rtrim($value,'/'); |
|
144 | + $this->_baseUrl=rtrim($value, '/'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -158,19 +158,19 @@ discard block |
||
158 | 158 | * @throws TInvalidDataValueException if the file path to be published is |
159 | 159 | * invalid |
160 | 160 | */ |
161 | - public function publishFilePath($path,$checkTimestamp=false) |
|
161 | + public function publishFilePath($path, $checkTimestamp=false) |
|
162 | 162 | { |
163 | 163 | if(isset($this->_published[$path])) |
164 | 164 | return $this->_published[$path]; |
165 | 165 | else if(empty($path) || ($fullpath=realpath($path))===false) |
166 | - throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path); |
|
166 | + throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
|
167 | 167 | else if(is_file($fullpath)) |
168 | 168 | { |
169 | 169 | $dir=$this->hash(dirname($fullpath)); |
170 | 170 | $fileName=basename($fullpath); |
171 | 171 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
172 | 172 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
173 | - $this->copyFile($fullpath,$dst); |
|
173 | + $this->copyFile($fullpath, $dst); |
|
174 | 174 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
175 | 175 | } |
176 | 176 | else |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | $dir=$this->hash($fullpath); |
179 | 179 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
180 | 180 | { |
181 | - Prado::trace("Publishing directory $fullpath",'Prado\Web\TAssetManager'); |
|
182 | - $this->copyDirectory($fullpath,$this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
181 | + Prado::trace("Publishing directory $fullpath", 'Prado\Web\TAssetManager'); |
|
182 | + $this->copyDirectory($fullpath, $this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
183 | 183 | } |
184 | 184 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
185 | 185 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function setPublished($values=array()) |
202 | 202 | { |
203 | - $this->_published = $values; |
|
203 | + $this->_published=$values; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function hash($dir) |
245 | 245 | { |
246 | - return sprintf('%x',crc32($dir.Prado::getVersion())); |
|
246 | + return sprintf('%x', crc32($dir.Prado::getVersion())); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param string source file path |
254 | 254 | * @param string destination directory (if not exists, it will be created) |
255 | 255 | */ |
256 | - protected function copyFile($src,$dst) |
|
256 | + protected function copyFile($src, $dst) |
|
257 | 257 | { |
258 | 258 | if(!is_dir($dst)) |
259 | 259 | { |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | @chmod($dst, PRADO_CHMOD); |
262 | 262 | } |
263 | 263 | $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
264 | - if(@filemtime($dstFile)<@filemtime($src)) |
|
264 | + if(@filemtime($dstFile) < @filemtime($src)) |
|
265 | 265 | { |
266 | - Prado::trace("Publishing file $src to $dstFile",'Prado\Web\TAssetManager'); |
|
267 | - @copy($src,$dstFile); |
|
266 | + Prado::trace("Publishing file $src to $dstFile", 'Prado\Web\TAssetManager'); |
|
267 | + @copy($src, $dstFile); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param string the destination directory |
277 | 277 | * @todo a generic solution to ignore certain directories and files |
278 | 278 | */ |
279 | - public function copyDirectory($src,$dst) |
|
279 | + public function copyDirectory($src, $dst) |
|
280 | 280 | { |
281 | 281 | if(!is_dir($dst)) |
282 | 282 | { |
@@ -291,14 +291,14 @@ discard block |
||
291 | 291 | continue; |
292 | 292 | else if(is_file($src.DIRECTORY_SEPARATOR.$file)) |
293 | 293 | { |
294 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
294 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$file) < @filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
295 | 295 | { |
296 | - @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
296 | + @copy($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
297 | 297 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
298 | 298 | } |
299 | 299 | } |
300 | 300 | else |
301 | - $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
301 | + $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
302 | 302 | } |
303 | 303 | closedir($folder); |
304 | 304 | } else { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | if(isset($this->_published[$md5sum])) |
323 | 323 | return $this->_published[$md5sum]; |
324 | 324 | else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
325 | - throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum); |
|
325 | + throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
|
326 | 326 | else |
327 | 327 | { |
328 | 328 | $dir=$this->hash(dirname($fullpath)); |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
331 | 331 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
332 | 332 | { |
333 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName)<@filemtime($fullpath)) |
|
333 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName) < @filemtime($fullpath)) |
|
334 | 334 | { |
335 | - $this->copyFile($fullpath,$dst); |
|
336 | - $this->deployTarFile($tarfile,$dst); |
|
335 | + $this->copyFile($fullpath, $dst); |
|
336 | + $this->deployTarFile($tarfile, $dst); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | * @param string path where the contents of tar file are to be extracted |
348 | 348 | * @return boolean true if extract successful, false otherwise. |
349 | 349 | */ |
350 | - protected function deployTarFile($path,$destination) |
|
350 | + protected function deployTarFile($path, $destination) |
|
351 | 351 | { |
352 | 352 | if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
353 | - throw new TIOException('assetmanager_tarfile_invalid',$path); |
|
353 | + throw new TIOException('assetmanager_tarfile_invalid', $path); |
|
354 | 354 | else |
355 | 355 | { |
356 | - $tar = new TTarFileExtractor($fullpath); |
|
356 | + $tar=new TTarFileExtractor($fullpath); |
|
357 | 357 | return $tar->extract($destination); |
358 | 358 | } |
359 | 359 | } |