@@ -77,7 +77,6 @@ |
||
77 | 77 | /** |
78 | 78 | * Factory method to get a new request object or the one for an existing request |
79 | 79 | * |
80 | - * @param string $id=null |
|
81 | 80 | * @return etemplate_request|boolean the object or false if $id is not found |
82 | 81 | */ |
83 | 82 | static function read($id=null) |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param array $id |
58 | 58 | */ |
59 | - private function __construct($id=null) |
|
59 | + private function __construct($id = null) |
|
60 | 60 | { |
61 | 61 | if (!$id) $id = self::request_id(); |
62 | 62 | |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | * @param string $id=null |
81 | 81 | * @return etemplate_request|boolean the object or false if $id is not found |
82 | 82 | */ |
83 | - static function read($id=null) |
|
83 | + static function read($id = null) |
|
84 | 84 | { |
85 | 85 | $request = new etemplate_request_session($id); |
86 | 86 | |
87 | 87 | if (!is_null($id)) |
88 | 88 | { |
89 | - if (!($data = $GLOBALS['egw']->session->appsession($id,'etemplate'))) |
|
89 | + if (!($data = $GLOBALS['egw']->session->appsession($id, 'etemplate'))) |
|
90 | 90 | { |
91 | - return false; // request not found |
|
91 | + return false; // request not found |
|
92 | 92 | } |
93 | 93 | $request->data = $data; |
94 | 94 | } |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | */ |
104 | 104 | static function request_id() |
105 | 105 | { |
106 | - $time = (int) (100 * microtime(true)); // gives precision of 1/100 sec |
|
107 | - $id = $GLOBALS['egw_info']['flags']['currentapp'] .':'. $time; |
|
106 | + $time = (int)(100 * microtime(true)); // gives precision of 1/100 sec |
|
107 | + $id = $GLOBALS['egw_info']['flags']['currentapp'].':'.$time; |
|
108 | 108 | |
109 | 109 | return $id; |
110 | 110 | } |
@@ -144,30 +144,30 @@ discard block |
||
144 | 144 | protected function _php4_request_garbage_collection() |
145 | 145 | { |
146 | 146 | // now we are on php4 sessions and do a bit of garbage collection |
147 | - $appsessions =& $_SESSION[egw_session::EGW_APPSESSION_VAR]['etemplate']; |
|
148 | - $session_used =& $appsessions['session_used']; |
|
147 | + $appsessions = & $_SESSION[egw_session::EGW_APPSESSION_VAR]['etemplate']; |
|
148 | + $session_used = & $appsessions['session_used']; |
|
149 | 149 | |
150 | 150 | if ($this->id) |
151 | 151 | { |
152 | 152 | //echo "session_used[$id_used]='".$session_used[$id_used]."'<br/>\n"; |
153 | - ++$session_used[$this->id]; // count the number of times a session got used |
|
153 | + ++$session_used[$this->id]; // count the number of times a session got used |
|
154 | 154 | } |
155 | 155 | $this->garbage_collection_done = true; |
156 | 156 | |
157 | - if (count($appsessions) < 20) return; // we dont need to care |
|
157 | + if (count($appsessions) < 20) return; // we dont need to care |
|
158 | 158 | |
159 | - $now = (int) (100 * microtime(true)); // gives precision of 1/100 sec |
|
159 | + $now = (int)(100 * microtime(true)); // gives precision of 1/100 sec |
|
160 | 160 | |
161 | - foreach(array_keys($appsessions) as $id) |
|
161 | + foreach (array_keys($appsessions) as $id) |
|
162 | 162 | { |
163 | - list(,$time) = explode(':',$id); |
|
163 | + list(,$time) = explode(':', $id); |
|
164 | 164 | |
165 | - if (!$time) continue; // other data, no session |
|
165 | + if (!$time) continue; // other data, no session |
|
166 | 166 | |
167 | 167 | //echo ++$n.') '.$id.': '.(($now-$time)/100.0)."secs old, used=".$session_used[$id].", size=".strlen($appsessions[$id])."<br>\n"; |
168 | 168 | |
169 | - if ($session_used[$id] == 1 && $time < $now - 10*6000 || // session used and older then 10min |
|
170 | - $time < $now - 30*6000) // session not used and older then 30min |
|
169 | + if ($session_used[$id] == 1 && $time < $now - 10 * 6000 || // session used and older then 10min |
|
170 | + $time < $now - 30 * 6000) // session not used and older then 30min |
|
171 | 171 | { |
172 | 172 | //echo "<p>boetemplate::php4_session_garbage_collection('$id_used'): unsetting session '$id' (now=$now)</p>\n"; |
173 | 173 | unset($appsessions[$id]); |
@@ -58,7 +58,10 @@ discard block |
||
58 | 58 | */ |
59 | 59 | private function __construct($id=null) |
60 | 60 | { |
61 | - if (!$id) $id = self::request_id(); |
|
61 | + if (!$id) |
|
62 | + { |
|
63 | + $id = self::request_id(); |
|
64 | + } |
|
62 | 65 | |
63 | 66 | $this->id = $id; |
64 | 67 | } |
@@ -154,7 +157,11 @@ discard block |
||
154 | 157 | } |
155 | 158 | $this->garbage_collection_done = true; |
156 | 159 | |
157 | - if (count($appsessions) < 20) return; // we dont need to care |
|
160 | + if (count($appsessions) < 20) |
|
161 | + { |
|
162 | + return; |
|
163 | + } |
|
164 | + // we dont need to care |
|
158 | 165 | |
159 | 166 | $now = (int) (100 * microtime(true)); // gives precision of 1/100 sec |
160 | 167 | |
@@ -162,15 +169,22 @@ discard block |
||
162 | 169 | { |
163 | 170 | list(,$time) = explode(':',$id); |
164 | 171 | |
165 | - if (!$time) continue; // other data, no session |
|
172 | + if (!$time) |
|
173 | + { |
|
174 | + continue; |
|
175 | + } |
|
176 | + // other data, no session |
|
166 | 177 | |
167 | 178 | //echo ++$n.') '.$id.': '.(($now-$time)/100.0)."secs old, used=".$session_used[$id].", size=".strlen($appsessions[$id])."<br>\n"; |
168 | 179 | |
169 | 180 | if ($session_used[$id] == 1 && $time < $now - 10*6000 || // session used and older then 10min |
170 | - $time < $now - 30*6000) // session not used and older then 30min |
|
181 | + $time < $now - 30*6000) |
|
182 | + { |
|
183 | + // session not used and older then 30min |
|
171 | 184 | { |
172 | 185 | //echo "<p>boetemplate::php4_session_garbage_collection('$id_used'): unsetting session '$id' (now=$now)</p>\n"; |
173 | 186 | unset($appsessions[$id]); |
187 | + } |
|
174 | 188 | unset($session_used[$id]); |
175 | 189 | } |
176 | 190 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
43 | 43 | * @param array $content |
44 | 44 | * @param array &$validated=array() validated content |
45 | - * @return boolean true if no validation error, false otherwise |
|
45 | + * @return boolean|null true if no validation error, false otherwise |
|
46 | 46 | */ |
47 | 47 | public function validate($cname, array $expand, array $content, &$validated=array()) |
48 | 48 | { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param array &$validated=array() validated content |
41 | 41 | * @return boolean true if no validation error, false otherwise |
42 | 42 | */ |
43 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
43 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
44 | 44 | { |
45 | 45 | $form_name = self::form_name($cname, $this->id, $expand); |
46 | 46 | //error_log(__METHOD__."('$cname', ".array2string($expand).", ...) $this: get_array(\$content, '$form_name')=".array2string(self::get_array($content, $form_name))); |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | { |
50 | 50 | $value = self::get_array($content, $form_name); |
51 | 51 | |
52 | - if( |
|
52 | + if ( |
|
53 | 53 | // Handle case of not existing $row_cont[id], eg: create[] |
54 | 54 | is_array($value) && count($value) == 1 || |
55 | 55 | // check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]" |
56 | 56 | $value == true |
57 | 57 | ) |
58 | 58 | { |
59 | - $valid =& self::get_array($validated, $form_name, true); |
|
59 | + $valid = & self::get_array($validated, $form_name, true); |
|
60 | 60 | $valid = is_array($value) ? $value : 'pressed'; |
61 | 61 | |
62 | 62 | // recorded pressed button globally, was in the template object before, put now as static on this object |
63 | - if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name,-10) == '[cancel]') |
|
63 | + if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name, -10) == '[cancel]') |
|
64 | 64 | { |
65 | 65 | self::$canceled = true; |
66 | 66 | } |
@@ -72,4 +72,4 @@ discard block |
||
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | -etemplate_widget::registerWidget('etemplate_widget_button', array('button','buttononly')); |
|
75 | +etemplate_widget::registerWidget('etemplate_widget_button', array('button', 'buttononly')); |
@@ -54,8 +54,7 @@ |
||
54 | 54 | is_array($value) && count($value) == 1 || |
55 | 55 | // check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]" |
56 | 56 | $value == true |
57 | - ) |
|
58 | - { |
|
57 | + ) { |
|
59 | 58 | $valid =& self::get_array($validated, $form_name, true); |
60 | 59 | $valid = is_array($value) ? $value : 'pressed'; |
61 | 60 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
43 | 43 | * @param array $content |
44 | 44 | * @param array &$validated=array() validated content |
45 | - * @return boolean true if no validation error, false otherwise |
|
45 | + * @return boolean|null true if no validation error, false otherwise |
|
46 | 46 | */ |
47 | 47 | public function validate($cname, array $expand, array $content, &$validated=array()) |
48 | 48 | { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array &$validated=array() validated content |
45 | 45 | * @return boolean true if no validation error, false otherwise |
46 | 46 | */ |
47 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
47 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
48 | 48 | { |
49 | 49 | $form_name = self::form_name($cname, $this->id, $expand); |
50 | 50 | |
@@ -56,28 +56,28 @@ discard block |
||
56 | 56 | if (!$this->is_readonly($cname, $form_name)) |
57 | 57 | { |
58 | 58 | $value = self::get_array($content, $form_name); |
59 | - if (!isset($value)) return; // value not transmitted --> nothing to validate |
|
60 | - $valid =& self::get_array($validated, $form_name, true); |
|
59 | + if (!isset($value)) return; // value not transmitted --> nothing to validate |
|
60 | + $valid = & self::get_array($validated, $form_name, true); |
|
61 | 61 | |
62 | 62 | if (!$value && $this->attrs['needed']) |
63 | 63 | { |
64 | - self::set_validation_error($form_name,lang('Field must not be empty !!!'),''); |
|
64 | + self::set_validation_error($form_name, lang('Field must not be empty !!!'), ''); |
|
65 | 65 | } |
66 | 66 | $type = $this->type ? $this->type : $this->attrs['type']; |
67 | 67 | $value_attr = $type == 'radio' ? 'set_value' : 'selected_value'; |
68 | 68 | // defaults for set and unset values |
69 | 69 | $selected_value = true; |
70 | 70 | $unselected_value = false; |
71 | - if (array_key_exists($value_attr, $this->attrs) || array_key_exists('unselected_value',$this->attrs)) |
|
71 | + if (array_key_exists($value_attr, $this->attrs) || array_key_exists('unselected_value', $this->attrs)) |
|
72 | 72 | { |
73 | - if(array_key_exists($value_attr, $this->attrs)) |
|
73 | + if (array_key_exists($value_attr, $this->attrs)) |
|
74 | 74 | { |
75 | 75 | // Expand any content stuff |
76 | - $selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); |
|
76 | + $selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
|
77 | 77 | } |
78 | - if(array_key_exists('unselected_value',$this->attrs)) |
|
78 | + if (array_key_exists('unselected_value', $this->attrs)) |
|
79 | 79 | { |
80 | - $unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); |
|
80 | + $unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | if ($type == 'radio') |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | { |
88 | 88 | $valid = $value; |
89 | 89 | } |
90 | - elseif ( !$options && $selected_value && $value == $selected_value) |
|
90 | + elseif (!$options && $selected_value && $value == $selected_value) |
|
91 | 91 | { |
92 | 92 | // Options set in template, not in sel_options |
93 | 93 | $valid = $selected_value; |
94 | 94 | } |
95 | 95 | elseif (!isset($valid)) |
96 | 96 | { |
97 | - $valid = ''; // do not overwrite value of an other radio-button of the same group (identical name)! |
|
97 | + $valid = ''; // do not overwrite value of an other radio-button of the same group (identical name)! |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | elseif (in_array((string)$selected_value, (array)$value)) |
@@ -56,7 +56,11 @@ discard block |
||
56 | 56 | if (!$this->is_readonly($cname, $form_name)) |
57 | 57 | { |
58 | 58 | $value = self::get_array($content, $form_name); |
59 | - if (!isset($value)) return; // value not transmitted --> nothing to validate |
|
59 | + if (!isset($value)) |
|
60 | + { |
|
61 | + return; |
|
62 | + } |
|
63 | + // value not transmitted --> nothing to validate |
|
60 | 64 | $valid =& self::get_array($validated, $form_name, true); |
61 | 65 | |
62 | 66 | if (!$value && $this->attrs['needed']) |
@@ -101,7 +105,10 @@ discard block |
||
101 | 105 | { |
102 | 106 | if ($multiple) |
103 | 107 | { |
104 | - if (!isset($valid)) $valid = array(); |
|
108 | + if (!isset($valid)) |
|
109 | + { |
|
110 | + $valid = array(); |
|
111 | + } |
|
105 | 112 | $valid[] = $selected_value; |
106 | 113 | } |
107 | 114 | else |
@@ -113,7 +120,10 @@ discard block |
||
113 | 120 | { |
114 | 121 | if ($multiple) |
115 | 122 | { |
116 | - if (!isset($valid)) $valid = array(); |
|
123 | + if (!isset($valid)) |
|
124 | + { |
|
125 | + $valid = array(); |
|
126 | + } |
|
117 | 127 | } |
118 | 128 | elseif ($value === 'true') |
119 | 129 | { |
@@ -101,7 +101,6 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * Put date in the proper format for sending to client |
103 | 103 | * @param string|int $value |
104 | - * @param string $format |
|
105 | 104 | */ |
106 | 105 | public function format_date($value) |
107 | 106 | { |
@@ -139,7 +138,7 @@ discard block |
||
139 | 138 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
140 | 139 | * @param array $content |
141 | 140 | * @param array &$validated=array() validated content |
142 | - * @return boolean true if no validation error, false otherwise |
|
141 | + * @return boolean|null true if no validation error, false otherwise |
|
143 | 142 | */ |
144 | 143 | public function validate($cname, array $expand, array $content, &$validated=array()) |
145 | 144 | { |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | * @param string $cname |
57 | 57 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
58 | 58 | */ |
59 | - public function beforeSendToClient($cname, array $expand=null) |
|
59 | + public function beforeSendToClient($cname, array $expand = null) |
|
60 | 60 | { |
61 | - if($this->type == 'date-houronly') |
|
61 | + if ($this->type == 'date-houronly') |
|
62 | 62 | { |
63 | 63 | return parent::beforeSendToClient($cname, $expand); |
64 | 64 | } |
65 | 65 | |
66 | 66 | $form_name = self::form_name($cname, $this->id, $expand); |
67 | - $value =& self::get_array(self::$request->content, $form_name, false, true); |
|
67 | + $value = & self::get_array(self::$request->content, $form_name, false, true); |
|
68 | 68 | |
69 | - if($this->type != 'date-duration' && $value) |
|
69 | + if ($this->type != 'date-duration' && $value) |
|
70 | 70 | { |
71 | 71 | $value = $this->format_date($value); |
72 | 72 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function set_row_value($cname, Array $expand, Array &$data) |
88 | 88 | { |
89 | - if($this->type == 'date-duration') return; |
|
89 | + if ($this->type == 'date-duration') return; |
|
90 | 90 | |
91 | 91 | $form_name = self::form_name($cname, $this->id, $expand); |
92 | - $value =& $this->get_array($data, $form_name, true); |
|
92 | + $value = & $this->get_array($data, $form_name, true); |
|
93 | 93 | |
94 | 94 | $value = $this->format_date($value); |
95 | 95 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function format_date($value) |
103 | 103 | { |
104 | - if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
104 | + if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
105 | 105 | |
106 | 106 | if ($this->attrs['dataformat'] && !is_numeric($value)) |
107 | 107 | { |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | { |
112 | 112 | $date = new egw_time($value); |
113 | 113 | } |
114 | - if($this->type == 'date-timeonly') |
|
114 | + if ($this->type == 'date-timeonly') |
|
115 | 115 | { |
116 | 116 | $date->setDate(1970, 1, 1); |
117 | 117 | } |
118 | - if($date) |
|
118 | + if ($date) |
|
119 | 119 | { |
120 | 120 | // postfix date-string with "Z" so javascript doesn't add/subtract anything |
121 | 121 | $value = $date->format('Y-m-d\TH:i:s\Z'); |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | * @param array &$validated=array() validated content |
138 | 138 | * @return boolean true if no validation error, false otherwise |
139 | 139 | */ |
140 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
140 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
141 | 141 | { |
142 | 142 | $form_name = self::form_name($cname, $this->id, $expand); |
143 | 143 | |
144 | 144 | if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') // date-since is always readonly |
145 | 145 | { |
146 | 146 | $value = self::get_array($content, $form_name); |
147 | - $valid =& self::get_array($validated, $form_name, true); |
|
147 | + $valid = & self::get_array($validated, $form_name, true); |
|
148 | 148 | |
149 | 149 | if ((string)$value === '' && $this->attrs['needed']) |
150 | 150 | { |
151 | - self::set_validation_error($form_name,lang('Field must not be empty !!!')); |
|
151 | + self::set_validation_error($form_name, lang('Field must not be empty !!!')); |
|
152 | 152 | } |
153 | 153 | elseif (is_null($value)) |
154 | 154 | { |
@@ -158,49 +158,49 @@ discard block |
||
158 | 158 | { |
159 | 159 | $valid = (string)$value === '' ? '' : (int)$value; |
160 | 160 | } |
161 | - if($value) |
|
161 | + if ($value) |
|
162 | 162 | { |
163 | 163 | $date = new egw_time($value); |
164 | 164 | } |
165 | 165 | if (!empty($this->attrs['min'])) |
166 | 166 | { |
167 | - if(is_numeric($this->attrs['min'])) |
|
167 | + if (is_numeric($this->attrs['min'])) |
|
168 | 168 | { |
169 | - $min = new egw_time(strtotime( $this->attrs['min'] . 'days')); |
|
169 | + $min = new egw_time(strtotime($this->attrs['min'].'days')); |
|
170 | 170 | } |
171 | 171 | else |
172 | 172 | { |
173 | 173 | $min = new egw_time(strtotime($this->attrs['min'])); |
174 | 174 | } |
175 | - if($value < $min) |
|
175 | + if ($value < $min) |
|
176 | 176 | { |
177 | - self::set_validation_error($form_name,lang( |
|
177 | + self::set_validation_error($form_name, lang( |
|
178 | 178 | "Value has to be at least '%1' !!!", |
179 | 179 | $min->format($this->type != 'date') |
180 | - ),''); |
|
180 | + ), ''); |
|
181 | 181 | $value = $min; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | if (!empty($this->attrs['max'])) |
185 | 185 | { |
186 | - if(is_numeric($this->attrs['max'])) |
|
186 | + if (is_numeric($this->attrs['max'])) |
|
187 | 187 | { |
188 | - $max = new egw_time(strtotime( $this->attrs['max'] . 'days')); |
|
188 | + $max = new egw_time(strtotime($this->attrs['max'].'days')); |
|
189 | 189 | } |
190 | 190 | else |
191 | 191 | { |
192 | 192 | $max = new egw_time(strtotime($this->attrs['max'])); |
193 | 193 | } |
194 | - if($value < $max) |
|
194 | + if ($value < $max) |
|
195 | 195 | { |
196 | - self::set_validation_error($form_name,lang( |
|
196 | + self::set_validation_error($form_name, lang( |
|
197 | 197 | "Value has to be at maximum '%1' !!!", |
198 | 198 | $max->format($this->type != 'date') |
199 | - ),''); |
|
199 | + ), ''); |
|
200 | 200 | $value = $max; |
201 | 201 | } |
202 | 202 | } |
203 | - if(!$value) |
|
203 | + if (!$value) |
|
204 | 204 | { |
205 | 205 | // Not null, blank |
206 | 206 | $value = ''; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | else |
218 | 218 | { |
219 | 219 | // this is not really a user error, but one of the clientside engine |
220 | - self::set_validation_error($form_name,lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); |
|
220 | + self::set_validation_error($form_name, lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); |
|
221 | 221 | } |
222 | 222 | //error_log("$this : ($valid)" . egw_time::to($valid)); |
223 | 223 | } |
@@ -86,7 +86,10 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function set_row_value($cname, Array $expand, Array &$data) |
88 | 88 | { |
89 | - if($this->type == 'date-duration') return; |
|
89 | + if($this->type == 'date-duration') |
|
90 | + { |
|
91 | + return; |
|
92 | + } |
|
90 | 93 | |
91 | 94 | $form_name = self::form_name($cname, $this->id, $expand); |
92 | 95 | $value =& $this->get_array($data, $form_name, true); |
@@ -101,7 +104,11 @@ discard block |
||
101 | 104 | */ |
102 | 105 | public function format_date($value) |
103 | 106 | { |
104 | - if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
107 | + if (!$value) |
|
108 | + { |
|
109 | + return $value; |
|
110 | + } |
|
111 | + // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
105 | 112 | |
106 | 113 | if ($this->attrs['dataformat'] && !is_numeric($value)) |
107 | 114 | { |
@@ -141,9 +148,12 @@ discard block |
||
141 | 148 | { |
142 | 149 | $form_name = self::form_name($cname, $this->id, $expand); |
143 | 150 | |
144 | - if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') // date-since is always readonly |
|
151 | + if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') |
|
152 | + { |
|
153 | + // date-since is always readonly |
|
145 | 154 | { |
146 | 155 | $value = self::get_array($content, $form_name); |
156 | + } |
|
147 | 157 | $valid =& self::get_array($validated, $form_name, true); |
148 | 158 | |
149 | 159 | if ((string)$value === '' && $this->attrs['needed']) |
@@ -205,10 +215,13 @@ discard block |
||
205 | 215 | // Not null, blank |
206 | 216 | $value = ''; |
207 | 217 | } |
208 | - elseif (empty($this->attrs['dataformat'])) // integer timestamp |
|
218 | + elseif (empty($this->attrs['dataformat'])) |
|
219 | + { |
|
220 | + // integer timestamp |
|
209 | 221 | { |
210 | 222 | $valid = $date->format('ts'); |
211 | 223 | } |
224 | + } |
|
212 | 225 | // string with formatting letters like for php's date() method |
213 | 226 | elseif (($valid = $date->format($this->attrs['dataformat']))) |
214 | 227 | { |
@@ -88,7 +88,7 @@ |
||
88 | 88 | * @param array $data Row data |
89 | 89 | * @return type |
90 | 90 | */ |
91 | - public function set_row_value($cname, Array $expand, Array &$data) |
|
91 | + public function set_row_value($cname, array $expand, array &$data) |
|
92 | 92 | { |
93 | 93 | if($this->type == 'date-duration') return; |
94 | 94 |
@@ -57,8 +57,7 @@ |
||
57 | 57 | * - as a grid can contain other grid's as direct child, we have to backup and initialise $columns_disabled in grid run! |
58 | 58 | * |
59 | 59 | * @param string $method_name |
60 | - * @param array $params=array('') parameter(s) first parameter has to be the cname, second $expand! |
|
61 | - * @param boolean $respect_disabled=false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
|
60 | + * @param boolean $respect_disabled false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
|
62 | 61 | * @param array $columns_disabled=array() disabled columns |
63 | 62 | */ |
64 | 63 | public function run($method_name, $params=array(''), $respect_disabled=false, &$columns_disabled=array()) |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * @param boolean $respect_disabled=false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
62 | 62 | * @param array $columns_disabled=array() disabled columns |
63 | 63 | */ |
64 | - public function run($method_name, $params=array(''), $respect_disabled=false, &$columns_disabled=array()) |
|
64 | + public function run($method_name, $params = array(''), $respect_disabled = false, &$columns_disabled = array()) |
|
65 | 65 | { |
66 | 66 | // maintain $expand array name-expansion |
67 | - $cname =& $params[0]; |
|
68 | - $expand =& $params[1]; |
|
67 | + $cname = & $params[0]; |
|
68 | + $expand = & $params[1]; |
|
69 | 69 | $old_cname = $params[0]; |
70 | 70 | $old_expand = $params[1]; |
71 | 71 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | //error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running"); |
82 | 82 | $params[0] = $old_cname; |
83 | 83 | $params[1] = $old_expand; |
84 | - return false; // return |
|
84 | + return false; // return |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | if ($this->id) $cname = self::form_name($cname, $this->id, $expand); |
88 | 88 | if ($expand['cname'] !== $cname && $cname) |
89 | 89 | { |
90 | - $expand['cont'] =& self::get_array(self::$request->content, $cname); |
|
90 | + $expand['cont'] = & self::get_array(self::$request->content, $cname); |
|
91 | 91 | $expand['cname'] = $cname; |
92 | 92 | } |
93 | 93 | |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | } |
98 | 98 | //foreach($this->children as $n => $child) |
99 | 99 | $repeat_child = null; |
100 | - for($n = 0; ; ++$n) |
|
100 | + for ($n = 0; ; ++$n) |
|
101 | 101 | { |
102 | 102 | // maintain $expand array name-expansion |
103 | - switch($this->type) |
|
103 | + switch ($this->type) |
|
104 | 104 | { |
105 | 105 | case 'rows': |
106 | 106 | $expand['row'] = $n; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if (isset($this->children[$n])) |
113 | 113 | { |
114 | 114 | $child = $this->children[$n]; |
115 | - if($this->type == 'rows' || $this->type == 'columns') |
|
115 | + if ($this->type == 'rows' || $this->type == 'columns') |
|
116 | 116 | { |
117 | 117 | /* |
118 | 118 | * We store a clone of the repeated child, because at the end |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if (in_array($n, $columns_disabled)) |
140 | 140 | { |
141 | 141 | //error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this column $n is disabled: NOT running"); |
142 | - continue; // do NOT run $method_name on disabled columns |
|
142 | + continue; // do NOT run $method_name on disabled columns |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | //error_log('Running ' . $method_name . ' on child ' . $n . '(' . $child . ') ['.$expand['row'] . ','.$expand['c'] . ']'); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | if ($this->type == 'columns' && $disabled) |
149 | 149 | { |
150 | - $columns_disabled[] = $n; // mark column as disabled |
|
150 | + $columns_disabled[] = $n; // mark column as disabled |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | if ($this->type == 'grid') |
@@ -171,34 +171,34 @@ discard block |
||
171 | 171 | private function need_autorepeat($cname, array $expand) |
172 | 172 | { |
173 | 173 | // check id's of children |
174 | - foreach($this->children as $n => $direct_child) |
|
174 | + foreach ($this->children as $n => $direct_child) |
|
175 | 175 | { |
176 | - foreach(array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child) |
|
176 | + foreach (array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child) |
|
177 | 177 | { |
178 | 178 | $pat = $child->id; |
179 | - while(($pat = strstr($pat, '$'))) |
|
179 | + while (($pat = strstr($pat, '$'))) |
|
180 | 180 | { |
181 | - $pat = substr($pat,$pat[1] == '{' ? 2 : 1); |
|
181 | + $pat = substr($pat, $pat[1] == '{' ? 2 : 1); |
|
182 | 182 | |
183 | 183 | switch ($this->type) |
184 | 184 | { |
185 | 185 | case 'column': |
186 | - $Ok = $pat[0] == 'c' && !(substr($pat,0,4) == 'cont' || substr($pat,0,2) == 'c_' || |
|
187 | - substr($pat,0,4) == 'col_'); |
|
186 | + $Ok = $pat[0] == 'c' && !(substr($pat, 0, 4) == 'cont' || substr($pat, 0, 2) == 'c_' || |
|
187 | + substr($pat, 0, 4) == 'col_'); |
|
188 | 188 | break; |
189 | 189 | case 'row': |
190 | - $Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' || |
|
191 | - substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont'); |
|
190 | + $Ok = $pat[0] == 'r' && !(substr($pat, 0, 2) == 'r_' || |
|
191 | + substr($pat, 0, 4) == 'row_' && substr($pat, 0, 8) != 'row_cont'); |
|
192 | 192 | //error_log(__METHOD__."() pat='$pat' --> Ok=".array2string($Ok)); |
193 | 193 | break; |
194 | 194 | default: |
195 | 195 | return false; |
196 | 196 | } |
197 | - if ($Ok && ($fname=self::form_name($cname, $child->id, $expand)) && |
|
197 | + if ($Ok && ($fname = self::form_name($cname, $child->id, $expand)) && |
|
198 | 198 | // need to break if fname ends in [] as get_array() will ignore it and returns whole array |
199 | 199 | // for an id like "run[$row_cont[appname]]" |
200 | 200 | substr($fname, -2) != '[]' && |
201 | - ($value = self::get_array(self::$request->content,$fname)) !== null) // null = not found (can be false!) |
|
201 | + ($value = self::get_array(self::$request->content, $fname)) !== null) // null = not found (can be false!) |
|
202 | 202 | { |
203 | 203 | //error_log(__METHOD__."('$cname', ) $this autorepeating row $expand[row] because of $child->id = '$fname' is ".array2string($value)); |
204 | 204 | return true; |
@@ -88,7 +88,10 @@ discard block |
||
88 | 88 | return false; // return |
89 | 89 | } |
90 | 90 | |
91 | - if ($this->id) $cname = self::form_name($cname, $this->id, $expand); |
|
91 | + if ($this->id) |
|
92 | + { |
|
93 | + $cname = self::form_name($cname, $this->id, $expand); |
|
94 | + } |
|
92 | 95 | if ($expand['cname'] !== $cname && $cname) |
93 | 96 | { |
94 | 97 | $expand['cont'] =& self::get_array(self::$request->content, $cname); |
@@ -202,10 +205,13 @@ discard block |
||
202 | 205 | // need to break if fname ends in [] as get_array() will ignore it and returns whole array |
203 | 206 | // for an id like "run[$row_cont[appname]]" |
204 | 207 | substr($fname, -2) != '[]' && |
205 | - ($value = self::get_array(self::$request->content,$fname)) !== null) // null = not found (can be false!) |
|
208 | + ($value = self::get_array(self::$request->content,$fname)) !== null) |
|
209 | + { |
|
210 | + // null = not found (can be false!) |
|
206 | 211 | { |
207 | 212 | //error_log(__METHOD__."('$cname', ) $this autorepeating row $expand[row] because of $child->id = '$fname' is ".array2string($value)); |
208 | 213 | unset($value); |
214 | + } |
|
209 | 215 | return true; |
210 | 216 | } |
211 | 217 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
43 | 43 | * @param array $content |
44 | 44 | * @param array &$validated=array() validated content |
45 | - * @return boolean true if no validation error, false otherwise |
|
45 | + * @return boolean|null true if no validation error, false otherwise |
|
46 | 46 | */ |
47 | 47 | public function validate($cname, array $expand, array $content, &$validated=array()) |
48 | 48 | { |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | $form_name = self::form_name($cname, $this->id); |
39 | 39 | |
40 | 40 | $config = Api\Html\CkEditorConfig::get_ckeditor_config_array($this->attrs['mode'], $this->attrs['height'], |
41 | - $this->attrs['expand_toolbar'],$this->attrs['base_href'] |
|
41 | + $this->attrs['expand_toolbar'], $this->attrs['base_href'] |
|
42 | 42 | ); |
43 | 43 | // User preferences |
44 | 44 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
45 | 45 | $font_size = Api\Html\CkEditorConfig::font_size_from_prefs(); |
46 | 46 | $font_span = '<span style="width: 100%; display: inline; '. |
47 | - ($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':''). |
|
47 | + ($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : ''). |
|
48 | 48 | '">​</span>'; |
49 | 49 | if (empty($font) && empty($font_size)) $font_span = ''; |
50 | - if($font_span) |
|
50 | + if ($font_span) |
|
51 | 51 | { |
52 | 52 | $config['preference_style'] = $font_span; |
53 | 53 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array &$validated=array() validated content |
66 | 66 | * @return boolean true if no validation error, false otherwise |
67 | 67 | */ |
68 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
68 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
69 | 69 | { |
70 | 70 | $form_name = self::form_name($cname, $this->id, $expand); |
71 | 71 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $value = Api\Html\HtmLawed::purify($value, $this->attrs['validation_rules']); |
79 | 79 | } |
80 | - $valid =& self::get_array($validated, $form_name, true); |
|
80 | + $valid = & self::get_array($validated, $form_name, true); |
|
81 | 81 | if (true) $valid = $value; |
82 | 82 | } |
83 | 83 | } |
@@ -46,7 +46,10 @@ discard block |
||
46 | 46 | $font_span = '<span style="width: 100%; display: inline; '. |
47 | 47 | ($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':''). |
48 | 48 | '">​</span>'; |
49 | - if (empty($font) && empty($font_size)) $font_span = ''; |
|
49 | + if (empty($font) && empty($font_size)) |
|
50 | + { |
|
51 | + $font_span = ''; |
|
52 | + } |
|
50 | 53 | if($font_span) |
51 | 54 | { |
52 | 55 | $config['preference_style'] = $font_span; |
@@ -78,7 +81,10 @@ discard block |
||
78 | 81 | $value = Api\Html\HtmLawed::purify($value, $this->attrs['validation_rules']); |
79 | 82 | } |
80 | 83 | $valid =& self::get_array($validated, $form_name, true); |
81 | - if (true) $valid = $value; |
|
84 | + if (true) |
|
85 | + { |
|
86 | + $valid = $value; |
|
87 | + } |
|
82 | 88 | } |
83 | 89 | } |
84 | 90 | } |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | * content. This prevents running the method on disabled tabs. |
35 | 35 | * |
36 | 36 | * @param string $method_name |
37 | - * @param array $params=array('') parameter(s) first parameter has to be the cname, second $expand! |
|
38 | - * @param boolean $respect_disabled=false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
|
37 | + * @param boolean $respect_disabled false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
|
39 | 38 | */ |
40 | 39 | public function run($method_name, $params=array(''), $respect_disabled=false) |
41 | 40 | { |
@@ -87,7 +86,6 @@ discard block |
||
87 | 86 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
88 | 87 | * @param array $content |
89 | 88 | * @param array &$validated=array() validated content |
90 | - * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
91 | 89 | */ |
92 | 90 | public function validate($cname, array $expand, array $content, &$validated=array()) |
93 | 91 | { |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | * @param array $params=array('') parameter(s) first parameter has to be the cname, second $expand! |
38 | 38 | * @param boolean $respect_disabled=false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
39 | 39 | */ |
40 | - public function run($method_name, $params=array(''), $respect_disabled=false) |
|
40 | + public function run($method_name, $params = array(''), $respect_disabled = false) |
|
41 | 41 | { |
42 | 42 | |
43 | 43 | // Make sure additional tabs are processed for any method |
44 | - if($this->attrs['tabs'] && !$this->tabs_attr_evaluated) |
|
44 | + if ($this->attrs['tabs'] && !$this->tabs_attr_evaluated) |
|
45 | 45 | { |
46 | - $this->tabs_attr_evaluated = true; // we must not evaluate tabs attribte more then once! |
|
46 | + $this->tabs_attr_evaluated = true; // we must not evaluate tabs attribte more then once! |
|
47 | 47 | |
48 | 48 | // add_tabs toggles replacing or adding to existing tabs |
49 | - if(!$this->attrs['add_tabs']) |
|
49 | + if (!$this->attrs['add_tabs']) |
|
50 | 50 | { |
51 | 51 | $this->children[1]->children = array(); |
52 | 52 | } |
53 | 53 | |
54 | - foreach($this->attrs['tabs'] as $tab) |
|
54 | + foreach ($this->attrs['tabs'] as $tab) |
|
55 | 55 | { |
56 | - $template= clone etemplate_widget_template::instance($tab['template']); |
|
57 | - if($tab['id']) $template->attrs['content'] = $tab['id']; |
|
56 | + $template = clone etemplate_widget_template::instance($tab['template']); |
|
57 | + if ($tab['id']) $template->attrs['content'] = $tab['id']; |
|
58 | 58 | $this->children[1]->children[] = $template; |
59 | 59 | unset($template); |
60 | 60 | } |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | // Check for disabled tabs set via readonly, and set them as disabled |
64 | 64 | $form_name = self::form_name($params[0], $this->id, $params[1]); |
65 | 65 | $readonlys = self::get_array(self::$request->readonlys, $form_name); |
66 | - if($respect_disabled && $readonlys) |
|
66 | + if ($respect_disabled && $readonlys) |
|
67 | 67 | { |
68 | - foreach($this->children[1]->children as $tab) |
|
68 | + foreach ($this->children[1]->children as $tab) |
|
69 | 69 | { |
70 | - $ro_id = explode('.',$tab->template ? $tab->template : $tab->id); |
|
71 | - $ro_id = $ro_id[count($ro_id)-1]; |
|
72 | - if($readonlys[$ro_id]) |
|
70 | + $ro_id = explode('.', $tab->template ? $tab->template : $tab->id); |
|
71 | + $ro_id = $ro_id[count($ro_id) - 1]; |
|
72 | + if ($readonlys[$ro_id]) |
|
73 | 73 | { |
74 | 74 | $tab->attrs['disabled'] = $readonlys[$ro_id]; |
75 | 75 | } |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | * @param array &$validated=array() validated content |
90 | 90 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
91 | 91 | */ |
92 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
92 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
93 | 93 | { |
94 | 94 | $form_name = self::form_name($cname, $this->id, $expand); |
95 | 95 | |
96 | 96 | if (!empty($form_name)) |
97 | 97 | { |
98 | 98 | $value = self::get_array($content, $form_name); |
99 | - $valid =& self::get_array($validated, $form_name, true); |
|
99 | + $valid = & self::get_array($validated, $form_name, true); |
|
100 | 100 | if (true) $valid = $value; |
101 | 101 | } |
102 | 102 | } |
@@ -65,7 +65,10 @@ discard block |
||
65 | 65 | foreach($tabs as &$tab) |
66 | 66 | { |
67 | 67 | $template= clone Template::instance($tab['template']); |
68 | - if($tab['id']) $template->attrs['content'] = $tab['id']; |
|
68 | + if($tab['id']) |
|
69 | + { |
|
70 | + $template->attrs['content'] = $tab['id']; |
|
71 | + } |
|
69 | 72 | $this->children[1]->children[] = $template; |
70 | 73 | $tab['url'] = Template::rel2url($template->rel_path); |
71 | 74 | //$this->tabs[] = $tab; |
@@ -112,7 +115,10 @@ discard block |
||
112 | 115 | { |
113 | 116 | $value = self::get_array($content, $form_name); |
114 | 117 | $valid =& self::get_array($validated, $form_name, true); |
115 | - if (true) $valid = $value; |
|
118 | + if (true) |
|
119 | + { |
|
120 | + $valid = $value; |
|
121 | + } |
|
116 | 122 | } |
117 | 123 | } |
118 | 124 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * Reimplemented to handle legacy read-only by setting size < 0 |
50 | 50 | * |
51 | 51 | * @param string|XMLReader $xml |
52 | - * @param boolean $cloned=true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
|
53 | - * @return etemplate_widget_template current object or clone, if any attribute was set |
|
52 | + * @param boolean $cloned true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
|
53 | + * @return etemplate_widget_textbox current object or clone, if any attribute was set |
|
54 | 54 | */ |
55 | 55 | public function set_attrs($xml, $cloned=true) |
56 | 56 | { |
@@ -105,7 +105,6 @@ discard block |
||
105 | 105 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
106 | 106 | * @param array $content |
107 | 107 | * @param array &$validated=array() validated content |
108 | - * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
109 | 108 | */ |
110 | 109 | public function validate($cname, array $expand, array $content, &$validated=array()) |
111 | 110 | { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param boolean $cloned=true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
53 | 53 | * @return etemplate_widget_template current object or clone, if any attribute was set |
54 | 54 | */ |
55 | - public function set_attrs($xml, $cloned=true) |
|
55 | + public function set_attrs($xml, $cloned = true) |
|
56 | 56 | { |
57 | 57 | parent::set_attrs($xml, $cloned); |
58 | 58 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->setElementAttribute($this->id, 'size', abs($this->attrs['size'])); |
65 | 65 | self::$request->readonlys[$this->id] = false; |
66 | 66 | $this->setElementAttribute($this->id, 'readonly', true); |
67 | - trigger_error("Using a negative size to set textbox readonly. " .$this, E_USER_DEPRECATED); |
|
67 | + trigger_error("Using a negative size to set textbox readonly. ".$this, E_USER_DEPRECATED); |
|
68 | 68 | } |
69 | 69 | return $this; |
70 | 70 | } |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | * @param string $cname |
76 | 76 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
77 | 77 | */ |
78 | - public function beforeSendToClient($cname, array $expand=null) |
|
78 | + public function beforeSendToClient($cname, array $expand = null) |
|
79 | 79 | { |
80 | 80 | // to NOT transmit passwords back to client, we need to store (non-empty) value in preserv |
81 | 81 | if ($this->attrs['type'] == 'passwd' || $this->type == 'passwd') |
82 | 82 | { |
83 | 83 | $form_name = self::form_name($cname, $this->id, $expand); |
84 | - $value =& self::get_array(self::$request->content, $form_name); |
|
84 | + $value = & self::get_array(self::$request->content, $form_name); |
|
85 | 85 | if (!empty($value)) |
86 | 86 | { |
87 | - $preserv =& self::get_array(self::$request->preserv, $form_name, true); |
|
87 | + $preserv = & self::get_array(self::$request->preserv, $form_name, true); |
|
88 | 88 | if (true) $preserv = (string)$value; |
89 | 89 | $value = str_repeat('*', strlen($preserv)); |
90 | 90 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param array &$validated=array() validated content |
108 | 108 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
109 | 109 | */ |
110 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
110 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
111 | 111 | { |
112 | 112 | $form_name = self::form_name($cname, $this->id, $expand); |
113 | 113 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | if (!isset($this->attrs['validator'])) |
117 | 117 | { |
118 | - switch($this->type) |
|
118 | + switch ($this->type) |
|
119 | 119 | { |
120 | 120 | case 'int': |
121 | 121 | case 'integer': |
@@ -145,24 +145,24 @@ discard block |
||
145 | 145 | |
146 | 146 | if ((string)$value === '' && $this->attrs['needed']) |
147 | 147 | { |
148 | - self::set_validation_error($form_name,lang('Field must not be empty !!!'),''); |
|
148 | + self::set_validation_error($form_name, lang('Field must not be empty !!!'), ''); |
|
149 | 149 | } |
150 | - if ((int) $this->attrs['maxlength'] > 0 && mb_strlen($value) > (int) $this->attrs['maxlength']) |
|
150 | + if ((int)$this->attrs['maxlength'] > 0 && mb_strlen($value) > (int)$this->attrs['maxlength']) |
|
151 | 151 | { |
152 | - $value = mb_substr($value,0,(int) $this->attrs['maxlength']); |
|
152 | + $value = mb_substr($value, 0, (int)$this->attrs['maxlength']); |
|
153 | 153 | } |
154 | - if ($this->attrs['validator'] && !preg_match($this->attrs['validator'],$value)) |
|
154 | + if ($this->attrs['validator'] && !preg_match($this->attrs['validator'], $value)) |
|
155 | 155 | { |
156 | - switch($this->type) |
|
156 | + switch ($this->type) |
|
157 | 157 | { |
158 | 158 | case 'integer': |
159 | - self::set_validation_error($form_name,lang("'%1' is not a valid integer !!!",$value),''); |
|
159 | + self::set_validation_error($form_name, lang("'%1' is not a valid integer !!!", $value), ''); |
|
160 | 160 | break; |
161 | 161 | case 'float': |
162 | - self::set_validation_error($form_name,lang("'%1' is not a valid floatingpoint number !!!",$value),''); |
|
162 | + self::set_validation_error($form_name, lang("'%1' is not a valid floatingpoint number !!!", $value), ''); |
|
163 | 163 | break; |
164 | 164 | default: |
165 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$this->attrs[validator]', '$value')"*/,''); |
|
165 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$this->attrs[validator]', '$value')"*/, ''); |
|
166 | 166 | break; |
167 | 167 | } |
168 | 168 | } |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | { |
171 | 171 | if ((string)$value !== '' || $this->attrs['needed']) // empty values are Ok if needed is not set |
172 | 172 | { |
173 | - $value = $this->type == 'integer' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format |
|
173 | + $value = $this->type == 'integer' ? (int)$value : (float)str_replace(',', '.', $value); // allow for german (and maybe other) format |
|
174 | 174 | |
175 | 175 | if (!empty($this->attrs['min']) && $value < $this->attrs['min']) |
176 | 176 | { |
177 | - self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$this->attrs['min']),''); |
|
178 | - $value = $this->type == 'integer' ? (int) $this->attrs['min'] : (float) $this->attrs['min']; |
|
177 | + self::set_validation_error($form_name, lang("Value has to be at least '%1' !!!", $this->attrs['min']), ''); |
|
178 | + $value = $this->type == 'integer' ? (int)$this->attrs['min'] : (float)$this->attrs['min']; |
|
179 | 179 | } |
180 | 180 | if (!empty($this->attrs['max']) && $value > $this->attrs['max']) |
181 | 181 | { |
182 | - self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$this->attrs['max']),''); |
|
183 | - $value = $this->type == 'integer' ? (int) $this->attrs['max'] : (float) $this->attrs['max']; |
|
182 | + self::set_validation_error($form_name, lang("Value has to be at maximum '%1' !!!", $this->attrs['max']), ''); |
|
183 | + $value = $this->type == 'integer' ? (int)$this->attrs['max'] : (float)$this->attrs['max']; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
@@ -192,4 +192,4 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | -etemplate_widget::registerWidget('etemplate_widget_textbox', array('textbox','text','int','integer','float','passwd','hidden','colorpicker','hidden')); |
|
195 | +etemplate_widget::registerWidget('etemplate_widget_textbox', array('textbox', 'text', 'int', 'integer', 'float', 'passwd', 'hidden', 'colorpicker', 'hidden')); |
@@ -41,7 +41,10 @@ discard block |
||
41 | 41 | // normalize types |
42 | 42 | if ($this->type !== 'textbox') |
43 | 43 | { |
44 | - if ($this->type == 'int') $this->type = 'integer'; |
|
44 | + if ($this->type == 'int') |
|
45 | + { |
|
46 | + $this->type = 'integer'; |
|
47 | + } |
|
45 | 48 | |
46 | 49 | $this->attrs['type'] = $this->type; |
47 | 50 | $this->type = 'textbox'; |
@@ -90,7 +93,10 @@ discard block |
||
90 | 93 | if (!empty($value)) |
91 | 94 | { |
92 | 95 | $preserv =& self::get_array(self::$request->preserv, $form_name, true); |
93 | - if (true) $preserv = (string)$value; |
|
96 | + if (true) |
|
97 | + { |
|
98 | + $preserv = (string)$value; |
|
99 | + } |
|
94 | 100 | $value = str_repeat('*', strlen($preserv)); |
95 | 101 | } |
96 | 102 | } |
@@ -171,11 +177,15 @@ discard block |
||
171 | 177 | break; |
172 | 178 | } |
173 | 179 | } |
174 | - elseif ($this->type == 'integer' || $this->type == 'float') // cast int and float and check range |
|
180 | + elseif ($this->type == 'integer' || $this->type == 'float') |
|
181 | + { |
|
182 | + // cast int and float and check range |
|
175 | 183 | { |
176 | 184 | if ((string)$value !== '' || $this->attrs['needed']) // empty values are Ok if needed is not set |
177 | 185 | { |
178 | - $value = $this->type == 'integer' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format |
|
186 | + $value = $this->type == 'integer' ? (int) $value : (float) str_replace(',','.',$value); |
|
187 | + } |
|
188 | + // allow for german (and maybe other) format |
|
179 | 189 | |
180 | 190 | if (!empty($this->attrs['min']) && $value < $this->attrs['min']) |
181 | 191 | { |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
43 | 43 | * @param array $content |
44 | 44 | * @param array &$validated=array() validated content |
45 | - * @return boolean true if no validation error, false otherwise |
|
45 | + * @return boolean|null true if no validation error, false otherwise |
|
46 | 46 | */ |
47 | 47 | public function validate($cname, array $expand, array $content, &$validated=array()) |
48 | 48 | { |
@@ -29,14 +29,14 @@ |
||
29 | 29 | * @param array &$validated=array() validated content |
30 | 30 | * @return boolean true if no validation error, false otherwise |
31 | 31 | */ |
32 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
32 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
33 | 33 | { |
34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
35 | 35 | |
36 | 36 | if (!$this->is_readonly($cname, $form_name)) |
37 | 37 | { |
38 | 38 | $value = self::get_array($content, $form_name); |
39 | - $valid =& self::get_array($validated, $form_name, true); |
|
39 | + $valid = & self::get_array($validated, $form_name, true); |
|
40 | 40 | if (true) $valid = $value; |
41 | 41 | } |
42 | 42 | } |
@@ -37,7 +37,10 @@ |
||
37 | 37 | { |
38 | 38 | $value = self::get_array($content, $form_name); |
39 | 39 | $valid =& self::get_array($validated, $form_name, true); |
40 | - if (true) $valid = $value; |
|
40 | + if (true) |
|
41 | + { |
|
42 | + $valid = $value; |
|
43 | + } |
|
41 | 44 | } |
42 | 45 | } |
43 | 46 | } |