@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | { |
77 | 77 | // should be Ok for all HTML 4 compatible browsers |
78 | 78 | $parts = $all_parts = null; |
79 | - if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts)) |
|
79 | + if (!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $parts)) |
|
80 | 80 | { |
81 | - preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$all_parts,PREG_SET_ORDER); |
|
81 | + preg_match_all('/([a-z]+)\/([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $all_parts, PREG_SET_ORDER); |
|
82 | 82 | $parts = array_pop($all_parts); |
83 | - foreach($all_parts as $p) |
|
83 | + foreach ($all_parts as $p) |
|
84 | 84 | { |
85 | 85 | if ($p[1] == 'Chrome' && $parts[1] != 'Edge') |
86 | 86 | { |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
92 | - list(,self::$user_agent,self::$ua_version) = $parts; |
|
92 | + list(,self::$user_agent, self::$ua_version) = $parts; |
|
93 | 93 | if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera'; |
94 | 94 | // IE no longer reports MSIE, but "Trident/7.0; rv:11.0" |
95 | - if (self::$user_agent=='trident') |
|
95 | + if (self::$user_agent == 'trident') |
|
96 | 96 | { |
97 | - self::$user_agent='msie'; |
|
97 | + self::$user_agent = 'msie'; |
|
98 | 98 | $matches = null; |
99 | 99 | self::$ua_version = preg_match('|Trident/[0-9.]+; rv:([0-9.]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) ? |
100 | 100 | $matches[1] : 11.0; |
@@ -90,7 +90,10 @@ |
||
90 | 90 | } |
91 | 91 | } |
92 | 92 | list(,self::$user_agent,self::$ua_version) = $parts; |
93 | - if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera'; |
|
93 | + if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') |
|
94 | + { |
|
95 | + self::$user_agent = 'opera'; |
|
96 | + } |
|
94 | 97 | // IE no longer reports MSIE, but "Trident/7.0; rv:11.0" |
95 | 98 | if (self::$user_agent=='trident') |
96 | 99 | { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param boolean $force_download =true send content-disposition attachment header |
39 | 39 | * @param boolean $no_content_type =false do not send actual content-type and content-length header, just content-disposition |
40 | 40 | */ |
41 | - public static function safe(&$content, $path, &$mime='', &$length=0, $nocache=true, $force_download=true, $no_content_type=false) |
|
41 | + public static function safe(&$content, $path, &$mime = '', &$length = 0, $nocache = true, $force_download = true, $no_content_type = false) |
|
42 | 42 | { |
43 | 43 | // change old/aliased mime-types to new one, eg. image/pdf to application/pdf |
44 | 44 | $mime = Api\MimeMagic::fix_mime_type($mime); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if (UserAgent::type() == 'chrome' || UserAgent::type() == 'msie' && UserAgent::version() >= 8) |
54 | 54 | { |
55 | 55 | $mime = 'text/plain'; |
56 | - header('X-Content-Type-Options: nosniff'); // stop IE & Chrome from content-type sniffing |
|
56 | + header('X-Content-Type-Options: nosniff'); // stop IE & Chrome from content-type sniffing |
|
57 | 57 | } |
58 | 58 | // for the rest we change mime-type to text/html and let code below handle it safely |
59 | 59 | // this stops Safari and Firefox from using it as src attribute in a script tag |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $data = fread($content, $length); |
67 | 67 | fclose($content); |
68 | - $content =& $data; |
|
68 | + $content = & $data; |
|
69 | 69 | unset($data); |
70 | 70 | } |
71 | 71 | $content = '<pre>'.$content; |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | if (UserAgent::type() == 'chrome' && UserAgent::version() >= 24 || |
80 | 80 | // mobile FF 24 on Android does NOT honor CSP! |
81 | 81 | UserAgent::type() == 'firefox' && !UserAgent::mobile() && UserAgent::version() >= 24 || |
82 | - UserAgent::type() == 'safari' && !UserAgent::mobile() && UserAgent::version() >= 536 || // OS X |
|
82 | + UserAgent::type() == 'safari' && !UserAgent::mobile() && UserAgent::version() >= 536 || // OS X |
|
83 | 83 | UserAgent::type() == 'safari' && UserAgent::mobile() && UserAgent::version() >= 9537) // iOS 7 |
84 | 84 | { |
85 | - $csp = "script-src 'none'"; // forbid to execute any javascript |
|
85 | + $csp = "script-src 'none'"; // forbid to execute any javascript |
|
86 | 86 | header("Content-Security-Policy: $csp"); |
87 | - header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
|
87 | + header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
|
88 | 88 | //header("X-Content-Security-Policy: $csp"); // FF <= 22 |
89 | 89 | //error_log(__METHOD__."('$options[path]') ".UserAgent::type().'/'.UserAgent::version().(UserAgent::mobile()?'/mobile':'').": using Content-Security-Policy: $csp"); |
90 | 90 | } |
@@ -117,25 +117,25 @@ discard block |
||
117 | 117 | * @param boolean $nocache =true send headers to disallow browser/proxies to cache the download |
118 | 118 | * @param boolean $forceDownload =true send headers to handle as attachment/download |
119 | 119 | */ |
120 | - public static function type($fn,$mime='',$length=0,$nocache=True,$forceDownload=true) |
|
120 | + public static function type($fn, $mime = '', $length = 0, $nocache = True, $forceDownload = true) |
|
121 | 121 | { |
122 | 122 | // if no mime-type is given or it's the default binary-type, guess it from the extension |
123 | - if(empty($mime) || $mime == 'application/octet-stream') |
|
123 | + if (empty($mime) || $mime == 'application/octet-stream') |
|
124 | 124 | { |
125 | 125 | $mime = Api\MimeMagic::filename2mime($fn); |
126 | 126 | } |
127 | - if($fn) |
|
127 | + if ($fn) |
|
128 | 128 | { |
129 | 129 | // Show this for all |
130 | - self::disposition($fn,$forceDownload); |
|
130 | + self::disposition($fn, $forceDownload); |
|
131 | 131 | header('Content-type: '.$mime); |
132 | 132 | |
133 | - if($length) |
|
133 | + if ($length) |
|
134 | 134 | { |
135 | 135 | header('Content-length: '.$length); |
136 | 136 | } |
137 | 137 | |
138 | - if($nocache) |
|
138 | + if ($nocache) |
|
139 | 139 | { |
140 | 140 | header('Pragma: no-cache'); |
141 | 141 | header('Pragma: public'); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param string $fn filename |
152 | 152 | * @param boolean $forceDownload =true send headers to handle as attachment/download |
153 | 153 | */ |
154 | - public static function disposition($fn, $forceDownload=true) |
|
154 | + public static function disposition($fn, $forceDownload = true) |
|
155 | 155 | { |
156 | 156 | if ($forceDownload) |
157 | 157 | { |
@@ -80,9 +80,13 @@ discard block |
||
80 | 80 | // mobile FF 24 on Android does NOT honor CSP! |
81 | 81 | UserAgent::type() == 'firefox' && !UserAgent::mobile() && UserAgent::version() >= 24 || |
82 | 82 | UserAgent::type() == 'safari' && !UserAgent::mobile() && UserAgent::version() >= 536 || // OS X |
83 | - UserAgent::type() == 'safari' && UserAgent::mobile() && UserAgent::version() >= 9537) // iOS 7 |
|
83 | + UserAgent::type() == 'safari' && UserAgent::mobile() && UserAgent::version() >= 9537) |
|
84 | 84 | { |
85 | - $csp = "script-src 'none'"; // forbid to execute any javascript |
|
85 | + // iOS 7 |
|
86 | + { |
|
87 | + $csp = "script-src 'none'"; |
|
88 | + } |
|
89 | + // forbid to execute any javascript |
|
86 | 90 | header("Content-Security-Policy: $csp"); |
87 | 91 | header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
88 | 92 | //header("X-Content-Security-Policy: $csp"); // FF <= 22 |
@@ -96,7 +100,10 @@ discard block |
||
96 | 100 | } |
97 | 101 | if ($no_content_type) |
98 | 102 | { |
99 | - if ($force_download) self::disposition(Api\Vfs::basename($path), $force_download); |
|
103 | + if ($force_download) |
|
104 | + { |
|
105 | + self::disposition(Api\Vfs::basename($path), $force_download); |
|
106 | + } |
|
100 | 107 | } |
101 | 108 | else |
102 | 109 | { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @return string |
27 | 27 | * @todo get "real" referer for jDots template |
28 | 28 | */ |
29 | - static function get($default='',$referer='') |
|
29 | + static function get($default = '', $referer = '') |
|
30 | 30 | { |
31 | 31 | // HTTP_REFERER seems NOT to get urldecoded |
32 | 32 | if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | $webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; |
35 | 35 | if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path |
36 | 36 | { |
37 | - $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part |
|
37 | + $referer = preg_replace('/^https?:\/\/[^\/]+/', '', $referer); // removing the domain part |
|
38 | 38 | } |
39 | 39 | if (strlen($webserver_url) > 1) |
40 | 40 | { |
41 | - list(,$referer) = explode($webserver_url,$referer,2); |
|
41 | + list(,$referer) = explode($webserver_url, $referer, 2); |
|
42 | 42 | } |
43 | 43 | $ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer); |
44 | 44 |
@@ -29,12 +29,19 @@ discard block |
||
29 | 29 | static function get($default='',$referer='') |
30 | 30 | { |
31 | 31 | // HTTP_REFERER seems NOT to get urldecoded |
32 | - if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']); |
|
32 | + if (!$referer) |
|
33 | + { |
|
34 | + $referer = urldecode($_SERVER['HTTP_REFERER']); |
|
35 | + } |
|
33 | 36 | |
34 | 37 | $webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; |
35 | - if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path |
|
38 | + if (empty($webserver_url) || $webserver_url{0} == '/') |
|
39 | + { |
|
40 | + // url is just a path |
|
36 | 41 | { |
37 | - $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part |
|
42 | + $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); |
|
43 | + } |
|
44 | + // removing the domain part |
|
38 | 45 | } |
39 | 46 | if (strlen($webserver_url) > 1) |
40 | 47 | { |
@@ -42,7 +49,10 @@ discard block |
||
42 | 49 | } |
43 | 50 | $ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer); |
44 | 51 | |
45 | - if (empty($ret) || strpos($ret, 'cd=yes') !== false) $ret = $default; |
|
52 | + if (empty($ret) || strpos($ret, 'cd=yes') !== false) |
|
53 | + { |
|
54 | + $ret = $default; |
|
55 | + } |
|
46 | 56 | |
47 | 57 | return $ret; |
48 | 58 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param string $cname |
62 | 62 | */ |
63 | - public function beforeSendToClient($cname, array $expand=array()) |
|
63 | + public function beforeSendToClient($cname, array $expand = array()) |
|
64 | 64 | { |
65 | 65 | $attrs = $this->attrs; |
66 | 66 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | $attrs['id'] = $this->id; |
69 | 69 | |
70 | 70 | $form_name = self::form_name($cname, $this->id); |
71 | - $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id); |
|
71 | + $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX.$this->id); |
|
72 | 72 | |
73 | 73 | // No need to proceed |
74 | - if(!$data_id) return; |
|
74 | + if (!$data_id) return; |
|
75 | 75 | |
76 | 76 | // Find out which record to load |
77 | 77 | $value = self::get_array(self::$request->content, $form_name, false, true); |
78 | - if(!$value) |
|
78 | + if (!$value) |
|
79 | 79 | { |
80 | 80 | // Try here... legacy / fallback / just make it work |
81 | 81 | $value = self::get_array(self::$request->content, $data_id, true, false); |
@@ -85,23 +85,23 @@ discard block |
||
85 | 85 | { |
86 | 86 | // Get the record itself |
87 | 87 | $data = self::get_array(self::$request->content, $data_id, true, false); |
88 | - if(!$data) |
|
88 | + if (!$data) |
|
89 | 89 | { |
90 | 90 | $data = static::get_entry($value, $attrs); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Set the new value so transformer can find it. Use prefix to avoid changing the original value |
95 | - $new_value =& self::get_array(self::$request->content, self::ID_PREFIX .$this->id, true, false); |
|
95 | + $new_value = & self::get_array(self::$request->content, self::ID_PREFIX.$this->id, true, false); |
|
96 | 96 | if (true) $new_value = $data; |
97 | - $this->id = self::ID_PREFIX . $this->id . "[{$attrs['field']}]"; |
|
97 | + $this->id = self::ID_PREFIX.$this->id."[{$attrs['field']}]"; |
|
98 | 98 | |
99 | 99 | $old_type = self::getElementAttribute($this->id, 'type'); |
100 | 100 | |
101 | 101 | parent::beforeSendToClient($cname, $expand); |
102 | 102 | |
103 | 103 | // Check for conflict - more than one with same id/field and different type |
104 | - if($old_type && $old_type != $this->type) |
|
104 | + if ($old_type && $old_type != $this->type) |
|
105 | 105 | { |
106 | 106 | //self::set_validation_error($this->id, lang('%1, duplicate ID', $this)); |
107 | 107 | } |
@@ -71,7 +71,10 @@ discard block |
||
71 | 71 | $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id); |
72 | 72 | |
73 | 73 | // No need to proceed |
74 | - if(!$data_id) return; |
|
74 | + if(!$data_id) |
|
75 | + { |
|
76 | + return; |
|
77 | + } |
|
75 | 78 | |
76 | 79 | // Find out which record to load |
77 | 80 | $value = self::get_array(self::$request->content, $form_name, false, true); |
@@ -93,7 +96,10 @@ discard block |
||
93 | 96 | |
94 | 97 | // Set the new value so transformer can find it. Use prefix to avoid changing the original value |
95 | 98 | $new_value =& self::get_array(self::$request->content, self::ID_PREFIX .$this->id, true, false); |
96 | - if (true) $new_value = $data; |
|
99 | + if (true) |
|
100 | + { |
|
101 | + $new_value = $data; |
|
102 | + } |
|
97 | 103 | $this->id = self::ID_PREFIX . $this->id . "[{$attrs['field']}]"; |
98 | 104 | |
99 | 105 | $old_type = self::getElementAttribute($this->id, 'type'); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param string $load_via ='' use given template to load $name |
58 | 58 | * @return Template|boolean false if not found |
59 | 59 | */ |
60 | - public static function instance($_name, $template_set=null, $version='', $load_via='') |
|
60 | + public static function instance($_name, $template_set = null, $version = '', $load_via = '') |
|
61 | 61 | { |
62 | 62 | if (Api\Header\UserAgent::mobile()) |
63 | 63 | { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | //$start = microtime(true); |
68 | - list($name) = explode('?', $_name); // remove optional cache-buster |
|
68 | + list($name) = explode('?', $_name); // remove optional cache-buster |
|
69 | 69 | if (isset(self::$cache[$name]) || !($path = self::relPath($name, $template_set, $version))) |
70 | 70 | { |
71 | 71 | if ((!$path || self::read($load_via, $template_set)) && isset(self::$cache[$name])) |
@@ -74,25 +74,25 @@ discard block |
||
74 | 74 | return self::$cache[$name]; |
75 | 75 | } |
76 | 76 | // Template not found, try again as if $name were a partial name |
77 | - else if(!$path && strpos($name,'.') === false) |
|
77 | + else if (!$path && strpos($name, '.') === false) |
|
78 | 78 | { |
79 | - foreach(self::$cache as $c_name => $c_template) |
|
79 | + foreach (self::$cache as $c_name => $c_template) |
|
80 | 80 | { |
81 | - list(,, $c_sub) = explode('.',$c_name, 3); |
|
82 | - if($name == $c_sub) |
|
81 | + list(,, $c_sub) = explode('.', $c_name, 3); |
|
82 | + if ($name == $c_sub) |
|
83 | 83 | { |
84 | 84 | //error_log(__METHOD__ . "('$name' loaded from cache ($c_name)"); |
85 | 85 | return $c_template; |
86 | 86 | } |
87 | 87 | |
88 | - $parts = explode('.',$c_name); |
|
89 | - if($name == $parts[count($parts)-1]) return $c_template; |
|
88 | + $parts = explode('.', $c_name); |
|
89 | + if ($name == $parts[count($parts) - 1]) return $c_template; |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | // Template not found, try again with content expansion |
93 | 93 | if (is_array(self::$request->content)) |
94 | 94 | { |
95 | - $expand_name = self::expand_name($name, '','','','',self::$cont); |
|
95 | + $expand_name = self::expand_name($name, '', '', '', '', self::$cont); |
|
96 | 96 | if ($expand_name && $expand_name != $name && |
97 | 97 | ($template = self::instance($expand_name, $template_set, $version, $load_via))) |
98 | 98 | { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $reader = new XMLReader(); |
109 | 109 | if (!$reader->open(self::rel2path($path))) return false; |
110 | 110 | |
111 | - while($reader->read()) |
|
111 | + while ($reader->read()) |
|
112 | 112 | { |
113 | 113 | if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'template') |
114 | 114 | { |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * @param string $version ='' |
142 | 142 | * @return string path of template xml file or null if not found |
143 | 143 | */ |
144 | - public static function relPath($name, $template_set=null, $version='') |
|
144 | + public static function relPath($name, $template_set = null, $version = '') |
|
145 | 145 | { |
146 | - unset($version); // not used currently |
|
146 | + unset($version); // not used currently |
|
147 | 147 | list($app, $rest) = explode('.', $name, 2); |
148 | 148 | |
149 | 149 | if (empty($template_set)) |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $template_path = '/'.$app.'/templates/'.$template_set.'/'.$rest.'.xet'; |
154 | 154 | $default_path = '/'.$app.'/templates/default/'.$rest.'.xet'; |
155 | 155 | |
156 | - foreach(array(Api\Vfs::PREFIX.self::VFS_TEMPLATE_PATH, EGW_SERVER_ROOT) as $prefix) |
|
156 | + foreach (array(Api\Vfs::PREFIX.self::VFS_TEMPLATE_PATH, EGW_SERVER_ROOT) as $prefix) |
|
157 | 157 | { |
158 | 158 | if (file_exists($prefix.$template_path)) |
159 | 159 | { |
@@ -227,21 +227,21 @@ discard block |
||
227 | 227 | * @param array $params =array('') parameter(s) first parameter has to be cname, second $expand! |
228 | 228 | * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
229 | 229 | */ |
230 | - public function run($method_name, $params=array(''), $respect_disabled=false) |
|
230 | + public function run($method_name, $params = array(''), $respect_disabled = false) |
|
231 | 231 | { |
232 | - $cname =& $params[0]; |
|
232 | + $cname = & $params[0]; |
|
233 | 233 | $old_cname = $params[0]; |
234 | 234 | if ($this->attrs['content']) $cname = self::form_name($cname, $this->attrs['content'], $params[1]); |
235 | 235 | |
236 | 236 | // Check for template from content, and run over it |
237 | 237 | // templates included via template tag have their name to load them from in attribute "template" |
238 | - $expand_name = self::expand_name($this->id ? $this->id : $this->attrs['template'], '','','','',self::$request->content); |
|
239 | - if($this->original_name) |
|
238 | + $expand_name = self::expand_name($this->id ? $this->id : $this->attrs['template'], '', '', '', '', self::$request->content); |
|
239 | + if ($this->original_name) |
|
240 | 240 | { |
241 | - $expand_name = self::expand_name($this->original_name, '','','','',self::$request->content); |
|
241 | + $expand_name = self::expand_name($this->original_name, '', '', '', '', self::$request->content); |
|
242 | 242 | } |
243 | 243 | //error_log("$this running $method_name() cname: {$this->id} -> expand_name: $expand_name"); |
244 | - if($expand_name && $expand_name != $this->id) |
|
244 | + if ($expand_name && $expand_name != $this->id) |
|
245 | 245 | { |
246 | 246 | if (($row_template = self::instance($expand_name))) |
247 | 247 | { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @param string $cname |
262 | 262 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
263 | 263 | */ |
264 | - public function beforeSendToClient($cname, array $expand=null) |
|
264 | + public function beforeSendToClient($cname, array $expand = null) |
|
265 | 265 | { |
266 | 266 | //error_log(__METHOD__."('$cname') this->id=$this->id, this->type=$this->type, this->attrs=".array2string($this->attrs)); |
267 | 267 | $form_name = self::form_name($cname, $this->id, $expand); |
@@ -86,7 +86,10 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | $parts = explode('.',$c_name); |
89 | - if($name == $parts[count($parts)-1]) return $c_template; |
|
89 | + if($name == $parts[count($parts)-1]) |
|
90 | + { |
|
91 | + return $c_template; |
|
92 | + } |
|
90 | 93 | } |
91 | 94 | } |
92 | 95 | // Template not found, try again with content expansion |
@@ -106,7 +109,10 @@ discard block |
||
106 | 109 | return false; |
107 | 110 | } |
108 | 111 | $reader = new XMLReader(); |
109 | - if (!$reader->open(self::rel2path($path))) return false; |
|
112 | + if (!$reader->open(self::rel2path($path))) |
|
113 | + { |
|
114 | + return false; |
|
115 | + } |
|
110 | 116 | |
111 | 117 | while($reader->read()) |
112 | 118 | { |
@@ -208,7 +214,10 @@ discard block |
||
208 | 214 | { |
209 | 215 | $url = Api\Vfs::download_url($path); |
210 | 216 | |
211 | - if ($url[0] == '/') $url = Api\Framework::link($url); |
|
217 | + if ($url[0] == '/') |
|
218 | + { |
|
219 | + $url = Api\Framework::link($url); |
|
220 | + } |
|
212 | 221 | |
213 | 222 | // mtime postfix has to use '?download=', as our WebDAV treats everything else literal and not ignore them like Apache for static files! |
214 | 223 | $url .= '?download='.filemtime($path); |
@@ -231,7 +240,10 @@ discard block |
||
231 | 240 | { |
232 | 241 | $cname =& $params[0]; |
233 | 242 | $old_cname = $params[0]; |
234 | - if ($this->attrs['content']) $cname = self::form_name($cname, $this->attrs['content'], $params[1]); |
|
243 | + if ($this->attrs['content']) |
|
244 | + { |
|
245 | + $cname = self::form_name($cname, $this->attrs['content'], $params[1]); |
|
246 | + } |
|
235 | 247 | |
236 | 248 | // Check for template from content, and run over it |
237 | 249 | // templates included via template tag have their name to load them from in attribute "template" |
@@ -42,30 +42,30 @@ discard block |
||
42 | 42 | * @param array $params =array('') parameter(s) first parameter has to be the cname, second $expand! |
43 | 43 | * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
44 | 44 | */ |
45 | - public function run($method_name, $params=array(''), $respect_disabled=false) |
|
45 | + public function run($method_name, $params = array(''), $respect_disabled = false) |
|
46 | 46 | { |
47 | 47 | $form_name = self::form_name($params[0], $this->id, $params[1]); |
48 | 48 | |
49 | 49 | // Make sure additional tabs are processed for any method |
50 | - if (!($tabs =& self::getElementAttribute($form_name, 'tabs'))) |
|
50 | + if (!($tabs = & self::getElementAttribute($form_name, 'tabs'))) |
|
51 | 51 | { |
52 | 52 | $tabs = $this->attrs['tabs']; |
53 | 53 | } |
54 | - if($tabs && !$this->tabs_attr_evaluated) |
|
54 | + if ($tabs && !$this->tabs_attr_evaluated) |
|
55 | 55 | { |
56 | - $this->tabs_attr_evaluated = true; // we must not evaluate tabs attribte more then once! |
|
56 | + $this->tabs_attr_evaluated = true; // we must not evaluate tabs attribte more then once! |
|
57 | 57 | |
58 | 58 | // add_tabs toggles replacing or adding to existing tabs |
59 | - if(!$this->attrs['add_tabs']) |
|
59 | + if (!$this->attrs['add_tabs']) |
|
60 | 60 | { |
61 | 61 | $this->children[1]->children = array(); |
62 | 62 | } |
63 | 63 | |
64 | 64 | //$this->tabs = array(); |
65 | - foreach($tabs as &$tab) |
|
65 | + foreach ($tabs as &$tab) |
|
66 | 66 | { |
67 | - $template= clone Template::instance($tab['template']); |
|
68 | - if($tab['id']) $template->attrs['content'] = $tab['id']; |
|
67 | + $template = clone Template::instance($tab['template']); |
|
68 | + if ($tab['id']) $template->attrs['content'] = $tab['id']; |
|
69 | 69 | $this->children[1]->children[] = $template; |
70 | 70 | $tab['url'] = Template::rel2url($template->rel_path); |
71 | 71 | //$this->tabs[] = $tab; |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | |
79 | 79 | // Check for disabled tabs set via readonly, and set them as disabled |
80 | 80 | $readonlys = self::get_array(self::$request->readonlys, $form_name); |
81 | - if($respect_disabled && $readonlys) |
|
81 | + if ($respect_disabled && $readonlys) |
|
82 | 82 | { |
83 | - foreach($this->children[1]->children as $tab) |
|
83 | + foreach ($this->children[1]->children as $tab) |
|
84 | 84 | { |
85 | - $parts = explode('.',$tab->template ? $tab->template : $tab->id); |
|
85 | + $parts = explode('.', $tab->template ? $tab->template : $tab->id); |
|
86 | 86 | $ro_id = array_pop($parts); |
87 | - if($readonlys[$ro_id]) |
|
87 | + if ($readonlys[$ro_id]) |
|
88 | 88 | { |
89 | 89 | $tab->attrs['disabled'] = $readonlys[$ro_id]; |
90 | 90 | } |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | * @param array &$validated=array() validated content |
105 | 105 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
106 | 106 | */ |
107 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
107 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
108 | 108 | { |
109 | 109 | $form_name = self::form_name($cname, $this->id, $expand); |
110 | 110 | |
111 | 111 | if (!empty($form_name)) |
112 | 112 | { |
113 | 113 | $value = self::get_array($content, $form_name); |
114 | - $valid =& self::get_array($validated, $form_name, true); |
|
114 | + $valid = & self::get_array($validated, $form_name, true); |
|
115 | 115 | if (true) $valid = $value; |
116 | 116 | } |
117 | 117 | } |
@@ -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 | { |
@@ -65,7 +65,10 @@ discard block |
||
65 | 65 | foreach($tabs as &$tab) |
66 | 66 | { |
67 | 67 | $template= clone Template::instance($tab['template']); |
68 | - if($tab['id']) $template->attrs['content'] = $tab['id']; |
|
68 | + if($tab['id']) |
|
69 | + { |
|
70 | + $template->attrs['content'] = $tab['id']; |
|
71 | + } |
|
69 | 72 | $this->children[1]->children[] = $template; |
70 | 73 | $tab['url'] = Template::rel2url($template->rel_path); |
71 | 74 | //$this->tabs[] = $tab; |
@@ -112,7 +115,10 @@ discard block |
||
112 | 115 | { |
113 | 116 | $value = self::get_array($content, $form_name); |
114 | 117 | $valid =& self::get_array($validated, $form_name, true); |
115 | - if (true) $valid = $value; |
|
118 | + if (true) |
|
119 | + { |
|
120 | + $valid = $value; |
|
121 | + } |
|
116 | 122 | } |
117 | 123 | } |
118 | 124 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param string $cname |
75 | 75 | */ |
76 | - public function beforeSendToClient($cname, array $expand=array()) |
|
76 | + public function beforeSendToClient($cname, array $expand = array()) |
|
77 | 77 | { |
78 | 78 | $attrs = $this->attrs; |
79 | 79 | $form_name = self::form_name($cname, $this->id); |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | error_log(__METHOD__."() $this has no id!"); |
83 | 83 | return; |
84 | 84 | } |
85 | - $attrs['value'] = $value =& self::get_array(self::$request->content, $form_name, false, true); |
|
85 | + $attrs['value'] = $value = & self::get_array(self::$request->content, $form_name, false, true); |
|
86 | 86 | $attrs['type'] = $this->type; |
87 | 87 | $attrs['id'] = $this->id; |
88 | 88 | |
89 | 89 | $unmodified = $attrs; |
90 | 90 | |
91 | 91 | // run the transformation |
92 | - foreach(static::$transformation as $filter => $data) |
|
92 | + foreach (static::$transformation as $filter => $data) |
|
93 | 93 | { |
94 | 94 | $this->action($filter, $data, $attrs); |
95 | 95 | } |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | //echo $this; _debug_array($unmodified); _debug_array($attrs); _debug_array(array_diff_assoc($attrs, $unmodified)); |
98 | 98 | // compute the difference and send it to the client as modifications |
99 | 99 | $type_changed = false; |
100 | - foreach(array_diff_assoc($attrs, $unmodified) as $attr => $val) |
|
100 | + foreach (array_diff_assoc($attrs, $unmodified) as $attr => $val) |
|
101 | 101 | { |
102 | - switch($attr) |
|
102 | + switch ($attr) |
|
103 | 103 | { |
104 | 104 | case 'value': |
105 | 105 | if ($val != $value) |
106 | 106 | { |
107 | - $value = $val; // $value is reference to self::$request->content |
|
107 | + $value = $val; // $value is reference to self::$request->content |
|
108 | 108 | } |
109 | 109 | break; |
110 | 110 | case 'sel_options': |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | break; |
113 | 113 | case 'type': // not an attribute in etemplate2 |
114 | 114 | $type_changed = true; |
115 | - if($val == 'template') |
|
115 | + if ($val == 'template') |
|
116 | 116 | { |
117 | 117 | // If the widget has been transformed into a template, we |
118 | 118 | // also need to try and instanciate & parse the template too |
119 | 119 | $transformed_template = Template::instance($attrs['template']); |
120 | - if($transformed_template) |
|
120 | + if ($transformed_template) |
|
121 | 121 | { |
122 | 122 | $this->expand_widget($transformed_template, $expand); |
123 | - $transformed_template->run('beforeSendToClient',array($cname,$expand)); |
|
123 | + $transformed_template->run('beforeSendToClient', array($cname, $expand)); |
|
124 | 124 | } |
125 | 125 | $type_changed = false; |
126 | 126 | } |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | break; |
130 | 130 | } |
131 | 131 | } |
132 | - if($type_changed) |
|
132 | + if ($type_changed) |
|
133 | 133 | { |
134 | 134 | // Run the new widget type's beforeSendToClient |
135 | - $expanded_child = self::factory($attrs['type'], false,$this->id); |
|
135 | + $expanded_child = self::factory($attrs['type'], false, $this->id); |
|
136 | 136 | $expanded_child->id = $this->id; |
137 | 137 | $expanded_child->type = $attrs['type']; |
138 | 138 | $expanded_child->attrs = $attrs; |
139 | - $expanded_child->run('beforeSendToClient',array($cname,$expand)); |
|
139 | + $expanded_child->run('beforeSendToClient', array($cname, $expand)); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | if (strpos($action, '@') !== false) |
159 | 159 | { |
160 | 160 | $replace = array(); |
161 | - foreach($attrs as $a => $v) |
|
161 | + foreach ($attrs as $a => $v) |
|
162 | 162 | { |
163 | 163 | if (is_scalar($v) || is_null($v)) $replace['@'.$a] = $v; |
164 | 164 | } |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | // now replace with non-scalar value, eg. if values is an array: "@value", "@value[key] or "@value[@key]" |
167 | 167 | if (($a = strstr($action, '@'))) |
168 | 168 | { |
169 | - $action = self::get_array($attrs, substr($a,1)); |
|
169 | + $action = self::get_array($attrs, substr($a, 1)); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | $attrs[$attr] = $action; |
173 | 173 | if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
174 | 174 | } |
175 | 175 | // action is a serverside callback |
176 | - elseif(is_array($action) && isset($action['__callback__'])) |
|
176 | + elseif (is_array($action) && isset($action['__callback__'])) |
|
177 | 177 | { |
178 | 178 | if (!is_string(($callback = $action['__callback__']))) |
179 | 179 | { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | $attrs[$attr] = $this->$callback($attrs[$attr], $attrs); |
185 | 185 | } |
186 | - elseif(count(explode('.', $callback)) == 3) |
|
186 | + elseif (count(explode('.', $callback)) == 3) |
|
187 | 187 | { |
188 | 188 | $attrs[$attr] = ExecMethod($callback, $attrs[$attr], $attrs); |
189 | 189 | } |
@@ -197,29 +197,29 @@ discard block |
||
197 | 197 | } |
198 | 198 | } |
199 | 199 | // action is a clientside callback |
200 | - elseif(is_array($action) && isset($action['__js__'])) |
|
200 | + elseif (is_array($action) && isset($action['__js__'])) |
|
201 | 201 | { |
202 | 202 | // nothing to do here |
203 | 203 | } |
204 | 204 | // TODO: Might be a better way to handle when value to be set is an array |
205 | - elseif(is_array($action) && $attr == 'sel_options') |
|
205 | + elseif (is_array($action) && $attr == 'sel_options') |
|
206 | 206 | { |
207 | 207 | $attrs[$attr] = $action; |
208 | 208 | } |
209 | 209 | // action is a switch --> check cases |
210 | - elseif(is_array($action)) |
|
210 | + elseif (is_array($action)) |
|
211 | 211 | { |
212 | 212 | // case matches --> run all actions |
213 | 213 | if (isset($action[$attrs[$attr]]) || !isset($action[$attrs[$attr]]) && isset($action['__default__'])) |
214 | 214 | { |
215 | 215 | $actions = isset($action[$attrs[$attr]]) ? $action[$attrs[$attr]] : $action['__default__']; |
216 | - if(!is_array($actions)) |
|
216 | + if (!is_array($actions)) |
|
217 | 217 | { |
218 | 218 | $attrs[$attr] = $actions; |
219 | 219 | $actions = array($attr => $actions); |
220 | 220 | } |
221 | 221 | if (self::DEBUG) error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
222 | - foreach($actions as $attr => $action) |
|
222 | + foreach ($actions as $attr => $action) |
|
223 | 223 | { |
224 | 224 | $this->action($attr, $action, $attrs); |
225 | 225 | } |
@@ -150,7 +150,10 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function action($attr, $action, array &$attrs) |
152 | 152 | { |
153 | - if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).')'); |
|
153 | + if (self::DEBUG) |
|
154 | + { |
|
155 | + error_log(__METHOD__."('$attr', ".array2string($action).')'); |
|
156 | + } |
|
154 | 157 | // action is an assignment |
155 | 158 | if (is_scalar($action) || is_null($action)) |
156 | 159 | { |
@@ -160,7 +163,10 @@ discard block |
||
160 | 163 | $replace = array(); |
161 | 164 | foreach($attrs as $a => $v) |
162 | 165 | { |
163 | - if (is_scalar($v) || is_null($v)) $replace['@'.$a] = $v; |
|
166 | + if (is_scalar($v) || is_null($v)) |
|
167 | + { |
|
168 | + $replace['@'.$a] = $v; |
|
169 | + } |
|
164 | 170 | } |
165 | 171 | $action = strtr($action, $replace); |
166 | 172 | // now replace with non-scalar value, eg. if values is an array: "@value", "@value[key] or "@value[@key]" |
@@ -170,7 +176,10 @@ discard block |
||
170 | 176 | } |
171 | 177 | } |
172 | 178 | $attrs[$attr] = $action; |
173 | - if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
|
179 | + if (self::DEBUG) |
|
180 | + { |
|
181 | + error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
|
182 | + } |
|
174 | 183 | } |
175 | 184 | // action is a serverside callback |
176 | 185 | elseif(is_array($action) && isset($action['__callback__'])) |
@@ -218,7 +227,10 @@ discard block |
||
218 | 227 | $attrs[$attr] = $actions; |
219 | 228 | $actions = array($attr => $actions); |
220 | 229 | } |
221 | - if (self::DEBUG) error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
|
230 | + if (self::DEBUG) |
|
231 | + { |
|
232 | + error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
|
233 | + } |
|
222 | 234 | foreach($actions as $attr => $action) |
223 | 235 | { |
224 | 236 | $this->action($attr, $action, $attrs); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | 'date' => 'Date', |
43 | 43 | 'date-time'=> 'Date+Time', |
44 | 44 | 'select-account' => 'Select account', |
45 | - 'button' => 'Button', // button to execute javascript |
|
45 | + 'button' => 'Button', // button to execute javascript |
|
46 | 46 | 'url' => 'Url', |
47 | 47 | 'url-email'=> 'EMail', |
48 | 48 | 'url-phone'=> 'Phone number', |
49 | 49 | 'htmlarea' => 'Formatted Text (HTML)', |
50 | - 'link-entry' => 'Select entry', // should be last type, as the individual apps get added behind |
|
50 | + 'link-entry' => 'Select entry', // should be last type, as the individual apps get added behind |
|
51 | 51 | ); |
52 | 52 | |
53 | 53 | /** |
@@ -86,24 +86,24 @@ discard block |
||
86 | 86 | * @param string $cname |
87 | 87 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
88 | 88 | */ |
89 | - public function beforeSendToClient($cname, array $expand=null) |
|
89 | + public function beforeSendToClient($cname, array $expand = null) |
|
90 | 90 | { |
91 | 91 | // No name, no way to get parameters client-side. |
92 | - if(!$this->id) $this->id = self::GLOBAL_ID; |
|
92 | + if (!$this->id) $this->id = self::GLOBAL_ID; |
|
93 | 93 | |
94 | 94 | $form_name = self::form_name($cname, $this->id, $expand); |
95 | 95 | |
96 | 96 | // Store properties at top level, so all customfield widgets can share |
97 | - if($this->attrs['app']) |
|
97 | + if ($this->attrs['app']) |
|
98 | 98 | { |
99 | 99 | $app = $this->attrs['app']; |
100 | 100 | } |
101 | 101 | else |
102 | 102 | { |
103 | - $app =& $this->getElementAttribute(self::GLOBAL_VALS, 'app'); |
|
104 | - if($this->getElementAttribute($form_name, 'app')) |
|
103 | + $app = & $this->getElementAttribute(self::GLOBAL_VALS, 'app'); |
|
104 | + if ($this->getElementAttribute($form_name, 'app')) |
|
105 | 105 | { |
106 | - $app =& $this->getElementAttribute($form_name, 'app'); |
|
106 | + $app = & $this->getElementAttribute($form_name, 'app'); |
|
107 | 107 | } |
108 | 108 | else |
109 | 109 | { |
@@ -112,21 +112,21 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - if($this->getElementAttribute($form_name, 'customfields')) |
|
115 | + if ($this->getElementAttribute($form_name, 'customfields')) |
|
116 | 116 | { |
117 | - $customfields =& $this->getElementAttribute($form_name, 'customfields'); |
|
117 | + $customfields = & $this->getElementAttribute($form_name, 'customfields'); |
|
118 | 118 | } |
119 | - elseif($app) |
|
119 | + elseif ($app) |
|
120 | 120 | { |
121 | 121 | // Checking creates it even if it wasn't there |
122 | 122 | unset(self::$request->modifications[$form_name]['customfields']); |
123 | - $customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields'); |
|
123 | + $customfields = & $this->getElementAttribute(self::GLOBAL_VALS, 'customfields'); |
|
124 | 124 | } |
125 | 125 | |
126 | - if(!$app) |
|
126 | + if (!$app) |
|
127 | 127 | { |
128 | - $app =& $this->setElementAttribute(self::GLOBAL_VALS, 'app', $GLOBALS['egw_info']['flags']['currentapp']); |
|
129 | - $customfields =& $this->setElementAttribute(self::GLOBAL_VALS, 'customfields', Api\Storage\Customfields::get($app)); |
|
128 | + $app = & $this->setElementAttribute(self::GLOBAL_VALS, 'app', $GLOBALS['egw_info']['flags']['currentapp']); |
|
129 | + $customfields = & $this->setElementAttribute(self::GLOBAL_VALS, 'customfields', Api\Storage\Customfields::get($app)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // if we are in the etemplate editor or the app has no cf's, load the cf's from the app the tpl belongs too |
@@ -134,29 +134,29 @@ discard block |
||
134 | 134 | ($GLOBALS['egw_info']['flags']['currentapp'] == 'etemplate' || !$this->attrs['customfields']) || !isset($customfields)) |
135 | 135 | { |
136 | 136 | // app changed |
137 | - $customfields =& Api\Storage\Customfields::get($app); |
|
137 | + $customfields = & Api\Storage\Customfields::get($app); |
|
138 | 138 | } |
139 | 139 | // Filter fields |
140 | - if($this->attrs['field-names']) |
|
140 | + if ($this->attrs['field-names']) |
|
141 | 141 | { |
142 | 142 | $fields_name = explode(',', $this->attrs['field-names']); |
143 | - foreach($fields_name as &$f) |
|
143 | + foreach ($fields_name as &$f) |
|
144 | 144 | { |
145 | 145 | if ($f[0] == "!") |
146 | 146 | { |
147 | - $f= substr($f,1); |
|
148 | - $negate_fields[]= $f; |
|
147 | + $f = substr($f, 1); |
|
148 | + $negate_fields[] = $f; |
|
149 | 149 | } |
150 | - $field_filters []= $f; |
|
150 | + $field_filters [] = $f; |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | 154 | $fields = $customfields; |
155 | 155 | |
156 | - $use_private = self::expand_name($this->attrs['use-private'],0,0,'','',self::$cont); |
|
157 | - $this->attrs['sub-type'] = self::expand_name($this->attrs['sub-type'],0,0,'','',self::$cont); |
|
156 | + $use_private = self::expand_name($this->attrs['use-private'], 0, 0, '', '', self::$cont); |
|
157 | + $this->attrs['sub-type'] = self::expand_name($this->attrs['sub-type'], 0, 0, '', '', self::$cont); |
|
158 | 158 | |
159 | - foreach((array)$fields as $key => $field) |
|
159 | + foreach ((array)$fields as $key => $field) |
|
160 | 160 | { |
161 | 161 | // remove private or non-private cf's, if only one kind should be displayed |
162 | 162 | if ((string)$use_private !== '' && (boolean)$field['private'] != (boolean)$use_private) |
@@ -165,36 +165,36 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | // Remove filtered fields |
168 | - if($field_filters && in_array($key, $negate_fields) && in_array($key, $field_filters)) |
|
168 | + if ($field_filters && in_array($key, $negate_fields) && in_array($key, $field_filters)) |
|
169 | 169 | { |
170 | 170 | unset($fields[$key]); |
171 | 171 | } |
172 | 172 | } |
173 | 173 | // check if name refers to a single custom field --> show only that |
174 | 174 | $matches = null; |
175 | - if (($pos=strpos($form_name,self::$prefix)) !== false && // allow the prefixed name to be an array index too |
|
176 | - preg_match($preg = '/'.self::$prefix.'([^\]]+)/',$form_name,$matches) && isset($fields[$name=$matches[1]])) |
|
175 | + if (($pos = strpos($form_name, self::$prefix)) !== false && // allow the prefixed name to be an array index too |
|
176 | + preg_match($preg = '/'.self::$prefix.'([^\]]+)/', $form_name, $matches) && isset($fields[$name = $matches[1]])) |
|
177 | 177 | { |
178 | 178 | $fields = array($name => $fields[$name]); |
179 | 179 | $value = array(self::$prefix.$name => $value); |
180 | 180 | $form_name = self::$prefix.$name; |
181 | 181 | } |
182 | 182 | |
183 | - if(!is_array($fields)) $fields = array(); |
|
184 | - switch($type = $this->type) |
|
183 | + if (!is_array($fields)) $fields = array(); |
|
184 | + switch ($type = $this->type) |
|
185 | 185 | { |
186 | 186 | case 'customfields-types': |
187 | - foreach(self::$cf_types as $lname => $label) |
|
187 | + foreach (self::$cf_types as $lname => $label) |
|
188 | 188 | { |
189 | 189 | $sel_options[$lname] = lang($label); |
190 | - $fields_with_vals[]=$lname; |
|
190 | + $fields_with_vals[] = $lname; |
|
191 | 191 | } |
192 | 192 | $link_types = array_intersect_key(Api\Link::app_list('query'), Api\Link::app_list('title')); |
193 | 193 | // Explicitly add in filemanager, which does not support query or title |
194 | 194 | $link_types['filemanager'] = lang('filemanager'); |
195 | 195 | |
196 | 196 | ksort($link_types); |
197 | - foreach($link_types as $lname => $label) |
|
197 | + foreach ($link_types as $lname => $label) |
|
198 | 198 | { |
199 | 199 | $sel_options[$lname] = '- '.$label; |
200 | 200 | } |
@@ -202,32 +202,32 @@ discard block |
||
202 | 202 | self::$transformation['type'][$type]['no_lang'] = true; |
203 | 203 | return parent::beforeSendToClient($cname, $expand); |
204 | 204 | case 'customfields-list': |
205 | - foreach(array_reverse($fields) as $lname => $field) |
|
205 | + foreach (array_reverse($fields) as $lname => $field) |
|
206 | 206 | { |
207 | 207 | if (!empty($this->attrs['sub-type']) && !empty($field['type2']) && |
208 | - strpos(','.$field['type2'].',',','.$field['type2'].',') === false) continue; // not for our content type// |
|
208 | + strpos(','.$field['type2'].',', ','.$field['type2'].',') === false) continue; // not for our content type// |
|
209 | 209 | if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') //break; |
210 | 210 | { |
211 | - $fields_with_vals[]=$lname; |
|
211 | + $fields_with_vals[] = $lname; |
|
212 | 212 | } |
213 | 213 | //$stop_at_field = $name; |
214 | 214 | } |
215 | 215 | break; |
216 | 216 | default: |
217 | - foreach(array_reverse($fields) as $lname => $field) |
|
217 | + foreach (array_reverse($fields) as $lname => $field) |
|
218 | 218 | { |
219 | - $fields_with_vals[]=$lname; |
|
219 | + $fields_with_vals[] = $lname; |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | // need to encode values/select-options to keep their order |
223 | - foreach($customfields as &$data) |
|
223 | + foreach ($customfields as &$data) |
|
224 | 224 | { |
225 | 225 | if (!empty($data['values'])) |
226 | 226 | { |
227 | 227 | Select::fix_encoded_options($data['values']); |
228 | 228 | } |
229 | 229 | } |
230 | - if($fields != $customfields) |
|
230 | + if ($fields != $customfields) |
|
231 | 231 | { |
232 | 232 | // This widget has different settings from global |
233 | 233 | $this->setElementAttribute($form_name, 'customfields', $fields); |
@@ -239,14 +239,14 @@ discard block |
||
239 | 239 | parent::beforeSendToClient($cname, $expand); |
240 | 240 | |
241 | 241 | // Re-format date custom fields from Y-m-d |
242 | - $field_settings =& self::get_array(self::$request->modifications, "{$this->id}[customfields]",true); |
|
242 | + $field_settings = & self::get_array(self::$request->modifications, "{$this->id}[customfields]", true); |
|
243 | 243 | if (true) $field_settings = array(); |
244 | 244 | $link_types = Api\Link::app_list(); |
245 | - foreach($fields as $fname => $field) |
|
245 | + foreach ($fields as $fname => $field) |
|
246 | 246 | { |
247 | 247 | // Run beforeSendToClient for each field |
248 | 248 | $widget = $this->_widget($fname, $field); |
249 | - if(method_exists($widget, 'beforeSendToClient')) |
|
249 | + if (method_exists($widget, 'beforeSendToClient')) |
|
250 | 250 | { |
251 | 251 | $widget->beforeSendToClient($this->id == self::GLOBAL_ID ? '' : $this->id, $expand); |
252 | 252 | } |
@@ -263,13 +263,13 @@ discard block |
||
263 | 263 | protected function _widget($fname, array $field) |
264 | 264 | { |
265 | 265 | static $link_types = null; |
266 | - if (!isset($link_types)) $link_types = Api\Link::app_list (); |
|
266 | + if (!isset($link_types)) $link_types = Api\Link::app_list(); |
|
267 | 267 | |
268 | 268 | $type = $field['type']; |
269 | 269 | // Link-tos needs to change from appname to link-to |
270 | - if($link_types[$field['type']]) |
|
270 | + if ($link_types[$field['type']]) |
|
271 | 271 | { |
272 | - if($type == 'filemanager') |
|
272 | + if ($type == 'filemanager') |
|
273 | 273 | { |
274 | 274 | $type = 'vfs-upload'; |
275 | 275 | } |
@@ -283,18 +283,18 @@ discard block |
||
283 | 283 | $widget->attrs['type'] = $type; |
284 | 284 | |
285 | 285 | // some type-specific (default) attributes |
286 | - switch($type) |
|
286 | + switch ($type) |
|
287 | 287 | { |
288 | 288 | case 'date': |
289 | 289 | case 'date-time': |
290 | 290 | $widget->attrs['dataformat'] = $type == 'date' ? 'Y-m-d' : 'Y-m-d H:i:s'; |
291 | - if($field['values']['min']) $widget->attrs['min'] = $field['values']['min']; |
|
292 | - if($field['values']['max']) $widget->attrs['min'] = $field['values']['max']; |
|
291 | + if ($field['values']['min']) $widget->attrs['min'] = $field['values']['min']; |
|
292 | + if ($field['values']['max']) $widget->attrs['min'] = $field['values']['max']; |
|
293 | 293 | break; |
294 | 294 | |
295 | 295 | case 'vfs-upload': |
296 | - $widget->attrs['path'] = $field['app'] . ':' . |
|
297 | - self::expand_name('$cont['.Api\Link::get_registry($field['app'],'view_id').']',0,0,0,0,self::$request->content). |
|
296 | + $widget->attrs['path'] = $field['app'].':'. |
|
297 | + self::expand_name('$cont['.Api\Link::get_registry($field['app'], 'view_id').']', 0, 0, 0, 0, self::$request->content). |
|
298 | 298 | ':'.$field['label']; |
299 | 299 | break; |
300 | 300 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param array $content |
354 | 354 | * @param array &$validated=array() validated content |
355 | 355 | */ |
356 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
356 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
357 | 357 | { |
358 | 358 | if ($this->id) |
359 | 359 | { |
@@ -369,14 +369,14 @@ discard block |
||
369 | 369 | // if we have no id / use self::GLOBAL_ID, we have to set $value_in in global namespace for regular widgets validation to find |
370 | 370 | if (!$this->id) $content = array_merge($content, $value_in); |
371 | 371 | //error_log(__METHOD__."($cname, ...) form_name=$form_name, use-private={$this->attrs['use-private']}, value_in=".array2string($value_in)); |
372 | - $customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields'); |
|
373 | - if(is_array($value_in)) |
|
372 | + $customfields = & $this->getElementAttribute(self::GLOBAL_VALS, 'customfields'); |
|
373 | + if (is_array($value_in)) |
|
374 | 374 | { |
375 | - foreach($value_in as $field => $value) |
|
375 | + foreach ($value_in as $field => $value) |
|
376 | 376 | { |
377 | - $field_settings = $customfields[$fname=substr($field,1)]; |
|
377 | + $field_settings = $customfields[$fname = substr($field, 1)]; |
|
378 | 378 | |
379 | - if ((string)$this->attrs['use-private'] !== '' && // are only (non-)private fields requested |
|
379 | + if ((string)$this->attrs['use-private'] !== '' && // are only (non-)private fields requested |
|
380 | 380 | (boolean)$field_settings['private'] != ($this->attrs['use-private'] != '0')) |
381 | 381 | { |
382 | 382 | continue; |
@@ -396,10 +396,10 @@ discard block |
||
396 | 396 | $widget->validate($form_name != self::GLOBAL_ID ? $form_name : $cname, $expand, $content, $validated); |
397 | 397 | if ($field_settings['needed'] && (is_array($value) ? !$value : (string)$value === '')) |
398 | 398 | { |
399 | - self::set_validation_error($field,lang('Field must not be empty !!!'),''); |
|
399 | + self::set_validation_error($field, lang('Field must not be empty !!!'), ''); |
|
400 | 400 | } |
401 | - $field_name = $this->id[0] == self::$prefix && $customfields[substr($this->id,1)] ? $this->id : self::form_name($form_name != self::GLOBAL_ID ? $form_name : $cname, $field); |
|
402 | - $valid =& self::get_array($validated, $field_name, true); |
|
401 | + $field_name = $this->id[0] == self::$prefix && $customfields[substr($this->id, 1)] ? $this->id : self::form_name($form_name != self::GLOBAL_ID ? $form_name : $cname, $field); |
|
402 | + $valid = & self::get_array($validated, $field_name, true); |
|
403 | 403 | |
404 | 404 | if (is_array($valid)) $valid = implode(',', $valid); |
405 | 405 | // NULL is valid for most fields, but not custom fields due to backend handling |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | elseif ($this->type == 'customfields-types') |
412 | 412 | { |
413 | 413 | // Transformation doesn't handle validation |
414 | - $valid =& self::get_array($validated, $this->id ? $form_name : $field, true); |
|
414 | + $valid = & self::get_array($validated, $this->id ? $form_name : $field, true); |
|
415 | 415 | if (true) $valid = $value_in; |
416 | 416 | //error_log(__METHOD__."() $form_name $field: ".array2string($value).' --> '.array2string($value)); |
417 | 417 | } |
@@ -89,7 +89,10 @@ discard block |
||
89 | 89 | public function beforeSendToClient($cname, array $expand=null) |
90 | 90 | { |
91 | 91 | // No name, no way to get parameters client-side. |
92 | - if(!$this->id) $this->id = self::GLOBAL_ID; |
|
92 | + if(!$this->id) |
|
93 | + { |
|
94 | + $this->id = self::GLOBAL_ID; |
|
95 | + } |
|
93 | 96 | |
94 | 97 | $form_name = self::form_name($cname, $this->id, $expand); |
95 | 98 | |
@@ -180,7 +183,10 @@ discard block |
||
180 | 183 | $form_name = self::$prefix.$name; |
181 | 184 | } |
182 | 185 | |
183 | - if(!is_array($fields)) $fields = array(); |
|
186 | + if(!is_array($fields)) |
|
187 | + { |
|
188 | + $fields = array(); |
|
189 | + } |
|
184 | 190 | switch($type = $this->type) |
185 | 191 | { |
186 | 192 | case 'customfields-types': |
@@ -205,11 +211,18 @@ discard block |
||
205 | 211 | foreach(array_reverse($fields) as $lname => $field) |
206 | 212 | { |
207 | 213 | if (!empty($this->attrs['sub-type']) && !empty($field['type2']) && |
208 | - strpos(','.$field['type2'].',',','.$field['type2'].',') === false) continue; // not for our content type// |
|
209 | - if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') //break; |
|
214 | + strpos(','.$field['type2'].',',','.$field['type2'].',') === false) |
|
215 | + { |
|
216 | + continue; |
|
217 | + } |
|
218 | + // not for our content type// |
|
219 | + if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') |
|
220 | + { |
|
221 | + //break; |
|
210 | 222 | { |
211 | 223 | $fields_with_vals[]=$lname; |
212 | 224 | } |
225 | + } |
|
213 | 226 | //$stop_at_field = $name; |
214 | 227 | } |
215 | 228 | break; |
@@ -240,7 +253,10 @@ discard block |
||
240 | 253 | |
241 | 254 | // Re-format date custom fields from Y-m-d |
242 | 255 | $field_settings =& self::get_array(self::$request->modifications, "{$this->id}[customfields]",true); |
243 | - if (true) $field_settings = array(); |
|
256 | + if (true) |
|
257 | + { |
|
258 | + $field_settings = array(); |
|
259 | + } |
|
244 | 260 | $link_types = Api\Link::app_list(); |
245 | 261 | foreach($fields as $fname => $field) |
246 | 262 | { |
@@ -263,7 +279,10 @@ discard block |
||
263 | 279 | protected function _widget($fname, array $field) |
264 | 280 | { |
265 | 281 | static $link_types = null; |
266 | - if (!isset($link_types)) $link_types = Api\Link::app_list (); |
|
282 | + if (!isset($link_types)) |
|
283 | + { |
|
284 | + $link_types = Api\Link::app_list (); |
|
285 | + } |
|
267 | 286 | |
268 | 287 | $type = $field['type']; |
269 | 288 | // Link-tos needs to change from appname to link-to |
@@ -288,8 +307,14 @@ discard block |
||
288 | 307 | case 'date': |
289 | 308 | case 'date-time': |
290 | 309 | $widget->attrs['dataformat'] = $type == 'date' ? 'Y-m-d' : 'Y-m-d H:i:s'; |
291 | - if($field['values']['min']) $widget->attrs['min'] = $field['values']['min']; |
|
292 | - if($field['values']['max']) $widget->attrs['min'] = $field['values']['max']; |
|
310 | + if($field['values']['min']) |
|
311 | + { |
|
312 | + $widget->attrs['min'] = $field['values']['min']; |
|
313 | + } |
|
314 | + if($field['values']['max']) |
|
315 | + { |
|
316 | + $widget->attrs['min'] = $field['values']['max']; |
|
317 | + } |
|
293 | 318 | break; |
294 | 319 | |
295 | 320 | case 'vfs-upload': |
@@ -306,7 +331,10 @@ discard block |
||
306 | 331 | break; |
307 | 332 | |
308 | 333 | default: |
309 | - if (substr($type, 0, 7) !== 'select-' && $type != 'ajax_select') break; |
|
334 | + if (substr($type, 0, 7) !== 'select-' && $type != 'ajax_select') |
|
335 | + { |
|
336 | + break; |
|
337 | + } |
|
310 | 338 | // fall-through for all select-* widgets |
311 | 339 | case 'select': |
312 | 340 | $this->attrs['multiple'] = $field['rows'] > 1; |
@@ -367,7 +395,10 @@ discard block |
||
367 | 395 | $all_readonly = $this->is_readonly($cname, $form_name); |
368 | 396 | $value_in = self::get_array($content, $form_name); |
369 | 397 | // if we have no id / use self::GLOBAL_ID, we have to set $value_in in global namespace for regular widgets validation to find |
370 | - if (!$this->id) $content = array_merge($content, $value_in); |
|
398 | + if (!$this->id) |
|
399 | + { |
|
400 | + $content = array_merge($content, $value_in); |
|
401 | + } |
|
371 | 402 | //error_log(__METHOD__."($cname, ...) form_name=$form_name, use-private={$this->attrs['use-private']}, value_in=".array2string($value_in)); |
372 | 403 | $customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields'); |
373 | 404 | if(is_array($value_in)) |
@@ -392,7 +423,10 @@ discard block |
||
392 | 423 | // run validation method of widget implementing this custom field |
393 | 424 | $widget = $this->_widget($fname, $field_settings); |
394 | 425 | // widget has no validate method, eg. is only displaying stuff --> nothing to validate |
395 | - if (!method_exists($widget, 'validate')) continue; |
|
426 | + if (!method_exists($widget, 'validate')) |
|
427 | + { |
|
428 | + continue; |
|
429 | + } |
|
396 | 430 | $widget->validate($form_name != self::GLOBAL_ID ? $form_name : $cname, $expand, $content, $validated); |
397 | 431 | if ($field_settings['needed'] && (is_array($value) ? !$value : (string)$value === '')) |
398 | 432 | { |
@@ -401,10 +435,16 @@ discard block |
||
401 | 435 | $field_name = $this->id[0] == self::$prefix && $customfields[substr($this->id,1)] ? $this->id : self::form_name($form_name != self::GLOBAL_ID ? $form_name : $cname, $field); |
402 | 436 | $valid =& self::get_array($validated, $field_name, true); |
403 | 437 | |
404 | - if (is_array($valid)) $valid = implode(',', $valid); |
|
438 | + if (is_array($valid)) |
|
439 | + { |
|
440 | + $valid = implode(',', $valid); |
|
441 | + } |
|
405 | 442 | // NULL is valid for most fields, but not custom fields due to backend handling |
406 | 443 | // See so_sql_cf->save() |
407 | - if (is_null($valid)) $valid = false; |
|
444 | + if (is_null($valid)) |
|
445 | + { |
|
446 | + $valid = false; |
|
447 | + } |
|
408 | 448 | //error_log(__METHOD__."() $field_name: ".array2string($value).' --> '.array2string($valid)); |
409 | 449 | } |
410 | 450 | } |
@@ -412,7 +452,10 @@ discard block |
||
412 | 452 | { |
413 | 453 | // Transformation doesn't handle validation |
414 | 454 | $valid =& self::get_array($validated, $this->id ? $form_name : $field, true); |
415 | - if (true) $valid = $value_in; |
|
455 | + if (true) |
|
456 | + { |
|
457 | + $valid = $value_in; |
|
458 | + } |
|
416 | 459 | //error_log(__METHOD__."() $form_name $field: ".array2string($value).' --> '.array2string($value)); |
417 | 460 | } |
418 | 461 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | $this->contacts->__construct(); |
130 | 130 | $options = $this->contacts->contact_fields; |
131 | - foreach($this->contacts->customfields as $name => $data) |
|
131 | + foreach ($this->contacts->customfields as $name => $data) |
|
132 | 132 | { |
133 | 133 | $options['#'.$name] = $data['label']; |
134 | 134 | } |
@@ -148,28 +148,28 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function get_contact($value, array $attrs) |
150 | 150 | { |
151 | - if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; |
|
151 | + if (is_array($value) && !(array_key_exists('app', $value) && array_key_exists('id', $value))) return $value; |
|
152 | 152 | |
153 | - if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
154 | - switch($attrs['type']) |
|
153 | + if (is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
154 | + switch ($attrs['type']) |
|
155 | 155 | { |
156 | 156 | case 'contact-account': |
157 | 157 | case 'contact-template': |
158 | - if (substr($value,0,8) != 'account:') |
|
158 | + if (substr($value, 0, 8) != 'account:') |
|
159 | 159 | { |
160 | 160 | $value = 'account:'.($attrs['name'] != 'account:' ? $value : $GLOBALS['egw_info']['user']['account_id']); |
161 | 161 | } |
162 | 162 | // fall-through |
163 | 163 | case 'contact-value': |
164 | 164 | default: |
165 | - if (substr($value,0,12) == 'addressbook:') $value = substr($value,12); // link-entry syntax |
|
165 | + if (substr($value, 0, 12) == 'addressbook:') $value = substr($value, 12); // link-entry syntax |
|
166 | 166 | if (!($contact = $this->contacts->read($value))) |
167 | 167 | { |
168 | 168 | $contact = array(); |
169 | 169 | } |
170 | 170 | break; |
171 | 171 | } |
172 | - unset($contact['jpegphoto']); // makes no sense to return binary image |
|
172 | + unset($contact['jpegphoto']); // makes no sense to return binary image |
|
173 | 173 | |
174 | 174 | //error_log(__METHOD__."('$value') returning ".array2string($contact)); |
175 | 175 | return $contact; |
@@ -148,9 +148,15 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function get_contact($value, array $attrs) |
150 | 150 | { |
151 | - if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; |
|
151 | + if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) |
|
152 | + { |
|
153 | + return $value; |
|
154 | + } |
|
152 | 155 | |
153 | - if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
156 | + if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) |
|
157 | + { |
|
158 | + $value = $value['id']; |
|
159 | + } |
|
154 | 160 | switch($attrs['type']) |
155 | 161 | { |
156 | 162 | case 'contact-account': |
@@ -162,7 +168,11 @@ discard block |
||
162 | 168 | // fall-through |
163 | 169 | case 'contact-value': |
164 | 170 | default: |
165 | - if (substr($value,0,12) == 'addressbook:') $value = substr($value,12); // link-entry syntax |
|
171 | + if (substr($value,0,12) == 'addressbook:') |
|
172 | + { |
|
173 | + $value = substr($value,12); |
|
174 | + } |
|
175 | + // link-entry syntax |
|
166 | 176 | if (!($contact = $this->contacts->read($value))) |
167 | 177 | { |
168 | 178 | $contact = array(); |