@@ -543,7 +543,7 @@ |
||
| 543 | 543 | * |
| 544 | 544 | * @param string $name cell-name |
| 545 | 545 | * @param string $attr attribute-name |
| 546 | - * @param mixed $val if not NULL sets attribute else returns it |
|
| 546 | + * @param boolean|string $val if not NULL sets attribute else returns it |
|
| 547 | 547 | * @return reference to attribute |
| 548 | 548 | * @deprecated use setElementAttribute($name, $attr, $val) |
| 549 | 549 | */ |
@@ -47,14 +47,24 @@ discard block |
||
| 47 | 47 | function __construct($name='',$load_via='') |
| 48 | 48 | { |
| 49 | 49 | // we do NOT call parent consturctor, as we only want to enherit it's (static) methods |
| 50 | - if (false) parent::__construct ($name); // satisfy IDE, as we dont call parent constructor |
|
| 50 | + if (false) |
|
| 51 | + { |
|
| 52 | + parent::__construct ($name); |
|
| 53 | + } |
|
| 54 | + // satisfy IDE, as we dont call parent constructor |
|
| 51 | 55 | |
| 52 | 56 | $this->sitemgr = isset($GLOBALS['Common_BO']) && is_object($GLOBALS['Common_BO']); |
| 53 | 57 | |
| 54 | - if ($name) $this->read($name,$template='default','default',0,'',$load_via); |
|
| 58 | + if ($name) |
|
| 59 | + { |
|
| 60 | + $this->read($name,$template='default','default',0,'',$load_via); |
|
| 61 | + } |
|
| 55 | 62 | |
| 56 | 63 | // generate new etemplate request object, if not already existing |
| 57 | - if(!isset(self::$request)) self::$request = Etemplate\Request::read(); |
|
| 64 | + if(!isset(self::$request)) |
|
| 65 | + { |
|
| 66 | + self::$request = Etemplate\Request::read(); |
|
| 67 | + } |
|
| 58 | 68 | } |
| 59 | 69 | |
| 60 | 70 | /** |
@@ -111,7 +121,10 @@ discard block |
||
| 111 | 121 | |
| 112 | 122 | foreach($hook_data as $extras) |
| 113 | 123 | { |
| 114 | - if (!$extras) continue; |
|
| 124 | + if (!$extras) |
|
| 125 | + { |
|
| 126 | + continue; |
|
| 127 | + } |
|
| 115 | 128 | |
| 116 | 129 | foreach(isset($extras[0]) ? $extras : array($extras) as $extra) |
| 117 | 130 | { |
@@ -136,7 +149,10 @@ discard block |
||
| 136 | 149 | // Include the etemplate2 javascript code |
| 137 | 150 | Framework::includeJS('etemplate', 'etemplate2', 'api'); |
| 138 | 151 | |
| 139 | - if (!$this->rel_path) throw new Exception\AssertionFailed("No (valid) template '$this->name' found!"); |
|
| 152 | + if (!$this->rel_path) |
|
| 153 | + { |
|
| 154 | + throw new Exception\AssertionFailed("No (valid) template '$this->name' found!"); |
|
| 155 | + } |
|
| 140 | 156 | |
| 141 | 157 | if ($output_mode == 4) |
| 142 | 158 | { |
@@ -151,14 +167,23 @@ discard block |
||
| 151 | 167 | self::$request->preserv = $preserv ? $preserv : array(); |
| 152 | 168 | self::$request->method = $method; |
| 153 | 169 | self::$request->ignore_validation = $ignore_validation; |
| 154 | - if (self::$request->output_mode == -1) self::$request->output_mode = 0; |
|
| 170 | + if (self::$request->output_mode == -1) |
|
| 171 | + { |
|
| 172 | + self::$request->output_mode = 0; |
|
| 173 | + } |
|
| 155 | 174 | self::$request->template = $this->as_array(); |
| 156 | 175 | |
| 157 | - if (empty($this->name)) throw new Exception\AssertionFailed("Template name is not set '$this->name' !"); |
|
| 176 | + if (empty($this->name)) |
|
| 177 | + { |
|
| 178 | + throw new Exception\AssertionFailed("Template name is not set '$this->name' !"); |
|
| 179 | + } |
|
| 158 | 180 | // instanciate template to fill self::$request->sel_options for select-* widgets |
| 159 | 181 | // not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes |
| 160 | 182 | $template = self::instance($this->name, $this->template_set, $this->version, $this->laod_via); |
| 161 | - if (!$template) throw new Exception\AssertionFailed("Template $this->name not instanciable! Maybe you forgot to rename template id."); |
|
| 183 | + if (!$template) |
|
| 184 | + { |
|
| 185 | + throw new Exception\AssertionFailed("Template $this->name not instanciable! Maybe you forgot to rename template id."); |
|
| 186 | + } |
|
| 162 | 187 | $template->run('beforeSendToClient', array('', array('cont'=>$content))); |
| 163 | 188 | |
| 164 | 189 | // some apps (eg. InfoLog) set app_header only in get_rows depending on filter settings |
@@ -202,10 +227,13 @@ discard block |
||
| 202 | 227 | 'data' => $data, |
| 203 | 228 | 'DOMNodeID' => $dom_id, |
| 204 | 229 | ); |
| 205 | - if (self::$response) // call is within an ajax event / form submit |
|
| 230 | + if (self::$response) |
|
| 231 | + { |
|
| 232 | + // call is within an ajax event / form submit |
|
| 206 | 233 | { |
| 207 | 234 | //error_log("Ajax " . __LINE__); |
| 208 | 235 | self::$response->generic('et2_load', $load_array+Framework::get_extra()); |
| 236 | + } |
|
| 209 | 237 | Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view) |
| 210 | 238 | } |
| 211 | 239 | else // first call |
@@ -287,7 +315,10 @@ discard block |
||
| 287 | 315 | { |
| 288 | 316 | foreach($sel_options as &$options) |
| 289 | 317 | { |
| 290 | - if (!is_array($options)||empty($options)) continue; |
|
| 318 | + if (!is_array($options)||empty($options)) |
|
| 319 | + { |
|
| 320 | + continue; |
|
| 321 | + } |
|
| 291 | 322 | foreach($options as $key => $value) |
| 292 | 323 | { |
| 293 | 324 | if (is_numeric($key) && (!is_array($value) || !isset($value['value']))) |
@@ -325,7 +356,10 @@ discard block |
||
| 325 | 356 | |
| 326 | 357 | // Set current app for validation |
| 327 | 358 | list($app) = explode('.',self::$request->method); |
| 328 | - if(!$app) list($app) = explode('::',self::$request->method); |
|
| 359 | + if(!$app) |
|
| 360 | + { |
|
| 361 | + list($app) = explode('::',self::$request->method); |
|
| 362 | + } |
|
| 329 | 363 | if($app) |
| 330 | 364 | { |
| 331 | 365 | Translation::add_app($app); |
@@ -356,7 +390,10 @@ discard block |
||
| 356 | 390 | 'location_name' => $template->id, |
| 357 | 391 | ) + self::complete_array_merge(self::$request->preserv, $validated)) as $extras) |
| 358 | 392 | { |
| 359 | - if (!$extras) continue; |
|
| 393 | + if (!$extras) |
|
| 394 | + { |
|
| 395 | + continue; |
|
| 396 | + } |
|
| 360 | 397 | |
| 361 | 398 | foreach(isset($extras[0]) ? $extras : array($extras) as $extra) |
| 362 | 399 | { |
@@ -386,10 +423,15 @@ discard block |
||
| 386 | 423 | { |
| 387 | 424 | foreach($hook_data as $extras) |
| 388 | 425 | { |
| 389 | - if (!$extras) continue; |
|
| 426 | + if (!$extras) |
|
| 427 | + { |
|
| 428 | + continue; |
|
| 429 | + } |
|
| 390 | 430 | |
| 391 | - foreach(isset($extras[0]) ? $extras : array($extras) as $extra) { |
|
| 392 | - if ($extra['data'] && is_array($extra['data'])) { |
|
| 431 | + foreach(isset($extras[0]) ? $extras : array($extras) as $extra) |
|
| 432 | + { |
|
| 433 | + if ($extra['data'] && is_array($extra['data'])) |
|
| 434 | + { |
|
| 393 | 435 | $content = array_merge($content, $extra['data']); |
| 394 | 436 | } |
| 395 | 437 | } |
@@ -428,7 +470,10 @@ discard block |
||
| 428 | 470 | */ |
| 429 | 471 | static public function process_exec() |
| 430 | 472 | { |
| 431 | - if (get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']); |
|
| 473 | + if (get_magic_quotes_gpc()) |
|
| 474 | + { |
|
| 475 | + $_POST['value'] = stripslashes($_POST['value']); |
|
| 476 | + } |
|
| 432 | 477 | $content = json_decode($_POST['value'],true); |
| 433 | 478 | //error_log(__METHOD__."(".array2string($content).")"); |
| 434 | 479 | |
@@ -580,16 +625,22 @@ discard block |
||
| 580 | 625 | { |
| 581 | 626 | if (is_array($new)) |
| 582 | 627 | { |
| 583 | - if (!is_array($old)) $old = (array) $old; |
|
| 628 | + if (!is_array($old)) |
|
| 629 | + { |
|
| 630 | + $old = (array) $old; |
|
| 631 | + } |
|
| 584 | 632 | |
| 585 | 633 | foreach($new as $k => $v) |
| 586 | 634 | { |
| 587 | 635 | if (!is_array($v) || !isset($old[$k]) || // no array or a new array |
| 588 | 636 | isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]) || // or no associative array, eg. selecting multiple accounts |
| 589 | - is_array($v) && count($v) == 0) // Empty array replacing non-empty |
|
| 637 | + is_array($v) && count($v) == 0) |
|
| 638 | + { |
|
| 639 | + // Empty array replacing non-empty |
|
| 590 | 640 | { |
| 591 | 641 | $old[$k] = $v; |
| 592 | 642 | } |
| 643 | + } |
|
| 593 | 644 | else |
| 594 | 645 | { |
| 595 | 646 | $old[$k] = self::complete_array_merge($old[$k],$v); |
@@ -642,10 +693,16 @@ discard block |
||
| 642 | 693 | if (is_null($dec_separator)) |
| 643 | 694 | { |
| 644 | 695 | $dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
| 645 | - if (empty($dec_separator)) $dec_separator = '.'; |
|
| 696 | + if (empty($dec_separator)) |
|
| 697 | + { |
|
| 698 | + $dec_separator = '.'; |
|
| 699 | + } |
|
| 646 | 700 | $thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1]; |
| 647 | 701 | } |
| 648 | - if ((string)$number === '') return ''; |
|
| 702 | + if ((string)$number === '') |
|
| 703 | + { |
|
| 704 | + return ''; |
|
| 705 | + } |
|
| 649 | 706 | |
| 650 | 707 | return number_format(str_replace(' ','',$number),$num_decimal_places,$dec_separator,$readonly ? $thousands_separator : ''); |
| 651 | 708 | } |
@@ -158,7 +158,7 @@ |
||
| 158 | 158 | // instanciate template to fill self::$request->sel_options for select-* widgets |
| 159 | 159 | // not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes |
| 160 | 160 | $template = self::instance($this->name, $this->template_set, $this->version, $this->laod_via); |
| 161 | - if (!$template) throw new Exception\AssertionFailed("Template $this->name not instanciable! Maybe you forgot to rename template id."); |
|
| 161 | + if (!$template) throw new Exception\AssertionFailed("template $this->name not instanciable! Maybe you forgot to rename template id."); |
|
| 162 | 162 | $template->run('beforeSendToClient', array('', array('cont'=>$content))); |
| 163 | 163 | |
| 164 | 164 | // some apps (eg. InfoLog) set app_header only in get_rows depending on filter settings |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @public boolean |
| 31 | 31 | */ |
| 32 | - public $sitemgr=false; |
|
| 32 | + public $sitemgr = false; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Tell egw framework it's ok to call this |
@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | * @param string $name of etemplate or array with name and other keys |
| 45 | 45 | * @param string|array $load_via with keys of other etemplate to load in order to get $name |
| 46 | 46 | */ |
| 47 | - function __construct($name='',$load_via='') |
|
| 47 | + function __construct($name = '', $load_via = '') |
|
| 48 | 48 | { |
| 49 | 49 | // we do NOT call parent consturctor, as we only want to enherit it's (static) methods |
| 50 | - if (false) parent::__construct ($name); // satisfy IDE, as we dont call parent constructor |
|
| 50 | + if (false) parent::__construct($name); // satisfy IDE, as we dont call parent constructor |
|
| 51 | 51 | |
| 52 | 52 | $this->sitemgr = isset($GLOBALS['Common_BO']) && is_object($GLOBALS['Common_BO']); |
| 53 | 53 | |
| 54 | - if ($name) $this->read($name,$template='default','default',0,'',$load_via); |
|
| 54 | + if ($name) $this->read($name, $template = 'default', 'default', 0, '', $load_via); |
|
| 55 | 55 | |
| 56 | 56 | // generate new etemplate request object, if not already existing |
| 57 | - if(!isset(self::$request)) self::$request = Etemplate\Request::read(); |
|
| 57 | + if (!isset(self::$request)) self::$request = Etemplate\Request::read(); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param string|array $params url or array with get-params incl. menuaction |
| 67 | 67 | */ |
| 68 | - static function location($params='') |
|
| 68 | + static function location($params = '') |
|
| 69 | 69 | { |
| 70 | 70 | Framework::redirect_link(is_array($params) ? '/index.php' : $params, |
| 71 | 71 | is_array($params) ? $params : ''); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param array $changes change made in the last call if looping, only used internaly by process_exec |
| 101 | 101 | * @return string html for $output_mode == 1, else nothing |
| 102 | 102 | */ |
| 103 | - function exec($method,array $content,array $sel_options=null,array $readonlys=null,array $preserv=null,$output_mode=0,$ignore_validation='',array $changes=null) |
|
| 103 | + function exec($method, array $content, array $sel_options = null, array $readonlys = null, array $preserv = null, $output_mode = 0, $ignore_validation = '', array $changes = null) |
|
| 104 | 104 | { |
| 105 | 105 | $hook_data = Hooks::process( |
| 106 | 106 | array('hook_location' => 'etemplate2_before_exec') + |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | $content |
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | - foreach($hook_data as $extras) |
|
| 112 | + foreach ($hook_data as $extras) |
|
| 113 | 113 | { |
| 114 | 114 | if (!$extras) continue; |
| 115 | 115 | |
| 116 | - foreach(isset($extras[0]) ? $extras : array($extras) as $extra) |
|
| 116 | + foreach (isset($extras[0]) ? $extras : array($extras) as $extra) |
|
| 117 | 117 | { |
| 118 | 118 | if ($extra['data'] && is_array($extra['data'])) |
| 119 | 119 | { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $output_mode = 0; |
| 144 | 144 | self::$response = Json\Response::get(); |
| 145 | 145 | } |
| 146 | - self::$request->output_mode = $output_mode; // let extensions "know" they are run eg. in a popup |
|
| 146 | + self::$request->output_mode = $output_mode; // let extensions "know" they are run eg. in a popup |
|
| 147 | 147 | self::$request->content = self::$cont = $content; |
| 148 | 148 | self::$request->changes = $changes; |
| 149 | 149 | self::$request->sel_options = is_array($sel_options) ? self::fix_sel_options($sel_options) : array(); |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | // compile required translations translations |
| 168 | 168 | $currentapp = $GLOBALS['egw_info']['flags']['currentapp']; |
| 169 | - $langRequire = array('common' => array(), 'etemplate' => array()); // keep that order |
|
| 170 | - foreach(Translation::$loaded_apps as $l_app => $lang) |
|
| 169 | + $langRequire = array('common' => array(), 'etemplate' => array()); // keep that order |
|
| 170 | + foreach (Translation::$loaded_apps as $l_app => $lang) |
|
| 171 | 171 | { |
| 172 | 172 | if (!in_array($l_app, array($currentapp, 'custom'))) |
| 173 | 173 | { |
| 174 | 174 | $langRequire[$l_app] = array('app' => $l_app, 'lang' => $lang, 'etag' => Translation::etag($l_app, $lang)); |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | - foreach(array($currentapp, 'custom') as $l_app) |
|
| 177 | + foreach (array($currentapp, 'custom') as $l_app) |
|
| 178 | 178 | { |
| 179 | 179 | if (isset(Translation::$loaded_apps[$l_app])) |
| 180 | 180 | { |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | ); |
| 196 | 196 | |
| 197 | 197 | // Info required to load the etemplate client-side |
| 198 | - $dom_id = str_replace('.','-',$this->dom_id); |
|
| 198 | + $dom_id = str_replace('.', '-', $this->dom_id); |
|
| 199 | 199 | $load_array = array( |
| 200 | 200 | 'name' => $this->name, |
| 201 | 201 | 'url' => self::rel2url($this->rel_path), |
@@ -205,16 +205,16 @@ discard block |
||
| 205 | 205 | if (self::$response) // call is within an ajax event / form submit |
| 206 | 206 | { |
| 207 | 207 | //error_log("Ajax " . __LINE__); |
| 208 | - self::$response->generic('et2_load', $load_array+Framework::get_extra()); |
|
| 209 | - Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view) |
|
| 208 | + self::$response->generic('et2_load', $load_array + Framework::get_extra()); |
|
| 209 | + Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view) |
|
| 210 | 210 | } |
| 211 | 211 | else // first call |
| 212 | 212 | { |
| 213 | 213 | // check if application of template has a app.js file --> load it |
| 214 | - list($app) = explode('.',$this->name); |
|
| 214 | + list($app) = explode('.', $this->name); |
|
| 215 | 215 | if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.js')) |
| 216 | 216 | { |
| 217 | - Framework::includeJS('.','app',$app,false); |
|
| 217 | + Framework::includeJS('.', 'app', $app, false); |
|
| 218 | 218 | } |
| 219 | 219 | // Category styles |
| 220 | 220 | Categories::css($app); |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | $content = '<form target="egw_iframe_autocomplete_helper" action="'.$form_action.'" id="'.$dom_id.'" class="et2_container"></form>'."\n". |
| 233 | 233 | '<iframe name="egw_iframe_autocomplete_helper" style="width:0;height:0;position: absolute;visibility:hidden;"></iframe>'; |
| 234 | 234 | $GLOBALS['egw']->framework->response->generic("data", array($content)); |
| 235 | - $GLOBALS['egw']->framework->response->generic('et2_load',$load_array+Framework::get_extra()); |
|
| 236 | - Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view) |
|
| 235 | + $GLOBALS['egw']->framework->response->generic('et2_load', $load_array + Framework::get_extra()); |
|
| 236 | + Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view) |
|
| 237 | 237 | self::$request = null; |
| 238 | 238 | return; |
| 239 | 239 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | echo '<div id="popupMainDiv" class="popupMainDiv">'."\n"; |
| 253 | 253 | } |
| 254 | 254 | // Send any accumulated json responses - after flush to avoid sending the buffer as a response |
| 255 | - if(Json\Response::isJSONResponse()) |
|
| 255 | + if (Json\Response::isJSONResponse()) |
|
| 256 | 256 | { |
| 257 | 257 | $load_array['response'] = Json\Response::get()->returnResult(); |
| 258 | 258 | } |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | static protected function fix_sel_options(array $sel_options) |
| 281 | 281 | { |
| 282 | - foreach($sel_options as &$options) |
|
| 282 | + foreach ($sel_options as &$options) |
|
| 283 | 283 | { |
| 284 | - if (!is_array($options)||empty($options)) continue; |
|
| 285 | - foreach($options as $key => $value) |
|
| 284 | + if (!is_array($options) || empty($options)) continue; |
|
| 285 | + foreach ($options as $key => $value) |
|
| 286 | 286 | { |
| 287 | 287 | if (is_numeric($key) && (!is_array($value) || !isset($value['value']))) |
| 288 | 288 | { |
@@ -318,9 +318,9 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Set current app for validation |
| 321 | - list($app) = explode('.',self::$request->method); |
|
| 322 | - if(!$app) list($app) = explode('::',self::$request->method); |
|
| 323 | - if($app) |
|
| 321 | + list($app) = explode('.', self::$request->method); |
|
| 322 | + if (!$app) list($app) = explode('::', self::$request->method); |
|
| 323 | + if ($app) |
|
| 324 | 324 | { |
| 325 | 325 | Translation::add_app($app); |
| 326 | 326 | $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $expand = array( |
| 330 | 330 | 'cont' => &self::$request->content, |
| 331 | 331 | ); |
| 332 | - $template->run('validate', array('', $expand, $_content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children |
|
| 332 | + $template->run('validate', array('', $expand, $_content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children |
|
| 333 | 333 | |
| 334 | 334 | if ($no_validation) |
| 335 | 335 | { |
@@ -345,14 +345,14 @@ discard block |
||
| 345 | 345 | // tell request call to remove request, if it is not modified eg. by call to exec in callback |
| 346 | 346 | self::$request->remove_if_not_modified(); |
| 347 | 347 | |
| 348 | - foreach(Hooks::process(array( |
|
| 348 | + foreach (Hooks::process(array( |
|
| 349 | 349 | 'hook_location' => 'etemplate2_before_process', |
| 350 | 350 | 'location_name' => $template->id, |
| 351 | 351 | ) + self::complete_array_merge(self::$request->preserv, $validated)) as $extras) |
| 352 | 352 | { |
| 353 | 353 | if (!$extras) continue; |
| 354 | 354 | |
| 355 | - foreach(isset($extras[0]) ? $extras : array($extras) as $extra) |
|
| 355 | + foreach (isset($extras[0]) ? $extras : array($extras) as $extra) |
|
| 356 | 356 | { |
| 357 | 357 | if ($extra['data'] && is_array($extra['data'])) |
| 358 | 358 | { |
@@ -365,8 +365,7 @@ discard block |
||
| 365 | 365 | //error_log(' validated='.array2string($validated)); |
| 366 | 366 | $content = ExecMethod(self::$request->method, self::complete_array_merge(self::$request->preserv, $validated)); |
| 367 | 367 | |
| 368 | - $tcontent = is_array($content) ? $content : |
|
| 369 | - self::complete_array_merge(self::$request->preserv, $validated); |
|
| 368 | + $tcontent = is_array($content) ? $content : self::complete_array_merge(self::$request->preserv, $validated); |
|
| 370 | 369 | |
| 371 | 370 | $hook_data = Hooks::process( |
| 372 | 371 | array( |
@@ -378,11 +377,11 @@ discard block |
||
| 378 | 377 | |
| 379 | 378 | if (is_array($content)) |
| 380 | 379 | { |
| 381 | - foreach($hook_data as $extras) |
|
| 380 | + foreach ($hook_data as $extras) |
|
| 382 | 381 | { |
| 383 | 382 | if (!$extras) continue; |
| 384 | 383 | |
| 385 | - foreach(isset($extras[0]) ? $extras : array($extras) as $extra) { |
|
| 384 | + foreach (isset($extras[0]) ? $extras : array($extras) as $extra) { |
|
| 386 | 385 | if ($extra['data'] && is_array($extra['data'])) { |
| 387 | 386 | $content = array_merge($content, $extra['data']); |
| 388 | 387 | } |
@@ -394,7 +393,7 @@ discard block |
||
| 394 | 393 | if (isset($GLOBALS['egw_info']['flags']['java_script'])) |
| 395 | 394 | { |
| 396 | 395 | // Strip out any script tags |
| 397 | - $GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is','/<\/script>/'),array('$2',''),$GLOBALS['egw_info']['flags']['java_script']); |
|
| 396 | + $GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is', '/<\/script>/'), array('$2', ''), $GLOBALS['egw_info']['flags']['java_script']); |
|
| 398 | 397 | self::$response->script($GLOBALS['egw_info']['flags']['java_script']); |
| 399 | 398 | //error_log($app .' added javascript to $GLOBALS[egw_info][flags][java_script] - use Json\Response->script() instead.'); |
| 400 | 399 | } |
@@ -423,7 +422,7 @@ discard block |
||
| 423 | 422 | static public function process_exec() |
| 424 | 423 | { |
| 425 | 424 | if (get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']); |
| 426 | - $content = json_decode($_POST['value'],true); |
|
| 425 | + $content = json_decode($_POST['value'], true); |
|
| 427 | 426 | //error_log(__METHOD__."(".array2string($content).")"); |
| 428 | 427 | |
| 429 | 428 | self::$request = Etemplate\Request::read($_POST['etemplate_exec_id']); |
@@ -437,7 +436,7 @@ discard block |
||
| 437 | 436 | $expand = array( |
| 438 | 437 | 'cont' => &self::$request->content, |
| 439 | 438 | ); |
| 440 | - $template->run('validate', array('', $expand, $content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children |
|
| 439 | + $template->run('validate', array('', $expand, $content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children |
|
| 441 | 440 | if (self::validation_errors(self::$request->ignore_validation)) |
| 442 | 441 | { |
| 443 | 442 | error_log(__METHOD__."(,".array2string($content).') validation_errors='.array2string(self::$validation_errors)); |
@@ -473,7 +472,7 @@ discard block |
||
| 473 | 472 | * |
| 474 | 473 | * @ToDo supported customized templates stored in DB |
| 475 | 474 | */ |
| 476 | - public function read($name,$template_set=null,$lang='default',$group=0,$version='',$load_via='') |
|
| 475 | + public function read($name, $template_set = null, $lang = 'default', $group = 0, $version = '', $load_via = '') |
|
| 477 | 476 | { |
| 478 | 477 | |
| 479 | 478 | // For mobile experience try to load custom mobile templates |
@@ -482,9 +481,9 @@ discard block |
||
| 482 | 481 | $template_set = "mobile"; |
| 483 | 482 | } |
| 484 | 483 | |
| 485 | - unset($lang); unset($group); // not used, but in old signature |
|
| 486 | - $this->rel_path = self::relPath($this->name=$name, $this->template_set=$template_set, |
|
| 487 | - $this->version=$version, $this->laod_via = $load_via); |
|
| 484 | + unset($lang); unset($group); // not used, but in old signature |
|
| 485 | + $this->rel_path = self::relPath($this->name = $name, $this->template_set = $template_set, |
|
| 486 | + $this->version = $version, $this->laod_via = $load_via); |
|
| 488 | 487 | //error_log(__METHOD__."('$name', '$template_set', '$lang', $group, '$version', '$load_via') rel_path=".array2string($this->rel_path)); |
| 489 | 488 | |
| 490 | 489 | $this->dom_id = $name; |
@@ -527,7 +526,7 @@ discard block |
||
| 527 | 526 | * @return mixed reference to attribute, usually NULL |
| 528 | 527 | * @deprecated use getElementAttribute($name, $attr) |
| 529 | 528 | */ |
| 530 | - public function &get_cell_attribute($name,$attr) |
|
| 529 | + public function &get_cell_attribute($name, $attr) |
|
| 531 | 530 | { |
| 532 | 531 | return self::getElementAttribute($name, $attr); |
| 533 | 532 | } |
@@ -541,7 +540,7 @@ discard block |
||
| 541 | 540 | * @return reference to attribute |
| 542 | 541 | * @deprecated use setElementAttribute($name, $attr, $val) |
| 543 | 542 | */ |
| 544 | - public function &set_cell_attribute($name,$attr,$val) |
|
| 543 | + public function &set_cell_attribute($name, $attr, $val) |
|
| 545 | 544 | { |
| 546 | 545 | return self::setElementAttribute($name, $attr, $val); |
| 547 | 546 | } |
@@ -554,7 +553,7 @@ discard block |
||
| 554 | 553 | * @return reference to attribute |
| 555 | 554 | * @deprecated use disableElement($name, $disabled=true) |
| 556 | 555 | */ |
| 557 | - public function disable_cells($name,$disabled=True) |
|
| 556 | + public function disable_cells($name, $disabled = True) |
|
| 558 | 557 | { |
| 559 | 558 | return self::disableElement($name, $disabled); |
| 560 | 559 | } |
@@ -570,23 +569,23 @@ discard block |
||
| 570 | 569 | * @param array $new |
| 571 | 570 | * @return array the merged array |
| 572 | 571 | */ |
| 573 | - public static function complete_array_merge($old,$new) |
|
| 572 | + public static function complete_array_merge($old, $new) |
|
| 574 | 573 | { |
| 575 | 574 | if (is_array($new)) |
| 576 | 575 | { |
| 577 | - if (!is_array($old)) $old = (array) $old; |
|
| 576 | + if (!is_array($old)) $old = (array)$old; |
|
| 578 | 577 | |
| 579 | - foreach($new as $k => $v) |
|
| 578 | + foreach ($new as $k => $v) |
|
| 580 | 579 | { |
| 581 | - if (!is_array($v) || !isset($old[$k]) || // no array or a new array |
|
| 582 | - isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]) || // or no associative array, eg. selecting multiple accounts |
|
| 580 | + if (!is_array($v) || !isset($old[$k]) || // no array or a new array |
|
| 581 | + isset($v[0]) && !is_array($v[0]) && isset($v[count($v) - 1]) || // or no associative array, eg. selecting multiple accounts |
|
| 583 | 582 | is_array($v) && count($v) == 0) // Empty array replacing non-empty |
| 584 | 583 | { |
| 585 | 584 | $old[$k] = $v; |
| 586 | 585 | } |
| 587 | 586 | else |
| 588 | 587 | { |
| 589 | - $old[$k] = self::complete_array_merge($old[$k],$v); |
|
| 588 | + $old[$k] = self::complete_array_merge($old[$k], $v); |
|
| 590 | 589 | } |
| 591 | 590 | } |
| 592 | 591 | } |
@@ -598,7 +597,7 @@ discard block |
||
| 598 | 597 | * |
| 599 | 598 | * @param array $content =null |
| 600 | 599 | */ |
| 601 | - public function debug(array $content=null) |
|
| 600 | + public function debug(array $content = null) |
|
| 602 | 601 | { |
| 603 | 602 | $GLOBALS['egw']->framework->render(print_r($content, true)); |
| 604 | 603 | } |
@@ -612,11 +611,11 @@ discard block |
||
| 612 | 611 | * @param int &$max_upload=null on return max. upload size in byte |
| 613 | 612 | * @return string |
| 614 | 613 | */ |
| 615 | - static function max_upload_size_message(&$max_upload=null) |
|
| 614 | + static function max_upload_size_message(&$max_upload = null) |
|
| 616 | 615 | { |
| 617 | 616 | $upload_max_filesize = ini_get('upload_max_filesize'); |
| 618 | 617 | $post_max_size = ini_get('post_max_size'); |
| 619 | - $max_upload = min(self::km2int($upload_max_filesize),self::km2int($post_max_size)-2800); |
|
| 618 | + $max_upload = min(self::km2int($upload_max_filesize), self::km2int($post_max_size) - 2800); |
|
| 620 | 619 | |
| 621 | 620 | return lang('Maximum size for uploads').': '.Vfs::hsize($max_upload). |
| 622 | 621 | " (php.ini: upload_max_filesize=$upload_max_filesize, post_max_size=$post_max_size)"; |
@@ -630,9 +629,9 @@ discard block |
||
| 630 | 629 | * @param boolean $readonly =true |
| 631 | 630 | * @return string |
| 632 | 631 | */ |
| 633 | - static public function number_format($number,$num_decimal_places=2,$readonly=true) |
|
| 632 | + static public function number_format($number, $num_decimal_places = 2, $readonly = true) |
|
| 634 | 633 | { |
| 635 | - static $dec_separator=null,$thousands_separator=null; |
|
| 634 | + static $dec_separator = null, $thousands_separator = null; |
|
| 636 | 635 | if (is_null($dec_separator)) |
| 637 | 636 | { |
| 638 | 637 | $dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
@@ -641,7 +640,7 @@ discard block |
||
| 641 | 640 | } |
| 642 | 641 | if ((string)$number === '') return ''; |
| 643 | 642 | |
| 644 | - return number_format(str_replace(' ','',$number),$num_decimal_places,$dec_separator,$readonly ? $thousands_separator : ''); |
|
| 643 | + return number_format(str_replace(' ', '', $number), $num_decimal_places, $dec_separator, $readonly ? $thousands_separator : ''); |
|
| 645 | 644 | } |
| 646 | 645 | |
| 647 | 646 | /** |
@@ -654,13 +653,13 @@ discard block |
||
| 654 | 653 | { |
| 655 | 654 | if (!is_numeric($size)) |
| 656 | 655 | { |
| 657 | - switch(strtolower(substr($size,-1))) |
|
| 656 | + switch (strtolower(substr($size, -1))) |
|
| 658 | 657 | { |
| 659 | 658 | case 'm': |
| 660 | - $size = 1024*1024*(int)$size; |
|
| 659 | + $size = 1024 * 1024 * (int)$size; |
|
| 661 | 660 | break; |
| 662 | 661 | case 'k': |
| 663 | - $size = 1024*(int)$size; |
|
| 662 | + $size = 1024 * (int)$size; |
|
| 664 | 663 | break; |
| 665 | 664 | } |
| 666 | 665 | } |
@@ -155,7 +155,7 @@ |
||
| 155 | 155 | * |
| 156 | 156 | * @param string|XMLReader $xml |
| 157 | 157 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
| 158 | - * @return Template current object or clone, if any attribute was set |
|
| 158 | + * @return Widget current object or clone, if any attribute was set |
|
| 159 | 159 | */ |
| 160 | 160 | public function set_attrs($xml, $cloned=true) |
| 161 | 161 | { |
@@ -903,12 +903,12 @@ |
||
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
| 906 | - * Check if we have not ignored validation errors |
|
| 907 | - * |
|
| 908 | - * @param string $ignore_validation ='' if not empty regular expression for validation-errors to ignore |
|
| 909 | - * @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars |
|
| 910 | - * @return boolean true if there are not ignored validation errors, false otherwise |
|
| 911 | - */ |
|
| 906 | + * Check if we have not ignored validation errors |
|
| 907 | + * |
|
| 908 | + * @param string $ignore_validation ='' if not empty regular expression for validation-errors to ignore |
|
| 909 | + * @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars |
|
| 910 | + * @return boolean true if there are not ignored validation errors, false otherwise |
|
| 911 | + */ |
|
| 912 | 912 | public static function validation_errors($ignore_validation='',$cname='') |
| 913 | 913 | { |
| 914 | 914 | // not yet used: if (is_null($cname)) $cname = self::$name_vars; |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | $this->id = $reader->getAttribute('id'); |
| 100 | 100 | |
| 101 | 101 | // Update content? |
| 102 | - if(self::$cont == null) |
|
| 102 | + if (self::$cont == null) |
|
| 103 | 103 | self::$cont = is_array(self::$request->content) ? self::$request->content : array(); |
| 104 | - if($this->id && is_array(self::$cont[$this->id])) |
|
| 104 | + if ($this->id && is_array(self::$cont[$this->id])) |
|
| 105 | 105 | { |
| 106 | 106 | $old_cont = self::$cont; |
| 107 | 107 | self::$cont = self::$cont[$this->id]; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | // read all attributes |
| 111 | 111 | $this->set_attrs($reader); |
| 112 | 112 | |
| 113 | - while($reader->read() && $reader->depth > $depth) |
|
| 113 | + while ($reader->read() && $reader->depth > $depth) |
|
| 114 | 114 | { |
| 115 | 115 | if ($reader->nodeType == XMLReader::ELEMENT && $reader->depth > $depth) |
| 116 | 116 | { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // Reset content as we leave |
| 122 | - if($old_cont) { |
|
| 122 | + if ($old_cont) { |
|
| 123 | 123 | self::$cont = $old_cont; |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
| 158 | 158 | * @return Template current object or clone, if any attribute was set |
| 159 | 159 | */ |
| 160 | - public function set_attrs($xml, $cloned=true) |
|
| 160 | + public function set_attrs($xml, $cloned = true) |
|
| 161 | 161 | { |
| 162 | 162 | $reader = self::get_reader($xml); |
| 163 | 163 | |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | // read and set all attributes |
| 176 | 176 | $template = $this; |
| 177 | - while($reader->moveToNextAttribute()) |
|
| 177 | + while ($reader->moveToNextAttribute()) |
|
| 178 | 178 | { |
| 179 | 179 | if ($reader->name != 'id' && $template->attr[$reader->name] != $reader->value) |
| 180 | 180 | { |
| 181 | 181 | if (!$cloned) |
| 182 | 182 | { |
| 183 | 183 | $template = clone($this); |
| 184 | - $cloned = true; // only clone it once, otherwise we loose attributes! |
|
| 184 | + $cloned = true; // only clone it once, otherwise we loose attributes! |
|
| 185 | 185 | } |
| 186 | 186 | // $reader->value is an object and therefore assigned by reference |
| 187 | 187 | // this is important to not loose content when validating dynamic generated tabs as in settings! |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | if ($legacy_options && $reader->name == 'options') |
| 199 | 199 | { |
| 200 | 200 | $legacy_options = explode(',', $legacy_options); |
| 201 | - foreach(self::csv_split($value, count($legacy_options)) as $n => $val) |
|
| 201 | + foreach (self::csv_split($value, count($legacy_options)) as $n => $val) |
|
| 202 | 202 | { |
| 203 | 203 | if ($legacy_options[$n] && (string)$val !== '') $template->attrs[$legacy_options[$n]] = $val; |
| 204 | 204 | } |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // Add in anything in the modification array |
| 210 | - if(is_array(self::$request->modifications[$this->id])) |
|
| 210 | + if (is_array(self::$request->modifications[$this->id])) |
|
| 211 | 211 | { |
| 212 | - $this->attrs = array_merge($this->attrs,self::$request->modifications[$this->id]); |
|
| 212 | + $this->attrs = array_merge($this->attrs, self::$request->modifications[$this->id]); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | return $template; |
@@ -230,32 +230,32 @@ discard block |
||
| 230 | 230 | * @param string $enclosure ='"' |
| 231 | 231 | * @return array |
| 232 | 232 | */ |
| 233 | - public static function csv_split($str,$num=null,$delimiter=',',$enclosure='"') |
|
| 233 | + public static function csv_split($str, $num = null, $delimiter = ',', $enclosure = '"') |
|
| 234 | 234 | { |
| 235 | - if (strpos($str,$enclosure) === false) |
|
| 235 | + if (strpos($str, $enclosure) === false) |
|
| 236 | 236 | { |
| 237 | - return is_null($num) ? explode($delimiter,$str) : explode($delimiter,$str,$num); // no need to run this more expensive code |
|
| 237 | + return is_null($num) ? explode($delimiter, $str) : explode($delimiter, $str, $num); // no need to run this more expensive code |
|
| 238 | 238 | } |
| 239 | - $parts = explode($delimiter,$str); |
|
| 240 | - for($n = 0; isset($parts[$n]); ++$n) |
|
| 239 | + $parts = explode($delimiter, $str); |
|
| 240 | + for ($n = 0; isset($parts[$n]); ++$n) |
|
| 241 | 241 | { |
| 242 | - $part =& $parts[$n]; |
|
| 242 | + $part = & $parts[$n]; |
|
| 243 | 243 | if ($part[0] === $enclosure) |
| 244 | 244 | { |
| 245 | - while (isset($parts[$n+1]) && substr($part,-1) !== $enclosure) |
|
| 245 | + while (isset($parts[$n + 1]) && substr($part, -1) !== $enclosure) |
|
| 246 | 246 | { |
| 247 | 247 | $part .= $delimiter.$parts[++$n]; |
| 248 | 248 | unset($parts[$n]); |
| 249 | 249 | } |
| 250 | - $part = substr(str_replace($enclosure.$enclosure,$enclosure,$part),1,-1); |
|
| 250 | + $part = substr(str_replace($enclosure.$enclosure, $enclosure, $part), 1, -1); |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | - $parts_renum = array_values($parts); // renumber the parts (in case we had to concat them) |
|
| 253 | + $parts_renum = array_values($parts); // renumber the parts (in case we had to concat them) |
|
| 254 | 254 | |
| 255 | 255 | if ($num > 0 && count($parts_renum) > $num) |
| 256 | 256 | { |
| 257 | - $parts_renum[$num-1] = implode($delimiter,array_slice($parts_renum,$num-1,count($parts_renum)-$num+1)); |
|
| 258 | - $parts_renum = array_slice($parts_renum,0,$num); |
|
| 257 | + $parts_renum[$num - 1] = implode($delimiter, array_slice($parts_renum, $num - 1, count($parts_renum) - $num + 1)); |
|
| 258 | + $parts_renum = array_slice($parts_renum, 0, $num); |
|
| 259 | 259 | } |
| 260 | 260 | return $parts_renum; |
| 261 | 261 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | { |
| 283 | 283 | throw new Api\Exception\WrongParameter(__METHOD__."('$class', ".array2string($widgets).") $class is no subclass of ".__CLASS__.'!'); |
| 284 | 284 | } |
| 285 | - foreach((array)$widgets as $widget) |
|
| 285 | + foreach ((array)$widgets as $widget) |
|
| 286 | 286 | { |
| 287 | 287 | self::$widget_registry[$widget] = $class; |
| 288 | 288 | } |
@@ -307,15 +307,15 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | if (!$widget_registry) // not in instance cache --> rescan from filesystem |
| 309 | 309 | { |
| 310 | - foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__.'/Widget')) as $path) |
|
| 310 | + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__.'/Widget')) as $path) |
|
| 311 | 311 | { |
| 312 | - if(substr($path, -4) == '.php') |
|
| 312 | + if (substr($path, -4) == '.php') |
|
| 313 | 313 | { |
| 314 | 314 | try |
| 315 | 315 | { |
| 316 | 316 | include_once($path); |
| 317 | 317 | } |
| 318 | - catch(Exception $e) |
|
| 318 | + catch (Exception $e) |
|
| 319 | 319 | { |
| 320 | 320 | error_log($e->getMessage()); |
| 321 | 321 | } |
@@ -323,18 +323,18 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Use hook to load custom widgets from other apps |
| 326 | - $widgets = Api\Hooks::process('etemplate2_register_widgets',array(),true); |
|
| 327 | - foreach($widgets as $list) |
|
| 326 | + $widgets = Api\Hooks::process('etemplate2_register_widgets', array(), true); |
|
| 327 | + foreach ($widgets as $list) |
|
| 328 | 328 | { |
| 329 | 329 | if (is_array($list)) |
| 330 | 330 | { |
| 331 | - foreach($list as $class) |
|
| 331 | + foreach ($list as $class) |
|
| 332 | 332 | { |
| 333 | 333 | try |
| 334 | 334 | { |
| 335 | - class_exists($class); // trigger autoloader |
|
| 335 | + class_exists($class); // trigger autoloader |
|
| 336 | 336 | } |
| 337 | - catch(Exception $e) |
|
| 337 | + catch (Exception $e) |
|
| 338 | 338 | { |
| 339 | 339 | error_log($e->getMessage()); |
| 340 | 340 | } |
@@ -357,22 +357,22 @@ discard block |
||
| 357 | 357 | * @param string|XMLReader $xml |
| 358 | 358 | * @param string $id =null |
| 359 | 359 | */ |
| 360 | - public static function factory($type, $xml, $id=null) |
|
| 360 | + public static function factory($type, $xml, $id = null) |
|
| 361 | 361 | { |
| 362 | - $class_name =& self::$widget_registry[$type]; |
|
| 362 | + $class_name = & self::$widget_registry[$type]; |
|
| 363 | 363 | |
| 364 | 364 | if (!isset($class_name)) |
| 365 | 365 | { |
| 366 | - list($basetype) = explode('-',$type); |
|
| 366 | + list($basetype) = explode('-', $type); |
|
| 367 | 367 | if (//dont think this is used: !class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$type)) && |
| 368 | 368 | !class_exists($class_name = __CLASS__.'\\'.ucfirst($basetype)) && |
| 369 | 369 | // widgets supplied by application in class ${app}_widget_etemplate or ${app}_${subtype}_widget_etemplate |
| 370 | 370 | !(isset($GLOBALS['egw_info']['apps'][$basetype]) && |
| 371 | - (class_exists($class_name = str_replace('-','_',$type).'_etemplate_widget') || |
|
| 371 | + (class_exists($class_name = str_replace('-', '_', $type).'_etemplate_widget') || |
|
| 372 | 372 | class_exists($class_name = $basetype.'_etemplate_widget')))) |
| 373 | 373 | { |
| 374 | 374 | // Try for base type, it's probably better than the root |
| 375 | - if(self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name) |
|
| 375 | + if (self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name) |
|
| 376 | 376 | { |
| 377 | 377 | $class_name = self::$widget_registry[$basetype]; |
| 378 | 378 | } |
@@ -393,22 +393,22 @@ discard block |
||
| 393 | 393 | { |
| 394 | 394 | // Class in widget registry, but not loaded |
| 395 | 395 | // Try for a base class |
| 396 | - $subtypes = explode('-',$type); |
|
| 396 | + $subtypes = explode('-', $type); |
|
| 397 | 397 | $basetype = $subtypes[0]; |
| 398 | - $class_name = __CLASS__.'\\'.implode('\\',array_map('ucfirst',$subtypes)); |
|
| 399 | - if(!class_exists($class_name) && self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name) |
|
| 398 | + $class_name = __CLASS__.'\\'.implode('\\', array_map('ucfirst', $subtypes)); |
|
| 399 | + if (!class_exists($class_name) && self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name) |
|
| 400 | 400 | { |
| 401 | 401 | // Try for base type, it's probably better than the root |
| 402 | 402 | $class_name = self::$widget_registry[$basetype]; |
| 403 | 403 | } |
| 404 | - if(!class_exists($class_name)) |
|
| 404 | + if (!class_exists($class_name)) |
|
| 405 | 405 | { |
| 406 | 406 | // Fall back to widget class, we can not ignore it, as the widget may contain other widgets |
| 407 | 407 | $class_name = __CLASS__; |
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if(!$xml) |
|
| 411 | + if (!$xml) |
|
| 412 | 412 | { |
| 413 | 413 | if (empty($type)) $type = 'widget'; |
| 414 | 414 | $xml = "<$type id='$id'/>"; |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | if ($type == 'template' && $id && ($template = Widget\Template::instance($id))) |
| 420 | 420 | { |
| 421 | 421 | // references can set different attributes like: class, span, content (namespace) |
| 422 | - return $template->set_attrs($xml, false); // false = need to clone template, if attributs are set! |
|
| 422 | + return $template->set_attrs($xml, false); // false = need to clone template, if attributs are set! |
|
| 423 | 423 | } |
| 424 | 424 | return new $class_name($xml); |
| 425 | 425 | } |
@@ -431,9 +431,9 @@ discard block |
||
| 431 | 431 | * @param string $type =null |
| 432 | 432 | * @return Widget|NULL |
| 433 | 433 | */ |
| 434 | - public function getElementById($id, $type=null) |
|
| 434 | + public function getElementById($id, $type = null) |
|
| 435 | 435 | { |
| 436 | - foreach($this->children as $child) |
|
| 436 | + foreach ($this->children as $child) |
|
| 437 | 437 | { |
| 438 | 438 | if ($child->id === $id && (is_null($type) || $child->type === $type)) |
| 439 | 439 | { |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | public function getElementsByType($type) |
| 457 | 457 | { |
| 458 | 458 | $elements = array(); |
| 459 | - foreach($this->children as $child) |
|
| 459 | + foreach ($this->children as $child) |
|
| 460 | 460 | { |
| 461 | 461 | if ($child->type === $type) |
| 462 | 462 | { |
@@ -476,14 +476,14 @@ discard block |
||
| 476 | 476 | * @param array $params =array('') parameter(s) first parameter has to be the cname, second $expand! |
| 477 | 477 | * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
| 478 | 478 | */ |
| 479 | - public function run($method_name, $params=array(''), $respect_disabled=false) |
|
| 479 | + public function run($method_name, $params = array(''), $respect_disabled = false) |
|
| 480 | 480 | { |
| 481 | 481 | // maintain $expand array name-expansion |
| 482 | 482 | $cname = $params[0]; |
| 483 | - $expand =& $params[1]; |
|
| 483 | + $expand = & $params[1]; |
|
| 484 | 484 | if ($expand['cname'] && $expand['cname'] !== $cname) |
| 485 | 485 | { |
| 486 | - $expand['cont'] =& self::get_array(self::$request->content, $cname); |
|
| 486 | + $expand['cont'] = & self::get_array(self::$request->content, $cname); |
|
| 487 | 487 | $expand['cname'] = $cname; |
| 488 | 488 | } |
| 489 | 489 | if ($respect_disabled && ($disabled = $this->attrs['disabled'] && self::check_disabled($this->attrs['disabled'], $expand))) |
@@ -496,22 +496,22 @@ discard block |
||
| 496 | 496 | // Some parameter checking to avoid fatal errors |
| 497 | 497 | $call = true; |
| 498 | 498 | $method = new ReflectionMethod($this, $method_name); |
| 499 | - foreach($method->getParameters() as $index => $param) |
|
| 499 | + foreach ($method->getParameters() as $index => $param) |
|
| 500 | 500 | { |
| 501 | - if(!$param->isOptional() && !array_key_exists($index,$params)) |
|
| 501 | + if (!$param->isOptional() && !array_key_exists($index, $params)) |
|
| 502 | 502 | { |
| 503 | 503 | error_log("Missing required parameter {$param->getPosition()}: {$param->getName()}"); |
| 504 | 504 | $call = false; |
| 505 | 505 | } |
| 506 | - if($param->isArray() && !is_array($params[$index])) |
|
| 506 | + if ($param->isArray() && !is_array($params[$index])) |
|
| 507 | 507 | { |
| 508 | 508 | error_log("$method_name expects an array for {$param->getPosition()}: {$param->getName()}"); |
| 509 | 509 | $params[$index] = (array)$params[$index]; |
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | - if($call) call_user_func_array(array($this, $method_name), $params); |
|
| 512 | + if ($call) call_user_func_array(array($this, $method_name), $params); |
|
| 513 | 513 | } |
| 514 | - foreach($this->children as $child) |
|
| 514 | + foreach ($this->children as $child) |
|
| 515 | 515 | { |
| 516 | 516 | // If type has something that can be expanded, we need to expand it so the correct method is run |
| 517 | 517 | $this->expand_widget($child, $expand); |
@@ -526,15 +526,15 @@ discard block |
||
| 526 | 526 | * @param Widget& $child Widget to check & expand if needed |
| 527 | 527 | * @param array& $expand Expansion array |
| 528 | 528 | */ |
| 529 | - protected function expand_widget(Widget &$child, array &$expand) |
|
| 529 | + protected function expand_widget(Widget&$child, array &$expand) |
|
| 530 | 530 | { |
| 531 | - if(strpos($child->attrs['type'], '@') !== false || strpos($child->attrs['type'], '$') !== false) |
|
| 531 | + if (strpos($child->attrs['type'], '@') !== false || strpos($child->attrs['type'], '$') !== false) |
|
| 532 | 532 | { |
| 533 | - $type = self::expand_name($child->attrs['type'],$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
|
| 534 | - $id = self::expand_name($child->id,$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
|
| 533 | + $type = self::expand_name($child->attrs['type'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
|
| 534 | + $id = self::expand_name($child->id, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
|
| 535 | 535 | $attrs = $child->attrs; |
| 536 | 536 | unset($attrs['type']); |
| 537 | - $expanded_child = self::factory($type, false,$id); |
|
| 537 | + $expanded_child = self::factory($type, false, $id); |
|
| 538 | 538 | $expanded_child->id = $id; |
| 539 | 539 | $expanded_child->type = $type; |
| 540 | 540 | $expanded_child->attrs = $attrs + array('type' => $type); |
@@ -557,14 +557,14 @@ discard block |
||
| 557 | 557 | { |
| 558 | 558 | if (($not = $disabled[0] == '!')) |
| 559 | 559 | { |
| 560 | - $disabled = substr($disabled,1); |
|
| 560 | + $disabled = substr($disabled, 1); |
|
| 561 | 561 | } |
| 562 | - list($value,$check) = $vals = explode('=',$disabled); |
|
| 562 | + list($value, $check) = $vals = explode('=', $disabled); |
|
| 563 | 563 | |
| 564 | 564 | // use expand_name to be able to use @ or $ |
| 565 | 565 | $val = self::expand_name($value, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
| 566 | 566 | $check_val = self::expand_name($check, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
| 567 | - $result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val,$val) : $val == $check_val); |
|
| 567 | + $result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val, $val) : $val == $check_val); |
|
| 568 | 568 | if ($not) $result = !$result; |
| 569 | 569 | |
| 570 | 570 | //error_log(__METHOD__."('".($not?'!':'')."$disabled' = '$val' ".(count($vals) == 1 ? '' : ($not?'!':'=')."= '$check_val'")." = ".($result?'True':'False')); |
@@ -606,33 +606,33 @@ discard block |
||
| 606 | 606 | * "del[$cont[id]]" expands to "del[123]" if $cont = array('id' => 123) |
| 607 | 607 | * @return string the expanded name |
| 608 | 608 | */ |
| 609 | - protected static function expand_name($name,$c,$row,$c_='',$row_='',$cont='') |
|
| 609 | + protected static function expand_name($name, $c, $row, $c_ = '', $row_ = '', $cont = '') |
|
| 610 | 610 | { |
| 611 | 611 | $is_index_in_content = $name[0] == '@'; |
| 612 | - if (($pos_var=strpos($name,'$')) !== false) |
|
| 612 | + if (($pos_var = strpos($name, '$')) !== false) |
|
| 613 | 613 | { |
| 614 | 614 | if (!$cont) |
| 615 | 615 | { |
| 616 | 616 | $cont = array(); |
| 617 | 617 | } |
| 618 | 618 | if (!is_numeric($c)) $c = self::chrs2num($c); |
| 619 | - $col = self::num2chrs($c-1); // $c-1 to get: 0:'@', 1:'A', ... |
|
| 620 | - $col_ = self::num2chrs($c_-1); |
|
| 619 | + $col = self::num2chrs($c - 1); // $c-1 to get: 0:'@', 1:'A', ... |
|
| 620 | + $col_ = self::num2chrs($c_ - 1); |
|
| 621 | 621 | $row_cont = $cont[$row]; |
| 622 | 622 | $col_row_cont = $cont[$col.$row]; |
| 623 | 623 | |
| 624 | - eval('$name = "'.str_replace('"','\\"',$name).'";'); |
|
| 625 | - unset($col_, $row_, $row_cont, $col_row_cont); // quiten IDE warning about used vars, they might be used in above eval! |
|
| 624 | + eval('$name = "'.str_replace('"', '\\"', $name).'";'); |
|
| 625 | + unset($col_, $row_, $row_cont, $col_row_cont); // quiten IDE warning about used vars, they might be used in above eval! |
|
| 626 | 626 | } |
| 627 | 627 | if ($is_index_in_content) |
| 628 | 628 | { |
| 629 | 629 | if ($name[1] == '@' && is_array(self::$request->content)) |
| 630 | 630 | { |
| 631 | - $name = self::get_array(self::$request->content,substr($name,2)); |
|
| 631 | + $name = self::get_array(self::$request->content, substr($name, 2)); |
|
| 632 | 632 | } |
| 633 | - elseif(is_array($cont)) |
|
| 633 | + elseif (is_array($cont)) |
|
| 634 | 634 | { |
| 635 | - $name = self::get_array($cont,substr($name,1)); |
|
| 635 | + $name = self::get_array($cont, substr($name, 1)); |
|
| 636 | 636 | } |
| 637 | 637 | else |
| 638 | 638 | { |
@@ -654,11 +654,11 @@ discard block |
||
| 654 | 654 | $min = ord('A'); |
| 655 | 655 | $max = ord('Z') - $min + 1; |
| 656 | 656 | |
| 657 | - $num = 1+ord($chrs{0})-$min; |
|
| 657 | + $num = 1 + ord($chrs{0}) - $min; |
|
| 658 | 658 | if (strlen($chrs) > 1) |
| 659 | 659 | { |
| 660 | 660 | $num *= 1 + $max - $min; |
| 661 | - $num += 1+ord($chrs{1})-$min; |
|
| 661 | + $num += 1 + ord($chrs{1}) - $min; |
|
| 662 | 662 | } |
| 663 | 663 | return $num; |
| 664 | 664 | } |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | */ |
| 690 | 690 | public function __toString() |
| 691 | 691 | { |
| 692 | - return '['.get_class($this).'] ' . |
|
| 692 | + return '['.get_class($this).'] '. |
|
| 693 | 693 | $this->type.($this->attrs['type'] && $this->attrs['type'] != $this->type ? '('.$this->attrs['type'].')' : '').'#'.$this->id; |
| 694 | 694 | } |
| 695 | 695 | |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | */ |
| 699 | 699 | public function __clone() |
| 700 | 700 | { |
| 701 | - foreach($this->children as $child_num => $child) { |
|
| 701 | + foreach ($this->children as $child_num => $child) { |
|
| 702 | 702 | $this->children[$child_num] = clone $child; |
| 703 | 703 | } |
| 704 | 704 | } |
@@ -709,16 +709,16 @@ discard block |
||
| 709 | 709 | * @param string $indent ='' |
| 710 | 710 | * @return string |
| 711 | 711 | */ |
| 712 | - public function toXml($indent='') |
|
| 712 | + public function toXml($indent = '') |
|
| 713 | 713 | { |
| 714 | 714 | echo "$indent<$this->type"; |
| 715 | 715 | if ($this->id) echo ' id="'.htmlspecialchars($this->id).'"'; |
| 716 | - foreach($this->attrs as $name => $value) |
|
| 716 | + foreach ($this->attrs as $name => $value) |
|
| 717 | 717 | { |
| 718 | 718 | if ($name == 'options' && $this->legacy_options && (!is_array($this->legacy_options) || |
| 719 | 719 | isset($this->legacy_options[$this->attrs['type'] ? $this->attrs['type'] : $this->type]))) |
| 720 | 720 | { |
| 721 | - continue; // do NOT output already converted legacy options |
|
| 721 | + continue; // do NOT output already converted legacy options |
|
| 722 | 722 | } |
| 723 | 723 | echo ' '.$name.'="'.htmlspecialchars($value).'"'; |
| 724 | 724 | } |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | if ($this->children) |
| 728 | 728 | { |
| 729 | 729 | echo ">\n"; |
| 730 | - foreach($this->children as $child) |
|
| 730 | + foreach ($this->children as $child) |
|
| 731 | 731 | { |
| 732 | 732 | $child->toXml($indent."\t"); |
| 733 | 733 | } |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | * @param array $expand =null values for keys 'c', 'row', 'c_', 'row_', 'cont' |
| 751 | 751 | * @return string complete form-name |
| 752 | 752 | */ |
| 753 | - static function form_name($cname,$name,array $expand=null) |
|
| 753 | + static function form_name($cname, $name, array $expand = null) |
|
| 754 | 754 | { |
| 755 | 755 | if ($expand && !empty($name)) |
| 756 | 756 | { |
@@ -758,18 +758,18 @@ discard block |
||
| 758 | 758 | } |
| 759 | 759 | if (count($name_parts = explode('[', $name, 2)) > 1) |
| 760 | 760 | { |
| 761 | - $name_parts = array_merge(array($name_parts[0]), explode('][', substr($name_parts[1],0,-1))); |
|
| 761 | + $name_parts = array_merge(array($name_parts[0]), explode('][', substr($name_parts[1], 0, -1))); |
|
| 762 | 762 | } |
| 763 | 763 | if (!empty($cname)) |
| 764 | 764 | { |
| 765 | - array_unshift($name_parts,$cname); |
|
| 765 | + array_unshift($name_parts, $cname); |
|
| 766 | 766 | } |
| 767 | 767 | $form_name = array_shift($name_parts); |
| 768 | 768 | if (count($name_parts)) |
| 769 | 769 | { |
| 770 | 770 | // RB: not sure why this business with entity encoding for square brakets, it messes up validation |
| 771 | 771 | //$form_name .= '['.implode('][',$name_parts).']'; |
| 772 | - $form_name .= '['.implode('][',$name_parts).']'; |
|
| 772 | + $form_name .= '['.implode('][', $name_parts).']'; |
|
| 773 | 773 | } |
| 774 | 774 | return $form_name; |
| 775 | 775 | } |
@@ -786,36 +786,36 @@ discard block |
||
| 786 | 786 | * @param bool $skip_empty returns false if $idx is not present in $arr |
| 787 | 787 | * @return mixed reference to $arr[$idx] or null if $idx is not set and not $reference_into |
| 788 | 788 | */ |
| 789 | - static function &get_array(&$arr,$_idx,$reference_into=False,$skip_empty=False) |
|
| 789 | + static function &get_array(&$arr, $_idx, $reference_into = False, $skip_empty = False) |
|
| 790 | 790 | { |
| 791 | 791 | if (!is_array($arr)) |
| 792 | 792 | { |
| 793 | 793 | throw new Api\Exception\AssertionFailed(__METHOD__."(\$arr,'$_idx',$reference_into,$skip_empty) \$arr is no array!"); |
| 794 | 794 | } |
| 795 | - if (is_object($_idx)) return false; // given an error in php5.2 |
|
| 795 | + if (is_object($_idx)) return false; // given an error in php5.2 |
|
| 796 | 796 | |
| 797 | 797 | // Make sure none of these are left |
| 798 | - $idx = str_replace(array('[',']'), array('[',']'), $_idx); |
|
| 798 | + $idx = str_replace(array('[', ']'), array('[', ']'), $_idx); |
|
| 799 | 799 | |
| 800 | 800 | // Handle things expecting arrays - ends in [] |
| 801 | - if(substr($idx,-2) == "[]") |
|
| 801 | + if (substr($idx, -2) == "[]") |
|
| 802 | 802 | { |
| 803 | - $idx = substr($idx,0,-2); |
|
| 803 | + $idx = substr($idx, 0, -2); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | if (count($idxs = explode('[', $idx, 2)) > 1) |
| 807 | 807 | { |
| 808 | - $idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1))); |
|
| 808 | + $idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1], 0, -1))); |
|
| 809 | 809 | } |
| 810 | 810 | $pos = &$arr; |
| 811 | - foreach($idxs as $idx) |
|
| 811 | + foreach ($idxs as $idx) |
|
| 812 | 812 | { |
| 813 | 813 | if (!is_array($pos) && (!$reference_into || $reference_into && isset($pos))) |
| 814 | 814 | { |
| 815 | 815 | //if ($reference_into) error_log(__METHOD__."(".(strlen($s=array2string($arr))>512?substr($s,0,512).'...':$s).", '$idx', ".array2string($reference_into).", ".array2string($skip_empty).") ".function_backtrace()); |
| 816 | 816 | return null; |
| 817 | 817 | } |
| 818 | - if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return null; |
|
| 818 | + if ($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return null; |
|
| 819 | 819 | $pos = &$pos[$idx]; |
| 820 | 820 | } |
| 821 | 821 | return $pos; |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | */ |
| 834 | 834 | static function set_array(&$_arr, $_idx, $_value) |
| 835 | 835 | { |
| 836 | - $ref =& self::get_array($_arr, $_idx, true); |
|
| 836 | + $ref = & self::get_array($_arr, $_idx, true); |
|
| 837 | 837 | if (true) $ref = $_value; |
| 838 | 838 | } |
| 839 | 839 | |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | * @param string $form_name =null form_name, to not calculate him again |
| 848 | 848 | * @return boolean |
| 849 | 849 | */ |
| 850 | - public function is_readonly($cname='', $form_name=null) |
|
| 850 | + public function is_readonly($cname = '', $form_name = null) |
|
| 851 | 851 | { |
| 852 | 852 | if (!isset($form_name)) |
| 853 | 853 | { |
@@ -857,11 +857,11 @@ discard block |
||
| 857 | 857 | $form_name = self::form_name($cname, $this->id, $expand); |
| 858 | 858 | } |
| 859 | 859 | $readonly = $this->attrs['readonly'] || self::$request->readonlys[$form_name] || |
| 860 | - self::get_array(self::$request->readonlys,$form_name) === true || |
|
| 860 | + self::get_array(self::$request->readonlys, $form_name) === true || |
|
| 861 | 861 | isset(self::$request->readonlys['__ALL__']) && ( |
| 862 | 862 | // Exceptions to all |
| 863 | 863 | self::$request->readonlys[$form_name] !== false && |
| 864 | - self::get_array(self::$request->readonlys,$form_name) !== false |
|
| 864 | + self::get_array(self::$request->readonlys, $form_name) !== false |
|
| 865 | 865 | ); |
| 866 | 866 | |
| 867 | 867 | //error_log(__METHOD__."('$cname') this->id='$this->id' --> form_name='$form_name': attrs[readonly]=".array2string($this->attrs['readonly']).", readonlys['$form_name']=".array2string(self::$request->readonlys[$form_name]).", readonlys[$form_name]=".array2string(self::get_array(self::$request->readonlys,$form_name)).", readonlys['__ALL__']=".array2string(self::$request->readonlys['__ALL__'])." returning ".array2string($readonly)); |
@@ -881,12 +881,12 @@ discard block |
||
| 881 | 881 | * @param string|boolean $error error-message already translated or false to reset all existing error for given name |
| 882 | 882 | * @param string $cname =null set it to '', if the name is already a form-name, defaults to self::$name_vars |
| 883 | 883 | */ |
| 884 | - public static function set_validation_error($name,$error,$cname=null) |
|
| 884 | + public static function set_validation_error($name, $error, $cname = null) |
|
| 885 | 885 | { |
| 886 | 886 | // not yet used: if (is_null($cname)) $cname = self::$name_vars; |
| 887 | 887 | error_log(__METHOD__."('$name','$error','$cname') ".function_backtrace()); |
| 888 | 888 | |
| 889 | - if ($cname) $name = self::form_name($cname,$name); |
|
| 889 | + if ($cname) $name = self::form_name($cname, $name); |
|
| 890 | 890 | |
| 891 | 891 | if ($error === false) |
| 892 | 892 | { |
@@ -909,18 +909,18 @@ discard block |
||
| 909 | 909 | * @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars |
| 910 | 910 | * @return boolean true if there are not ignored validation errors, false otherwise |
| 911 | 911 | */ |
| 912 | - public static function validation_errors($ignore_validation='',$cname='') |
|
| 912 | + public static function validation_errors($ignore_validation = '', $cname = '') |
|
| 913 | 913 | { |
| 914 | 914 | // not yet used: if (is_null($cname)) $cname = self::$name_vars; |
| 915 | 915 | //echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors); |
| 916 | 916 | if (!$ignore_validation) return count(self::$validation_errors) > 0; |
| 917 | 917 | |
| 918 | - foreach(array_values(self::$validation_errors) as $name) |
|
| 918 | + foreach (array_values(self::$validation_errors) as $name) |
|
| 919 | 919 | { |
| 920 | - if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name); |
|
| 920 | + if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/', '\\1\\2', $name); |
|
| 921 | 921 | |
| 922 | 922 | // treat $ignoare_validation only as regular expression, if it starts with a slash |
| 923 | - if ($ignore_validation[0] == '/' && !preg_match($ignore_validation,$name) || |
|
| 923 | + if ($ignore_validation[0] == '/' && !preg_match($ignore_validation, $name) || |
|
| 924 | 924 | $ignore_validation[0] != '/' && $ignore_validation != $name) |
| 925 | 925 | { |
| 926 | 926 | //echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') name='$name' ($error) not ignored!!!</p>\n"; |
@@ -957,14 +957,14 @@ discard block |
||
| 957 | 957 | * @param mixed $val if not NULL sets attribute else returns it |
| 958 | 958 | * @return reference to attribute |
| 959 | 959 | */ |
| 960 | - public static function &setElementAttribute($name,$attr,$val) |
|
| 960 | + public static function &setElementAttribute($name, $attr, $val) |
|
| 961 | 961 | { |
| 962 | 962 | //error_log(__METHOD__."('$name', '$attr', ...) request=".get_class(self::$request).", response=".get_class(self::$response).function_backtrace()); |
| 963 | - $ref =& self::$request->modifications[$name][$attr]; |
|
| 964 | - if(self::$request && self::$response && (!isset($this) || $val != $this->attrs[$attr])) |
|
| 963 | + $ref = & self::$request->modifications[$name][$attr]; |
|
| 964 | + if (self::$request && self::$response && (!isset($this) || $val != $this->attrs[$attr])) |
|
| 965 | 965 | { |
| 966 | 966 | // In an AJAX response - automatically add |
| 967 | - self::$response->generic('assign',array( |
|
| 967 | + self::$response->generic('assign', array( |
|
| 968 | 968 | 'etemplate_exec_id' => self::$request->id(), |
| 969 | 969 | 'id' => $name, |
| 970 | 970 | 'key' => $attr, |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | * @param boolean $disabled =true disable or enable a cell, default true=disable |
| 989 | 989 | * @return reference to attribute |
| 990 | 990 | */ |
| 991 | - public function disableElement($name,$disabled=True) |
|
| 991 | + public function disableElement($name, $disabled = True) |
|
| 992 | 992 | { |
| 993 | 993 | return self::setElementAttribute($name, 'disabled', $disabled); |
| 994 | 994 | } |
@@ -100,7 +100,9 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | // Update content? |
| 102 | 102 | if(self::$cont == null) |
| 103 | - self::$cont = is_array(self::$request->content) ? self::$request->content : array(); |
|
| 103 | + { |
|
| 104 | + self::$cont = is_array(self::$request->content) ? self::$request->content : array(); |
|
| 105 | + } |
|
| 104 | 106 | if($this->id && is_array(self::$cont[$this->id])) |
| 105 | 107 | { |
| 106 | 108 | $old_cont = self::$cont; |
@@ -119,7 +121,8 @@ discard block |
||
| 119 | 121 | } |
| 120 | 122 | |
| 121 | 123 | // Reset content as we leave |
| 122 | - if($old_cont) { |
|
| 124 | + if($old_cont) |
|
| 125 | + { |
|
| 123 | 126 | self::$cont = $old_cont; |
| 124 | 127 | } |
| 125 | 128 | } |
@@ -200,7 +203,10 @@ discard block |
||
| 200 | 203 | $legacy_options = explode(',', $legacy_options); |
| 201 | 204 | foreach(self::csv_split($value, count($legacy_options)) as $n => $val) |
| 202 | 205 | { |
| 203 | - if ($legacy_options[$n] && (string)$val !== '') $template->attrs[$legacy_options[$n]] = $val; |
|
| 206 | + if ($legacy_options[$n] && (string)$val !== '') |
|
| 207 | + { |
|
| 208 | + $template->attrs[$legacy_options[$n]] = $val; |
|
| 209 | + } |
|
| 204 | 210 | } |
| 205 | 211 | } |
| 206 | 212 | } |
@@ -305,7 +311,9 @@ discard block |
||
| 305 | 311 | |
| 306 | 312 | $widget_registry = Api\Cache::getInstance('etemplate', 'widget_registry'); |
| 307 | 313 | |
| 308 | - if (!$widget_registry) // not in instance cache --> rescan from filesystem |
|
| 314 | + if (!$widget_registry) |
|
| 315 | + { |
|
| 316 | + // not in instance cache --> rescan from filesystem |
|
| 309 | 317 | { |
| 310 | 318 | foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__.'/Widget')) as $path) |
| 311 | 319 | { |
@@ -314,6 +322,7 @@ discard block |
||
| 314 | 322 | try |
| 315 | 323 | { |
| 316 | 324 | include_once($path); |
| 325 | + } |
|
| 317 | 326 | } |
| 318 | 327 | catch(Exception $e) |
| 319 | 328 | { |
@@ -410,7 +419,10 @@ discard block |
||
| 410 | 419 | |
| 411 | 420 | if(!$xml) |
| 412 | 421 | { |
| 413 | - if (empty($type)) $type = 'widget'; |
|
| 422 | + if (empty($type)) |
|
| 423 | + { |
|
| 424 | + $type = 'widget'; |
|
| 425 | + } |
|
| 414 | 426 | $xml = "<$type id='$id'/>"; |
| 415 | 427 | } |
| 416 | 428 | //error_log(__METHOD__."('$type', ..., '$id') using $class_name"); |
@@ -509,7 +521,10 @@ discard block |
||
| 509 | 521 | $params[$index] = (array)$params[$index]; |
| 510 | 522 | } |
| 511 | 523 | } |
| 512 | - if($call) call_user_func_array(array($this, $method_name), $params); |
|
| 524 | + if($call) |
|
| 525 | + { |
|
| 526 | + call_user_func_array(array($this, $method_name), $params); |
|
| 527 | + } |
|
| 513 | 528 | } |
| 514 | 529 | foreach($this->children as $child) |
| 515 | 530 | { |
@@ -565,7 +580,10 @@ discard block |
||
| 565 | 580 | $val = self::expand_name($value, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
| 566 | 581 | $check_val = self::expand_name($check, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
| 567 | 582 | $result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val,$val) : $val == $check_val); |
| 568 | - if ($not) $result = !$result; |
|
| 583 | + if ($not) |
|
| 584 | + { |
|
| 585 | + $result = !$result; |
|
| 586 | + } |
|
| 569 | 587 | |
| 570 | 588 | //error_log(__METHOD__."('".($not?'!':'')."$disabled' = '$val' ".(count($vals) == 1 ? '' : ($not?'!':'=')."= '$check_val'")." = ".($result?'True':'False')); |
| 571 | 589 | return $result; |
@@ -615,7 +633,10 @@ discard block |
||
| 615 | 633 | { |
| 616 | 634 | $cont = array(); |
| 617 | 635 | } |
| 618 | - if (!is_numeric($c)) $c = self::chrs2num($c); |
|
| 636 | + if (!is_numeric($c)) |
|
| 637 | + { |
|
| 638 | + $c = self::chrs2num($c); |
|
| 639 | + } |
|
| 619 | 640 | $col = self::num2chrs($c-1); // $c-1 to get: 0:'@', 1:'A', ... |
| 620 | 641 | $col_ = self::num2chrs($c_-1); |
| 621 | 642 | $row_cont = $cont[$row]; |
@@ -698,7 +719,8 @@ discard block |
||
| 698 | 719 | */ |
| 699 | 720 | public function __clone() |
| 700 | 721 | { |
| 701 | - foreach($this->children as $child_num => $child) { |
|
| 722 | + foreach($this->children as $child_num => $child) |
|
| 723 | + { |
|
| 702 | 724 | $this->children[$child_num] = clone $child; |
| 703 | 725 | } |
| 704 | 726 | } |
@@ -712,7 +734,10 @@ discard block |
||
| 712 | 734 | public function toXml($indent='') |
| 713 | 735 | { |
| 714 | 736 | echo "$indent<$this->type"; |
| 715 | - if ($this->id) echo ' id="'.htmlspecialchars($this->id).'"'; |
|
| 737 | + if ($this->id) |
|
| 738 | + { |
|
| 739 | + echo ' id="'.htmlspecialchars($this->id).'"'; |
|
| 740 | + } |
|
| 716 | 741 | foreach($this->attrs as $name => $value) |
| 717 | 742 | { |
| 718 | 743 | if ($name == 'options' && $this->legacy_options && (!is_array($this->legacy_options) || |
@@ -792,7 +817,11 @@ discard block |
||
| 792 | 817 | { |
| 793 | 818 | throw new Api\Exception\AssertionFailed(__METHOD__."(\$arr,'$_idx',$reference_into,$skip_empty) \$arr is no array!"); |
| 794 | 819 | } |
| 795 | - if (is_object($_idx)) return false; // given an error in php5.2 |
|
| 820 | + if (is_object($_idx)) |
|
| 821 | + { |
|
| 822 | + return false; |
|
| 823 | + } |
|
| 824 | + // given an error in php5.2 |
|
| 796 | 825 | |
| 797 | 826 | // Make sure none of these are left |
| 798 | 827 | $idx = str_replace(array('[',']'), array('[',']'), $_idx); |
@@ -815,7 +844,10 @@ discard block |
||
| 815 | 844 | //if ($reference_into) error_log(__METHOD__."(".(strlen($s=array2string($arr))>512?substr($s,0,512).'...':$s).", '$idx', ".array2string($reference_into).", ".array2string($skip_empty).") ".function_backtrace()); |
| 816 | 845 | return null; |
| 817 | 846 | } |
| 818 | - if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return null; |
|
| 847 | + if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) |
|
| 848 | + { |
|
| 849 | + return null; |
|
| 850 | + } |
|
| 819 | 851 | $pos = &$pos[$idx]; |
| 820 | 852 | } |
| 821 | 853 | return $pos; |
@@ -834,7 +866,10 @@ discard block |
||
| 834 | 866 | static function set_array(&$_arr, $_idx, $_value) |
| 835 | 867 | { |
| 836 | 868 | $ref =& self::get_array($_arr, $_idx, true); |
| 837 | - if (true) $ref = $_value; |
|
| 869 | + if (true) |
|
| 870 | + { |
|
| 871 | + $ref = $_value; |
|
| 872 | + } |
|
| 838 | 873 | } |
| 839 | 874 | |
| 840 | 875 | /** |
@@ -886,7 +921,10 @@ discard block |
||
| 886 | 921 | // not yet used: if (is_null($cname)) $cname = self::$name_vars; |
| 887 | 922 | error_log(__METHOD__."('$name','$error','$cname') ".function_backtrace()); |
| 888 | 923 | |
| 889 | - if ($cname) $name = self::form_name($cname,$name); |
|
| 924 | + if ($cname) |
|
| 925 | + { |
|
| 926 | + $name = self::form_name($cname,$name); |
|
| 927 | + } |
|
| 890 | 928 | |
| 891 | 929 | if ($error === false) |
| 892 | 930 | { |
@@ -913,11 +951,17 @@ discard block |
||
| 913 | 951 | { |
| 914 | 952 | // not yet used: if (is_null($cname)) $cname = self::$name_vars; |
| 915 | 953 | //echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors); |
| 916 | - if (!$ignore_validation) return count(self::$validation_errors) > 0; |
|
| 954 | + if (!$ignore_validation) |
|
| 955 | + { |
|
| 956 | + return count(self::$validation_errors) > 0; |
|
| 957 | + } |
|
| 917 | 958 | |
| 918 | 959 | foreach(array_values(self::$validation_errors) as $name) |
| 919 | 960 | { |
| 920 | - if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name); |
|
| 961 | + if ($cname) |
|
| 962 | + { |
|
| 963 | + $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name); |
|
| 964 | + } |
|
| 921 | 965 | |
| 922 | 966 | // treat $ignoare_validation only as regular expression, if it starts with a slash |
| 923 | 967 | if ($ignore_validation[0] == '/' && !preg_match($ignore_validation,$name) || |
@@ -974,8 +1018,14 @@ discard block |
||
| 974 | 1018 | self::$request->unset_to_process(''); |
| 975 | 1019 | //error_log(__METHOD__."('$name', '$attr', ...) ".function_backtrace()); |
| 976 | 1020 | } |
| 977 | - if (isset($this)) $this->attrs[$attr] = $val; |
|
| 978 | - if (!is_null($val)) $ref = $val; |
|
| 1021 | + if (isset($this)) |
|
| 1022 | + { |
|
| 1023 | + $this->attrs[$attr] = $val; |
|
| 1024 | + } |
|
| 1025 | + if (!is_null($val)) |
|
| 1026 | + { |
|
| 1027 | + $ref = $val; |
|
| 1028 | + } |
|
| 979 | 1029 | |
| 980 | 1030 | //error_log(__METHOD__."('$name', '$attr', ".array2string($val).')'); |
| 981 | 1031 | return $ref; |
@@ -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 | { |
@@ -60,17 +60,17 @@ discard block |
||
| 60 | 60 | * @param string $cname |
| 61 | 61 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
| 62 | 62 | */ |
| 63 | - public function beforeSendToClient($cname, array $expand=null) |
|
| 63 | + public function beforeSendToClient($cname, array $expand = null) |
|
| 64 | 64 | { |
| 65 | - if($this->type == 'date-houronly') |
|
| 65 | + if ($this->type == 'date-houronly') |
|
| 66 | 66 | { |
| 67 | 67 | return parent::beforeSendToClient($cname, $expand); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $form_name = self::form_name($cname, $this->id, $expand); |
| 71 | - $value =& self::get_array(self::$request->content, $form_name, false, true); |
|
| 71 | + $value = & self::get_array(self::$request->content, $form_name, false, true); |
|
| 72 | 72 | |
| 73 | - if($this->type != 'date-duration' && $value) |
|
| 73 | + if ($this->type != 'date-duration' && $value) |
|
| 74 | 74 | { |
| 75 | 75 | $value = $this->format_date($value); |
| 76 | 76 | } |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function set_row_value($cname, Array $expand, Array &$data) |
| 92 | 92 | { |
| 93 | - if($this->type == 'date-duration') return; |
|
| 93 | + if ($this->type == 'date-duration') return; |
|
| 94 | 94 | |
| 95 | 95 | $form_name = self::form_name($cname, $this->id, $expand); |
| 96 | - $value =& $this->get_array($data, $form_name, true); |
|
| 96 | + $value = & $this->get_array($data, $form_name, true); |
|
| 97 | 97 | |
| 98 | 98 | if (true) $value = $this->format_date($value); |
| 99 | 99 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function format_date($value) |
| 107 | 107 | { |
| 108 | - if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
| 108 | + if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
| 109 | 109 | |
| 110 | 110 | if ($this->attrs['dataformat'] && !is_numeric($value)) |
| 111 | 111 | { |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | $date = new Api\DateTime($value); |
| 117 | 117 | } |
| 118 | - if($this->type == 'date-timeonly') |
|
| 118 | + if ($this->type == 'date-timeonly') |
|
| 119 | 119 | { |
| 120 | 120 | $date->setDate(1970, 1, 1); |
| 121 | 121 | } |
| 122 | - if($date) |
|
| 122 | + if ($date) |
|
| 123 | 123 | { |
| 124 | 124 | // postfix date-string with "Z" so javascript doesn't add/subtract anything |
| 125 | 125 | $value = $date->format('Y-m-d\TH:i:s\Z'); |
@@ -141,18 +141,18 @@ discard block |
||
| 141 | 141 | * @param array &$validated=array() validated content |
| 142 | 142 | * @return boolean true if no validation error, false otherwise |
| 143 | 143 | */ |
| 144 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
| 144 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
| 145 | 145 | { |
| 146 | 146 | $form_name = self::form_name($cname, $this->id, $expand); |
| 147 | 147 | |
| 148 | 148 | if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') // date-since is always readonly |
| 149 | 149 | { |
| 150 | 150 | $value = self::get_array($content, $form_name); |
| 151 | - $valid =& self::get_array($validated, $form_name, true); |
|
| 151 | + $valid = & self::get_array($validated, $form_name, true); |
|
| 152 | 152 | |
| 153 | 153 | if ((string)$value === '' && $this->attrs['needed']) |
| 154 | 154 | { |
| 155 | - self::set_validation_error($form_name,lang('Field must not be empty !!!')); |
|
| 155 | + self::set_validation_error($form_name, lang('Field must not be empty !!!')); |
|
| 156 | 156 | } |
| 157 | 157 | elseif (is_null($value)) |
| 158 | 158 | { |
@@ -162,49 +162,49 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $valid = (string)$value === '' ? '' : (int)$value; |
| 164 | 164 | } |
| 165 | - if($value) |
|
| 165 | + if ($value) |
|
| 166 | 166 | { |
| 167 | 167 | $date = new Api\DateTime($value); |
| 168 | 168 | } |
| 169 | 169 | if (!empty($this->attrs['min'])) |
| 170 | 170 | { |
| 171 | - if(is_numeric($this->attrs['min'])) |
|
| 171 | + if (is_numeric($this->attrs['min'])) |
|
| 172 | 172 | { |
| 173 | - $min = new Api\DateTime(strtotime( $this->attrs['min'] . 'days')); |
|
| 173 | + $min = new Api\DateTime(strtotime($this->attrs['min'].'days')); |
|
| 174 | 174 | } |
| 175 | 175 | else |
| 176 | 176 | { |
| 177 | 177 | $min = new Api\DateTime(strtotime($this->attrs['min'])); |
| 178 | 178 | } |
| 179 | - if($value < $min) |
|
| 179 | + if ($value < $min) |
|
| 180 | 180 | { |
| 181 | - self::set_validation_error($form_name,lang( |
|
| 181 | + self::set_validation_error($form_name, lang( |
|
| 182 | 182 | "Value has to be at least '%1' !!!", |
| 183 | 183 | $min->format($this->type != 'date') |
| 184 | - ),''); |
|
| 184 | + ), ''); |
|
| 185 | 185 | $value = $min; |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | if (!empty($this->attrs['max'])) |
| 189 | 189 | { |
| 190 | - if(is_numeric($this->attrs['max'])) |
|
| 190 | + if (is_numeric($this->attrs['max'])) |
|
| 191 | 191 | { |
| 192 | - $max = new Api\DateTime(strtotime( $this->attrs['max'] . 'days')); |
|
| 192 | + $max = new Api\DateTime(strtotime($this->attrs['max'].'days')); |
|
| 193 | 193 | } |
| 194 | 194 | else |
| 195 | 195 | { |
| 196 | 196 | $max = new Api\DateTime(strtotime($this->attrs['max'])); |
| 197 | 197 | } |
| 198 | - if($value < $max) |
|
| 198 | + if ($value < $max) |
|
| 199 | 199 | { |
| 200 | - self::set_validation_error($form_name,lang( |
|
| 200 | + self::set_validation_error($form_name, lang( |
|
| 201 | 201 | "Value has to be at maximum '%1' !!!", |
| 202 | 202 | $max->format($this->type != 'date') |
| 203 | - ),''); |
|
| 203 | + ), ''); |
|
| 204 | 204 | $value = $max; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | - if(!$value) |
|
| 207 | + if (!$value) |
|
| 208 | 208 | { |
| 209 | 209 | // Not null, blank |
| 210 | 210 | $value = ''; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | else |
| 222 | 222 | { |
| 223 | 223 | // this is not really a user error, but one of the clientside engine |
| 224 | - self::set_validation_error($form_name,lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); |
|
| 224 | + self::set_validation_error($form_name, lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); |
|
| 225 | 225 | } |
| 226 | 226 | //error_log("$this : ($valid)" . Api\DateTime::to($valid)); |
| 227 | 227 | } |
@@ -90,12 +90,18 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function set_row_value($cname, Array $expand, Array &$data) |
| 92 | 92 | { |
| 93 | - if($this->type == 'date-duration') return; |
|
| 93 | + if($this->type == 'date-duration') |
|
| 94 | + { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 94 | 97 | |
| 95 | 98 | $form_name = self::form_name($cname, $this->id, $expand); |
| 96 | 99 | $value =& $this->get_array($data, $form_name, true); |
| 97 | 100 | |
| 98 | - if (true) $value = $this->format_date($value); |
|
| 101 | + if (true) |
|
| 102 | + { |
|
| 103 | + $value = $this->format_date($value); |
|
| 104 | + } |
|
| 99 | 105 | } |
| 100 | 106 | |
| 101 | 107 | /** |
@@ -105,7 +111,11 @@ discard block |
||
| 105 | 111 | */ |
| 106 | 112 | public function format_date($value) |
| 107 | 113 | { |
| 108 | - if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
| 114 | + if (!$value) |
|
| 115 | + { |
|
| 116 | + return $value; |
|
| 117 | + } |
|
| 118 | + // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
| 109 | 119 | |
| 110 | 120 | if ($this->attrs['dataformat'] && !is_numeric($value)) |
| 111 | 121 | { |
@@ -145,9 +155,12 @@ discard block |
||
| 145 | 155 | { |
| 146 | 156 | $form_name = self::form_name($cname, $this->id, $expand); |
| 147 | 157 | |
| 148 | - if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') // date-since is always readonly |
|
| 158 | + if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') |
|
| 159 | + { |
|
| 160 | + // date-since is always readonly |
|
| 149 | 161 | { |
| 150 | 162 | $value = self::get_array($content, $form_name); |
| 163 | + } |
|
| 151 | 164 | $valid =& self::get_array($validated, $form_name, true); |
| 152 | 165 | |
| 153 | 166 | if ((string)$value === '' && $this->attrs['needed']) |
@@ -209,10 +222,13 @@ discard block |
||
| 209 | 222 | // Not null, blank |
| 210 | 223 | $value = ''; |
| 211 | 224 | } |
| 212 | - elseif (empty($this->attrs['dataformat'])) // integer timestamp |
|
| 225 | + elseif (empty($this->attrs['dataformat'])) |
|
| 226 | + { |
|
| 227 | + // integer timestamp |
|
| 213 | 228 | { |
| 214 | 229 | $valid = $date->format('ts'); |
| 215 | 230 | } |
| 231 | + } |
|
| 216 | 232 | // string with formatting letters like for php's date() method |
| 217 | 233 | elseif ($date && ($valid = $date->format($this->attrs['dataformat']))) |
| 218 | 234 | { |
@@ -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 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @param string|XMLReader $xml |
| 57 | 57 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
| 58 | - * @return Template current object or clone, if any attribute was set |
|
| 58 | + * @return Textbox current object or clone, if any attribute was set |
|
| 59 | 59 | */ |
| 60 | 60 | public function set_attrs($xml, $cloned=true) |
| 61 | 61 | { |
@@ -110,7 +110,6 @@ discard block |
||
| 110 | 110 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
| 111 | 111 | * @param array $content |
| 112 | 112 | * @param array &$validated=array() validated content |
| 113 | - * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
| 114 | 113 | */ |
| 115 | 114 | public function validate($cname, array $expand, array $content, &$validated=array()) |
| 116 | 115 | { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
| 58 | 58 | * @return Template current object or clone, if any attribute was set |
| 59 | 59 | */ |
| 60 | - public function set_attrs($xml, $cloned=true) |
|
| 60 | + public function set_attrs($xml, $cloned = true) |
|
| 61 | 61 | { |
| 62 | 62 | parent::set_attrs($xml, $cloned); |
| 63 | 63 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $this->setElementAttribute($this->id, 'size', abs($this->attrs['size'])); |
| 70 | 70 | self::$request->readonlys[$this->id] = false; |
| 71 | 71 | $this->setElementAttribute($this->id, 'readonly', true); |
| 72 | - trigger_error("Using a negative size to set textbox readonly. " .$this, E_USER_DEPRECATED); |
|
| 72 | + trigger_error("Using a negative size to set textbox readonly. ".$this, E_USER_DEPRECATED); |
|
| 73 | 73 | } |
| 74 | 74 | return $this; |
| 75 | 75 | } |
@@ -80,16 +80,16 @@ discard block |
||
| 80 | 80 | * @param string $cname |
| 81 | 81 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
| 82 | 82 | */ |
| 83 | - public function beforeSendToClient($cname, array $expand=null) |
|
| 83 | + public function beforeSendToClient($cname, array $expand = null) |
|
| 84 | 84 | { |
| 85 | 85 | // to NOT transmit passwords back to client, we need to store (non-empty) value in preserv |
| 86 | 86 | if ($this->attrs['type'] == 'passwd' || $this->type == 'passwd') |
| 87 | 87 | { |
| 88 | 88 | $form_name = self::form_name($cname, $this->id, $expand); |
| 89 | - $value =& self::get_array(self::$request->content, $form_name); |
|
| 89 | + $value = & self::get_array(self::$request->content, $form_name); |
|
| 90 | 90 | if (!empty($value)) |
| 91 | 91 | { |
| 92 | - $preserv =& self::get_array(self::$request->preserv, $form_name, true); |
|
| 92 | + $preserv = & self::get_array(self::$request->preserv, $form_name, true); |
|
| 93 | 93 | if (true) $preserv = (string)$value; |
| 94 | 94 | $value = str_repeat('*', strlen($preserv)); |
| 95 | 95 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param array &$validated=array() validated content |
| 113 | 113 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
| 114 | 114 | */ |
| 115 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
| 115 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
| 116 | 116 | { |
| 117 | 117 | $form_name = self::form_name($cname, $this->id, $expand); |
| 118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | if (!isset($this->attrs['validator'])) |
| 122 | 122 | { |
| 123 | - switch($this->type) |
|
| 123 | + switch ($this->type) |
|
| 124 | 124 | { |
| 125 | 125 | case 'int': |
| 126 | 126 | case 'integer': |
@@ -150,24 +150,24 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | if ((string)$value === '' && $this->attrs['needed']) |
| 152 | 152 | { |
| 153 | - self::set_validation_error($form_name,lang('Field must not be empty !!!'),''); |
|
| 153 | + self::set_validation_error($form_name, lang('Field must not be empty !!!'), ''); |
|
| 154 | 154 | } |
| 155 | - if ((int) $this->attrs['maxlength'] > 0 && mb_strlen($value) > (int) $this->attrs['maxlength']) |
|
| 155 | + if ((int)$this->attrs['maxlength'] > 0 && mb_strlen($value) > (int)$this->attrs['maxlength']) |
|
| 156 | 156 | { |
| 157 | - $value = mb_substr($value,0,(int) $this->attrs['maxlength']); |
|
| 157 | + $value = mb_substr($value, 0, (int)$this->attrs['maxlength']); |
|
| 158 | 158 | } |
| 159 | - if ($this->attrs['validator'] && !preg_match($this->attrs['validator'],$value)) |
|
| 159 | + if ($this->attrs['validator'] && !preg_match($this->attrs['validator'], $value)) |
|
| 160 | 160 | { |
| 161 | - switch($this->type) |
|
| 161 | + switch ($this->type) |
|
| 162 | 162 | { |
| 163 | 163 | case 'integer': |
| 164 | - self::set_validation_error($form_name,lang("'%1' is not a valid integer !!!",$value),''); |
|
| 164 | + self::set_validation_error($form_name, lang("'%1' is not a valid integer !!!", $value), ''); |
|
| 165 | 165 | break; |
| 166 | 166 | case 'float': |
| 167 | - self::set_validation_error($form_name,lang("'%1' is not a valid floatingpoint number !!!",$value),''); |
|
| 167 | + self::set_validation_error($form_name, lang("'%1' is not a valid floatingpoint number !!!", $value), ''); |
|
| 168 | 168 | break; |
| 169 | 169 | default: |
| 170 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$this->attrs[validator]', '$value')"*/,''); |
|
| 170 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$this->attrs[validator]', '$value')"*/, ''); |
|
| 171 | 171 | break; |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -175,17 +175,17 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | if ((string)$value !== '' || $this->attrs['needed']) // empty values are Ok if needed is not set |
| 177 | 177 | { |
| 178 | - $value = $this->type == 'integer' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format |
|
| 178 | + $value = $this->type == 'integer' ? (int)$value : (float)str_replace(',', '.', $value); // allow for german (and maybe other) format |
|
| 179 | 179 | |
| 180 | 180 | if (!empty($this->attrs['min']) && $value < $this->attrs['min']) |
| 181 | 181 | { |
| 182 | - self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$this->attrs['min']),''); |
|
| 183 | - $value = $this->type == 'integer' ? (int) $this->attrs['min'] : (float) $this->attrs['min']; |
|
| 182 | + self::set_validation_error($form_name, lang("Value has to be at least '%1' !!!", $this->attrs['min']), ''); |
|
| 183 | + $value = $this->type == 'integer' ? (int)$this->attrs['min'] : (float)$this->attrs['min']; |
|
| 184 | 184 | } |
| 185 | 185 | if (!empty($this->attrs['max']) && $value > $this->attrs['max']) |
| 186 | 186 | { |
| 187 | - self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$this->attrs['max']),''); |
|
| 188 | - $value = $this->type == 'integer' ? (int) $this->attrs['max'] : (float) $this->attrs['max']; |
|
| 187 | + self::set_validation_error($form_name, lang("Value has to be at maximum '%1' !!!", $this->attrs['max']), ''); |
|
| 188 | + $value = $this->type == 'integer' ? (int)$this->attrs['max'] : (float)$this->attrs['max']; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -197,4 +197,4 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | -Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Textbox', array('textbox','text','int','integer','float','passwd','hidden','colorpicker','hidden')); |
|
| 200 | +Etemplate\Widget::registerWidget(__NAMESPACE__.'\\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 | { |
@@ -361,7 +361,6 @@ discard block |
||
| 361 | 361 | * Get options from $sel_options array for a given selectbox name |
| 362 | 362 | * |
| 363 | 363 | * @param string $name |
| 364 | - * @param boolean $no_lang=false value of no_lang attribute |
|
| 365 | 364 | * @return array |
| 366 | 365 | */ |
| 367 | 366 | public static function selOptions($name) |
@@ -400,7 +399,7 @@ discard block |
||
| 400 | 399 | * |
| 401 | 400 | * @param string $widget_type |
| 402 | 401 | * @param string $legacy_options options string of widget |
| 403 | - * @param boolean $no_lang=false initial value of no_lang attribute (some types set it to true) |
|
| 402 | + * @param boolean $no_lang initial value of no_lang attribute (some types set it to true) |
|
| 404 | 403 | * @param boolean $readonly =false |
| 405 | 404 | * @param mixed $value =null value for readonly |
| 406 | 405 | * @return array with value => label pairs |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
| 121 | 121 | * @return Etempalte\Widget current object or clone, if any attribute was set |
| 122 | 122 | */ |
| 123 | - public function set_attrs($xml, $cloned=true) |
|
| 123 | + public function set_attrs($xml, $cloned = true) |
|
| 124 | 124 | { |
| 125 | 125 | $this->attrs['type'] = $xml->localName; |
| 126 | 126 | parent::set_attrs($xml, $cloned); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | if (isset($item['item']) && is_array($item['item'])) |
| 166 | 166 | { |
| 167 | - foreach($item['item'] as &$child) |
|
| 167 | + foreach ($item['item'] as &$child) |
|
| 168 | 168 | { |
| 169 | 169 | $child = self::htmlencode_node($child); |
| 170 | 170 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | return true; |
| 187 | 187 | } |
| 188 | - foreach((array)$item['item'] as $child) |
|
| 188 | + foreach ((array)$item['item'] as $child) |
|
| 189 | 189 | { |
| 190 | 190 | if (self::in_tree($id, $child)) return true; |
| 191 | 191 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param array $content |
| 218 | 218 | * @param array &$validated=array() validated content |
| 219 | 219 | */ |
| 220 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
| 220 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
| 221 | 221 | { |
| 222 | 222 | $form_name = self::form_name($cname, $this->id, $expand); |
| 223 | 223 | |
@@ -231,13 +231,13 @@ discard block |
||
| 231 | 231 | { |
| 232 | 232 | $allowed = $this->attrs['multiple'] ? array() : array('' => $this->attrs['options']); |
| 233 | 233 | $allowed += self::selOptions($form_name); |
| 234 | - foreach((array) $value as $val) |
|
| 234 | + foreach ((array)$value as $val) |
|
| 235 | 235 | { |
| 236 | 236 | if ($this->type == 'tree-cat' && !($this->attrs['multiple'] && !$val) && !self::in_cats($val, $allowed) || |
| 237 | 237 | $this->type == 'tree' && !self::in_tree($val, $allowed)) |
| 238 | 238 | { |
| 239 | - self::set_validation_error($form_name,lang("'%1' is NOT allowed%2)!", $val, |
|
| 240 | - $this->type == 'tree-cat' ? " ('".implode("','",array_keys($allowed)).')' : ''), ''); |
|
| 239 | + self::set_validation_error($form_name, lang("'%1' is NOT allowed%2)!", $val, |
|
| 240 | + $this->type == 'tree-cat' ? " ('".implode("','", array_keys($allowed)).')' : ''), ''); |
|
| 241 | 241 | $value = ''; |
| 242 | 242 | break; |
| 243 | 243 | } |
@@ -254,18 +254,18 @@ discard block |
||
| 254 | 254 | { |
| 255 | 255 | $value = array_merge($value, (array)self::$request->preserv[$unavailable_name]); |
| 256 | 256 | } |
| 257 | - elseif(!$value) // for single cat, we only restore unavailable one, if no other was selected |
|
| 257 | + elseif (!$value) // for single cat, we only restore unavailable one, if no other was selected |
|
| 258 | 258 | { |
| 259 | 259 | $value = self::$request->preserv[$unavailable_name]; |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | - $value = implode(',',$value); |
|
| 262 | + $value = implode(',', $value); |
|
| 263 | 263 | } |
| 264 | 264 | if ($ok && $value === '' && $this->attrs['needed']) |
| 265 | 265 | { |
| 266 | - self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),''); |
|
| 266 | + self::set_validation_error($form_name, lang('Field must not be empty !!!', $value), ''); |
|
| 267 | 267 | } |
| 268 | - $valid =& self::get_array($validated, $form_name, true); |
|
| 268 | + $valid = & self::get_array($validated, $form_name, true); |
|
| 269 | 269 | if (true) $valid = $value; |
| 270 | 270 | //error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed)); |
| 271 | 271 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | { |
| 292 | 292 | // += to keep further options set by app code |
| 293 | 293 | self::$request->sel_options[$form_name] += self::typeOptions($this->attrs['type'], $this->attrs['options'], |
| 294 | - $no_lang=null, $this->attrs['readonly'], self::get_array(self::$request->content, $form_name), $form_name); |
|
| 294 | + $no_lang = null, $this->attrs['readonly'], self::get_array(self::$request->content, $form_name), $form_name); |
|
| 295 | 295 | |
| 296 | 296 | // if no_lang was modified, forward modification to the client |
| 297 | 297 | if ($no_lang != $this->attr['no_lang']) |
@@ -301,15 +301,15 @@ discard block |
||
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // Make sure s, etc. are properly encoded when sent, and not double-encoded |
| 304 | - foreach(self::$request->sel_options[$form_name] as &$label) |
|
| 304 | + foreach (self::$request->sel_options[$form_name] as &$label) |
|
| 305 | 305 | { |
| 306 | - if(!is_array($label)) |
|
| 306 | + if (!is_array($label)) |
|
| 307 | 307 | { |
| 308 | - $label = html_entity_decode($label, ENT_NOQUOTES,'utf-8'); |
|
| 308 | + $label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8'); |
|
| 309 | 309 | } |
| 310 | - elseif($label['label']) |
|
| 310 | + elseif ($label['label']) |
|
| 311 | 311 | { |
| 312 | - $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8'); |
|
| 312 | + $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8'); |
|
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @param string $image_path =null default path to use, or empty to use default of /api/templates/default/images/dhtmlxtree |
| 322 | 322 | * @return string templated url if available, otherwise default path |
| 323 | 323 | */ |
| 324 | - public static function templateImagePath($image_path=null) |
|
| 324 | + public static function templateImagePath($image_path = null) |
|
| 325 | 325 | { |
| 326 | 326 | $webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; |
| 327 | 327 | if (empty($image_path)) |
@@ -353,20 +353,20 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | public static function imagePath($image) |
| 355 | 355 | { |
| 356 | - static $image_path=null; |
|
| 357 | - if (!isset($image_path)) $image_path = self::templateImagePath (); |
|
| 356 | + static $image_path = null; |
|
| 357 | + if (!isset($image_path)) $image_path = self::templateImagePath(); |
|
| 358 | 358 | |
| 359 | 359 | $parts = explode('/', $image_path); |
| 360 | - $image_parts = explode('/', $image); |
|
| 360 | + $image_parts = explode('/', $image); |
|
| 361 | 361 | |
| 362 | 362 | // remove common parts |
| 363 | - while(isset($parts[0]) && $parts[0] === $image_parts[0]) |
|
| 363 | + while (isset($parts[0]) && $parts[0] === $image_parts[0]) |
|
| 364 | 364 | { |
| 365 | 365 | array_shift($parts); |
| 366 | 366 | array_shift($image_parts); |
| 367 | 367 | } |
| 368 | 368 | // add .. for different parts, except last image part |
| 369 | - $url = implode('/', array_merge(array_fill(0, count($parts)-1, '..'), $image_parts)); |
|
| 369 | + $url = implode('/', array_merge(array_fill(0, count($parts) - 1, '..'), $image_parts)); |
|
| 370 | 370 | |
| 371 | 371 | //error_log(__METHOD__."('$image') image_path=$image_path returning $url"); |
| 372 | 372 | return $url; |
@@ -388,10 +388,10 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | else |
| 390 | 390 | { |
| 391 | - $name_parts = explode('[',str_replace(']','',$name)); |
|
| 391 | + $name_parts = explode('[', str_replace(']', '', $name)); |
|
| 392 | 392 | if (count($name_parts)) |
| 393 | 393 | { |
| 394 | - $org_name = $name_parts[count($name_parts)-1]; |
|
| 394 | + $org_name = $name_parts[count($name_parts) - 1]; |
|
| 395 | 395 | if (isset(self::$request->sel_options[$org_name]) && is_array(self::$request->sel_options[$org_name])) |
| 396 | 396 | { |
| 397 | 397 | $options += self::$request->sel_options[$org_name]; |
@@ -421,9 +421,9 @@ discard block |
||
| 421 | 421 | * @param string $form_name form-name of widget, used to store unavailable cats |
| 422 | 422 | * @return array with value => label pairs |
| 423 | 423 | */ |
| 424 | - public static function typeOptions($widget_type, $legacy_options, &$no_lang=false, $readonly=false, $value=null, $form_name=null) |
|
| 424 | + public static function typeOptions($widget_type, $legacy_options, &$no_lang = false, $readonly = false, $value = null, $form_name = null) |
|
| 425 | 425 | { |
| 426 | - list($rows,$type,$type2,$type3) = explode(',',$legacy_options); |
|
| 426 | + list($rows, $type, $type2, $type3) = explode(',', $legacy_options); |
|
| 427 | 427 | |
| 428 | 428 | $no_lang = false; |
| 429 | 429 | $options = array(); |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | if ($readonly) // for readonly we dont need to fetch all cat's, nor do we need to indent them by level |
| 434 | 434 | { |
| 435 | 435 | $cell['no_lang'] = True; |
| 436 | - foreach(is_array($value) ? $value : (strpos($value,',') !== false ? explode(',',$value) : array($value)) as $id) |
|
| 436 | + foreach (is_array($value) ? $value : (strpos($value, ',') !== false ? explode(',', $value) : array($value)) as $id) |
|
| 437 | 437 | { |
| 438 | 438 | if ($id) $cell['sel_options'][$id] = stripslashes($GLOBALS['egw']->categories->id2name($id)); |
| 439 | 439 | } |
@@ -441,14 +441,14 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | if (!$type3 || $type3 === $GLOBALS['egw']->categories->app_name) |
| 443 | 443 | { |
| 444 | - $categories =& $GLOBALS['egw']->categories; |
|
| 444 | + $categories = & $GLOBALS['egw']->categories; |
|
| 445 | 445 | } |
| 446 | 446 | else // we need to instanciate a new cat object for the correct application |
| 447 | 447 | { |
| 448 | - $categories = new Api\Categories('',$type3); |
|
| 448 | + $categories = new Api\Categories('', $type3); |
|
| 449 | 449 | } |
| 450 | - $cat2path=array(); |
|
| 451 | - foreach((array)$categories->return_sorted_array(0,False,'','','',!$type,0,true) as $cat) |
|
| 450 | + $cat2path = array(); |
|
| 451 | + foreach ((array)$categories->return_sorted_array(0, False, '', '', '', !$type, 0, true) as $cat) |
|
| 452 | 452 | { |
| 453 | 453 | $s = stripslashes($cat['name']); |
| 454 | 454 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | if ($value) |
| 480 | 480 | { |
| 481 | 481 | $pathes = $unavailable = array(); |
| 482 | - foreach(is_array($value) ? $value : explode(',',$value) as $cat) |
|
| 482 | + foreach (is_array($value) ? $value : explode(',', $value) as $cat) |
|
| 483 | 483 | { |
| 484 | 484 | if (isset($cat2path[$cat])) |
| 485 | 485 | { |
@@ -187,7 +187,10 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | foreach((array)$item['item'] as $child) |
| 189 | 189 | { |
| 190 | - if (self::in_tree($id, $child)) return true; |
|
| 190 | + if (self::in_tree($id, $child)) |
|
| 191 | + { |
|
| 192 | + return true; |
|
| 193 | + } |
|
| 191 | 194 | } |
| 192 | 195 | return false; |
| 193 | 196 | } |
@@ -254,10 +257,13 @@ discard block |
||
| 254 | 257 | { |
| 255 | 258 | $value = array_merge($value, (array)self::$request->preserv[$unavailable_name]); |
| 256 | 259 | } |
| 257 | - elseif(!$value) // for single cat, we only restore unavailable one, if no other was selected |
|
| 260 | + elseif(!$value) |
|
| 261 | + { |
|
| 262 | + // for single cat, we only restore unavailable one, if no other was selected |
|
| 258 | 263 | { |
| 259 | 264 | $value = self::$request->preserv[$unavailable_name]; |
| 260 | 265 | } |
| 266 | + } |
|
| 261 | 267 | } |
| 262 | 268 | $value = implode(',',$value); |
| 263 | 269 | } |
@@ -266,7 +272,10 @@ discard block |
||
| 266 | 272 | self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),''); |
| 267 | 273 | } |
| 268 | 274 | $valid =& self::get_array($validated, $form_name, true); |
| 269 | - if (true) $valid = $value; |
|
| 275 | + if (true) |
|
| 276 | + { |
|
| 277 | + $valid = $value; |
|
| 278 | + } |
|
| 270 | 279 | //error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed)); |
| 271 | 280 | } |
| 272 | 281 | } |
@@ -286,7 +295,10 @@ discard block |
||
| 286 | 295 | //error_log(__METHOD__."() setting templated image-path for $form_name: $templated_path"); |
| 287 | 296 | } |
| 288 | 297 | |
| 289 | - if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array(); |
|
| 298 | + if (!is_array(self::$request->sel_options[$form_name])) |
|
| 299 | + { |
|
| 300 | + self::$request->sel_options[$form_name] = array(); |
|
| 301 | + } |
|
| 290 | 302 | if ($this->attrs['type']) |
| 291 | 303 | { |
| 292 | 304 | // += to keep further options set by app code |
@@ -354,7 +366,10 @@ discard block |
||
| 354 | 366 | public static function imagePath($image) |
| 355 | 367 | { |
| 356 | 368 | static $image_path=null; |
| 357 | - if (!isset($image_path)) $image_path = self::templateImagePath (); |
|
| 369 | + if (!isset($image_path)) |
|
| 370 | + { |
|
| 371 | + $image_path = self::templateImagePath (); |
|
| 372 | + } |
|
| 358 | 373 | |
| 359 | 374 | $parts = explode('/', $image_path); |
| 360 | 375 | $image_parts = explode('/', $image); |
@@ -430,12 +445,18 @@ discard block |
||
| 430 | 445 | switch ($widget_type) |
| 431 | 446 | { |
| 432 | 447 | case 'tree-cat': // !$type == globals cats too, $type2: extraStyleMultiselect, $type3: application, if not current-app, $type4: parent-id, $type5=owner (-1=global),$type6=show missing |
| 433 | - if ($readonly) // for readonly we dont need to fetch all cat's, nor do we need to indent them by level |
|
| 448 | + if ($readonly) |
|
| 449 | + { |
|
| 450 | + // for readonly we dont need to fetch all cat's, nor do we need to indent them by level |
|
| 434 | 451 | { |
| 435 | 452 | $cell['no_lang'] = True; |
| 453 | + } |
|
| 436 | 454 | foreach(is_array($value) ? $value : (strpos($value,',') !== false ? explode(',',$value) : array($value)) as $id) |
| 437 | 455 | { |
| 438 | - if ($id) $cell['sel_options'][$id] = stripslashes($GLOBALS['egw']->categories->id2name($id)); |
|
| 456 | + if ($id) |
|
| 457 | + { |
|
| 458 | + $cell['sel_options'][$id] = stripslashes($GLOBALS['egw']->categories->id2name($id)); |
|
| 459 | + } |
|
| 439 | 460 | } |
| 440 | 461 | break; |
| 441 | 462 | } |
@@ -52,7 +52,6 @@ |
||
| 52 | 52 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
| 53 | 53 | * @param array $content |
| 54 | 54 | * @param array &$validated=array() validated content |
| 55 | - * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
| 56 | 55 | */ |
| 57 | 56 | public function validate($cname, array $expand, array $content, &$validated=array()) |
| 58 | 57 | { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param array &$validated=array() validated content |
| 55 | 55 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
| 56 | 56 | */ |
| 57 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
| 57 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
| 58 | 58 | { |
| 59 | 59 | $form_name = self::form_name($cname, $this->id, $expand); |
| 60 | 60 | |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if ((string)$value === '' && $this->attrs['needed']) |
| 66 | 66 | { |
| 67 | - self::set_validation_error($form_name,lang('Field must not be empty !!!'),''); |
|
| 67 | + self::set_validation_error($form_name, lang('Field must not be empty !!!'), ''); |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | elseif ((string)$value != '' && !isset($this->attrs['preg'])) |
| 71 | 71 | { |
| 72 | - switch($this->type) |
|
| 72 | + switch ($this->type) |
|
| 73 | 73 | { |
| 74 | 74 | case 'url': |
| 75 | 75 | // if no protocol given eg. "www.egroupware.org" prepend "http://" for validation |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | $url_valid = filter_var($value, FILTER_VALIDATE_URL) || |
| 81 | 81 | // Remove intl chars & check again, but if it passes we'll keep the original |
| 82 | - filter_var(preg_replace('/[^[:print:]]/','',$value), FILTER_VALIDATE_URL); |
|
| 82 | + filter_var(preg_replace('/[^[:print:]]/', '', $value), FILTER_VALIDATE_URL); |
|
| 83 | 83 | //error_log(__METHOD__."() filter_var(value=".array2string($value).", FILTER_VALIDATE_URL)=".array2string(filter_var($value, FILTER_VALIDATE_URL))." --> url_valid=".array2string($url_valid)); |
| 84 | 84 | // remove http:// validation prefix again |
| 85 | 85 | if ($missing_protocol) |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | if (!$url_valid) |
| 90 | 90 | { |
| 91 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value),''); |
|
| 91 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value), ''); |
|
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | break; |
@@ -98,19 +98,19 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $valid =& self::get_array($validated, $form_name, true); |
|
| 101 | + $valid = & self::get_array($validated, $form_name, true); |
|
| 102 | 102 | |
| 103 | - if ((int) $this->attrs['maxlength'] > 0 && strlen($value) > (int) $this->attrs['maxlength']) |
|
| 103 | + if ((int)$this->attrs['maxlength'] > 0 && strlen($value) > (int)$this->attrs['maxlength']) |
|
| 104 | 104 | { |
| 105 | - $value = substr($value,0,(int) $this->attrs['maxlength']); |
|
| 105 | + $value = substr($value, 0, (int)$this->attrs['maxlength']); |
|
| 106 | 106 | } |
| 107 | - if ($this->attrs['preg'] && !preg_match($this->attrs['preg'],$value)) |
|
| 107 | + if ($this->attrs['preg'] && !preg_match($this->attrs['preg'], $value)) |
|
| 108 | 108 | { |
| 109 | - switch($this->type) |
|
| 109 | + switch ($this->type) |
|
| 110 | 110 | { |
| 111 | 111 | default: |
| 112 | 112 | //error_log("preg_match('{$this->attrs['preg']}', '$value')=".array2string(preg_match($this->attrs['preg'], $value))); |
| 113 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$this->attrs[preg]', '$value')"*/,''); |
|
| 113 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$this->attrs[preg]', '$value')"*/, ''); |
|
| 114 | 114 | break; |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -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 | } |
@@ -230,6 +230,7 @@ |
||
| 230 | 230 | * If the entry is not yet created, the file information is stored into the widget's value. |
| 231 | 231 | * When the form is submitted, the information for all files uploaded is available in the returned |
| 232 | 232 | * $content array and the application should deal with the file. |
| 233 | + * @return string |
|
| 233 | 234 | */ |
| 234 | 235 | public static function store_file($path, $file) |
| 235 | 236 | { |
@@ -224,13 +224,13 @@ |
||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | - * Ajax callback to receive an incoming file |
|
| 228 | - * |
|
| 229 | - * The incoming file is automatically placed into the appropriate VFS location. |
|
| 230 | - * If the entry is not yet created, the file information is stored into the widget's value. |
|
| 231 | - * When the form is submitted, the information for all files uploaded is available in the returned |
|
| 232 | - * $content array and the application should deal with the file. |
|
| 233 | - */ |
|
| 227 | + * Ajax callback to receive an incoming file |
|
| 228 | + * |
|
| 229 | + * The incoming file is automatically placed into the appropriate VFS location. |
|
| 230 | + * If the entry is not yet created, the file information is stored into the widget's value. |
|
| 231 | + * When the form is submitted, the information for all files uploaded is available in the returned |
|
| 232 | + * $content array and the application should deal with the file. |
|
| 233 | + */ |
|
| 234 | 234 | public static function store_file($path, $file) |
| 235 | 235 | { |
| 236 | 236 | $name = $_REQUEST['widget_id']; |
@@ -27,7 +27,10 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function __construct($xml='') |
| 29 | 29 | { |
| 30 | - if($xml) parent::__construct($xml); |
|
| 30 | + if($xml) |
|
| 31 | + { |
|
| 32 | + parent::__construct($xml); |
|
| 33 | + } |
|
| 31 | 34 | } |
| 32 | 35 | |
| 33 | 36 | /** |
@@ -64,9 +67,15 @@ discard block |
||
| 64 | 67 | } |
| 65 | 68 | $value =& self::get_array(self::$request->content, $form_name, true); |
| 66 | 69 | $path = Api\Link::vfs_path($app,$id,'',true); |
| 67 | - if (!empty($relpath)) $path .= '/'.$relpath; |
|
| 70 | + if (!empty($relpath)) |
|
| 71 | + { |
|
| 72 | + $path .= '/'.$relpath; |
|
| 73 | + } |
|
| 68 | 74 | |
| 69 | - if (true) $value = array(); |
|
| 75 | + if (true) |
|
| 76 | + { |
|
| 77 | + $value = array(); |
|
| 78 | + } |
|
| 70 | 79 | |
| 71 | 80 | // Single file, already existing |
| 72 | 81 | if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) |
@@ -194,7 +203,10 @@ discard block |
||
| 194 | 203 | $replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] = |
| 195 | 204 | Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true); |
| 196 | 205 | |
| 197 | - if (!in_array($matches[1], $remove_dir)) $remove_dir[] = $matches[1]; |
|
| 206 | + if (!in_array($matches[1], $remove_dir)) |
|
| 207 | + { |
|
| 208 | + $remove_dir[] = $matches[1]; |
|
| 209 | + } |
|
| 198 | 210 | } |
| 199 | 211 | } |
| 200 | 212 | if ($replace) |
@@ -218,7 +230,10 @@ discard block |
||
| 218 | 230 | */ |
| 219 | 231 | static function get_temp_dir($app, $postfix=null) |
| 220 | 232 | { |
| 221 | - if (!isset($postfix)) $postfix = md5(time().session_id()); |
|
| 233 | + if (!isset($postfix)) |
|
| 234 | + { |
|
| 235 | + $postfix = md5(time().session_id()); |
|
| 236 | + } |
|
| 222 | 237 | |
| 223 | 238 | return '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/'.$app.'_'.$postfix; |
| 224 | 239 | } |
@@ -245,10 +260,13 @@ discard block |
||
| 245 | 260 | { |
| 246 | 261 | // add extension to path |
| 247 | 262 | $parts = explode('.',$filename); |
| 248 | - if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) // really an extension --> add it to path |
|
| 263 | + if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) |
|
| 264 | + { |
|
| 265 | + // really an extension --> add it to path |
|
| 249 | 266 | { |
| 250 | 267 | $path .= '.'.$extension; |
| 251 | 268 | } |
| 269 | + } |
|
| 252 | 270 | } |
| 253 | 271 | else // multiple upload with dir given (trailing slash) |
| 254 | 272 | { |
@@ -294,7 +312,10 @@ discard block |
||
| 294 | 312 | switch($this->type) |
| 295 | 313 | { |
| 296 | 314 | case 'vfs-upload': |
| 297 | - if(!is_array($value)) $value = array(); |
|
| 315 | + if(!is_array($value)) |
|
| 316 | + { |
|
| 317 | + $value = array(); |
|
| 318 | + } |
|
| 298 | 319 | /* Check & skip files that made it asyncronously |
| 299 | 320 | list($app,$id,$relpath) = explode(':',$this->id,3); |
| 300 | 321 | //... |
@@ -305,7 +326,10 @@ discard block |
||
| 305 | 326 | parent::validate($cname, $content, $validated); |
| 306 | 327 | break; |
| 307 | 328 | } |
| 308 | - if (true) $valid = $value; |
|
| 329 | + if (true) |
|
| 330 | + { |
|
| 331 | + $valid = $value; |
|
| 332 | + } |
|
| 309 | 333 | } |
| 310 | 334 | |
| 311 | 335 | /** |
@@ -317,14 +341,20 @@ discard block |
||
| 317 | 341 | if (empty($id) || $id == 'undefined') |
| 318 | 342 | { |
| 319 | 343 | static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
| 320 | - if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app); |
|
| 344 | + if (!isset($tmppath[$app])) |
|
| 345 | + { |
|
| 346 | + $tmppath[$app] = self::get_temp_dir ($app); |
|
| 347 | + } |
|
| 321 | 348 | $path = $tmppath[$app]; |
| 322 | 349 | } |
| 323 | 350 | else |
| 324 | 351 | { |
| 325 | 352 | $path = Api\Link::vfs_path($app,$id,'',true); |
| 326 | 353 | } |
| 327 | - if (!empty($relpath)) $path .= '/'.$relpath; |
|
| 354 | + if (!empty($relpath)) |
|
| 355 | + { |
|
| 356 | + $path .= '/'.$relpath; |
|
| 357 | + } |
|
| 328 | 358 | return $path; |
| 329 | 359 | } |
| 330 | 360 | } |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | // Legacy option for vfs-upload |
| 26 | 26 | protected $legacy_options = "mime"; |
| 27 | 27 | |
| 28 | - public function __construct($xml='') |
|
| 28 | + public function __construct($xml = '') |
|
| 29 | 29 | { |
| 30 | - if($xml) parent::__construct($xml); |
|
| 30 | + if ($xml) parent::__construct($xml); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function beforeSendToClient($cname, $expand = array()) |
| 38 | 38 | { |
| 39 | - if($this->type == 'vfs-upload' || $this->attrs['type'] == 'vfs-upload') |
|
| 39 | + if ($this->type == 'vfs-upload' || $this->attrs['type'] == 'vfs-upload') |
|
| 40 | 40 | { |
| 41 | 41 | $form_name = self::form_name($cname, $this->id, $expand ? $expand : array('cont'=>self::$request->content)); |
| 42 | - if($this->attrs['path']) |
|
| 42 | + if ($this->attrs['path']) |
|
| 43 | 43 | { |
| 44 | 44 | $path = $this->attrs['path']; |
| 45 | 45 | } |
@@ -50,26 +50,26 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $this->setElementAttribute($form_name, 'path', $path); |
| 52 | 52 | // ID maps to path - check there for any existing files |
| 53 | - list($app,$id,$relpath) = explode(':',$path,3); |
|
| 54 | - if($app && $id) |
|
| 53 | + list($app, $id, $relpath) = explode(':', $path, 3); |
|
| 54 | + if ($app && $id) |
|
| 55 | 55 | { |
| 56 | - if(!is_numeric($id)) |
|
| 56 | + if (!is_numeric($id)) |
|
| 57 | 57 | { |
| 58 | - $_id = self::expand_name($id,0,0,0,0,self::$request->content); |
|
| 59 | - if($_id != $id) |
|
| 58 | + $_id = self::expand_name($id, 0, 0, 0, 0, self::$request->content); |
|
| 59 | + if ($_id != $id) |
|
| 60 | 60 | { |
| 61 | 61 | $id = $_id; |
| 62 | 62 | $form_name = "$app:$id:$relpath"; |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | - $value =& self::get_array(self::$request->content, $form_name, true); |
|
| 66 | - $path = Api\Link::vfs_path($app,$id,'',true); |
|
| 65 | + $value = & self::get_array(self::$request->content, $form_name, true); |
|
| 66 | + $path = Api\Link::vfs_path($app, $id, '', true); |
|
| 67 | 67 | if (!empty($relpath)) $path .= '/'.$relpath; |
| 68 | 68 | |
| 69 | 69 | if (true) $value = array(); |
| 70 | 70 | |
| 71 | 71 | // Single file, already existing |
| 72 | - if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) |
|
| 72 | + if (substr($path, -1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) |
|
| 73 | 73 | { |
| 74 | 74 | $file = Api\Vfs::stat($path); |
| 75 | 75 | $file['path'] = $path; |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | $value = array($file); |
| 79 | 79 | } |
| 80 | 80 | // Single file, missing extension in path |
| 81 | - else if (substr($path, -1) != '/' && !Api\Vfs::file_exists($path) && $relpath && substr($relpath,-4,1) !== '.') |
|
| 81 | + else if (substr($path, -1) != '/' && !Api\Vfs::file_exists($path) && $relpath && substr($relpath, -4, 1) !== '.') |
|
| 82 | 82 | { |
| 83 | - $find = Api\Vfs::find(substr($path,0, - strlen($relpath)), array( |
|
| 83 | + $find = Api\Vfs::find(substr($path, 0, - strlen($relpath)), array( |
|
| 84 | 84 | 'type' => 'f', |
| 85 | 85 | 'maxdepth' => 1, |
| 86 | - 'name' => $relpath . '*' |
|
| 86 | + 'name' => $relpath.'*' |
|
| 87 | 87 | )); |
| 88 | - foreach($find as $file) |
|
| 88 | + foreach ($find as $file) |
|
| 89 | 89 | { |
| 90 | 90 | $file_info = Api\Vfs::stat($file); |
| 91 | 91 | $file_info['path'] = $file; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | else if (substr($path, -1) == '/' && Api\Vfs::is_dir($path)) |
| 98 | 98 | { |
| 99 | 99 | $scan = Api\Vfs::scandir($path); |
| 100 | - foreach($scan as $file) |
|
| 100 | + foreach ($scan as $file) |
|
| 101 | 101 | { |
| 102 | 102 | $file_info = Api\Vfs::stat("$path$file"); |
| 103 | 103 | $file_info['path'] = "$path$file"; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | public static function ajax_upload() |
| 114 | 114 | { |
| 115 | 115 | parent::ajax_upload(); |
| 116 | - foreach($_FILES as $file) |
|
| 116 | + foreach ($_FILES as $file) |
|
| 117 | 117 | { |
| 118 | 118 | self::store_file($_REQUEST['path'] ? $_REQUEST['path'] : $_REQUEST['widget_id'], $file); |
| 119 | 119 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $request_id = urldecode($_REQUEST['request_id']); |
| 128 | 128 | $widget_id = $_REQUEST['widget_id']; |
| 129 | - if(!self::$request = Etemplate\Request::read($request_id)) |
|
| 129 | + if (!self::$request = Etemplate\Request::read($request_id)) |
|
| 130 | 130 | { |
| 131 | 131 | $error = lang("Could not read session"); |
| 132 | 132 | } |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | static function fix_html_dragins($app, $id, array $links, &$html) |
| 187 | 187 | { |
| 188 | 188 | $replace = $remove_dir = array(); |
| 189 | - foreach($links as $link) |
|
| 189 | + foreach ($links as $link) |
|
| 190 | 190 | { |
| 191 | 191 | $matches = null; |
| 192 | - if (is_array($link) && preg_match('|^'.preg_quote(Api\Vfs::PREFIX,'|').'('.preg_quote(self::get_temp_dir($app, ''), '|').'[^/]+)/|', $link['id']['tmp_name'], $matches)) |
|
| 192 | + if (is_array($link) && preg_match('|^'.preg_quote(Api\Vfs::PREFIX, '|').'('.preg_quote(self::get_temp_dir($app, ''), '|').'[^/]+)/|', $link['id']['tmp_name'], $matches)) |
|
| 193 | 193 | { |
| 194 | 194 | $replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] = |
| 195 | 195 | Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | { |
| 202 | 202 | $html = strtr($old = $html, $replace); |
| 203 | 203 | // remove all dirs |
| 204 | - foreach($remove_dir as $dir) |
|
| 204 | + foreach ($remove_dir as $dir) |
|
| 205 | 205 | { |
| 206 | 206 | Api\Vfs::remove($dir); |
| 207 | 207 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * @param string $postfix =null default random id |
| 217 | 217 | * @return string vfs path |
| 218 | 218 | */ |
| 219 | - static function get_temp_dir($app, $postfix=null) |
|
| 219 | + static function get_temp_dir($app, $postfix = null) |
|
| 220 | 220 | { |
| 221 | 221 | if (!isset($postfix)) $postfix = md5(time().session_id()); |
| 222 | 222 | |
@@ -236,15 +236,15 @@ discard block |
||
| 236 | 236 | $name = $_REQUEST['widget_id']; |
| 237 | 237 | |
| 238 | 238 | // Find real path |
| 239 | - if($path[0] != '/') |
|
| 239 | + if ($path[0] != '/') |
|
| 240 | 240 | { |
| 241 | 241 | $path = self::get_vfs_path($path); |
| 242 | 242 | } |
| 243 | 243 | $filename = $file['name']; |
| 244 | - if (substr($path,-1) != '/') |
|
| 244 | + if (substr($path, -1) != '/') |
|
| 245 | 245 | { |
| 246 | 246 | // add extension to path |
| 247 | - $parts = explode('.',$filename); |
|
| 247 | + $parts = explode('.', $filename); |
|
| 248 | 248 | if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) // really an extension --> add it to path |
| 249 | 249 | { |
| 250 | 250 | $path .= '.'.$extension; |
@@ -256,17 +256,17 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | if (!($dir = Api\Vfs::dirname($path))) |
| 258 | 258 | { |
| 259 | - self::set_validation_error($name,lang('Error create parent directory %1!', "dirname('$path') === false")); |
|
| 259 | + self::set_validation_error($name, lang('Error create parent directory %1!', "dirname('$path') === false")); |
|
| 260 | 260 | return false; |
| 261 | 261 | } |
| 262 | - if (!Api\Vfs::file_exists($dir) && !Api\Vfs::mkdir($dir,null,STREAM_MKDIR_RECURSIVE)) |
|
| 262 | + if (!Api\Vfs::file_exists($dir) && !Api\Vfs::mkdir($dir, null, STREAM_MKDIR_RECURSIVE)) |
|
| 263 | 263 | { |
| 264 | - self::set_validation_error($name,lang('Error create parent directory %1!',Api\Vfs::decodePath($dir))); |
|
| 264 | + self::set_validation_error($name, lang('Error create parent directory %1!', Api\Vfs::decodePath($dir))); |
|
| 265 | 265 | return false; |
| 266 | 266 | } |
| 267 | - if (!copy($file['tmp_name'],Api\Vfs::PREFIX.$path)) |
|
| 267 | + if (!copy($file['tmp_name'], Api\Vfs::PREFIX.$path)) |
|
| 268 | 268 | { |
| 269 | - self::set_validation_error($name,lang('Error copying uploaded file to vfs!')); |
|
| 269 | + self::set_validation_error($name, lang('Error copying uploaded file to vfs!')); |
|
| 270 | 270 | return false; |
| 271 | 271 | } |
| 272 | 272 | |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param array $content |
| 286 | 286 | * @param array &$validated=array() validated content |
| 287 | 287 | */ |
| 288 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
| 288 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
| 289 | 289 | { |
| 290 | 290 | // do not validate, as it would overwrite preserved values with null! |
| 291 | 291 | if (in_array($this->type, array('vfs-size', 'vfs-uid', 'vfs-gid', 'vfs', 'vfs-mime'))) |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | $form_name = self::form_name($cname, $this->id, $expand); |
| 296 | 296 | $value = $value_in = self::get_array($content, $form_name); |
| 297 | - $valid =& self::get_array($validated, $form_name, true); |
|
| 297 | + $valid = & self::get_array($validated, $form_name, true); |
|
| 298 | 298 | |
| 299 | - switch($this->type) |
|
| 299 | + switch ($this->type) |
|
| 300 | 300 | { |
| 301 | 301 | case 'vfs-upload': |
| 302 | - if(!is_array($value)) $value = array(); |
|
| 302 | + if (!is_array($value)) $value = array(); |
|
| 303 | 303 | /* Check & skip files that made it asyncronously |
| 304 | 304 | list($app,$id,$relpath) = explode(':',$this->id,3); |
| 305 | 305 | //... |
@@ -318,16 +318,16 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public static function get_vfs_path($path) |
| 320 | 320 | { |
| 321 | - list($app,$id,$relpath) = explode(':',$path,3); |
|
| 321 | + list($app, $id, $relpath) = explode(':', $path, 3); |
|
| 322 | 322 | if (empty($id) || $id == 'undefined') |
| 323 | 323 | { |
| 324 | - static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
|
| 325 | - if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app); |
|
| 324 | + static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
|
| 325 | + if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir($app); |
|
| 326 | 326 | $path = $tmppath[$app]; |
| 327 | 327 | } |
| 328 | 328 | else |
| 329 | 329 | { |
| 330 | - $path = Api\Link::vfs_path($app,$id,'',true); |
|
| 330 | + $path = Api\Link::vfs_path($app, $id, '', true); |
|
| 331 | 331 | } |
| 332 | 332 | if (!empty($relpath)) $path .= '/'.$relpath; |
| 333 | 333 | return $path; |
@@ -19,6 +19,9 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Admin extends App |
| 21 | 21 | { |
| 22 | + /** |
|
| 23 | + * @param string $msg |
|
| 24 | + */ |
|
| 22 | 25 | function __construct($msg=null,$code=102) |
| 23 | 26 | { |
| 24 | 27 | if (is_null($msg)) $msg = 'admin'; |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Admin extends App |
| 21 | 21 | { |
| 22 | - function __construct($msg=null,$code=102) |
|
| 22 | + function __construct($msg = null, $code = 102) |
|
| 23 | 23 | { |
| 24 | 24 | if (is_null($msg)) $msg = 'admin'; |
| 25 | 25 | |
| 26 | - parent::__construct($msg,$code); |
|
| 26 | + parent::__construct($msg, $code); |
|
| 27 | 27 | } |
| 28 | 28 | } |
@@ -21,7 +21,10 @@ |
||
| 21 | 21 | { |
| 22 | 22 | function __construct($msg=null,$code=102) |
| 23 | 23 | { |
| 24 | - if (is_null($msg)) $msg = 'admin'; |
|
| 24 | + if (is_null($msg)) |
|
| 25 | + { |
|
| 26 | + $msg = 'admin'; |
|
| 27 | + } |
|
| 25 | 28 | |
| 26 | 29 | parent::__construct($msg,$code); |
| 27 | 30 | } |