@@ -55,7 +55,6 @@ |
||
55 | 55 | * |
56 | 56 | * This function is called before the extension gets rendered |
57 | 57 | * |
58 | - * @param string $name form-name of the control |
|
59 | 58 | * @param mixed &$value value / existing content, can be modified |
60 | 59 | * @param array &$cell array with the widget, can be modified for ui-independent widgets |
61 | 60 | * @param array &$readonlys names of widgets as key, to be made readonly |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | var $public_functions = array( |
34 | 34 | 'pre_process' => True, |
35 | 35 | 'post_process' => True, |
36 | - 'noReadonlysALL' => true, // mark extension as not to set readonly for $readonlys['__ALL__'] |
|
36 | + 'noReadonlysALL' => true, // mark extension as not to set readonly for $readonlys['__ALL__'] |
|
37 | 37 | ); |
38 | 38 | /** |
39 | 39 | * availible extensions and there names for the editor |
40 | 40 | * @var string |
41 | 41 | */ |
42 | - var $human_name = 'Tabs'; // this is the name for the editor |
|
42 | + var $human_name = 'Tabs'; // this is the name for the editor |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Constructor of the extension |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param etemplate &$tmpl reference to the template we belong too |
64 | 64 | * @return boolean true if extra label is allowed, false otherwise |
65 | 65 | */ |
66 | - function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) |
|
66 | + function pre_process($form_name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl) |
|
67 | 67 | { |
68 | 68 | //echo "<p>tab_widget::pre_process('$form_name',".array2string($value).','.array2string($readonlys).','.array2string($extension_data).")</p>\n"; |
69 | 69 | |
@@ -71,38 +71,38 @@ discard block |
||
71 | 71 | { |
72 | 72 | $dom_enabled = true; |
73 | 73 | } |
74 | - if (strpos($cell_name=$tab_names=$cell['name'],'=') !== false) |
|
74 | + if (strpos($cell_name = $tab_names = $cell['name'], '=') !== false) |
|
75 | 75 | { |
76 | - list($cell_name,$tab_names) = explode('=',$cell['name']); |
|
76 | + list($cell_name, $tab_names) = explode('=', $cell['name']); |
|
77 | 77 | $cell['name'] = $cell_name; |
78 | 78 | } |
79 | 79 | $labels = $helps = $names = $templates = $ids = array(); |
80 | 80 | if ($cell['tabs']) // set via etemplate::setElementAttribute() |
81 | 81 | { |
82 | - foreach($cell['tabs'] as $tab) |
|
82 | + foreach ($cell['tabs'] as $tab) |
|
83 | 83 | { |
84 | 84 | $labels[] = $tab['label']; |
85 | 85 | $helps[] = $tab['help']; |
86 | 86 | $names[] = $tab['id'] ? $tab['id'] : $tab['template']; |
87 | - if ($tab['template']) $templates[count($names)-1] = $tab['template']; |
|
88 | - if ($tab['id']) $ids[count($names)-1] = $tab['id']; |
|
87 | + if ($tab['template']) $templates[count($names) - 1] = $tab['template']; |
|
88 | + if ($tab['id']) $ids[count($names) - 1] = $tab['id']; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | else |
92 | 92 | { |
93 | - $labels = explode('|',$cell['label']); |
|
94 | - $helps = explode('|',$cell['help']); |
|
95 | - $names = explode('|',$tab_names); |
|
93 | + $labels = explode('|', $cell['label']); |
|
94 | + $helps = explode('|', $cell['help']); |
|
95 | + $names = explode('|', $tab_names); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $short_names = array(); |
99 | - foreach($names as $name) |
|
99 | + foreach ($names as $name) |
|
100 | 100 | { |
101 | 101 | $nparts = explode('.', $name); |
102 | 102 | $short_names[] = array_pop($nparts); |
103 | 103 | } |
104 | 104 | // disable tab mentioned in readonlys |
105 | - foreach(is_array($readonlys) ? $readonlys : array($readonlys => true) as $name => $disable) |
|
105 | + foreach (is_array($readonlys) ? $readonlys : array($readonlys => true) as $name => $disable) |
|
106 | 106 | { |
107 | 107 | if ($name && $disable && (($key = array_search($name, $names)) !== false || |
108 | 108 | ($key = array_search($name, $short_names)) !== false)) |
@@ -125,34 +125,34 @@ discard block |
||
125 | 125 | $tab_widget = new etemplate('etemplate.tab_widget'); |
126 | 126 | $tab_widget->no_onclick = true; |
127 | 127 | |
128 | - if ($value && strpos($value,'.') === false) |
|
128 | + if ($value && strpos($value, '.') === false) |
|
129 | 129 | { |
130 | - $value = $tmpl->name . '.' . $value; |
|
130 | + $value = $tmpl->name.'.'.$value; |
|
131 | 131 | } |
132 | - foreach($names as $k => $name) |
|
132 | + foreach ($names as $k => $name) |
|
133 | 133 | { |
134 | - if (strpos($name,'.') === false) |
|
134 | + if (strpos($name, '.') === false) |
|
135 | 135 | { |
136 | - $name = $names[$k] = $tmpl->name . '.' . $name; |
|
136 | + $name = $names[$k] = $tmpl->name.'.'.$name; |
|
137 | 137 | } |
138 | 138 | if ($value == $name) |
139 | 139 | { |
140 | 140 | $selected_tab = $name; |
141 | 141 | } |
142 | 142 | } |
143 | - $all_names = implode('|',$names); |
|
143 | + $all_names = implode('|', $names); |
|
144 | 144 | |
145 | 145 | if (empty($selected_tab)) |
146 | 146 | { |
147 | 147 | $value = $selected_tab = $names[0]; |
148 | 148 | } |
149 | - $extension_data = $value; // remember the active tab in the extension_data |
|
149 | + $extension_data = $value; // remember the active tab in the extension_data |
|
150 | 150 | |
151 | - foreach($names as $k => $name) |
|
151 | + foreach ($names as $k => $name) |
|
152 | 152 | { |
153 | - if (strpos($name,'.') === false) |
|
153 | + if (strpos($name, '.') === false) |
|
154 | 154 | { |
155 | - $name = $names[$k] = $tmpl->name . '.' . $name; |
|
155 | + $name = $names[$k] = $tmpl->name.'.'.$name; |
|
156 | 156 | } |
157 | 157 | $tcell = boetemplate::empty_cell(); |
158 | 158 | if ($value == $name) |
@@ -177,44 +177,44 @@ discard block |
||
177 | 177 | $tcell['label'] = '<div>'.lang($labels[$k]).'</div>'; |
178 | 178 | $tcell['help'] = $helps[$k]; |
179 | 179 | |
180 | - $tab_widget->set_cell_attribute('tabs',1+$k,$tcell); |
|
180 | + $tab_widget->set_cell_attribute('tabs', 1 + $k, $tcell); |
|
181 | 181 | } |
182 | - $tab_widget->set_cell_attribute('tabs','type','hbox'); |
|
183 | - $tab_widget->set_cell_attribute('tabs','size',count($names)); |
|
184 | - $tab_widget->set_cell_attribute('tabs','name',''); |
|
182 | + $tab_widget->set_cell_attribute('tabs', 'type', 'hbox'); |
|
183 | + $tab_widget->set_cell_attribute('tabs', 'size', count($names)); |
|
184 | + $tab_widget->set_cell_attribute('tabs', 'name', ''); |
|
185 | 185 | |
186 | 186 | if ($dom_enabled) |
187 | 187 | { |
188 | - foreach($names as $n => $name) |
|
188 | + foreach ($names as $n => $name) |
|
189 | 189 | { |
190 | - $bcell = boetemplate::empty_cell('template',$name); |
|
191 | - $bcell['obj'] = new etemplate(empty($templates[$n]) ? $name : $templates[$n],$tmpl->as_array()); |
|
190 | + $bcell = boetemplate::empty_cell('template', $name); |
|
191 | + $bcell['obj'] = new etemplate(empty($templates[$n]) ? $name : $templates[$n], $tmpl->as_array()); |
|
192 | 192 | // hack to set id / content attribute on first grid, as it's not supported on template itself |
193 | 193 | if (!empty($ids[$n]) && $bcell['obj']->children[0]['type'] == 'grid') |
194 | 194 | { |
195 | 195 | $bcell['obj']->children[0]['name'] = $ids[$n]; |
196 | 196 | } |
197 | - $tab_widget->set_cell_attribute('body',$n+1,$bcell); |
|
197 | + $tab_widget->set_cell_attribute('body', $n + 1, $bcell); |
|
198 | 198 | } |
199 | - $tab_widget->set_cell_attribute('body','type','deck'); |
|
200 | - $tab_widget->set_cell_attribute('body','size',count($names)); |
|
201 | - $tab_widget->set_cell_attribute('body','span',',tab_body'); |
|
202 | - $tab_widget->set_cell_attribute('body','name',$cell_name); |
|
199 | + $tab_widget->set_cell_attribute('body', 'type', 'deck'); |
|
200 | + $tab_widget->set_cell_attribute('body', 'size', count($names)); |
|
201 | + $tab_widget->set_cell_attribute('body', 'span', ',tab_body'); |
|
202 | + $tab_widget->set_cell_attribute('body', 'name', $cell_name); |
|
203 | 203 | } |
204 | 204 | else |
205 | 205 | { |
206 | - $stab = new etemplate($selected_tab,$tmpl->as_array()); |
|
207 | - $tab_widget->set_cell_attribute('body','type','template'); |
|
208 | - $tab_widget->set_cell_attribute('body','size',''); // the deck has a '1' there |
|
209 | - $tab_widget->set_cell_attribute('body','obj',$stab); |
|
206 | + $stab = new etemplate($selected_tab, $tmpl->as_array()); |
|
207 | + $tab_widget->set_cell_attribute('body', 'type', 'template'); |
|
208 | + $tab_widget->set_cell_attribute('body', 'size', ''); // the deck has a '1' there |
|
209 | + $tab_widget->set_cell_attribute('body', 'obj', $stab); |
|
210 | 210 | } |
211 | - $tab_widget->set_cell_attribute('body','name',$selected_tab); |
|
211 | + $tab_widget->set_cell_attribute('body', 'name', $selected_tab); |
|
212 | 212 | |
213 | 213 | $cell['type'] = 'template'; |
214 | 214 | $cell['obj'] = &$tab_widget; |
215 | 215 | $cell['label'] = $cell['help'] = ''; |
216 | 216 | |
217 | - return False; // NO extra Label |
|
217 | + return False; // NO extra Label |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @param mixed &value_in the posted values (already striped of magic-quotes) |
235 | 235 | * @return boolean true if $value has valid content, on false no content will be returned! |
236 | 236 | */ |
237 | - function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in) |
|
237 | + function post_process($name, &$value, &$extension_data, &$loop, &$tmpl, $value_in) |
|
238 | 238 | { |
239 | 239 | //echo "<p>tab_widget::post_process($name): value_in = "; _debug_array($value_in); |
240 | 240 |
@@ -67,25 +67,37 @@ |
||
67 | 67 | { |
68 | 68 | //echo "<p>tab_widget::pre_process('$form_name',".array2string($value).','.array2string($readonlys).','.array2string($extension_data).")</p>\n"; |
69 | 69 | |
70 | - if (!$cell['onchange']) // onchange allows to use the old behavior (submit for each new tab) |
|
70 | + if (!$cell['onchange']) |
|
71 | + { |
|
72 | + // onchange allows to use the old behavior (submit for each new tab) |
|
71 | 73 | { |
72 | 74 | $dom_enabled = true; |
73 | 75 | } |
76 | + } |
|
74 | 77 | if (strpos($cell_name=$tab_names=$cell['name'],'=') !== false) |
75 | 78 | { |
76 | 79 | list($cell_name,$tab_names) = explode('=',$cell['name']); |
77 | 80 | $cell['name'] = $cell_name; |
78 | 81 | } |
79 | 82 | $labels = $helps = $names = $templates = $ids = array(); |
80 | - if ($cell['tabs']) // set via etemplate::setElementAttribute() |
|
83 | + if ($cell['tabs']) |
|
84 | + { |
|
85 | + // set via etemplate::setElementAttribute() |
|
81 | 86 | { |
82 | 87 | foreach($cell['tabs'] as $tab) |
83 | 88 | { |
84 | 89 | $labels[] = $tab['label']; |
90 | + } |
|
85 | 91 | $helps[] = $tab['help']; |
86 | 92 | $names[] = $tab['id'] ? $tab['id'] : $tab['template']; |
87 | - if ($tab['template']) $templates[count($names)-1] = $tab['template']; |
|
88 | - if ($tab['id']) $ids[count($names)-1] = $tab['id']; |
|
93 | + if ($tab['template']) |
|
94 | + { |
|
95 | + $templates[count($names)-1] = $tab['template']; |
|
96 | + } |
|
97 | + if ($tab['id']) |
|
98 | + { |
|
99 | + $ids[count($names)-1] = $tab['id']; |
|
100 | + } |
|
89 | 101 | } |
90 | 102 | } |
91 | 103 | else |
@@ -484,6 +484,9 @@ discard block |
||
484 | 484 | return str_replace(array('[',']','&','"'),array('%5B','%5D','&','"'),$id); |
485 | 485 | } |
486 | 486 | |
487 | + /** |
|
488 | + * @return string |
|
489 | + */ |
|
487 | 490 | function recode_id($id) |
488 | 491 | { |
489 | 492 | if (get_magic_quotes_gpc()) |
@@ -493,6 +496,9 @@ discard block |
||
493 | 496 | return str_replace(array('%5B','%5D'),array('[',']'),$id); // & + " are recode by php |
494 | 497 | } |
495 | 498 | |
499 | + /** |
|
500 | + * @param string $which |
|
501 | + */ |
|
496 | 502 | function download($which,$userlang) |
497 | 503 | { |
498 | 504 | switch ($which) |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | function __construct() |
48 | 48 | { |
49 | 49 | $this->template = new Template(EGW_SERVER_ROOT.'/etemplate/templates/default'); |
50 | - $this->template->egroupware_hack = False; // else the phrases got translated |
|
50 | + $this->template->egroupware_hack = False; // else the phrases got translated |
|
51 | 51 | $this->bo = new bolangfile(); |
52 | 52 | $this->nextmatchs = new nextmatchs(); |
53 | 53 | translation::add_app('developer_tools'); |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | |
63 | 63 | function addphrase() |
64 | 64 | { |
65 | - $app_name = get_var('app_name',array('POST','GET')); |
|
66 | - $sourcelang = get_var('sourcelang',array('POST','GET')); |
|
67 | - $targetlang = get_var('targetlang',array('POST','GET')); |
|
65 | + $app_name = get_var('app_name', array('POST', 'GET')); |
|
66 | + $sourcelang = get_var('sourcelang', array('POST', 'GET')); |
|
67 | + $targetlang = get_var('targetlang', array('POST', 'GET')); |
|
68 | 68 | $entry = $_POST['entry']; |
69 | 69 | |
70 | 70 | $this->bo->read_sessiondata(); |
71 | - if($_POST['add'] || $_POST['cancel'] || $_POST['more']) |
|
71 | + if ($_POST['add'] || $_POST['cancel'] || $_POST['more']) |
|
72 | 72 | { |
73 | - if($_POST['add'] || $_POST['more']) |
|
73 | + if ($_POST['add'] || $_POST['more']) |
|
74 | 74 | { |
75 | 75 | if (get_magic_quotes_gpc()) |
76 | 76 | { |
77 | - foreach(array('message_id','content','target') as $name) |
|
77 | + foreach (array('message_id', 'content', 'target') as $name) |
|
78 | 78 | { |
79 | 79 | $entry[$name] = stripslashes($entry[$name]); |
80 | 80 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | if (!$_POST['more']) |
90 | 90 | { |
91 | - $GLOBALS['egw']->redirect_link('/index.php',array( |
|
91 | + $GLOBALS['egw']->redirect_link('/index.php', array( |
|
92 | 92 | 'menuaction' => $this->use_app.'.uilangfile.edit', |
93 | 93 | 'app_name' => $app_name, |
94 | 94 | 'sourcelang' => $sourcelang, |
@@ -102,42 +102,42 @@ discard block |
||
102 | 102 | common::egw_header(); |
103 | 103 | echo parse_navbar(); |
104 | 104 | |
105 | - $this->template->set_var('form_action',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.addphrase")); |
|
106 | - $this->template->set_var('sourcelang',$sourcelang); |
|
107 | - $this->template->set_var('targetlang',$targetlang); |
|
108 | - $this->template->set_var('app_name',$app_name); |
|
105 | + $this->template->set_var('form_action', $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.addphrase")); |
|
106 | + $this->template->set_var('sourcelang', $sourcelang); |
|
107 | + $this->template->set_var('targetlang', $targetlang); |
|
108 | + $this->template->set_var('app_name', $app_name); |
|
109 | 109 | |
110 | 110 | $this->template->set_file(array('form' => 'addphrase.tpl')); |
111 | - $this->template->set_var('message_id_field','<textarea rows="5" style="width: 100%;" name="entry[message_id]"></textarea>'); |
|
111 | + $this->template->set_var('message_id_field', '<textarea rows="5" style="width: 100%;" name="entry[message_id]"></textarea>'); |
|
112 | 112 | if ($app_name == 'api') $app_name = 'common'; |
113 | - $this->template->set_var('app_field',$this->lang_option($app_name,isset($entry)?$entry['app_name']:$app_name,'entry[app_name]')); |
|
114 | - $this->template->set_var('translation_field','<textarea rows="5" style="width: 100%;" name="entry[content]"></textarea>'); |
|
115 | - $this->template->set_var('target_field','<textarea rows="5" style="width: 100%;" name="entry[target]"></textarea>'); |
|
116 | - |
|
117 | - $this->template->set_var('lang_message_id',lang('message_id in English')); |
|
118 | - $this->template->set_var('lang_app',lang('Application')); |
|
119 | - $this->template->set_var('lang_translation',lang('Phrase in English (or empty if identical)')); |
|
120 | - $this->template->set_var('lang_target',lang('Translation of phrase')); |
|
121 | - $this->template->set_var('lang_add',lang('Add')); |
|
122 | - $this->template->set_var('lang_more',lang('Add more')); |
|
123 | - $this->template->set_var('lang_cancel',lang('Cancel')); |
|
124 | - |
|
125 | - $this->template->pfp('phpgw_body','form'); |
|
113 | + $this->template->set_var('app_field', $this->lang_option($app_name, isset($entry) ? $entry['app_name'] : $app_name, 'entry[app_name]')); |
|
114 | + $this->template->set_var('translation_field', '<textarea rows="5" style="width: 100%;" name="entry[content]"></textarea>'); |
|
115 | + $this->template->set_var('target_field', '<textarea rows="5" style="width: 100%;" name="entry[target]"></textarea>'); |
|
116 | + |
|
117 | + $this->template->set_var('lang_message_id', lang('message_id in English')); |
|
118 | + $this->template->set_var('lang_app', lang('Application')); |
|
119 | + $this->template->set_var('lang_translation', lang('Phrase in English (or empty if identical)')); |
|
120 | + $this->template->set_var('lang_target', lang('Translation of phrase')); |
|
121 | + $this->template->set_var('lang_add', lang('Add')); |
|
122 | + $this->template->set_var('lang_more', lang('Add more')); |
|
123 | + $this->template->set_var('lang_cancel', lang('Cancel')); |
|
124 | + |
|
125 | + $this->template->pfp('phpgw_body', 'form'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | function missingphrase() |
129 | 129 | { |
130 | - $app_name = get_var('app_name',array('POST','GET')); |
|
131 | - $sourcelang = get_var('sourcelang',array('POST','GET')); |
|
132 | - $targetlang = get_var('targetlang',array('POST','GET')); |
|
130 | + $app_name = get_var('app_name', array('POST', 'GET')); |
|
131 | + $sourcelang = get_var('sourcelang', array('POST', 'GET')); |
|
132 | + $targetlang = get_var('targetlang', array('POST', 'GET')); |
|
133 | 133 | |
134 | 134 | $this->bo->read_sessiondata(); |
135 | - $this->bo->missing_app($app_name,$sourcelang); |
|
135 | + $this->bo->missing_app($app_name, $sourcelang); |
|
136 | 136 | $this->bo->save_sessiondata(); |
137 | 137 | |
138 | 138 | // we have to redirect here, as solangfile defines function sidebox_menu, which clashes with the iDots func. |
139 | 139 | // |
140 | - $GLOBALS['egw']->redirect_link('/index.php',array( |
|
140 | + $GLOBALS['egw']->redirect_link('/index.php', array( |
|
141 | 141 | 'menuaction' => $this->use_app.'.uilangfile.missingphrase2', |
142 | 142 | 'app_name' => $app_name, |
143 | 143 | 'sourcelang' => $sourcelang, |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | |
148 | 148 | function missingphrase2() |
149 | 149 | { |
150 | - $app_name = get_var('app_name',array('POST','GET')); |
|
151 | - $sourcelang = get_var('sourcelang',array('POST','GET')); |
|
152 | - $targetlang = get_var('targetlang',array('POST','GET')); |
|
150 | + $app_name = get_var('app_name', array('POST', 'GET')); |
|
151 | + $sourcelang = get_var('sourcelang', array('POST', 'GET')); |
|
152 | + $targetlang = get_var('targetlang', array('POST', 'GET')); |
|
153 | 153 | $newlang = $_POST['newlang']; |
154 | 154 | $dlsource = $_POST['dlsource']; |
155 | 155 | $writesource = $_POST['writesource']; |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | $this->bo->read_sessiondata(); |
162 | 162 | |
163 | 163 | $this->template->set_file(array('langfile' => 'langmissing.tpl')); |
164 | - $this->template->set_block('langfile','header','header'); |
|
165 | - $this->template->set_block('langfile','postheader','postheader'); |
|
166 | - $this->template->set_block('langfile','detail','detail'); |
|
167 | - $this->template->set_block('langfile','prefooter','prefooter'); |
|
168 | - $this->template->set_block('langfile','footer','footer'); |
|
169 | - if(!$sourcelang) |
|
164 | + $this->template->set_block('langfile', 'header', 'header'); |
|
165 | + $this->template->set_block('langfile', 'postheader', 'postheader'); |
|
166 | + $this->template->set_block('langfile', 'detail', 'detail'); |
|
167 | + $this->template->set_block('langfile', 'prefooter', 'prefooter'); |
|
168 | + $this->template->set_block('langfile', 'footer', 'footer'); |
|
169 | + if (!$sourcelang) |
|
170 | 170 | { |
171 | 171 | $sourcelang = 'en'; |
172 | 172 | } |
173 | - if(!$targetlang) |
|
173 | + if (!$targetlang) |
|
174 | 174 | { |
175 | 175 | $targetlang = 'en'; |
176 | 176 | } |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | //echo "missingarray=<pre>"; print_r($this->bo->missing_langarray); echo "</pre>\n"; |
179 | 179 | if ($update) |
180 | 180 | { |
181 | - $deleteme = $_POST['delete']; |
|
181 | + $deleteme = $_POST['delete']; |
|
182 | 182 | //echo "deleteme=<pre>"; print_r($deleteme); echo "</pre>\n"; |
183 | 183 | |
184 | - while (list($_mess,$_checked) = @each($deleteme)) |
|
184 | + while (list($_mess, $_checked) = @each($deleteme)) |
|
185 | 185 | { |
186 | - if($_checked == 'on') |
|
186 | + if ($_checked == 'on') |
|
187 | 187 | { |
188 | 188 | $_mess = $this->recode_id($_mess); |
189 | 189 | $this->bo->movephrase($_mess); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | unset($deleteme); |
196 | 196 | |
197 | 197 | $this->bo->save_sessiondata(); |
198 | - $GLOBALS['egw']->redirect_link('/index.php',array( |
|
198 | + $GLOBALS['egw']->redirect_link('/index.php', array( |
|
199 | 199 | 'menuaction' => $this->use_app.'.uilangfile.edit', |
200 | 200 | 'app_name' => $app_name, |
201 | 201 | 'sourcelang' => $sourcelang, |
@@ -205,40 +205,40 @@ discard block |
||
205 | 205 | common::egw_header(); |
206 | 206 | echo parse_navbar(); |
207 | 207 | |
208 | - $this->template->set_var('lang_remove',lang('Add phrase')); |
|
209 | - $this->template->set_var('lang_application',lang('Application')); |
|
210 | - $this->template->set_var('lang_update',lang('Add')); |
|
211 | - $this->template->set_var('lang_view',lang('Cancel')); |
|
212 | - |
|
213 | - $this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.missingphrase2")); |
|
214 | - $this->template->set_var('sourcelang',$sourcelang); |
|
215 | - $this->template->set_var('targetlang',$targetlang); |
|
216 | - $this->template->set_var('app_name',$app_name); |
|
217 | - $this->template->set_var('app_title',$GLOBALS['egw_info']['apps'][$app_name]['title']); |
|
218 | - $this->template->pfp('out','header'); |
|
219 | - if($sourcelang && $targetlang) |
|
220 | - { |
|
221 | - $this->template->set_var('lang_appname',lang('Application')); |
|
222 | - $this->template->set_var('lang_message',lang('Message')); |
|
223 | - $this->template->set_var('lang_original',lang('Original')); |
|
208 | + $this->template->set_var('lang_remove', lang('Add phrase')); |
|
209 | + $this->template->set_var('lang_application', lang('Application')); |
|
210 | + $this->template->set_var('lang_update', lang('Add')); |
|
211 | + $this->template->set_var('lang_view', lang('Cancel')); |
|
212 | + |
|
213 | + $this->template->set_var('action_url', $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.missingphrase2")); |
|
214 | + $this->template->set_var('sourcelang', $sourcelang); |
|
215 | + $this->template->set_var('targetlang', $targetlang); |
|
216 | + $this->template->set_var('app_name', $app_name); |
|
217 | + $this->template->set_var('app_title', $GLOBALS['egw_info']['apps'][$app_name]['title']); |
|
218 | + $this->template->pfp('out', 'header'); |
|
219 | + if ($sourcelang && $targetlang) |
|
220 | + { |
|
221 | + $this->template->set_var('lang_appname', lang('Application')); |
|
222 | + $this->template->set_var('lang_message', lang('Message')); |
|
223 | + $this->template->set_var('lang_original', lang('Original')); |
|
224 | 224 | $this->template->set_var('view_link', |
225 | 225 | $GLOBALS['egw']->link( |
226 | 226 | '/index.php', |
227 | - "menuaction=$this->use_app.uilangfile.edit&app_name=".$app_name.'&sourcelang=' . $sourcelang . '&targetlang=' . $targetlang |
|
227 | + "menuaction=$this->use_app.uilangfile.edit&app_name=".$app_name.'&sourcelang='.$sourcelang.'&targetlang='.$targetlang |
|
228 | 228 | ) |
229 | 229 | ); |
230 | - $this->template->pfp('out','postheader'); |
|
231 | - while(list($key,$data) = @each($missingarray)) |
|
230 | + $this->template->pfp('out', 'postheader'); |
|
231 | + while (list($key, $data) = @each($missingarray)) |
|
232 | 232 | { |
233 | - $mess_id = $this->encode_id($key); |
|
234 | - $this->template->set_var('mess_id',$mess_id); |
|
235 | - $this->template->set_var('source_content',html::htmlspecialchars($data['content'])); |
|
236 | - $this->template->set_var('transapp',$this->lang_option($app_name,$data['app_name'],"transapp[$mess_id]")); |
|
237 | - $this->template->set_var('tr_class',$this->nextmatchs->alternate_row_color('',true)); |
|
238 | - $this->template->pfp('out','detail'); |
|
233 | + $mess_id = $this->encode_id($key); |
|
234 | + $this->template->set_var('mess_id', $mess_id); |
|
235 | + $this->template->set_var('source_content', html::htmlspecialchars($data['content'])); |
|
236 | + $this->template->set_var('transapp', $this->lang_option($app_name, $data['app_name'], "transapp[$mess_id]")); |
|
237 | + $this->template->set_var('tr_class', $this->nextmatchs->alternate_row_color('', true)); |
|
238 | + $this->template->pfp('out', 'detail'); |
|
239 | 239 | } |
240 | - $this->template->pfp('out','prefooter'); |
|
241 | - $this->template->pfp('out','footer'); |
|
240 | + $this->template->pfp('out', 'prefooter'); |
|
241 | + $this->template->pfp('out', 'footer'); |
|
242 | 242 | } |
243 | 243 | /* _debug_array($this->bo->loaded_apps); */ |
244 | 244 | $this->bo->save_sessiondata(); |
@@ -250,15 +250,15 @@ discard block |
||
250 | 250 | { |
251 | 251 | $GLOBALS['egw']->redirect_link('/index.php', "menuaction=$this->use_app.uilangfile.index"); |
252 | 252 | } |
253 | - $app_name = get_var('app_name',array('POST','GET')); |
|
254 | - $sourcelang = get_var('sourcelang',array('POST','GET')); |
|
255 | - $targetlang = get_var('targetlang',array('POST','GET')); |
|
256 | - $entry = $_POST['entry']; |
|
253 | + $app_name = get_var('app_name', array('POST', 'GET')); |
|
254 | + $sourcelang = get_var('sourcelang', array('POST', 'GET')); |
|
255 | + $targetlang = get_var('targetlang', array('POST', 'GET')); |
|
256 | + $entry = $_POST['entry']; |
|
257 | 257 | |
258 | - if($_POST['addphrase'] || $_POST['missingphrase']) |
|
258 | + if ($_POST['addphrase'] || $_POST['missingphrase']) |
|
259 | 259 | { |
260 | - $GLOBALS['egw']->redirect_link('/index.php',array( |
|
261 | - 'menuaction' => $this->use_app.'.uilangfile.'.($_POST['addphrase']?'addphrase':'missingphrase'), |
|
260 | + $GLOBALS['egw']->redirect_link('/index.php', array( |
|
261 | + 'menuaction' => $this->use_app.'.uilangfile.'.($_POST['addphrase'] ? 'addphrase' : 'missingphrase'), |
|
262 | 262 | 'app_name' => $app_name, |
263 | 263 | 'sourcelang' => $sourcelang, |
264 | 264 | 'targetlang' => $targetlang |
@@ -270,95 +270,95 @@ discard block |
||
270 | 270 | } |
271 | 271 | $this->bo->read_sessiondata(); |
272 | 272 | |
273 | - if($_POST['dlsource']) |
|
273 | + if ($_POST['dlsource']) |
|
274 | 274 | { |
275 | - $this->download('source',$sourcelang); |
|
275 | + $this->download('source', $sourcelang); |
|
276 | 276 | } |
277 | - if($_POST['dltarget']) |
|
277 | + if ($_POST['dltarget']) |
|
278 | 278 | { |
279 | - $this->download('target',$targetlang); |
|
279 | + $this->download('target', $targetlang); |
|
280 | 280 | } |
281 | 281 | $GLOBALS['egw_info']['flags']['css'] .= ".untranslated { background-color: #dab0b0; }\n"; |
282 | 282 | common::egw_header(); |
283 | 283 | echo parse_navbar(); |
284 | 284 | |
285 | 285 | $this->template->set_file(array('langfile' => 'langfile.tpl')); |
286 | - $this->template->set_block('langfile','header','header'); |
|
287 | - $this->template->set_block('langfile','postheader','postheader'); |
|
288 | - $this->template->set_block('langfile','detail','detail'); |
|
289 | - $this->template->set_block('langfile','detail_long','detail_long'); |
|
290 | - $this->template->set_block('langfile','footer','footer'); |
|
291 | - |
|
292 | - $this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit")); |
|
293 | - $this->template->set_var('lang_remove',lang('Remove')); |
|
294 | - $this->template->set_var('lang_application',lang('Application')); |
|
295 | - $this->template->set_var('lang_source',lang('Source Language')); |
|
296 | - $this->template->set_var('lang_target',lang('Target Language')); |
|
297 | - $this->template->set_var('lang_submit',lang('Load')); |
|
298 | - $this->template->set_var('lang_update',lang('Save')); |
|
299 | - $this->template->set_var('lang_revert',lang('Revert')); |
|
300 | - $this->template->set_var('lang_cancel',lang('Cancel')); |
|
301 | - $this->template->set_var('lang_step',lang('Step')); |
|
286 | + $this->template->set_block('langfile', 'header', 'header'); |
|
287 | + $this->template->set_block('langfile', 'postheader', 'postheader'); |
|
288 | + $this->template->set_block('langfile', 'detail', 'detail'); |
|
289 | + $this->template->set_block('langfile', 'detail_long', 'detail_long'); |
|
290 | + $this->template->set_block('langfile', 'footer', 'footer'); |
|
291 | + |
|
292 | + $this->template->set_var('action_url', $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit")); |
|
293 | + $this->template->set_var('lang_remove', lang('Remove')); |
|
294 | + $this->template->set_var('lang_application', lang('Application')); |
|
295 | + $this->template->set_var('lang_source', lang('Source Language')); |
|
296 | + $this->template->set_var('lang_target', lang('Target Language')); |
|
297 | + $this->template->set_var('lang_submit', lang('Load')); |
|
298 | + $this->template->set_var('lang_update', lang('Save')); |
|
299 | + $this->template->set_var('lang_revert', lang('Revert')); |
|
300 | + $this->template->set_var('lang_cancel', lang('Cancel')); |
|
301 | + $this->template->set_var('lang_step', lang('Step')); |
|
302 | 302 | $help = 'onMouseOver="self.status=\'%s\'; return true;" onMouseOut="self.status=\'\'; return true;"'; |
303 | - $this->template->set_var('cancel_help',sprintf($help,str_replace("'","\\'",lang('Returns to the application list, not saved changes get lost !!!')))); |
|
304 | - $this->template->set_var('load_help',sprintf($help,str_replace("'","\\'",lang('Loads the selected lang-files, to be modified in the next steps')))); |
|
305 | - $this->template->set_var('update_help',sprintf($help,str_replace("'","\\'",lang('Saves the added/changed translations to an internal buffer, to be used in further steps')))); |
|
306 | - $this->template->set_var('search_help',sprintf($help,str_replace("'","\\'",lang('Searches the source-code for phrases not in the actual source-lang-file')))); |
|
307 | - $this->template->set_var('add_help',sprintf($help,str_replace("'","\\'",lang('Allows you to add a single phrase')))); |
|
308 | - $this->template->set_var('revert_help',sprintf($help,str_replace("'","\\'",lang('Clears the internal buffer, all changes made sofar are lost')))); |
|
309 | - $this->template->set_var('download_help',sprintf($help,str_replace("'","\\'",lang('Download the lang-file to be saved in the apps setup-dir')))); |
|
310 | - $this->template->set_var('write_help',sprintf($help,str_replace("'","\\'",lang('Write the lang-file to the apps setup-dir')))); |
|
303 | + $this->template->set_var('cancel_help', sprintf($help, str_replace("'", "\\'", lang('Returns to the application list, not saved changes get lost !!!')))); |
|
304 | + $this->template->set_var('load_help', sprintf($help, str_replace("'", "\\'", lang('Loads the selected lang-files, to be modified in the next steps')))); |
|
305 | + $this->template->set_var('update_help', sprintf($help, str_replace("'", "\\'", lang('Saves the added/changed translations to an internal buffer, to be used in further steps')))); |
|
306 | + $this->template->set_var('search_help', sprintf($help, str_replace("'", "\\'", lang('Searches the source-code for phrases not in the actual source-lang-file')))); |
|
307 | + $this->template->set_var('add_help', sprintf($help, str_replace("'", "\\'", lang('Allows you to add a single phrase')))); |
|
308 | + $this->template->set_var('revert_help', sprintf($help, str_replace("'", "\\'", lang('Clears the internal buffer, all changes made sofar are lost')))); |
|
309 | + $this->template->set_var('download_help', sprintf($help, str_replace("'", "\\'", lang('Download the lang-file to be saved in the apps setup-dir')))); |
|
310 | + $this->template->set_var('write_help', sprintf($help, str_replace("'", "\\'", lang('Write the lang-file to the apps setup-dir')))); |
|
311 | 311 | |
312 | - if(!$sourcelang) |
|
312 | + if (!$sourcelang) |
|
313 | 313 | { |
314 | 314 | $sourcelang = 'en'; |
315 | 315 | } |
316 | - if(!$targetlang) |
|
316 | + if (!$targetlang) |
|
317 | 317 | { |
318 | 318 | $targetlang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; |
319 | 319 | } |
320 | 320 | |
321 | - foreach(translation::list_langs() as $lang_id => $lang_name) |
|
321 | + foreach (translation::list_langs() as $lang_id => $lang_name) |
|
322 | 322 | { |
323 | - $sourcelangs .= ' <option value="' . $lang_id . '"'; |
|
323 | + $sourcelangs .= ' <option value="'.$lang_id.'"'; |
|
324 | 324 | if ($lang_id == $sourcelang || !$sourcelang && $lang_id == 'en') |
325 | 325 | { |
326 | 326 | $sourcelangs .= ' selected="selected"'; |
327 | 327 | } |
328 | - $sourcelangs .= '>' . $lang_name . '</option>' . "\n"; |
|
328 | + $sourcelangs .= '>'.$lang_name.'</option>'."\n"; |
|
329 | 329 | |
330 | - $targetlangs .= ' <option value="' . $lang_id . '"'; |
|
330 | + $targetlangs .= ' <option value="'.$lang_id.'"'; |
|
331 | 331 | if ($lang_id == $targetlang || !$targetlang && $lang_id == 'en') |
332 | 332 | { |
333 | 333 | $targetlangs .= ' selected="selected"'; |
334 | 334 | } |
335 | - $targetlangs .= '>' . $lang_name . '</option>' . "\n"; |
|
335 | + $targetlangs .= '>'.$lang_name.'</option>'."\n"; |
|
336 | 336 | } |
337 | - $this->template->set_var('sourcelangs',$sourcelangs); |
|
338 | - $this->template->set_var('targetlangs',$targetlangs); |
|
339 | - $this->template->set_var('app_name',$app_name); |
|
340 | - $this->template->set_var('app_title',$GLOBALS['egw_info']['apps'][$app_name]['title']); |
|
341 | - $this->template->pfp('out','header'); |
|
337 | + $this->template->set_var('sourcelangs', $sourcelangs); |
|
338 | + $this->template->set_var('targetlangs', $targetlangs); |
|
339 | + $this->template->set_var('app_name', $app_name); |
|
340 | + $this->template->set_var('app_title', $GLOBALS['egw_info']['apps'][$app_name]['title']); |
|
341 | + $this->template->pfp('out', 'header'); |
|
342 | 342 | |
343 | - foreach($GLOBALS['egw_info']['apps']+array('setup' => array('title' => lang('Setup'))) as $app => $data) |
|
343 | + foreach ($GLOBALS['egw_info']['apps'] + array('setup' => array('title' => lang('Setup'))) as $app => $data) |
|
344 | 344 | { |
345 | - $userapps .= '<option value="' . $userapp . '"'; |
|
345 | + $userapps .= '<option value="'.$userapp.'"'; |
|
346 | 346 | if ($application_name == $userapp) |
347 | 347 | { |
348 | 348 | $userapps .= ' selected="selected"'; |
349 | 349 | } |
350 | - $userapps .= '>' . $data['title'] . '</option>' . "\n"; |
|
350 | + $userapps .= '>'.$data['title'].'</option>'."\n"; |
|
351 | 351 | } |
352 | - $this->template->set_var('userapps',$userapps); |
|
352 | + $this->template->set_var('userapps', $userapps); |
|
353 | 353 | |
354 | 354 | if ($_POST['update'] || $_POST['update_too']) |
355 | 355 | { |
356 | 356 | $transapp = $_POST['transapp']; |
357 | 357 | $translations = $_POST['translations']; |
358 | 358 | $deleteme = $_POST['delete']; |
359 | - foreach($transapp as $_mess => $_app) |
|
359 | + foreach ($transapp as $_mess => $_app) |
|
360 | 360 | { |
361 | - if($_mess) |
|
361 | + if ($_mess) |
|
362 | 362 | { |
363 | 363 | $_mess = strtolower(trim($this->recode_id($_mess))); |
364 | 364 | $this->bo->source_langarray[$_mess]['app_name'] = $_app; |
@@ -369,9 +369,9 @@ discard block |
||
369 | 369 | { |
370 | 370 | $this->bo->target_langarray = array(); |
371 | 371 | } |
372 | - foreach($translations as $_mess => $_cont) |
|
372 | + foreach ($translations as $_mess => $_cont) |
|
373 | 373 | { |
374 | - if($_mess && $_cont) |
|
374 | + if ($_mess && $_cont) |
|
375 | 375 | { |
376 | 376 | $_mess = strtolower(trim($this->recode_id($_mess))); |
377 | 377 | $this->bo->target_langarray[$_mess]['message_id'] = $_mess; |
@@ -381,16 +381,16 @@ discard block |
||
381 | 381 | $_cont = stripslashes($_cont); |
382 | 382 | } |
383 | 383 | $this->bo->target_langarray[$_mess]['content'] = $_cont; |
384 | - if($sourcelang == $targetlang) |
|
384 | + if ($sourcelang == $targetlang) |
|
385 | 385 | { |
386 | 386 | $this->bo->source_langarray[$_mess]['content'] = $_cont; |
387 | 387 | } |
388 | 388 | } |
389 | 389 | } |
390 | 390 | if ($deleteme) |
391 | - foreach($deleteme as $_mess => $_checked) |
|
391 | + foreach ($deleteme as $_mess => $_checked) |
|
392 | 392 | { |
393 | - if($_checked == 'on') |
|
393 | + if ($_checked == 'on') |
|
394 | 394 | { |
395 | 395 | $_mess = strtolower(trim($this->recode_id($_mess))); |
396 | 396 | unset($this->bo->source_langarray[$_mess]); |
@@ -402,78 +402,78 @@ discard block |
||
402 | 402 | /* $this->bo->save_sessiondata($this->bo->source_langarray,$this->bo->target_langarray); */ |
403 | 403 | unset($transapp); |
404 | 404 | unset($translations); |
405 | - if($deleteme) |
|
405 | + if ($deleteme) |
|
406 | 406 | { |
407 | 407 | $this->bo->save_sessiondata(); |
408 | 408 | } |
409 | 409 | unset($deleteme); |
410 | 410 | } |
411 | - if($_POST['writesource'] || $_POST['writesource_too']) |
|
411 | + if ($_POST['writesource'] || $_POST['writesource_too']) |
|
412 | 412 | { |
413 | - echo '<br>'.lang("Writing langfile for '%1' ...",$sourcelang); |
|
414 | - $this->bo->write_file('source',$app_name,$sourcelang); |
|
413 | + echo '<br>'.lang("Writing langfile for '%1' ...", $sourcelang); |
|
414 | + $this->bo->write_file('source', $app_name, $sourcelang); |
|
415 | 415 | } |
416 | - if($_POST['writetarget'] || $_POST['writetarget_too']) |
|
416 | + if ($_POST['writetarget'] || $_POST['writetarget_too']) |
|
417 | 417 | { |
418 | - echo '<br>'.lang("Writing langfile for '%1' ...",$targetlang); |
|
419 | - $this->bo->write_file('target',$app_name,$targetlang); |
|
418 | + echo '<br>'.lang("Writing langfile for '%1' ...", $targetlang); |
|
419 | + $this->bo->write_file('target', $app_name, $targetlang); |
|
420 | 420 | } |
421 | 421 | |
422 | - if($sourcelang && $targetlang) |
|
422 | + if ($sourcelang && $targetlang) |
|
423 | 423 | { |
424 | - $this->template->set_var('lang_appname',lang('Application')); |
|
425 | - $this->template->set_var('lang_message',lang('Message')); |
|
426 | - $this->template->set_var('lang_original',lang('Original')); |
|
427 | - $this->template->set_var('lang_translation',lang('Translation')); |
|
428 | - $this->template->set_var('lang_missingphrase',lang('Search new phrases')); |
|
429 | - $this->template->set_var('lang_addphrase',lang('Add new phrase')); |
|
430 | - $this->template->set_var('sourcelang',$sourcelang); |
|
431 | - $this->template->set_var('targetlang',$targetlang); |
|
432 | - $this->template->pfp('out','postheader'); |
|
424 | + $this->template->set_var('lang_appname', lang('Application')); |
|
425 | + $this->template->set_var('lang_message', lang('Message')); |
|
426 | + $this->template->set_var('lang_original', lang('Original')); |
|
427 | + $this->template->set_var('lang_translation', lang('Translation')); |
|
428 | + $this->template->set_var('lang_missingphrase', lang('Search new phrases')); |
|
429 | + $this->template->set_var('lang_addphrase', lang('Add new phrase')); |
|
430 | + $this->template->set_var('sourcelang', $sourcelang); |
|
431 | + $this->template->set_var('targetlang', $targetlang); |
|
432 | + $this->template->pfp('out', 'postheader'); |
|
433 | 433 | |
434 | - $langarray = $this->bo->add_app($app_name,$sourcelang); |
|
435 | - $translation = $this->bo->load_app($app_name,$targetlang); |
|
434 | + $langarray = $this->bo->add_app($app_name, $sourcelang); |
|
435 | + $translation = $this->bo->load_app($app_name, $targetlang); |
|
436 | 436 | |
437 | - while(list($key,$data) = @each($langarray)) |
|
437 | + while (list($key, $data) = @each($langarray)) |
|
438 | 438 | { |
439 | 439 | $mess_id = $this->encode_id($key); |
440 | 440 | $content = html::htmlspecialchars($mess_id == 'charset' ? $mess_id : $data['content']); |
441 | 441 | $transy = html::htmlspecialchars($translation[$key]['content']); |
442 | - $this->template->set_var('mess_id',$mess_id); |
|
443 | - $this->template->set_var('source_content',$content); |
|
444 | - $this->template->set_var('content',$transy); |
|
445 | - $this->template->set_var('transapp',$this->lang_option($app_name,$data['app_name'],"transapp[$mess_id]")); |
|
446 | - $this->template->set_var('tr_class',empty($transy) ? 'untranslated' : $this->nextmatchs->alternate_row_color('',true)); |
|
447 | - if (($len = max(strlen($key),strlen($content))) > 50) |
|
442 | + $this->template->set_var('mess_id', $mess_id); |
|
443 | + $this->template->set_var('source_content', $content); |
|
444 | + $this->template->set_var('content', $transy); |
|
445 | + $this->template->set_var('transapp', $this->lang_option($app_name, $data['app_name'], "transapp[$mess_id]")); |
|
446 | + $this->template->set_var('tr_class', empty($transy) ? 'untranslated' : $this->nextmatchs->alternate_row_color('', true)); |
|
447 | + if (($len = max(strlen($key), strlen($content))) > 50) |
|
448 | 448 | { |
449 | - $this->template->set_var('rows',min(intval($len/80+0.5),10)); |
|
450 | - $this->template->pfp('out','detail_long'); |
|
449 | + $this->template->set_var('rows', min(intval($len / 80 + 0.5), 10)); |
|
450 | + $this->template->pfp('out', 'detail_long'); |
|
451 | 451 | } |
452 | 452 | else |
453 | 453 | { |
454 | - $this->template->pfp('out','detail'); |
|
454 | + $this->template->pfp('out', 'detail'); |
|
455 | 455 | } |
456 | 456 | } |
457 | - $this->template->set_var('sourcelang',$sourcelang); |
|
458 | - $this->template->set_var('targetlang',$targetlang); |
|
459 | - $this->template->set_var('lang_write',lang('Write')); |
|
460 | - $this->template->set_var('lang_download',lang('Download')); |
|
461 | - $this->template->set_var('src_file',$this->bo->src_file); |
|
462 | - if(!$this->bo->loaded_apps[$sourcelang]['writeable']) |
|
457 | + $this->template->set_var('sourcelang', $sourcelang); |
|
458 | + $this->template->set_var('targetlang', $targetlang); |
|
459 | + $this->template->set_var('lang_write', lang('Write')); |
|
460 | + $this->template->set_var('lang_download', lang('Download')); |
|
461 | + $this->template->set_var('src_file', $this->bo->src_file); |
|
462 | + if (!$this->bo->loaded_apps[$sourcelang]['writeable']) |
|
463 | 463 | { |
464 | - $this->template->set_block('footer','srcwrite','srcwrite'); |
|
465 | - $this->template->set_var('srcwrite',''); |
|
464 | + $this->template->set_block('footer', 'srcwrite', 'srcwrite'); |
|
465 | + $this->template->set_var('srcwrite', ''); |
|
466 | 466 | } |
467 | - $this->template->set_var('tgt_file',$this->bo->tgt_file); |
|
468 | - $this->template->set_var('targetlang',$targetlang); |
|
469 | - if(!$this->bo->loaded_apps[$targetlang]['writeable']) |
|
467 | + $this->template->set_var('tgt_file', $this->bo->tgt_file); |
|
468 | + $this->template->set_var('targetlang', $targetlang); |
|
469 | + if (!$this->bo->loaded_apps[$targetlang]['writeable']) |
|
470 | 470 | { |
471 | - $this->template->set_block('footer','tgtwrite','tgtwrite'); |
|
472 | - $this->template->set_var('tgtwrite',''); |
|
471 | + $this->template->set_block('footer', 'tgtwrite', 'tgtwrite'); |
|
472 | + $this->template->set_var('tgtwrite', ''); |
|
473 | 473 | } |
474 | 474 | |
475 | - $this->template->set_var('helpmsg',lang('you have to [Save] every manual change in the above fields, before you can go to the next step !!!')); |
|
476 | - $this->template->pfp('out','footer'); |
|
475 | + $this->template->set_var('helpmsg', lang('you have to [Save] every manual change in the above fields, before you can go to the next step !!!')); |
|
476 | + $this->template->pfp('out', 'footer'); |
|
477 | 477 | } |
478 | 478 | /* _debug_array($this->bo->loaded_apps); */ |
479 | 479 | $this->bo->save_sessiondata(); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | |
482 | 482 | function encode_id($id) |
483 | 483 | { |
484 | - return str_replace(array('[',']','&','"'),array('%5B','%5D','&','"'),$id); |
|
484 | + return str_replace(array('[', ']', '&', '"'), array('%5B', '%5D', '&', '"'), $id); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | function recode_id($id) |
@@ -490,10 +490,10 @@ discard block |
||
490 | 490 | { |
491 | 491 | $id = stripslashes($id); |
492 | 492 | } |
493 | - return str_replace(array('%5B','%5D'),array('[',']'),$id); // & + " are recode by php |
|
493 | + return str_replace(array('%5B', '%5D'), array('[', ']'), $id); // & + " are recode by php |
|
494 | 494 | } |
495 | 495 | |
496 | - function download($which,$userlang) |
|
496 | + function download($which, $userlang) |
|
497 | 497 | { |
498 | 498 | switch ($which) |
499 | 499 | { |
@@ -502,20 +502,20 @@ discard block |
||
502 | 502 | break; |
503 | 503 | case 'target': |
504 | 504 | // removing phrases not in the source language |
505 | - $langarray = $this->bo->target_langarray = array_intersect_assoc($this->bo->target_langarray,$this->bo->source_langarray); |
|
505 | + $langarray = $this->bo->target_langarray = array_intersect_assoc($this->bo->target_langarray, $this->bo->source_langarray); |
|
506 | 506 | break; |
507 | 507 | default: |
508 | 508 | break; |
509 | 509 | } |
510 | - html::content_header(translation::LANGFILE_PREFIX . $userlang . '.lang'); |
|
510 | + html::content_header(translation::LANGFILE_PREFIX.$userlang.'.lang'); |
|
511 | 511 | $to = translation::charset($userlang); |
512 | 512 | $from = translation::charset(); |
513 | - while(list($mess_id,$data) = @each($langarray)) |
|
513 | + while (list($mess_id, $data) = @each($langarray)) |
|
514 | 514 | { |
515 | - $content = translation::convert(trim($data['content']),$from,$to); |
|
515 | + $content = translation::convert(trim($data['content']), $from, $to); |
|
516 | 516 | if (!empty($content)) |
517 | 517 | { |
518 | - echo $mess_id . "\t" . $data['app_name'] . "\t" . $userlang . "\t" . $content . "\n"; |
|
518 | + echo $mess_id."\t".$data['app_name']."\t".$userlang."\t".$content."\n"; |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | common::egw_exit(); |
@@ -528,15 +528,15 @@ discard block |
||
528 | 528 | $order = $_POST['order']; |
529 | 529 | $query = $_POST['query']; |
530 | 530 | |
531 | - $this->bo->save_sessiondata('',''); |
|
531 | + $this->bo->save_sessiondata('', ''); |
|
532 | 532 | $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title']. |
533 | 533 | ' - '.lang('Installed applications'); |
534 | 534 | common::egw_header(); |
535 | 535 | echo parse_navbar(); |
536 | 536 | |
537 | 537 | $this->template->set_file(array('applications' => 'applications.tpl')); |
538 | - $this->template->set_block('applications','list','list'); |
|
539 | - $this->template->set_block('applications','row','row'); |
|
538 | + $this->template->set_block('applications', 'list', 'list'); |
|
539 | + $this->template->set_block('applications', 'row', 'row'); |
|
540 | 540 | |
541 | 541 | $offset = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
542 | 542 | |
@@ -546,18 +546,18 @@ discard block |
||
546 | 546 | 'title' => lang('Setup') |
547 | 547 | ) |
548 | 548 | ); |
549 | - foreach($GLOBALS['egw_info']['apps'] as $app => $data) |
|
549 | + foreach ($GLOBALS['egw_info']['apps'] as $app => $data) |
|
550 | 550 | { |
551 | 551 | $apps[strtolower($data['title'])] = $data; |
552 | 552 | } |
553 | 553 | $total = count($apps); |
554 | 554 | |
555 | - if(!$sort) |
|
555 | + if (!$sort) |
|
556 | 556 | { |
557 | 557 | $sort = 'ASC'; |
558 | 558 | } |
559 | 559 | |
560 | - if($sort == 'ASC') |
|
560 | + if ($sort == 'ASC') |
|
561 | 561 | { |
562 | 562 | ksort($apps); |
563 | 563 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | { |
575 | 575 | $limit = $start; |
576 | 576 | } |
577 | - elseif(!$start && !$offset) |
|
577 | + elseif (!$start && !$offset) |
|
578 | 578 | { |
579 | 579 | $limit = $total; |
580 | 580 | } |
@@ -589,39 +589,39 @@ discard block |
||
589 | 589 | $limit = $total; |
590 | 590 | } |
591 | 591 | |
592 | - $this->template->set_var('sort_title',$this->nextmatchs->show_sort_order($sort,'title','title','/index.php',lang('Title'),"&menuaction=$this->use_app.uilangfile.index")); |
|
593 | - $this->template->set_var('lang_showing',$this->nextmatchs->show_hits($total,$start)); |
|
594 | - $this->template->set_var('left',$this->nextmatchs->left('/index.php',$start,$total,"&menuaction=$this->use_app.uilangfile.index")); |
|
595 | - $this->template->set_var('right',$this->nextmatchs->right('/index.php',$start,$total,"&menuaction=$this->use_app.uilangfile.index")); |
|
592 | + $this->template->set_var('sort_title', $this->nextmatchs->show_sort_order($sort, 'title', 'title', '/index.php', lang('Title'), "&menuaction=$this->use_app.uilangfile.index")); |
|
593 | + $this->template->set_var('lang_showing', $this->nextmatchs->show_hits($total, $start)); |
|
594 | + $this->template->set_var('left', $this->nextmatchs->left('/index.php', $start, $total, "&menuaction=$this->use_app.uilangfile.index")); |
|
595 | + $this->template->set_var('right', $this->nextmatchs->right('/index.php', $start, $total, "&menuaction=$this->use_app.uilangfile.index")); |
|
596 | 596 | |
597 | - $this->template->set_var('lang_edit',lang('Edit')); |
|
597 | + $this->template->set_var('lang_edit', lang('Edit')); |
|
598 | 598 | //$this->template->set_var('lang_translate',lang('Translate')); |
599 | - $this->template->set_var('new_action',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.create")); |
|
600 | - $this->template->set_var('create_new',lang('Create New Language File')); |
|
599 | + $this->template->set_var('new_action', $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.create")); |
|
600 | + $this->template->set_var('create_new', lang('Create New Language File')); |
|
601 | 601 | |
602 | 602 | $i = 0; |
603 | - foreach($apps as $data) |
|
603 | + foreach ($apps as $data) |
|
604 | 604 | { |
605 | - if($start <= $i && $i < $limit) |
|
605 | + if ($start <= $i && $i < $limit) |
|
606 | 606 | { |
607 | - $this->template->set_var('tr_class',$this->nextmatchs->alternate_row_color('',true)); |
|
607 | + $this->template->set_var('tr_class', $this->nextmatchs->alternate_row_color('', true)); |
|
608 | 608 | |
609 | - $this->template->set_var('name',$data['title']); |
|
609 | + $this->template->set_var('name', $data['title']); |
|
610 | 610 | |
611 | - $this->template->set_var('edit','<a href="' . $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit&app_name=" . urlencode($data['name'])) . '"> ' . lang('Edit') . ' </a>'); |
|
611 | + $this->template->set_var('edit', '<a href="'.$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit&app_name=".urlencode($data['name'])).'"> '.lang('Edit').' </a>'); |
|
612 | 612 | // $this->template->set_var('translate','<a href="' . $GLOBALS['egw']->link('/index.php',"menuaction=$this->use_app.uilangfile.translate&app_name=" . urlencode($app['name'])) . '"> ' . lang('Translate') . ' </a>'); |
613 | 613 | |
614 | - $this->template->set_var('status',$status); |
|
614 | + $this->template->set_var('status', $status); |
|
615 | 615 | |
616 | - $this->template->parse('rows','row',True); |
|
616 | + $this->template->parse('rows', 'row', True); |
|
617 | 617 | } |
618 | 618 | ++$i; |
619 | 619 | } |
620 | 620 | |
621 | - $this->template->pparse('phpgw_body','list'); |
|
621 | + $this->template->pparse('phpgw_body', 'list'); |
|
622 | 622 | } |
623 | 623 | |
624 | - function lang_option($app_name,$current,$name) |
|
624 | + function lang_option($app_name, $current, $name) |
|
625 | 625 | { |
626 | 626 | $list = (is_array($this->bo->src_apps) ? $this->bo->src_apps : array()) + array( |
627 | 627 | $app_name => $app_name, |
@@ -631,15 +631,15 @@ discard block |
||
631 | 631 | 'preferences' => 'preferences' |
632 | 632 | ); |
633 | 633 | |
634 | - $select = "\n" .'<select name="' . $name . '">' . "\n"; |
|
635 | - foreach($list as $key => $val) |
|
634 | + $select = "\n".'<select name="'.$name.'">'."\n"; |
|
635 | + foreach ($list as $key => $val) |
|
636 | 636 | { |
637 | - $select .= '<option value="' . $key . '"'; |
|
637 | + $select .= '<option value="'.$key.'"'; |
|
638 | 638 | if ($key == $current && $current != '') |
639 | 639 | { |
640 | 640 | $select .= ' selected="selected"'; |
641 | 641 | } |
642 | - $select .= '>' . $val . '</option>'."\n"; |
|
642 | + $select .= '>'.$val.'</option>'."\n"; |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | $select .= '</select>'."\n"; |
@@ -109,7 +109,10 @@ discard block |
||
109 | 109 | |
110 | 110 | $this->template->set_file(array('form' => 'addphrase.tpl')); |
111 | 111 | $this->template->set_var('message_id_field','<textarea rows="5" style="width: 100%;" name="entry[message_id]"></textarea>'); |
112 | - if ($app_name == 'api') $app_name = 'common'; |
|
112 | + if ($app_name == 'api') |
|
113 | + { |
|
114 | + $app_name = 'common'; |
|
115 | + } |
|
113 | 116 | $this->template->set_var('app_field',$this->lang_option($app_name,isset($entry)?$entry['app_name']:$app_name,'entry[app_name]')); |
114 | 117 | $this->template->set_var('translation_field','<textarea rows="5" style="width: 100%;" name="entry[content]"></textarea>'); |
115 | 118 | $this->template->set_var('target_field','<textarea rows="5" style="width: 100%;" name="entry[target]"></textarea>'); |
@@ -388,11 +391,13 @@ discard block |
||
388 | 391 | } |
389 | 392 | } |
390 | 393 | if ($deleteme) |
391 | - foreach($deleteme as $_mess => $_checked) |
|
394 | + { |
|
395 | + foreach($deleteme as $_mess => $_checked) |
|
392 | 396 | { |
393 | 397 | if($_checked == 'on') |
394 | 398 | { |
395 | 399 | $_mess = strtolower(trim($this->recode_id($_mess))); |
400 | + } |
|
396 | 401 | unset($this->bo->source_langarray[$_mess]); |
397 | 402 | unset($this->bo->target_langarray[$_mess]); |
398 | 403 | } |
@@ -230,7 +230,7 @@ |
||
230 | 230 | * replaces '%1' with the phonenumber to call, '%u' with the user's account_lid and '%t' with his work-phone-number |
231 | 231 | * |
232 | 232 | * @param string $number phone number |
233 | - * @return string|boolean string with link or false if no no telephony integration configured |
|
233 | + * @return false|string string with link or false if no no telephony integration configured |
|
234 | 234 | */ |
235 | 235 | static function phone2link($number) |
236 | 236 | { |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | * @param object &$tmpl reference to the template we belong too |
79 | 79 | * @return boolean true if extra label is allowed, false otherwise |
80 | 80 | */ |
81 | - function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) |
|
81 | + function pre_process($name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl) |
|
82 | 82 | { |
83 | 83 | $readonly = $cell['readonly'] || $readonlys; |
84 | 84 | |
85 | - switch($cell['type']) |
|
85 | + switch ($cell['type']) |
|
86 | 86 | { |
87 | 87 | case 'url-email': // size: size,max-size,{2=no validation,1=rfc822 name part allowed, default only email},default if value empty |
88 | - list($size,$max_size,$validation_type,$default) = explode(',',$cell['size'],4); // 4 = allow default to contain commas |
|
89 | - if (!$value) $value = $default; // use default from size/options if empty |
|
88 | + list($size, $max_size, $validation_type, $default) = explode(',', $cell['size'], 4); // 4 = allow default to contain commas |
|
89 | + if (!$value) $value = $default; // use default from size/options if empty |
|
90 | 90 | $cell['no_lang'] = 1; |
91 | 91 | |
92 | 92 | if (!$readonly) |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $cell['size'] = $size.','.$max_size.','; |
96 | 96 | if ((int)$validation_type < 2) |
97 | 97 | { |
98 | - $cell['size'] .= $cell['needed'] ? '/^(' : '/^(|'; // if not needed allow empty, as EMAIL_PREG does not |
|
98 | + $cell['size'] .= $cell['needed'] ? '/^(' : '/^(|'; // if not needed allow empty, as EMAIL_PREG does not |
|
99 | 99 | $cell['size'] .= self::EMAIL_PREG; |
100 | 100 | if ($validation_type == 1) // allow rfc822 name part too: Ralf Becker <[email protected]> |
101 | 101 | { |
@@ -108,76 +108,76 @@ discard block |
||
108 | 108 | break; |
109 | 109 | } |
110 | 110 | $rfc822 = $value; |
111 | - if (!(int)$size) $size = 22; // default size for display |
|
111 | + if (!(int)$size) $size = 22; // default size for display |
|
112 | 112 | if (is_numeric($value)) |
113 | 113 | { |
114 | - $email = $GLOBALS['egw']->accounts->id2name($value,'account_email'); |
|
115 | - $value = $GLOBALS['egw']->accounts->id2name($value,'account_fullname'); |
|
114 | + $email = $GLOBALS['egw']->accounts->id2name($value, 'account_email'); |
|
115 | + $value = $GLOBALS['egw']->accounts->id2name($value, 'account_fullname'); |
|
116 | 116 | $rfc822 = $value.' <'.$email.'>'; |
117 | 117 | } |
118 | - elseif (preg_match('/^(.*) ?<(.*)>/',$value,$matches)) |
|
118 | + elseif (preg_match('/^(.*) ?<(.*)>/', $value, $matches)) |
|
119 | 119 | { |
120 | 120 | $value = $matches[1]; |
121 | 121 | $email = $matches[2]; |
122 | 122 | } |
123 | - elseif (($at_pos = strpos($email=$value,'@')) !== false) |
|
123 | + elseif (($at_pos = strpos($email = $value, '@')) !== false) |
|
124 | 124 | { |
125 | - if (($amp_pos = strpos(substr($value,$at_pos),'&')) !== false) |
|
125 | + if (($amp_pos = strpos(substr($value, $at_pos), '&')) !== false) |
|
126 | 126 | { |
127 | 127 | //list($email,$addoptions) = explode('&',$value,2); |
128 | - $email = substr($value,0,$amp_pos+$at_pos); |
|
129 | - $addoptions = substr($value, $amp_pos+$at_pos+1); |
|
128 | + $email = substr($value, 0, $amp_pos + $at_pos); |
|
129 | + $addoptions = substr($value, $amp_pos + $at_pos + 1); |
|
130 | 130 | //error_log(__METHOD__.__LINE__.$email.' '.$addoptions); |
131 | 131 | $rfc822 = $value = $email; |
132 | 132 | } |
133 | 133 | else |
134 | 134 | { |
135 | - if (($q_pos = strpos(substr($value,$at_pos),'?')) !== false) |
|
135 | + if (($q_pos = strpos(substr($value, $at_pos), '?')) !== false) |
|
136 | 136 | { |
137 | - $email = substr($value,0,$q_pos+$at_pos); |
|
138 | - $addoptions = substr($value, $q_pos+$at_pos+1); |
|
137 | + $email = substr($value, 0, $q_pos + $at_pos); |
|
138 | + $addoptions = substr($value, $q_pos + $at_pos + 1); |
|
139 | 139 | $rfc822 = $value = $email; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | if (strlen($value) > $size) // shorten the name to size-2 plus '...' |
143 | 143 | { |
144 | - $value = substr($value,0,$size-2).'...'; |
|
144 | + $value = substr($value, 0, $size - 2).'...'; |
|
145 | 145 | } |
146 | 146 | } |
147 | - $link = $this->email2link($email,$rfc822).($addoptions ? '&'.$addoptions : ''); |
|
147 | + $link = $this->email2link($email, $rfc822).($addoptions ? '&'.$addoptions : ''); |
|
148 | 148 | |
149 | 149 | $cell['type'] = 'label'; |
150 | - $cell['size'] = ','.$link.',,,,'.($link[0]=='f'?'700x750':'').($value != $email ? ','.$email : ''); |
|
150 | + $cell['size'] = ','.$link.',,,,'.($link[0] == 'f' ? '700x750' : '').($value != $email ? ','.$email : ''); |
|
151 | 151 | break; |
152 | 152 | |
153 | 153 | case 'url': // options: [size[,max-size[,preg]]] |
154 | - list($size,$max_size,$preg) = explode(',',$cell['size'],3); // 3 = allow default to contain commas |
|
154 | + list($size, $max_size, $preg) = explode(',', $cell['size'], 3); // 3 = allow default to contain commas |
|
155 | 155 | if (!$readonly) |
156 | 156 | { |
157 | 157 | $cell['type'] = 'text'; |
158 | - $cell['size'] = "$size,$max_size,$preg"; // ,url"; not using html url type, as it requires a scheme |
|
158 | + $cell['size'] = "$size,$max_size,$preg"; // ,url"; not using html url type, as it requires a scheme |
|
159 | 159 | // todo: (optional) validation |
160 | 160 | break; |
161 | 161 | } |
162 | - if (!(int)$size) $size = 24; // default size for display |
|
162 | + if (!(int)$size) $size = 24; // default size for display |
|
163 | 163 | $cell['type'] = 'label'; |
164 | 164 | if ($value) |
165 | 165 | { |
166 | - $link = (strpos($value,'://') === false) ? 'http://'.$value : $value; |
|
166 | + $link = (strpos($value, '://') === false) ? 'http://'.$value : $value; |
|
167 | 167 | $cell['size'] = ','.$link.',,,_blank'; |
168 | 168 | } |
169 | - if (substr($value,0,7) == 'http://') |
|
169 | + if (substr($value, 0, 7) == 'http://') |
|
170 | 170 | { |
171 | - $value = substr($value,7); // cut off http:// in display |
|
171 | + $value = substr($value, 7); // cut off http:// in display |
|
172 | 172 | } |
173 | 173 | if (strlen($value) > $size) // shorten the name to size-2 plus '...' |
174 | 174 | { |
175 | - $value = substr($value,0,$size-2).'...'; |
|
175 | + $value = substr($value, 0, $size - 2).'...'; |
|
176 | 176 | } |
177 | 177 | break; |
178 | 178 | |
179 | 179 | case 'url-phone': // options: [size[,max-size[,preg]]] |
180 | - list($size,$max_size,$preg) = explode(',',$cell['size'],3); // 3 = allow default to contain commas |
|
180 | + list($size, $max_size, $preg) = explode(',', $cell['size'], 3); // 3 = allow default to contain commas |
|
181 | 181 | if (!$readonly) |
182 | 182 | { |
183 | 183 | $cell['type'] = 'text'; |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | if ($value) |
190 | 190 | { |
191 | 191 | $link = self::phone2link($value); |
192 | - $cell['size'] = ','.$link.($GLOBALS['egw_info']['server']['call_popup']=='none' ? '' : // 'none' = no target |
|
192 | + $cell['size'] = ','.$link.($GLOBALS['egw_info']['server']['call_popup'] == 'none' ? '' : // 'none' = no target |
|
193 | 193 | ',,,calling,'.$GLOBALS['egw_info']['server']['call_popup']); |
194 | 194 | } |
195 | 195 | break; |
196 | 196 | } |
197 | - return True; // extra Label Ok |
|
197 | + return True; // extra Label Ok |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -205,23 +205,23 @@ discard block |
||
205 | 205 | * @param string $rfc822 complete rfc822 addresse to use eg. for fmail |
206 | 206 | * @return array/string array with get-params or mailto:$email, or '' or no mail addresse |
207 | 207 | */ |
208 | - static function email2link($email,$rfc822='') |
|
208 | + static function email2link($email, $rfc822 = '') |
|
209 | 209 | { |
210 | - if (!$email || strpos($email,'@') === false) return ''; |
|
210 | + if (!$email || strpos($email, '@') === false) return ''; |
|
211 | 211 | |
212 | 212 | if (!$GLOBALS['egw_info']['user']['preferences']['addressbook']['force_mailto']) |
213 | 213 | { |
214 | - if($GLOBALS['egw_info']['user']['apps']['felamimail']) |
|
214 | + if ($GLOBALS['egw_info']['user']['apps']['felamimail']) |
|
215 | 215 | { |
216 | 216 | //return 'felamimail.uicompose.compose&preset[to]='.($rfc822 ? $rfc822 : $email); |
217 | 217 | return 'felamimail.uicompose.compose&send_to='.base64_encode($rfc822 ? $rfc822 : $email); |
218 | 218 | } |
219 | - if($GLOBALS['egw_info']['user']['apps']['email']) |
|
219 | + if ($GLOBALS['egw_info']['user']['apps']['email']) |
|
220 | 220 | { |
221 | 221 | return 'email.uicompose.compose&to='.$email; |
222 | 222 | } |
223 | 223 | } |
224 | - return 'mailto:' . $email; |
|
224 | + return 'mailto:'.$email; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | if (is_null($call_link)) |
239 | 239 | { |
240 | 240 | // for iPhone and Android: replace evtl. configured telephony integration link with tel: protocol |
241 | - if (strpos($_SERVER['HTTP_USER_AGENT'],'AppleWebKit') !== false && |
|
242 | - (strpos($_SERVER['HTTP_USER_AGENT'],'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'],'Android') !== false)) |
|
241 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false && |
|
242 | + (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false)) |
|
243 | 243 | { |
244 | 244 | $call_link = 'tel:%1'; |
245 | 245 | } |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | if (empty($number) || empty($call_link)) return false; |
252 | 252 | |
253 | 253 | static $userphone; |
254 | - if (is_null($userphone) && strpos($call_link,'%t') !== false) |
|
254 | + if (is_null($userphone) && strpos($call_link, '%t') !== false) |
|
255 | 255 | { |
256 | 256 | $user = $GLOBALS['egw']->contacts->read('account:'.$GLOBALS['egw_info']['user']['account_id']); |
257 | 257 | $userphone = is_array($user) ? ($user['tel_work'] ? $user['tel_work'] : $user['tel_home']) : false; |
258 | 258 | } |
259 | - $number = preg_replace('/[^0-9+]+/','',str_replace(array('♥','(0)'),'',$number)); // remove number formatting chars messing up the links |
|
259 | + $number = preg_replace('/[^0-9+]+/', '', str_replace(array('♥', '(0)'), '', $number)); // remove number formatting chars messing up the links |
|
260 | 260 | |
261 | - return str_replace(array('%1','%u','%t'),array(urlencode($number),$GLOBALS['egw_info']['user']['account_lid'],$userphone), |
|
261 | + return str_replace(array('%1', '%u', '%t'), array(urlencode($number), $GLOBALS['egw_info']['user']['account_lid'], $userphone), |
|
262 | 262 | $call_link); |
263 | 263 | } |
264 | 264 | } |
@@ -86,7 +86,11 @@ discard block |
||
86 | 86 | { |
87 | 87 | case 'url-email': // size: size,max-size,{2=no validation,1=rfc822 name part allowed, default only email},default if value empty |
88 | 88 | list($size,$max_size,$validation_type,$default) = explode(',',$cell['size'],4); // 4 = allow default to contain commas |
89 | - if (!$value) $value = $default; // use default from size/options if empty |
|
89 | + if (!$value) |
|
90 | + { |
|
91 | + $value = $default; |
|
92 | + } |
|
93 | + // use default from size/options if empty |
|
90 | 94 | $cell['no_lang'] = 1; |
91 | 95 | |
92 | 96 | if (!$readonly) |
@@ -97,10 +101,13 @@ discard block |
||
97 | 101 | { |
98 | 102 | $cell['size'] .= $cell['needed'] ? '/^(' : '/^(|'; // if not needed allow empty, as EMAIL_PREG does not |
99 | 103 | $cell['size'] .= self::EMAIL_PREG; |
100 | - if ($validation_type == 1) // allow rfc822 name part too: Ralf Becker <[email protected]> |
|
104 | + if ($validation_type == 1) |
|
105 | + { |
|
106 | + // allow rfc822 name part too: Ralf Becker <[email protected]> |
|
101 | 107 | { |
102 | 108 | $cell['size'] .= '|[^<]+ ?<'.self::EMAIL_PREG.'>'; |
103 | 109 | } |
110 | + } |
|
104 | 111 | //$cell['size'] .= ')$/iu,email';// ,email causes browser-side validation. browser is more restrictive, so we disable browserside validation |
105 | 112 | $cell['size'] .= ')$/iu'; |
106 | 113 | } |
@@ -108,7 +115,11 @@ discard block |
||
108 | 115 | break; |
109 | 116 | } |
110 | 117 | $rfc822 = $value; |
111 | - if (!(int)$size) $size = 22; // default size for display |
|
118 | + if (!(int)$size) |
|
119 | + { |
|
120 | + $size = 22; |
|
121 | + } |
|
122 | + // default size for display |
|
112 | 123 | if (is_numeric($value)) |
113 | 124 | { |
114 | 125 | $email = $GLOBALS['egw']->accounts->id2name($value,'account_email'); |
@@ -139,10 +150,13 @@ discard block |
||
139 | 150 | $rfc822 = $value = $email; |
140 | 151 | } |
141 | 152 | } |
142 | - if (strlen($value) > $size) // shorten the name to size-2 plus '...' |
|
153 | + if (strlen($value) > $size) |
|
154 | + { |
|
155 | + // shorten the name to size-2 plus '...' |
|
143 | 156 | { |
144 | 157 | $value = substr($value,0,$size-2).'...'; |
145 | 158 | } |
159 | + } |
|
146 | 160 | } |
147 | 161 | $link = $this->email2link($email,$rfc822).($addoptions ? '&'.$addoptions : ''); |
148 | 162 | |
@@ -159,7 +173,11 @@ discard block |
||
159 | 173 | // todo: (optional) validation |
160 | 174 | break; |
161 | 175 | } |
162 | - if (!(int)$size) $size = 24; // default size for display |
|
176 | + if (!(int)$size) |
|
177 | + { |
|
178 | + $size = 24; |
|
179 | + } |
|
180 | + // default size for display |
|
163 | 181 | $cell['type'] = 'label'; |
164 | 182 | if ($value) |
165 | 183 | { |
@@ -170,10 +188,13 @@ discard block |
||
170 | 188 | { |
171 | 189 | $value = substr($value,7); // cut off http:// in display |
172 | 190 | } |
173 | - if (strlen($value) > $size) // shorten the name to size-2 plus '...' |
|
191 | + if (strlen($value) > $size) |
|
192 | + { |
|
193 | + // shorten the name to size-2 plus '...' |
|
174 | 194 | { |
175 | 195 | $value = substr($value,0,$size-2).'...'; |
176 | 196 | } |
197 | + } |
|
177 | 198 | break; |
178 | 199 | |
179 | 200 | case 'url-phone': // options: [size[,max-size[,preg]]] |
@@ -207,7 +228,10 @@ discard block |
||
207 | 228 | */ |
208 | 229 | static function email2link($email,$rfc822='') |
209 | 230 | { |
210 | - if (!$email || strpos($email,'@') === false) return ''; |
|
231 | + if (!$email || strpos($email,'@') === false) |
|
232 | + { |
|
233 | + return ''; |
|
234 | + } |
|
211 | 235 | |
212 | 236 | if (!$GLOBALS['egw_info']['user']['preferences']['addressbook']['force_mailto']) |
213 | 237 | { |
@@ -248,7 +272,10 @@ discard block |
||
248 | 272 | $call_link = (string)$GLOBALS['egw_info']['server']['call_link']; |
249 | 273 | } |
250 | 274 | } |
251 | - if (empty($number) || empty($call_link)) return false; |
|
275 | + if (empty($number) || empty($call_link)) |
|
276 | + { |
|
277 | + return false; |
|
278 | + } |
|
252 | 279 | |
253 | 280 | static $userphone; |
254 | 281 | if (is_null($userphone) && strpos($call_link,'%t') !== false) |
@@ -368,7 +368,6 @@ discard block |
||
368 | 368 | * @param mixed &$value |
369 | 369 | * @param string $path vfs path of download |
370 | 370 | * @param string $name name of widget |
371 | - * @param string $label=null label, if not set basename($path) is used |
|
372 | 371 | * @return array |
373 | 372 | */ |
374 | 373 | static function file_widget(&$value,$path,$name,$label=null) |
@@ -404,7 +403,7 @@ discard block |
||
404 | 403 | * If you rename a file, you have to clear the cache ($clear_after=true)! |
405 | 404 | * |
406 | 405 | * @param string &$path on call path without extension, if existing on return full path incl. extension |
407 | - * @param boolean $clear_after=null clear file-cache after (true) or before (false), default dont clear |
|
406 | + * @param boolean $clear_after clear file-cache after (true) or before (false), default dont clear |
|
408 | 407 | * @return |
409 | 408 | */ |
410 | 409 | static function file_exists(&$path,$clear_after=null) |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | var $public_functions = array( |
45 | 45 | 'pre_process' => True, |
46 | - 'post_process' => true, // post_process is only used for vfs-upload (all other widgets set $cell['readlonly']!) |
|
46 | + 'post_process' => true, // post_process is only used for vfs-upload (all other widgets set $cell['readlonly']!) |
|
47 | 47 | ); |
48 | 48 | /** |
49 | 49 | * availible extensions and there names for the editor |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | * @var array |
52 | 52 | */ |
53 | 53 | var $human_name = array( |
54 | - 'vfs' => 'File name+link', // clickable filename, with evtl. clickable path-components |
|
55 | - 'vfs-name' => 'File name', // filename automatically urlencoded |
|
56 | - 'vfs-size' => 'File size', // human readable filesize |
|
57 | - 'vfs-mode' => 'File mode', // posix mode as string eg. drwxr-x--- |
|
58 | - 'vfs-mime' => 'File icon', // mime type icon or thumbnail |
|
59 | - 'vfs-uid' => 'File owner', // Owner of file, or 'root' if none |
|
60 | - 'vfs-gid' => 'File group', // Group of file, or 'root' if none |
|
61 | - 'vfs-upload' => 'VFS file', // displays either download and delete (x) links or a file upload |
|
54 | + 'vfs' => 'File name+link', // clickable filename, with evtl. clickable path-components |
|
55 | + 'vfs-name' => 'File name', // filename automatically urlencoded |
|
56 | + 'vfs-size' => 'File size', // human readable filesize |
|
57 | + 'vfs-mode' => 'File mode', // posix mode as string eg. drwxr-x--- |
|
58 | + 'vfs-mime' => 'File icon', // mime type icon or thumbnail |
|
59 | + 'vfs-uid' => 'File owner', // Owner of file, or 'root' if none |
|
60 | + 'vfs-gid' => 'File group', // Group of file, or 'root' if none |
|
61 | + 'vfs-upload' => 'VFS file', // displays either download and delete (x) links or a file upload |
|
62 | 62 | ); |
63 | 63 | |
64 | 64 | /** |
@@ -74,53 +74,53 @@ discard block |
||
74 | 74 | * @param object &$tmpl reference to the template we belong too |
75 | 75 | * @return boolean true if extra label is allowed, false otherwise |
76 | 76 | */ |
77 | - function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) |
|
77 | + function pre_process($form_name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl) |
|
78 | 78 | { |
79 | 79 | //echo "<p>".__METHOD__."($form_name,$value,".array2string($cell).",...)</p>\n"; |
80 | 80 | $type = $cell['type']; |
81 | - if (!in_array($type,array('vfs-name','vfs-upload'))) $cell['readonly'] = true; // to not call post-process |
|
81 | + if (!in_array($type, array('vfs-name', 'vfs-upload'))) $cell['readonly'] = true; // to not call post-process |
|
82 | 82 | |
83 | 83 | // check if we have a path and not the raw value, in that case we have to do a stat first |
84 | - if (in_array($type,array('vfs-size','vfs-mode','vfs-uid','vfs-gid')) && !is_numeric($value) || $type == 'vfs' && !$value) |
|
84 | + if (in_array($type, array('vfs-size', 'vfs-mode', 'vfs-uid', 'vfs-gid')) && !is_numeric($value) || $type == 'vfs' && !$value) |
|
85 | 85 | { |
86 | 86 | if (!$value || !($stat = egw_vfs::stat($value))) |
87 | 87 | { |
88 | - if ($value) $value = lang("File '%1' not found!",egw_vfs::decodePath($value)); |
|
88 | + if ($value) $value = lang("File '%1' not found!", egw_vfs::decodePath($value)); |
|
89 | 89 | $cell = boetemplate::empty_cell(); |
90 | - return true; // allow extra value; |
|
90 | + return true; // allow extra value; |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | $cell['type'] = 'label'; |
94 | 94 | |
95 | - switch($type) |
|
95 | + switch ($type) |
|
96 | 96 | { |
97 | 97 | case 'vfs-upload': // option: required mimetype or regular expression for mimetype to match, eg. '/^text\//i' for all text files |
98 | - if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/',$form_name,$matches)) // if no value via content array, use widget name |
|
98 | + if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/', $form_name, $matches)) // if no value via content array, use widget name |
|
99 | 99 | { |
100 | 100 | $value = $matches[1]; |
101 | 101 | } |
102 | 102 | $extension_data = array('value' => $value, 'mimetype' => $cell['size'], 'type' => $type); |
103 | 103 | if ($value[0] != '/') |
104 | 104 | { |
105 | - list($app,$id,$relpath) = explode(':',$value,3); |
|
105 | + list($app, $id, $relpath) = explode(':', $value, 3); |
|
106 | 106 | if (empty($id)) |
107 | 107 | { |
108 | - static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
|
108 | + static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
|
109 | 109 | if (!isset($tmppath[$app])) $tmppath[$app] = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.'.$app.'_'.md5(time().session_id()); |
110 | 110 | $value = $tmppath[$app]; |
111 | - unset($cell['onchange']); // no onchange, if we have to use a temporary dir |
|
111 | + unset($cell['onchange']); // no onchange, if we have to use a temporary dir |
|
112 | 112 | } |
113 | 113 | else |
114 | 114 | { |
115 | - $value = egw_link::vfs_path($app,$id,'',true); |
|
115 | + $value = egw_link::vfs_path($app, $id, '', true); |
|
116 | 116 | } |
117 | 117 | if (!empty($relpath)) $value .= '/'.$relpath; |
118 | 118 | } |
119 | 119 | $path = $extension_data['path'] = $value; |
120 | - if (substr($path,-1) != '/' && self::file_exists($path) && !egw_vfs::is_dir($path)) // display download link and delete icon |
|
120 | + if (substr($path, -1) != '/' && self::file_exists($path) && !egw_vfs::is_dir($path)) // display download link and delete icon |
|
121 | 121 | { |
122 | 122 | $extension_data['path'] = $path; |
123 | - $cell = $this->file_widget($value,$path,$cell['name'],$cell['label']); |
|
123 | + $cell = $this->file_widget($value, $path, $cell['name'], $cell['label']); |
|
124 | 124 | } |
125 | 125 | else // file does NOT exists --> display file upload |
126 | 126 | { |
@@ -136,26 +136,26 @@ discard block |
||
136 | 136 | { |
137 | 137 | $type = $cell['size']; |
138 | 138 | } |
139 | - $cell['help'] = lang('Allowed file type: %1',$type); |
|
139 | + $cell['help'] = lang('Allowed file type: %1', $type); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | // check if directory (trailing slash) is given --> upload of multiple files |
143 | - if (substr($path,-1) == '/' && egw_vfs::file_exists($path) && ($files = egw_vfs::scandir($path))) |
|
143 | + if (substr($path, -1) == '/' && egw_vfs::file_exists($path) && ($files = egw_vfs::scandir($path))) |
|
144 | 144 | { |
145 | 145 | //echo $path; _debug_array($files); |
146 | 146 | $upload = $cell; |
147 | - $cell = boetemplate::empty_cell('vbox','',array('size' => ',,0,0')); |
|
147 | + $cell = boetemplate::empty_cell('vbox', '', array('size' => ',,0,0')); |
|
148 | 148 | $extension_data['files'] = $files; |
149 | 149 | $value = array(); |
150 | - foreach($files as $file) |
|
150 | + foreach ($files as $file) |
|
151 | 151 | { |
152 | 152 | $file = $path.$file; |
153 | 153 | $basename = basename($file); |
154 | 154 | unset($widget); |
155 | - $widget = $this->file_widget($value[$basename],$file,$upload['name']."[$basename]"); |
|
156 | - boetemplate::add_child($cell,$widget); |
|
155 | + $widget = $this->file_widget($value[$basename], $file, $upload['name']."[$basename]"); |
|
156 | + boetemplate::add_child($cell, $widget); |
|
157 | 157 | } |
158 | - boetemplate::add_child($cell,$upload); |
|
158 | + boetemplate::add_child($cell, $upload); |
|
159 | 159 | } |
160 | 160 | break; |
161 | 161 | |
@@ -167,23 +167,23 @@ discard block |
||
167 | 167 | |
168 | 168 | case 'vfs-mode': |
169 | 169 | $value = egw_vfs::int2mode(is_numeric($value) ? $value : $stat['mode']); |
170 | - list($span,$class) = explode(',',$cell['span'],2); |
|
171 | - $class .= ($class ? ' ' : '') . 'vfsMode'; |
|
170 | + list($span, $class) = explode(',', $cell['span'], 2); |
|
171 | + $class .= ($class ? ' ' : '').'vfsMode'; |
|
172 | 172 | $cell['span'] = $span.','.$class; |
173 | 173 | $cell['no_lang'] = true; |
174 | 174 | break; |
175 | 175 | |
176 | 176 | case 'vfs-uid': |
177 | 177 | case 'vfs-gid': |
178 | - $uid = !is_numeric($value) ? $stat[$type=='vfs-uid'?'uid':'gid'] : $value; |
|
179 | - $value = !$uid ? 'root' : $GLOBALS['egw']->accounts->id2name($type=='vfs-uid'?$uid:-$uid); // our internal gid's are negative! |
|
178 | + $uid = !is_numeric($value) ? $stat[$type == 'vfs-uid' ? 'uid' : 'gid'] : $value; |
|
179 | + $value = !$uid ? 'root' : $GLOBALS['egw']->accounts->id2name($type == 'vfs-uid' ? $uid : -$uid); // our internal gid's are negative! |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case 'vfs': |
183 | 183 | if (is_array($value)) |
184 | 184 | { |
185 | 185 | $name = $value['name']; |
186 | - $path = substr($value['path'],0,-strlen($name)-1); |
|
186 | + $path = substr($value['path'], 0, -strlen($name) - 1); |
|
187 | 187 | $mime = $value['mime']; |
188 | 188 | } |
189 | 189 | else |
@@ -195,27 +195,27 @@ discard block |
||
195 | 195 | } |
196 | 196 | if (($cell_name = $cell['name']) == '$row') |
197 | 197 | { |
198 | - $arr = explode('][',substr($form_name,0,-1)); |
|
198 | + $arr = explode('][', substr($form_name, 0, -1)); |
|
199 | 199 | $cell_name = array_pop($arr); |
200 | 200 | } |
201 | 201 | $cell['name'] = ''; |
202 | 202 | $cell['type'] = 'hbox'; |
203 | 203 | $cell['size'] = '0,,0,0'; |
204 | - foreach($name != '/' ? explode('/',$name) : array('') as $n => $component) |
|
204 | + foreach ($name != '/' ? explode('/', $name) : array('') as $n => $component) |
|
205 | 205 | { |
206 | 206 | if ($n > (int)($path === '/')) |
207 | 207 | { |
208 | - $sep = soetemplate::empty_cell('label','',array('label' => '/')); |
|
209 | - soetemplate::add_child($cell,$sep); |
|
208 | + $sep = soetemplate::empty_cell('label', '', array('label' => '/')); |
|
209 | + soetemplate::add_child($cell, $sep); |
|
210 | 210 | unset($sep); |
211 | 211 | } |
212 | 212 | $value['c'.$n] = $component !== '' ? egw_vfs::decodePath($component) : '/'; |
213 | 213 | $path .= ($path != '/' ? '/' : '').$component; |
214 | 214 | // replace id's in /apps again with human readable titles |
215 | - $path_parts = explode('/',$path); |
|
215 | + $path_parts = explode('/', $path); |
|
216 | 216 | if ($path_parts[1] == 'apps') |
217 | 217 | { |
218 | - switch(count($path_parts)) |
|
218 | + switch (count($path_parts)) |
|
219 | 219 | { |
220 | 220 | case 2: |
221 | 221 | $value['c'.$n] = lang('Applications'); |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | $value['c'.$n] = lang($path_parts[2]); |
225 | 225 | break; |
226 | 226 | case 4: |
227 | - if (is_numeric($value['c'.$n])) $value['c'.$n] .= egw_link::title($path_parts[2],$path_parts[3]); |
|
227 | + if (is_numeric($value['c'.$n])) $value['c'.$n] .= egw_link::title($path_parts[2], $path_parts[3]); |
|
228 | 228 | break; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | $popup = null; |
232 | 232 | if (egw_vfs::is_readable($path)) // show link only if we have access to the file or dir |
233 | 233 | { |
234 | - if ($n < count($comps)-1 || $mime == egw_vfs::DIR_MIME_TYPE || egw_vfs::is_dir($path)) |
|
234 | + if ($n < count($comps) - 1 || $mime == egw_vfs::DIR_MIME_TYPE || egw_vfs::is_dir($path)) |
|
235 | 235 | { |
236 | 236 | $value['l'.$n] = egw_link::mime_open($path, egw_vfs::DIR_MIME_TYPE, $popup); |
237 | 237 | $target = ''; |
@@ -245,36 +245,36 @@ discard block |
||
245 | 245 | |
246 | 246 | if ($cell['onclick']) |
247 | 247 | { |
248 | - $comp = boetemplate::empty_cell('button',$cell_name.'[c'.$n.']',array( |
|
248 | + $comp = boetemplate::empty_cell('button', $cell_name.'[c'.$n.']', array( |
|
249 | 249 | 'size' => '1', |
250 | 250 | 'no_lang' => true, |
251 | 251 | 'span' => ',vfsFilename', |
252 | 252 | 'label' => $value['c'.$n], |
253 | - 'onclick' => str_replace('$path',"'".addslashes($path)."'",$cell['onclick']), |
|
253 | + 'onclick' => str_replace('$path', "'".addslashes($path)."'", $cell['onclick']), |
|
254 | 254 | )); |
255 | 255 | } |
256 | 256 | else |
257 | 257 | { |
258 | - $comp = boetemplate::empty_cell('label',$cell_name.'[c'.$n.']',array( |
|
258 | + $comp = boetemplate::empty_cell('label', $cell_name.'[c'.$n.']', array( |
|
259 | 259 | 'size' => ',@'.$cell_name.'[l'.$n.'],,,'.$target.','.$popup, |
260 | 260 | 'no_lang' => true, |
261 | 261 | 'span' => ',vfsFilename', |
262 | 262 | )); |
263 | 263 | } |
264 | - boetemplate::add_child($cell,$comp); |
|
264 | + boetemplate::add_child($cell, $comp); |
|
265 | 265 | unset($comp); |
266 | 266 | } |
267 | - unset($cell['onclick']); // otherwise it's handled by the grid too |
|
267 | + unset($cell['onclick']); // otherwise it's handled by the grid too |
|
268 | 268 | //_debug_array($comps); _debug_array($cell); _debug_array($value); |
269 | 269 | break; |
270 | 270 | |
271 | 271 | case 'vfs-name': // size: [length][,maxLength[,allowPath]] |
272 | 272 | $cell['type'] = 'text'; |
273 | - list($length,$maxLength,$allowPath) = $options = explode(',',$cell['size']); |
|
274 | - $preg = $allowPath ? '' : '/[^\\/]/'; // no slash '/' allowed, if not allowPath set |
|
273 | + list($length, $maxLength, $allowPath) = $options = explode(',', $cell['size']); |
|
274 | + $preg = $allowPath ? '' : '/[^\\/]/'; // no slash '/' allowed, if not allowPath set |
|
275 | 275 | $cell['size'] = "$length,$maxLength,$preg"; |
276 | 276 | $value = egw_vfs::decodePath($value); |
277 | - $extension_data = array('type' => $type,'allowPath' => $allowPath); |
|
277 | + $extension_data = array('type' => $type, 'allowPath' => $allowPath); |
|
278 | 278 | break; |
279 | 279 | |
280 | 280 | case 'vfs-mime': // size: [thsize] (thumbnail size) |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | } |
293 | 293 | if (!is_array($value)) |
294 | 294 | { |
295 | - if ($value[0] == '/' || count(explode('/',$value)) != 2) |
|
295 | + if ($value[0] == '/' || count(explode('/', $value)) != 2) |
|
296 | 296 | { |
297 | - $mime = egw_vfs::mime_content_type($path=$value); |
|
297 | + $mime = egw_vfs::mime_content_type($path = $value); |
|
298 | 298 | } |
299 | 299 | else |
300 | 300 | { |
@@ -310,24 +310,24 @@ discard block |
||
310 | 310 | $cell['type'] = 'image'; |
311 | 311 | $cell['label'] = mime_magic::mime2label($mime); |
312 | 312 | |
313 | - list($mime_main,$mime_sub) = explode('/',$mime); |
|
313 | + list($mime_main, $mime_sub) = explode('/', $mime); |
|
314 | 314 | if ($mime_main == 'egw' || isset($GLOBALS['egw_info']['apps'][$mime_main])) |
315 | 315 | { |
316 | - $value = $mime_main == 'egw' ? $mime_sub.'/navbar' : $mime; // egw-applications for link-widget |
|
316 | + $value = $mime_main == 'egw' ? $mime_sub.'/navbar' : $mime; // egw-applications for link-widget |
|
317 | 317 | $cell['label'] = lang($mime_main == 'egw' ? $mime_sub : $mime_main); |
318 | - list($span,$class) = explode(',',$cell['span'],2); |
|
319 | - $class .= ($class ? ' ' : '') . 'vfsMimeIcon'; |
|
318 | + list($span, $class) = explode(',', $cell['span'], 2); |
|
319 | + $class .= ($class ? ' ' : '').'vfsMimeIcon'; |
|
320 | 320 | $cell['span'] = $span.','.$class; |
321 | 321 | } |
322 | - elseif($path && $mime_main == 'image' && in_array($mime_sub,array('png','jpeg','jpg','gif','bmp')) && |
|
322 | + elseif ($path && $mime_main == 'image' && in_array($mime_sub, array('png', 'jpeg', 'jpg', 'gif', 'bmp')) && |
|
323 | 323 | (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' && |
324 | 324 | (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' && |
325 | 325 | // check the size of the image, as too big images get no icon, but a PHP Fatal error: Allowed memory size exhausted |
326 | 326 | (!is_array($value) && ($stat = egw_vfs::stat($path)) ? $stat['size'] : $value['size']) < 1600000) |
327 | 327 | { |
328 | - if (substr($path,0,6) == '/apps/') |
|
328 | + if (substr($path, 0, 6) == '/apps/') |
|
329 | 329 | { |
330 | - $path = egw_vfs::parse_url(egw_vfs::resolve_url_symlinks($path),PHP_URL_PATH); |
|
330 | + $path = egw_vfs::parse_url(egw_vfs::resolve_url_symlinks($path), PHP_URL_PATH); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | //Assemble the thumbnail parameters |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | $value = egw_vfs::mime_icon($mime); |
346 | 346 | } |
347 | 347 | // mark symlinks (check if method exists, to allow etemplate to run on 1.6 API!) |
348 | - if (method_exists('egw_vfs','is_link') && egw_vfs::is_link($path)) |
|
348 | + if (method_exists('egw_vfs', 'is_link') && egw_vfs::is_link($path)) |
|
349 | 349 | { |
350 | 350 | $broken = !egw_vfs::stat($path); |
351 | - list($span,$class) = explode(',',$cell['span'],2); |
|
352 | - $class .= ($class ? ' ' : '') . ($broken ? 'vfsIsBrokenLink' : 'vfsIsLink'); |
|
351 | + list($span, $class) = explode(',', $cell['span'], 2); |
|
352 | + $class .= ($class ? ' ' : '').($broken ? 'vfsIsBrokenLink' : 'vfsIsLink'); |
|
353 | 353 | $cell['span'] = $span.','.$class; |
354 | 354 | $cell['label'] = ($broken ? lang('Broken link') : lang('Link')).': '.egw_vfs::decodePath(egw_vfs::readlink($path)). |
355 | 355 | (!$broken ? ' ('.$cell['label'].')' : ''); |
@@ -371,25 +371,25 @@ discard block |
||
371 | 371 | * @param string $label=null label, if not set basename($path) is used |
372 | 372 | * @return array |
373 | 373 | */ |
374 | - static function file_widget(&$value,$path,$name,$label=null) |
|
374 | + static function file_widget(&$value, $path, $name, $label = null) |
|
375 | 375 | { |
376 | - $value = empty($label) ? egw_vfs::decodePath(egw_vfs::basename($path)) : lang($label); // display (translated) Label or filename (if label empty) |
|
376 | + $value = empty($label) ? egw_vfs::decodePath(egw_vfs::basename($path)) : lang($label); // display (translated) Label or filename (if label empty) |
|
377 | 377 | |
378 | - $vfs_link = boetemplate::empty_cell('label',$name,array( |
|
378 | + $vfs_link = boetemplate::empty_cell('label', $name, array( |
|
379 | 379 | 'size' => ','.egw_vfs::download_url($path).',,,_blank,,'.$path, |
380 | 380 | )); |
381 | 381 | // if dir is writable, add delete link |
382 | 382 | if (egw_vfs::is_writable(egw_vfs::dirname($path))) |
383 | 383 | { |
384 | - $cell = boetemplate::empty_cell('hbox','',array('size' => ',,0,0')); |
|
385 | - boetemplate::add_child($cell,$vfs_link); |
|
386 | - $delete_icon = boetemplate::empty_cell('button',$path,array( |
|
384 | + $cell = boetemplate::empty_cell('hbox', '', array('size' => ',,0,0')); |
|
385 | + boetemplate::add_child($cell, $vfs_link); |
|
386 | + $delete_icon = boetemplate::empty_cell('button', $path, array( |
|
387 | 387 | 'label' => 'delete', |
388 | - 'size' => 'delete', // icon |
|
388 | + 'size' => 'delete', // icon |
|
389 | 389 | 'onclick' => "return confirm('Delete this file');", |
390 | 390 | 'span' => ',leftPad5', |
391 | 391 | )); |
392 | - boetemplate::add_child($cell,$delete_icon); |
|
392 | + boetemplate::add_child($cell, $delete_icon); |
|
393 | 393 | } |
394 | 394 | else |
395 | 395 | { |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | * @param boolean $clear_after=null clear file-cache after (true) or before (false), default dont clear |
408 | 408 | * @return |
409 | 409 | */ |
410 | - static function file_exists(&$path,$clear_after=null) |
|
410 | + static function file_exists(&$path, $clear_after = null) |
|
411 | 411 | { |
412 | - static $files = array(); // static var, to scan each directory only once |
|
412 | + static $files = array(); // static var, to scan each directory only once |
|
413 | 413 | $dir = egw_vfs::dirname($path); |
414 | 414 | if ($clear_after === false) unset($files[$dir]); |
415 | 415 | if (!isset($files[$dir])) $files[$dir] = egw_vfs::file_exists($dir) ? egw_vfs::scandir($dir) : array(); |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | $basename = egw_vfs::basename($path); |
418 | 418 | $basename_len = strlen($basename); |
419 | 419 | $found = false; |
420 | - foreach($files[$dir] as $file) |
|
420 | + foreach ($files[$dir] as $file) |
|
421 | 421 | { |
422 | - if (substr($file,0,$basename_len) == $basename) |
|
422 | + if (substr($file, 0, $basename_len) == $basename) |
|
423 | 423 | { |
424 | 424 | $path = $dir.'/'.$file; |
425 | 425 | $found = true; |
@@ -447,21 +447,21 @@ discard block |
||
447 | 447 | * @param mixed &value_in the posted values (already striped of magic-quotes) |
448 | 448 | * @return boolean true if $value has valid content, on false no content will be returned! |
449 | 449 | */ |
450 | - function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in) |
|
450 | + function post_process($name, &$value, &$extension_data, &$loop, &$tmpl, $value_in) |
|
451 | 451 | { |
452 | 452 | //error_log(__METHOD__."('$name',".array2string($value).','.array2string($extension_data).",$loop,,".array2string($value_in).')'); |
453 | 453 | //echo '<p>'.__METHOD__."('$name',".array2string($value).','.array2string($extension_data).",$loop,,".array2string($value_in).")</p>\n"; |
454 | 454 | |
455 | 455 | if (!$extension_data) return false; |
456 | 456 | |
457 | - switch($extension_data['type']) |
|
457 | + switch ($extension_data['type']) |
|
458 | 458 | { |
459 | 459 | case 'vfs-name': |
460 | 460 | $value = $extension_data['allowPath'] ? egw_vfs::encodePath($value_in) : egw_vfs::encodePathComponent($value_in); |
461 | 461 | return true; |
462 | 462 | |
463 | 463 | case 'vfs-upload': |
464 | - break; // handeled below |
|
464 | + break; // handeled below |
|
465 | 465 | |
466 | 466 | default: |
467 | 467 | return false; |
@@ -469,18 +469,18 @@ discard block |
||
469 | 469 | // from here on vfs-upload only! |
470 | 470 | |
471 | 471 | // check if delete icon clicked |
472 | - if ($_POST['submit_button'] == ($fname = str_replace($extension_data['value'],$extension_data['path'],$name)) || |
|
473 | - substr($extension_data['path'],-1) == '/' && substr($_POST['submit_button'],0,strlen($fname)-1) == substr($fname,0,-1)) |
|
472 | + if ($_POST['submit_button'] == ($fname = str_replace($extension_data['value'], $extension_data['path'], $name)) || |
|
473 | + substr($extension_data['path'], -1) == '/' && substr($_POST['submit_button'], 0, strlen($fname) - 1) == substr($fname, 0, -1)) |
|
474 | 474 | { |
475 | - if (substr($extension_data['path'],-1) == '/') // multiple files? |
|
475 | + if (substr($extension_data['path'], -1) == '/') // multiple files? |
|
476 | 476 | { |
477 | - foreach($extension_data['files'] as $file) // check of each single file, to not allow deleting of arbitrary files |
|
477 | + foreach ($extension_data['files'] as $file) // check of each single file, to not allow deleting of arbitrary files |
|
478 | 478 | { |
479 | - if ($_POST['submit_button'] == substr($fname,0,-1).$file.']') |
|
479 | + if ($_POST['submit_button'] == substr($fname, 0, -1).$file.']') |
|
480 | 480 | { |
481 | 481 | if (!egw_vfs::unlink($extension_data['path'].$file)) |
482 | 482 | { |
483 | - etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'].$file))); |
|
483 | + etemplate::set_validation_error($name, lang('Error deleting %1!', egw_vfs::decodePath($extension_data['path'].$file))); |
|
484 | 484 | } |
485 | 485 | break; |
486 | 486 | } |
@@ -488,24 +488,24 @@ discard block |
||
488 | 488 | } |
489 | 489 | elseif (!egw_vfs::unlink($extension_data['path'])) |
490 | 490 | { |
491 | - etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path']))); |
|
491 | + etemplate::set_validation_error($name, lang('Error deleting %1!', egw_vfs::decodePath($extension_data['path']))); |
|
492 | 492 | } |
493 | 493 | $loop = true; |
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
497 | 497 | // handle file upload |
498 | - $name = preg_replace('/^exec\[([^]]+)\](.*)$/','\\1\\2',$name); // remove exec prefix |
|
498 | + $name = preg_replace('/^exec\[([^]]+)\](.*)$/', '\\1\\2', $name); // remove exec prefix |
|
499 | 499 | |
500 | - if (!is_array($_FILES['exec']) || !($filename = boetemplate::get_array($_FILES['exec']['name'],$name))) |
|
500 | + if (!is_array($_FILES['exec']) || !($filename = boetemplate::get_array($_FILES['exec']['name'], $name))) |
|
501 | 501 | { |
502 | - return false; // no file attached |
|
502 | + return false; // no file attached |
|
503 | 503 | } |
504 | - $tmp_name = boetemplate::get_array($_FILES['exec']['tmp_name'],$name); |
|
505 | - $error = boetemplate::get_array($_FILES['exec']['error'],$name); |
|
504 | + $tmp_name = boetemplate::get_array($_FILES['exec']['tmp_name'], $name); |
|
505 | + $error = boetemplate::get_array($_FILES['exec']['error'], $name); |
|
506 | 506 | if ($error) |
507 | 507 | { |
508 | - etemplate::set_validation_error($name,lang('Error uploading file!')."\n". |
|
508 | + etemplate::set_validation_error($name, lang('Error uploading file!')."\n". |
|
509 | 509 | etemplate::max_upload_size_message()); |
510 | 510 | $loop = true; |
511 | 511 | return false; |
@@ -517,19 +517,19 @@ discard block |
||
517 | 517 | // check if type matches required mime-type, if specified |
518 | 518 | if (!empty($extension_data['mimetype'])) |
519 | 519 | { |
520 | - $type = boetemplate::get_array($_FILES['exec']['type'],$name); |
|
520 | + $type = boetemplate::get_array($_FILES['exec']['type'], $name); |
|
521 | 521 | $is_preg = $extension_data['mimetype'][0] == '/'; |
522 | - if (!$is_preg && strcasecmp($extension_data['mimetype'],$type) || $is_preg && !preg_match($extension_data['mimetype'],$type)) |
|
522 | + if (!$is_preg && strcasecmp($extension_data['mimetype'], $type) || $is_preg && !preg_match($extension_data['mimetype'], $type)) |
|
523 | 523 | { |
524 | - etemplate::set_validation_error($name,lang('File is of wrong type (%1 != %2)!',$type,$extension_data['mimetype'])); |
|
524 | + etemplate::set_validation_error($name, lang('File is of wrong type (%1 != %2)!', $type, $extension_data['mimetype'])); |
|
525 | 525 | return false; |
526 | 526 | } |
527 | 527 | } |
528 | 528 | $path = $extension_data['path']; |
529 | - if (substr($path,-1) != '/') |
|
529 | + if (substr($path, -1) != '/') |
|
530 | 530 | { |
531 | 531 | // add extension to path |
532 | - $parts = explode('.',$filename); |
|
532 | + $parts = explode('.', $filename); |
|
533 | 533 | if (($extension = array_pop($parts)) && mime_magic::ext2mime($extension)) // really an extension --> add it to path |
534 | 534 | { |
535 | 535 | $path .= '.'.$extension; |
@@ -539,17 +539,17 @@ discard block |
||
539 | 539 | { |
540 | 540 | $path .= egw_vfs::encodePathComponent($filename); |
541 | 541 | } |
542 | - if (!egw_vfs::file_exists($dir = egw_vfs::dirname($path)) && !egw_vfs::mkdir($dir,null,STREAM_MKDIR_RECURSIVE)) |
|
542 | + if (!egw_vfs::file_exists($dir = egw_vfs::dirname($path)) && !egw_vfs::mkdir($dir, null, STREAM_MKDIR_RECURSIVE)) |
|
543 | 543 | { |
544 | - etemplate::set_validation_error($name,lang('Error create parent directory %1!',egw_vfs::decodePath($dir))); |
|
544 | + etemplate::set_validation_error($name, lang('Error create parent directory %1!', egw_vfs::decodePath($dir))); |
|
545 | 545 | return false; |
546 | 546 | } |
547 | - if (!copy($tmp_name,egw_vfs::PREFIX.$path)) |
|
547 | + if (!copy($tmp_name, egw_vfs::PREFIX.$path)) |
|
548 | 548 | { |
549 | - etemplate::set_validation_error($name,lang('Error copying uploaded file to vfs!')); |
|
549 | + etemplate::set_validation_error($name, lang('Error copying uploaded file to vfs!')); |
|
550 | 550 | return false; |
551 | 551 | } |
552 | - $value = $path; // return path of file, important if only a temporary location is used |
|
552 | + $value = $path; // return path of file, important if only a temporary location is used |
|
553 | 553 | |
554 | 554 | return true; |
555 | 555 | } |
@@ -78,14 +78,21 @@ discard block |
||
78 | 78 | { |
79 | 79 | //echo "<p>".__METHOD__."($form_name,$value,".array2string($cell).",...)</p>\n"; |
80 | 80 | $type = $cell['type']; |
81 | - if (!in_array($type,array('vfs-name','vfs-upload'))) $cell['readonly'] = true; // to not call post-process |
|
81 | + if (!in_array($type,array('vfs-name','vfs-upload'))) |
|
82 | + { |
|
83 | + $cell['readonly'] = true; |
|
84 | + } |
|
85 | + // to not call post-process |
|
82 | 86 | |
83 | 87 | // check if we have a path and not the raw value, in that case we have to do a stat first |
84 | 88 | if (in_array($type,array('vfs-size','vfs-mode','vfs-uid','vfs-gid')) && !is_numeric($value) || $type == 'vfs' && !$value) |
85 | 89 | { |
86 | 90 | if (!$value || !($stat = egw_vfs::stat($value))) |
87 | 91 | { |
88 | - if ($value) $value = lang("File '%1' not found!",egw_vfs::decodePath($value)); |
|
92 | + if ($value) |
|
93 | + { |
|
94 | + $value = lang("File '%1' not found!",egw_vfs::decodePath($value)); |
|
95 | + } |
|
89 | 96 | $cell = boetemplate::empty_cell(); |
90 | 97 | return true; // allow extra value; |
91 | 98 | } |
@@ -95,10 +102,13 @@ discard block |
||
95 | 102 | switch($type) |
96 | 103 | { |
97 | 104 | case 'vfs-upload': // option: required mimetype or regular expression for mimetype to match, eg. '/^text\//i' for all text files |
98 | - if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/',$form_name,$matches)) // if no value via content array, use widget name |
|
105 | + if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/',$form_name,$matches)) |
|
106 | + { |
|
107 | + // if no value via content array, use widget name |
|
99 | 108 | { |
100 | 109 | $value = $matches[1]; |
101 | 110 | } |
111 | + } |
|
102 | 112 | $extension_data = array('value' => $value, 'mimetype' => $cell['size'], 'type' => $type); |
103 | 113 | if ($value[0] != '/') |
104 | 114 | { |
@@ -106,7 +116,10 @@ discard block |
||
106 | 116 | if (empty($id)) |
107 | 117 | { |
108 | 118 | static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
109 | - if (!isset($tmppath[$app])) $tmppath[$app] = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.'.$app.'_'.md5(time().session_id()); |
|
119 | + if (!isset($tmppath[$app])) |
|
120 | + { |
|
121 | + $tmppath[$app] = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.'.$app.'_'.md5(time().session_id()); |
|
122 | + } |
|
110 | 123 | $value = $tmppath[$app]; |
111 | 124 | unset($cell['onchange']); // no onchange, if we have to use a temporary dir |
112 | 125 | } |
@@ -114,12 +127,18 @@ discard block |
||
114 | 127 | { |
115 | 128 | $value = egw_link::vfs_path($app,$id,'',true); |
116 | 129 | } |
117 | - if (!empty($relpath)) $value .= '/'.$relpath; |
|
130 | + if (!empty($relpath)) |
|
131 | + { |
|
132 | + $value .= '/'.$relpath; |
|
133 | + } |
|
118 | 134 | } |
119 | 135 | $path = $extension_data['path'] = $value; |
120 | - if (substr($path,-1) != '/' && self::file_exists($path) && !egw_vfs::is_dir($path)) // display download link and delete icon |
|
136 | + if (substr($path,-1) != '/' && self::file_exists($path) && !egw_vfs::is_dir($path)) |
|
137 | + { |
|
138 | + // display download link and delete icon |
|
121 | 139 | { |
122 | 140 | $extension_data['path'] = $path; |
141 | + } |
|
123 | 142 | $cell = $this->file_widget($value,$path,$cell['name'],$cell['label']); |
124 | 143 | } |
125 | 144 | else // file does NOT exists --> display file upload |
@@ -161,7 +180,10 @@ discard block |
||
161 | 180 | |
162 | 181 | case 'vfs-size': // option: add size in bytes in brackets |
163 | 182 | $value = egw_vfs::hsize($size = is_numeric($value) ? $value : $stat['size']); |
164 | - if ($cell['size']) $value .= ' ('.$size.')'; |
|
183 | + if ($cell['size']) |
|
184 | + { |
|
185 | + $value .= ' ('.$size.')'; |
|
186 | + } |
|
165 | 187 | $cell['type'] = 'label'; |
166 | 188 | break; |
167 | 189 | |
@@ -224,16 +246,22 @@ discard block |
||
224 | 246 | $value['c'.$n] = lang($path_parts[2]); |
225 | 247 | break; |
226 | 248 | case 4: |
227 | - if (is_numeric($value['c'.$n])) $value['c'.$n] .= egw_link::title($path_parts[2],$path_parts[3]); |
|
249 | + if (is_numeric($value['c'.$n])) |
|
250 | + { |
|
251 | + $value['c'.$n] .= egw_link::title($path_parts[2],$path_parts[3]); |
|
252 | + } |
|
228 | 253 | break; |
229 | 254 | } |
230 | 255 | } |
231 | 256 | $popup = null; |
232 | - if (egw_vfs::is_readable($path)) // show link only if we have access to the file or dir |
|
257 | + if (egw_vfs::is_readable($path)) |
|
258 | + { |
|
259 | + // show link only if we have access to the file or dir |
|
233 | 260 | { |
234 | 261 | if ($n < count($comps)-1 || $mime == egw_vfs::DIR_MIME_TYPE || egw_vfs::is_dir($path)) |
235 | 262 | { |
236 | 263 | $value['l'.$n] = egw_link::mime_open($path, egw_vfs::DIR_MIME_TYPE, $popup); |
264 | + } |
|
237 | 265 | $target = ''; |
238 | 266 | } |
239 | 267 | else |
@@ -411,8 +439,14 @@ discard block |
||
411 | 439 | { |
412 | 440 | static $files = array(); // static var, to scan each directory only once |
413 | 441 | $dir = egw_vfs::dirname($path); |
414 | - if ($clear_after === false) unset($files[$dir]); |
|
415 | - if (!isset($files[$dir])) $files[$dir] = egw_vfs::file_exists($dir) ? egw_vfs::scandir($dir) : array(); |
|
442 | + if ($clear_after === false) |
|
443 | + { |
|
444 | + unset($files[$dir]); |
|
445 | + } |
|
446 | + if (!isset($files[$dir])) |
|
447 | + { |
|
448 | + $files[$dir] = egw_vfs::file_exists($dir) ? egw_vfs::scandir($dir) : array(); |
|
449 | + } |
|
416 | 450 | |
417 | 451 | $basename = egw_vfs::basename($path); |
418 | 452 | $basename_len = strlen($basename); |
@@ -425,7 +459,10 @@ discard block |
||
425 | 459 | $found = true; |
426 | 460 | } |
427 | 461 | } |
428 | - if ($clear_after === true) unset($files[$dir]); |
|
462 | + if ($clear_after === true) |
|
463 | + { |
|
464 | + unset($files[$dir]); |
|
465 | + } |
|
429 | 466 | //echo "<p>".__METHOD__."($path) returning ".array2string($found)."</p>\n"; |
430 | 467 | return $found; |
431 | 468 | } |
@@ -452,7 +489,10 @@ discard block |
||
452 | 489 | //error_log(__METHOD__."('$name',".array2string($value).','.array2string($extension_data).",$loop,,".array2string($value_in).')'); |
453 | 490 | //echo '<p>'.__METHOD__."('$name',".array2string($value).','.array2string($extension_data).",$loop,,".array2string($value_in).")</p>\n"; |
454 | 491 | |
455 | - if (!$extension_data) return false; |
|
492 | + if (!$extension_data) |
|
493 | + { |
|
494 | + return false; |
|
495 | + } |
|
456 | 496 | |
457 | 497 | switch($extension_data['type']) |
458 | 498 | { |
@@ -472,7 +512,9 @@ discard block |
||
472 | 512 | if ($_POST['submit_button'] == ($fname = str_replace($extension_data['value'],$extension_data['path'],$name)) || |
473 | 513 | substr($extension_data['path'],-1) == '/' && substr($_POST['submit_button'],0,strlen($fname)-1) == substr($fname,0,-1)) |
474 | 514 | { |
475 | - if (substr($extension_data['path'],-1) == '/') // multiple files? |
|
515 | + if (substr($extension_data['path'],-1) == '/') |
|
516 | + { |
|
517 | + // multiple files? |
|
476 | 518 | { |
477 | 519 | foreach($extension_data['files'] as $file) // check of each single file, to not allow deleting of arbitrary files |
478 | 520 | { |
@@ -481,6 +523,7 @@ discard block |
||
481 | 523 | if (!egw_vfs::unlink($extension_data['path'].$file)) |
482 | 524 | { |
483 | 525 | etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'].$file))); |
526 | + } |
|
484 | 527 | } |
485 | 528 | break; |
486 | 529 | } |
@@ -530,10 +573,13 @@ discard block |
||
530 | 573 | { |
531 | 574 | // add extension to path |
532 | 575 | $parts = explode('.',$filename); |
533 | - if (($extension = array_pop($parts)) && mime_magic::ext2mime($extension)) // really an extension --> add it to path |
|
576 | + if (($extension = array_pop($parts)) && mime_magic::ext2mime($extension)) |
|
577 | + { |
|
578 | + // really an extension --> add it to path |
|
534 | 579 | { |
535 | 580 | $path .= '.'.$extension; |
536 | 581 | } |
582 | + } |
|
537 | 583 | } |
538 | 584 | else // multiple upload with dir given (trailing slash) |
539 | 585 | { |
@@ -158,6 +158,9 @@ discard block |
||
158 | 158 | return $this->attributes; |
159 | 159 | } |
160 | 160 | |
161 | + /** |
|
162 | + * @param string $comment |
|
163 | + */ |
|
161 | 164 | function add_comment ($comment) |
162 | 165 | { |
163 | 166 | $this->comments[] = $comment; |
@@ -382,6 +385,10 @@ discard block |
||
382 | 385 | } |
383 | 386 | |
384 | 387 | |
388 | + /** |
|
389 | + * @param integer $i |
|
390 | + * @param xmltool $parent_node |
|
391 | + */ |
|
385 | 392 | function import_xml_children($data, &$i, $parent_node) |
386 | 393 | { |
387 | 394 | while (++$i < count($data)) |
@@ -594,6 +601,9 @@ discard block |
||
594 | 601 | $this->set_version($version); |
595 | 602 | } |
596 | 603 | |
604 | + /** |
|
605 | + * @param xmlnode $root_node |
|
606 | + */ |
|
597 | 607 | function add_root($root_node) |
598 | 608 | { |
599 | 609 | return $this->add_node($root_node); |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | |
13 | 13 | function var2xml($name, $data) |
14 | 14 | { |
15 | - $doc = new xmltool('root','',''); |
|
16 | - return $doc->import_var($name,$data,True,True); |
|
15 | + $doc = new xmltool('root', '', ''); |
|
16 | + return $doc->import_var($name, $data, True, True); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | class xmltool |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | var $indentstring = "\t"; |
33 | 33 | |
34 | 34 | /* start the class as either a root or a node */ |
35 | - function xmltool ($node_type = 'root', $name='',$indentstring="\t") |
|
35 | + function xmltool($node_type = 'root', $name = '', $indentstring = "\t") |
|
36 | 36 | { |
37 | 37 | $this->node_type = $node_type; |
38 | 38 | $this->indentstring = $indentstring; |
39 | 39 | if ($this->node_type == 'node') |
40 | 40 | { |
41 | - if($name != '') |
|
41 | + if ($name != '') |
|
42 | 42 | { |
43 | 43 | $this->name = $name; |
44 | 44 | } |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - function set_version ($version = '1.0') |
|
53 | + function set_version($version = '1.0') |
|
54 | 54 | { |
55 | 55 | $this->xmlversion = $version; |
56 | 56 | return True; |
57 | 57 | } |
58 | 58 | |
59 | - function set_doctype ($name, $uri = '') |
|
59 | + function set_doctype($name, $uri = '') |
|
60 | 60 | { |
61 | 61 | if ($this->node_type == 'root') |
62 | 62 | { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - function add_node ($node_object, $name = '') |
|
72 | + function add_node($node_object, $name = '') |
|
73 | 73 | { |
74 | 74 | switch ($this->node_type) |
75 | 75 | { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | break; |
86 | 86 | case 'node': |
87 | - if(!is_array($this->data)) |
|
87 | + if (!is_array($this->data)) |
|
88 | 88 | { |
89 | 89 | $this->data = Array(); |
90 | 90 | $this->data_type = 'node'; |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - function get_node ($name = '') // what is that function doing: NOTHING !!! |
|
112 | + function get_node($name = '') // what is that function doing: NOTHING !!! |
|
113 | 113 | { |
114 | - switch ($this->data_type) |
|
114 | + switch ($this->data_type) |
|
115 | 115 | { |
116 | 116 | case 'root': |
117 | 117 | break; |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | - function set_value ($string) |
|
126 | + function set_value($string) |
|
127 | 127 | { |
128 | 128 | $this->data = $string; |
129 | 129 | $this->data_type = 'value'; |
130 | 130 | return True; |
131 | 131 | } |
132 | 132 | |
133 | - function get_value () |
|
133 | + function get_value() |
|
134 | 134 | { |
135 | - if($this->data_type == 'value') |
|
135 | + if ($this->data_type == 'value') |
|
136 | 136 | { |
137 | 137 | return $this->data; |
138 | 138 | } |
@@ -142,32 +142,32 @@ discard block |
||
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - function set_attribute ($name, $value = '') |
|
145 | + function set_attribute($name, $value = '') |
|
146 | 146 | { |
147 | 147 | $this->attributes[$name] = $value; |
148 | 148 | return True; |
149 | 149 | } |
150 | 150 | |
151 | - function get_attribute ($name) |
|
151 | + function get_attribute($name) |
|
152 | 152 | { |
153 | 153 | return $this->attributes[$name]; |
154 | 154 | } |
155 | 155 | |
156 | - function get_attributes () |
|
156 | + function get_attributes() |
|
157 | 157 | { |
158 | 158 | return $this->attributes; |
159 | 159 | } |
160 | 160 | |
161 | - function add_comment ($comment) |
|
161 | + function add_comment($comment) |
|
162 | 162 | { |
163 | 163 | $this->comments[] = $comment; |
164 | 164 | return True; |
165 | 165 | } |
166 | 166 | |
167 | - function import_var($name, $value,$is_root=False,$export_xml=False) |
|
167 | + function import_var($name, $value, $is_root = False, $export_xml = False) |
|
168 | 168 | { |
169 | 169 | //echo "<p>import_var: this->indentstring='$this->indentstring'</p>\n"; |
170 | - $node = new xmltool('node',$name,$this->indentstring); |
|
170 | + $node = new xmltool('node', $name, $this->indentstring); |
|
171 | 171 | switch (gettype($value)) |
172 | 172 | { |
173 | 173 | case 'string': |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $node->set_value($value); |
178 | 178 | break; |
179 | 179 | case 'boolean': |
180 | - if($value == True) |
|
180 | + if ($value == True) |
|
181 | 181 | { |
182 | 182 | $node->set_value('1'); |
183 | 183 | } |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | break; |
189 | 189 | case 'array': |
190 | 190 | $new_index = False; |
191 | - while (list ($idxkey, $idxval) = each ($value)) |
|
191 | + while (list ($idxkey, $idxval) = each($value)) |
|
192 | 192 | { |
193 | - if(is_array($idxval)) |
|
193 | + if (is_array($idxval)) |
|
194 | 194 | { |
195 | - while (list ($k, $i) = each ($idxval)) |
|
195 | + while (list ($k, $i) = each($idxval)) |
|
196 | 196 | { |
197 | 197 | if (is_int($k)) |
198 | 198 | { |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | } |
203 | 203 | } |
204 | 204 | reset($value); |
205 | - while (list ($key, $val) = each ($value)) |
|
205 | + while (list ($key, $val) = each($value)) |
|
206 | 206 | { |
207 | - if($new_index) |
|
207 | + if ($new_index) |
|
208 | 208 | { |
209 | 209 | $keyname = $name; |
210 | 210 | $nextkey = $key; |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | case 'integer': |
221 | 221 | case 'double': |
222 | 222 | case 'NULL': |
223 | - $subnode = new xmltool('node', $nextkey,$this->indentstring); |
|
223 | + $subnode = new xmltool('node', $nextkey, $this->indentstring); |
|
224 | 224 | $subnode->set_value($val); |
225 | 225 | $node->add_node($subnode); |
226 | 226 | break; |
227 | 227 | case 'boolean': |
228 | - $subnode = new xmltool('node', $nextkey,$this->indentstring); |
|
229 | - if($val == True) |
|
228 | + $subnode = new xmltool('node', $nextkey, $this->indentstring); |
|
229 | + if ($val == True) |
|
230 | 230 | { |
231 | 231 | $subnode->set_value('1'); |
232 | 232 | } |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | $node->add_node($subnode); |
238 | 238 | break; |
239 | 239 | case 'array': |
240 | - if($new_index) |
|
240 | + if ($new_index) |
|
241 | 241 | { |
242 | - while (list ($subkey, $subval) = each ($val)) |
|
242 | + while (list ($subkey, $subval) = each($val)) |
|
243 | 243 | { |
244 | 244 | $node->add_node($this->import_var($nextkey, $subval)); |
245 | 245 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | } |
252 | 252 | break; |
253 | 253 | case 'object': |
254 | - $subnode = new xmltool('node', $nextkey,$this->indentstring); |
|
254 | + $subnode = new xmltool('node', $nextkey, $this->indentstring); |
|
255 | 255 | $subnode->set_value('PHP_SERIALIZED_OBJECT&:'.serialize($val)); |
256 | 256 | $node->add_node($subnode); |
257 | 257 | break; |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | exit; |
276 | 276 | } |
277 | 277 | |
278 | - if($is_root) |
|
278 | + if ($is_root) |
|
279 | 279 | { |
280 | 280 | $this->add_node($node); |
281 | - if($export_xml) |
|
281 | + if ($export_xml) |
|
282 | 282 | { |
283 | 283 | $xml = $this->export_xml(); |
284 | 284 | return $xml; |
@@ -297,17 +297,17 @@ discard block |
||
297 | 297 | |
298 | 298 | function export_var() |
299 | 299 | { |
300 | - if($this->node_type == 'root') |
|
300 | + if ($this->node_type == 'root') |
|
301 | 301 | { |
302 | 302 | return $this->data->export_var(); |
303 | 303 | } |
304 | 304 | |
305 | - if($this->data_type != 'node') |
|
305 | + if ($this->data_type != 'node') |
|
306 | 306 | { |
307 | - $found_at = strpos($this->data,'PHP_SERIALIZED_OBJECT&:'); |
|
308 | - if($found_at !== False) |
|
307 | + $found_at = strpos($this->data, 'PHP_SERIALIZED_OBJECT&:'); |
|
308 | + if ($found_at !== False) |
|
309 | 309 | { |
310 | - return unserialize(str_replace ('PHP_SERIALIZED_OBJECT&:', '', $this->data)); |
|
310 | + return unserialize(str_replace('PHP_SERIALIZED_OBJECT&:', '', $this->data)); |
|
311 | 311 | } |
312 | 312 | return $this->data; |
313 | 313 | } |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | { |
316 | 316 | $new_index = False; |
317 | 317 | reset($this->data); |
318 | - while(list($key,$val) = each($this->data)) |
|
318 | + while (list($key, $val) = each($this->data)) |
|
319 | 319 | { |
320 | - if(!isset($found_keys[$val->name])) |
|
320 | + if (!isset($found_keys[$val->name])) |
|
321 | 321 | { |
322 | 322 | $found_keys[$val->name] = True; |
323 | 323 | } |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | - if($new_index) |
|
330 | + if ($new_index) |
|
331 | 331 | { |
332 | 332 | reset($this->data); |
333 | - while(list($key,$val) = each($this->data)) |
|
333 | + while (list($key, $val) = each($this->data)) |
|
334 | 334 | { |
335 | 335 | |
336 | 336 | $return_array[$val->name][] = $val->export_var(); |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | else |
340 | 340 | { |
341 | 341 | reset($this->data); |
342 | - while(list($key,$val) = each($this->data)) |
|
342 | + while (list($key, $val) = each($this->data)) |
|
343 | 343 | { |
344 | 344 | $return_array[$val->name] = $val->export_var(); |
345 | 345 | } |
@@ -350,19 +350,19 @@ discard block |
||
350 | 350 | |
351 | 351 | function export_struct() |
352 | 352 | { |
353 | - if($this->node_type == 'root') |
|
353 | + if ($this->node_type == 'root') |
|
354 | 354 | { |
355 | 355 | return $this->data->export_struct(); |
356 | 356 | } |
357 | 357 | |
358 | 358 | $retval['tag'] = $this->name; |
359 | 359 | $retval['attributes'] = $this->attributes; |
360 | - if($this->data_type != 'node') |
|
360 | + if ($this->data_type != 'node') |
|
361 | 361 | { |
362 | - $found_at = strpos($this->data,'PHP_SERIALIZED_OBJECT&:'); |
|
363 | - if($found_at !== False) |
|
362 | + $found_at = strpos($this->data, 'PHP_SERIALIZED_OBJECT&:'); |
|
363 | + if ($found_at !== False) |
|
364 | 364 | { |
365 | - $retval['value'] = unserialize(str_replace ('PHP_SERIALIZED_OBJECT&:', '', $this->data)); |
|
365 | + $retval['value'] = unserialize(str_replace('PHP_SERIALIZED_OBJECT&:', '', $this->data)); |
|
366 | 366 | } |
367 | 367 | else |
368 | 368 | { |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | else |
374 | 374 | { |
375 | 375 | reset($this->data); |
376 | - while(list($key,$val) = each($this->data)) |
|
376 | + while (list($key, $val) = each($this->data)) |
|
377 | 377 | { |
378 | 378 | $retval['children'][] = $val->export_struct(); |
379 | 379 | } |
@@ -390,24 +390,24 @@ discard block |
||
390 | 390 | { |
391 | 391 | case 'cdata': |
392 | 392 | case 'complete': |
393 | - $node = new xmltool('node',$data[$i]['tag'],$this->indentstring); |
|
394 | - if(is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0) |
|
393 | + $node = new xmltool('node', $data[$i]['tag'], $this->indentstring); |
|
394 | + if (is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0) |
|
395 | 395 | { |
396 | - while(list($k,$v)=each($data[$i]['attributes'])) |
|
396 | + while (list($k, $v) = each($data[$i]['attributes'])) |
|
397 | 397 | { |
398 | - $node->set_attribute($k,$v); |
|
398 | + $node->set_attribute($k, $v); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | $node->set_value($data[$i]['value']); |
402 | 402 | $parent_node->add_node($node); |
403 | 403 | break; |
404 | 404 | case 'open': |
405 | - $node = new xmltool('node',$data[$i]['tag'],$this->indentstring); |
|
406 | - if(is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0) |
|
405 | + $node = new xmltool('node', $data[$i]['tag'], $this->indentstring); |
|
406 | + if (is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0) |
|
407 | 407 | { |
408 | - while(list($k,$v)=each($data[$i]['attributes'])) |
|
408 | + while (list($k, $v) = each($data[$i]['attributes'])) |
|
409 | 409 | { |
410 | - $node->set_attribute($k,$v); |
|
410 | + $node->set_attribute($k, $v); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | { |
425 | 425 | $parser = xml_parser_create(); |
426 | 426 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
427 | - xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
427 | + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
428 | 428 | xml_parse_into_struct($parser, $xmldata, $vals, $index); |
429 | 429 | xml_parser_free($parser); |
430 | 430 | unset($index); |
431 | - $node = new xmltool('node',$vals[0]['tag'],$this->indentstring); |
|
432 | - if(isset($vals[0]['attributes'])) |
|
431 | + $node = new xmltool('node', $vals[0]['tag'], $this->indentstring); |
|
432 | + if (isset($vals[0]['attributes'])) |
|
433 | 433 | { |
434 | - while(list($key,$value) = each($vals[0]['attributes'])) |
|
434 | + while (list($key, $value) = each($vals[0]['attributes'])) |
|
435 | 435 | { |
436 | 436 | $node->set_attribute($key, $value); |
437 | 437 | } |
@@ -458,20 +458,20 @@ discard block |
||
458 | 458 | if ($this->node_type == 'root') |
459 | 459 | { |
460 | 460 | $result = '<?xml version="'.$this->xmlversion.'"?>'."\n"; |
461 | - if(count($this->doctype) == 1) |
|
461 | + if (count($this->doctype) == 1) |
|
462 | 462 | { |
463 | - list($doctype_name,$doctype_uri) = each($this->doctype); |
|
463 | + list($doctype_name, $doctype_uri) = each($this->doctype); |
|
464 | 464 | $result .= '<!DOCTYPE '.$doctype_name.' SYSTEM "'.$doctype_uri.'">'."\n"; |
465 | 465 | } |
466 | - if(count($this->comments) > 0 ) |
|
466 | + if (count($this->comments) > 0) |
|
467 | 467 | { |
468 | 468 | //reset($this->comments); |
469 | - while(list($key,$val) = each ($this->comments)) |
|
469 | + while (list($key, $val) = each($this->comments)) |
|
470 | 470 | { |
471 | 471 | $result .= "<!-- $val -->\n"; |
472 | 472 | } |
473 | 473 | } |
474 | - if(is_object($this->data)) |
|
474 | + if (is_object($this->data)) |
|
475 | 475 | { |
476 | 476 | $indent = 0; |
477 | 477 | $result .= $this->data->export_xml($indent); |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | } |
487 | 487 | |
488 | 488 | $result = $indentstring.'<'.$this->name; |
489 | - if(count($this->attributes) > 0 ) |
|
489 | + if (count($this->attributes) > 0) |
|
490 | 490 | { |
491 | 491 | reset($this->attributes); |
492 | - while(list($key,$val) = each ($this->attributes)) |
|
492 | + while (list($key, $val) = each($this->attributes)) |
|
493 | 493 | { |
494 | - if (!is_array($val)) $result .= ' '.$key.'="'.htmlspecialchars($val,ENT_COMPAT,'utf-8').'"'; |
|
494 | + if (!is_array($val)) $result .= ' '.$key.'="'.htmlspecialchars($val, ENT_COMPAT, 'utf-8').'"'; |
|
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | switch ($this->data_type) |
508 | 508 | { |
509 | 509 | case 'value': |
510 | - if(is_array($this->data)) |
|
510 | + if (is_array($this->data)) |
|
511 | 511 | { |
512 | 512 | $type_error = True; |
513 | 513 | break; |
@@ -518,37 +518,37 @@ discard block |
||
518 | 518 | $result .= '<![CDATA['.$this->data.']]>'; |
519 | 519 | $endtag_indent = ''; |
520 | 520 | } |
521 | - else*/if(strlen($this->data) > 30 && !empty($this->indentstring)) |
|
521 | + else*/if (strlen($this->data) > 30 && !empty($this->indentstring)) |
|
522 | 522 | { |
523 | - $result .= "\n".$indentstring.$this->indentstring.htmlspecialchars($this->data,ENT_COMPAT,'utf-8')."\n"; |
|
523 | + $result .= "\n".$indentstring.$this->indentstring.htmlspecialchars($this->data, ENT_COMPAT, 'utf-8')."\n"; |
|
524 | 524 | $endtag_indent = $indentstring; |
525 | 525 | } |
526 | 526 | else |
527 | 527 | { |
528 | - $result .= htmlspecialchars($this->data,ENT_COMPAT,'utf-8'); |
|
528 | + $result .= htmlspecialchars($this->data, ENT_COMPAT, 'utf-8'); |
|
529 | 529 | $endtag_indent = ''; |
530 | 530 | } |
531 | 531 | break; |
532 | 532 | case 'node': |
533 | 533 | $result .= "\n"; |
534 | - if(!is_array($this->data)) |
|
534 | + if (!is_array($this->data)) |
|
535 | 535 | { |
536 | 536 | $type_error = True; |
537 | 537 | break; |
538 | 538 | } |
539 | 539 | |
540 | - $subindent = $indent+1; |
|
540 | + $subindent = $indent + 1; |
|
541 | 541 | reset($this->data); |
542 | - while(list($key,$val) = each ($this->data)) |
|
542 | + while (list($key, $val) = each($this->data)) |
|
543 | 543 | { |
544 | - if(is_object($val)) |
|
544 | + if (is_object($val)) |
|
545 | 545 | { |
546 | 546 | $result .= $val->export_xml($subindent); |
547 | 547 | } |
548 | 548 | } |
549 | 549 | break; |
550 | 550 | default: |
551 | - if($this->data != '') |
|
551 | + if ($this->data != '') |
|
552 | 552 | { |
553 | 553 | echo 'Invalid or unset data type ('.$this->data_type.'). This should not be possible if using the class as intended<br>'; |
554 | 554 | } |
@@ -560,15 +560,15 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | $result .= $endtag_indent.'</'.$this->name.'>'; |
563 | - if($indent != 0) |
|
563 | + if ($indent != 0) |
|
564 | 564 | { |
565 | 565 | $result .= "\n"; |
566 | 566 | } |
567 | 567 | } |
568 | - if(count($this->comments) > 0 ) |
|
568 | + if (count($this->comments) > 0) |
|
569 | 569 | { |
570 | 570 | reset($this->comments); |
571 | - while(list($key,$val) = each ($this->comments)) |
|
571 | + while (list($key, $val) = each($this->comments)) |
|
572 | 572 | { |
573 | 573 | $result .= $endtag_indent."<!-- $val -->\n"; |
574 | 574 | } |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | { |
583 | 583 | function xmlnode($name) |
584 | 584 | { |
585 | - $this->xmltool('node',$name); |
|
585 | + $this->xmltool('node', $name); |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | } |
304 | 304 | |
305 | 305 | if($this->data_type != 'node') |
306 | - { |
|
306 | + { |
|
307 | 307 | $found_at = strpos($this->data,'PHP_SERIALIZED_OBJECT&:'); |
308 | 308 | if($found_at !== False) |
309 | 309 | { |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | $retval['tag'] = $this->name; |
359 | 359 | $retval['attributes'] = $this->attributes; |
360 | 360 | if($this->data_type != 'node') |
361 | - { |
|
361 | + { |
|
362 | 362 | $found_at = strpos($this->data,'PHP_SERIALIZED_OBJECT&:'); |
363 | 363 | if($found_at !== False) |
364 | 364 | { |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | } |
422 | 422 | |
423 | - function import_xml($xmldata) |
|
423 | + function import_xml($xmldata) |
|
424 | 424 | { |
425 | 425 | $parser = xml_parser_create(); |
426 | 426 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
@@ -491,7 +491,10 @@ discard block |
||
491 | 491 | reset($this->attributes); |
492 | 492 | while(list($key,$val) = each ($this->attributes)) |
493 | 493 | { |
494 | - if (!is_array($val)) $result .= ' '.$key.'="'.htmlspecialchars($val,ENT_COMPAT,'utf-8').'"'; |
|
494 | + if (!is_array($val)) |
|
495 | + { |
|
496 | + $result .= ' '.$key.'="'.htmlspecialchars($val,ENT_COMPAT,'utf-8').'"'; |
|
497 | + } |
|
495 | 498 | } |
496 | 499 | } |
497 | 500 |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | { |
21 | 21 | /* for root nodes */ |
22 | 22 | var $xmlversion = '1.0'; |
23 | - var $doctype = Array(); |
|
23 | + var $doctype = array(); |
|
24 | 24 | /* shared */ |
25 | 25 | var $node_type = ''; |
26 | 26 | var $name = ''; |
27 | 27 | var $data_type; |
28 | 28 | var $data; |
29 | 29 | /* for nodes */ |
30 | - var $attributes = Array(); |
|
31 | - var $comments = Array(); |
|
30 | + var $attributes = array(); |
|
31 | + var $comments = array(); |
|
32 | 32 | var $indentstring = "\t"; |
33 | 33 | |
34 | 34 | /* start the class as either a root or a node */ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | case 'node': |
87 | 87 | if(!is_array($this->data)) |
88 | 88 | { |
89 | - $this->data = Array(); |
|
89 | + $this->data = array(); |
|
90 | 90 | $this->data_type = 'node'; |
91 | 91 | } |
92 | 92 | if (is_object($node_object)) |
@@ -80,6 +80,7 @@ |
||
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Returns the maximum width/height of a thumbnail |
83 | + * @return integer|null |
|
83 | 84 | */ |
84 | 85 | function get_maxsize() |
85 | 86 | { |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - if (!preg_match('/^[a-z0-9_-]+$/i',$app)) |
|
71 | + if (!preg_match('/^[a-z0-9_-]+$/i', $app)) |
|
72 | 72 | { |
73 | - die('Stop'); // just to prevent someone doing nasty things |
|
73 | + die('Stop'); // just to prevent someone doing nasty things |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return $app; |
@@ -81,8 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function get_maxsize() |
83 | 83 | { |
84 | - $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : |
|
85 | - $GLOBALS['egw_info']['server']['link_list_thumbnail']; |
|
84 | + $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : $GLOBALS['egw_info']['server']['link_list_thumbnail']; |
|
86 | 85 | |
87 | 86 | // Another maximum size may be passed if thumbnails are turned on |
88 | 87 | if ($preset != 0 && isset($_GET['thsize']) && is_numeric($_GET['thsize'])) |
@@ -148,7 +147,7 @@ discard block |
||
148 | 147 | } |
149 | 148 | $dst = gen_dstfile($stat && !empty($stat['url']) ? $stat['url'] : $src, $maxsize, $height, $width, $minsize); |
150 | 149 | $dst_dir = dirname($dst); |
151 | - if(file_exists($dst_dir)) |
|
150 | + if (file_exists($dst_dir)) |
|
152 | 151 | { |
153 | 152 | // Check whether the destination file already exists and is newer than |
154 | 153 | // the source file. Assume the file doesn't exist if thumbnailing is turned off. |
@@ -188,7 +187,7 @@ discard block |
||
188 | 187 | { |
189 | 188 | // Allow client to cache these, makes scrolling in filemanager much nicer |
190 | 189 | // setting maximum allow caching time of one year, if url contains (non-empty) moditication time |
191 | - egw_session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching |
|
190 | + egw_session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching |
|
192 | 191 | header('Content-Type: '.$output_mime); |
193 | 192 | readfile($dst); |
194 | 193 | return true; |
@@ -210,7 +209,7 @@ discard block |
||
210 | 209 | * @param int $minsize =null |
211 | 210 | * @return string |
212 | 211 | */ |
213 | -function gen_dstfile($src, $maxsize, $height=null, $width=null, $minsize=null) |
|
212 | +function gen_dstfile($src, $maxsize, $height = null, $width = null, $minsize = null) |
|
214 | 213 | { |
215 | 214 | // Use the egroupware file cache to store the thumbnails on a per instance basis |
216 | 215 | $cachefile = new egw_cache_files(array()); |
@@ -236,7 +235,7 @@ discard block |
||
236 | 235 | * TODO: As this is a general purpose function, it might probably be moved |
237 | 236 | * to some other php file or an "image utils" class. |
238 | 237 | */ |
239 | -function get_scaled_image_size($w, $h, $maxw, $maxh, $minw=0, $minh=0) |
|
238 | +function get_scaled_image_size($w, $h, $maxw, $maxh, $minw = 0, $minh = 0) |
|
240 | 239 | { |
241 | 240 | //Scale will contain the factor by which the image has to be scaled down |
242 | 241 | $scale = 1.0; |
@@ -297,7 +296,7 @@ discard block |
||
297 | 296 | * @param int $maxh the maximum height of the thumbnail |
298 | 297 | * @returns boolean|resource false or a gd_image |
299 | 298 | */ |
300 | -function gd_image_load($file,$maxw,$maxh) |
|
299 | +function gd_image_load($file, $maxw, $maxh) |
|
301 | 300 | { |
302 | 301 | // Get mime type |
303 | 302 | list($type, $image_type) = explode('/', egw_vfs::mime_content_type($file)); |
@@ -305,9 +304,9 @@ discard block |
||
305 | 304 | if (!$type) list($type, $image_type) = explode('/', mime_magic::filename2mime($file)); |
306 | 305 | |
307 | 306 | // Call the according gd constructor depending on the file type |
308 | - if($type == 'image') |
|
307 | + if ($type == 'image') |
|
309 | 308 | { |
310 | - if (in_array($image_type, array('tiff','jpeg')) && ($image = exif_thumbnail_load($file))) |
|
309 | + if (in_array($image_type, array('tiff', 'jpeg')) && ($image = exif_thumbnail_load($file))) |
|
311 | 310 | { |
312 | 311 | return $image; |
313 | 312 | } |
@@ -326,12 +325,12 @@ discard block |
||
326 | 325 | else if ($type == 'application') |
327 | 326 | { |
328 | 327 | $thumb = false; |
329 | - if(strpos($image_type,'vnd.oasis.opendocument.') === 0) |
|
328 | + if (strpos($image_type, 'vnd.oasis.opendocument.') === 0) |
|
330 | 329 | { |
331 | 330 | // OpenDocuments have thumbnails inside already |
332 | 331 | $thumb = get_opendocument_thumbnail($file); |
333 | 332 | } |
334 | - else if($image_type == 'pdf') |
|
333 | + else if ($image_type == 'pdf') |
|
335 | 334 | { |
336 | 335 | $thumb = get_pdf_thumbnail($file); |
337 | 336 | } |
@@ -341,7 +340,7 @@ discard block |
||
341 | 340 | //$thumb = get_msoffice_thumbnail($file); |
342 | 341 | } |
343 | 342 | // Mark it with mime type icon |
344 | - if($thumb) |
|
343 | + if ($thumb) |
|
345 | 344 | { |
346 | 345 | // Need to scale first, or the mark will be wrong size |
347 | 346 | $scaled = get_scaled_image_size(imagesx($thumb), imagesy($thumb), $maxw, $maxh); |
@@ -381,8 +380,8 @@ discard block |
||
381 | 380 | |
382 | 381 | // Image is already there, but we can't access them directly through VFS |
383 | 382 | $ext = $mimetype == 'application/vnd.oasis.opendocument.text' ? '.odt' : '.ods'; |
384 | - $archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file,$ext).'-'); |
|
385 | - copy($file,$archive); |
|
383 | + $archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file, $ext).'-'); |
|
384 | + copy($file, $archive); |
|
386 | 385 | |
387 | 386 | $thumbnail_url = 'zip://'.$archive.'#Thumbnails/thumbnail.png'; |
388 | 387 | $image = imagecreatefromstring(file_get_contents($thumbnail_url)); |
@@ -436,7 +435,7 @@ discard block |
||
436 | 435 | */ |
437 | 436 | function get_pdf_thumbnail($file) |
438 | 437 | { |
439 | - if(!pdf_thumbnails_available()) return false; |
|
438 | + if (!pdf_thumbnails_available()) return false; |
|
440 | 439 | |
441 | 440 | // switch off max_excution_time, as some thumbnails take longer and |
442 | 441 | // will be startet over and over again, if they dont finish |
@@ -465,7 +464,7 @@ discard block |
||
465 | 464 | $target_height = imagesy($target_image); |
466 | 465 | |
467 | 466 | // Find mime image, if no tag image set |
468 | - if(!$tag_image && $mime) |
|
467 | + if (!$tag_image && $mime) |
|
469 | 468 | { |
470 | 469 | list($app, $icon) = explode('/', egw_vfs::mime_icon($mime), 2); |
471 | 470 | list(, $path) = explode($GLOBALS['egw_info']['server']['webserver_url'], |
@@ -476,16 +475,16 @@ discard block |
||
476 | 475 | |
477 | 476 | // Find correct size - max 1/3 target |
478 | 477 | $tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3); |
479 | - if(!$tag_size) return; |
|
480 | - list($tag_width,$tag_height) = $tag_size; |
|
478 | + if (!$tag_size) return; |
|
479 | + list($tag_width, $tag_height) = $tag_size; |
|
481 | 480 | |
482 | 481 | // Put it in |
483 | - if($mime) |
|
482 | + if ($mime) |
|
484 | 483 | { |
485 | - imagecopyresampled($target_image,$tag_image, |
|
484 | + imagecopyresampled($target_image, $tag_image, |
|
486 | 485 | $target_width - $tag_width, |
487 | 486 | $target_height - $tag_height, |
488 | - 0,0, |
|
487 | + 0, 0, |
|
489 | 488 | $tag_width, |
490 | 489 | $tag_height, |
491 | 490 | imagesx($tag_image), |
@@ -539,7 +538,7 @@ discard block |
||
539 | 538 | function gd_image_thumbnail($file, $maxw, $maxh, $minw, $minh) |
540 | 539 | { |
541 | 540 | //Load the image |
542 | - if (($img_src = gd_image_load($file,$maxw,$maxh)) !== false) |
|
541 | + if (($img_src = gd_image_load($file, $maxw, $maxh)) !== false) |
|
543 | 542 | { |
544 | 543 | //Get the constraints of the image |
545 | 544 | $w = imagesx($img_src); |
@@ -569,14 +568,14 @@ discard block |
||
569 | 568 | */ |
570 | 569 | function gdVersion($user_ver = 0) |
571 | 570 | { |
572 | - if (! extension_loaded('gd')) { return; } |
|
571 | + if (!extension_loaded('gd')) { return; } |
|
573 | 572 | static $gd_ver = 0; |
574 | 573 | |
575 | 574 | // Just accept the specified setting if it's 1. |
576 | 575 | if ($user_ver == 1) { $gd_ver = 1; return 1; } |
577 | 576 | |
578 | 577 | // Use the static variable if function was called previously. |
579 | - if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } |
|
578 | + if ($user_ver != 2 && $gd_ver > 0) { return $gd_ver; } |
|
580 | 579 | |
581 | 580 | // Use the gd_info() function if possible. |
582 | 581 | if (function_exists('gd_info')) { |
@@ -242,10 +242,13 @@ discard block |
||
242 | 242 | $scale = 1.0; |
243 | 243 | |
244 | 244 | //Select the constraining dimension |
245 | - if ($w > $h) // landscape image: constraining factor $minh or $maxw |
|
245 | + if ($w > $h) |
|
246 | + { |
|
247 | + // landscape image: constraining factor $minh or $maxw |
|
246 | 248 | { |
247 | 249 | $scale = $minh ? $minh / $h : $maxw / $w; |
248 | 250 | } |
251 | + } |
|
249 | 252 | else // portrail image: constraining factor $minw or $maxh |
250 | 253 | { |
251 | 254 | $scale = $minw ? $minw / $w : $maxh / $h; |
@@ -302,7 +305,10 @@ discard block |
||
302 | 305 | // Get mime type |
303 | 306 | list($type, $image_type) = explode('/', egw_vfs::mime_content_type($file)); |
304 | 307 | // if $file is not from vfs, use mime_magic::filename2mime to get mime-type from extension |
305 | - if (!$type) list($type, $image_type) = explode('/', mime_magic::filename2mime($file)); |
|
308 | + if (!$type) |
|
309 | + { |
|
310 | + list($type, $image_type) = explode('/', mime_magic::filename2mime($file)); |
|
311 | + } |
|
306 | 312 | |
307 | 313 | // Call the according gd constructor depending on the file type |
308 | 314 | if($type == 'image') |
@@ -436,7 +442,10 @@ discard block |
||
436 | 442 | */ |
437 | 443 | function get_pdf_thumbnail($file) |
438 | 444 | { |
439 | - if(!pdf_thumbnails_available()) return false; |
|
445 | + if(!pdf_thumbnails_available()) |
|
446 | + { |
|
447 | + return false; |
|
448 | + } |
|
440 | 449 | |
441 | 450 | // switch off max_excution_time, as some thumbnails take longer and |
442 | 451 | // will be startet over and over again, if they dont finish |
@@ -476,7 +485,10 @@ discard block |
||
476 | 485 | |
477 | 486 | // Find correct size - max 1/3 target |
478 | 487 | $tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3); |
479 | - if(!$tag_size) return; |
|
488 | + if(!$tag_size) |
|
489 | + { |
|
490 | + return; |
|
491 | + } |
|
480 | 492 | list($tag_width,$tag_height) = $tag_size; |
481 | 493 | |
482 | 494 | // Put it in |
@@ -569,17 +581,24 @@ discard block |
||
569 | 581 | */ |
570 | 582 | function gdVersion($user_ver = 0) |
571 | 583 | { |
572 | - if (! extension_loaded('gd')) { return; } |
|
584 | + if (! extension_loaded('gd')) |
|
585 | + { |
|
586 | +return; } |
|
573 | 587 | static $gd_ver = 0; |
574 | 588 | |
575 | 589 | // Just accept the specified setting if it's 1. |
576 | - if ($user_ver == 1) { $gd_ver = 1; return 1; } |
|
590 | + if ($user_ver == 1) |
|
591 | + { |
|
592 | +$gd_ver = 1; return 1; } |
|
577 | 593 | |
578 | 594 | // Use the static variable if function was called previously. |
579 | - if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } |
|
595 | + if ($user_ver !=2 && $gd_ver > 0 ) |
|
596 | + { |
|
597 | +return $gd_ver; } |
|
580 | 598 | |
581 | 599 | // Use the gd_info() function if possible. |
582 | - if (function_exists('gd_info')) { |
|
600 | + if (function_exists('gd_info')) |
|
601 | + { |
|
583 | 602 | $ver_info = gd_info(); |
584 | 603 | $match = null; |
585 | 604 | preg_match('/\d/', $ver_info['GD Version'], $match); |
@@ -588,11 +607,15 @@ discard block |
||
588 | 607 | } |
589 | 608 | |
590 | 609 | // If phpinfo() is disabled use a specified / fail-safe choice... |
591 | - if (preg_match('/phpinfo/', ini_get('disable_functions'))) { |
|
592 | - if ($user_ver == 2) { |
|
610 | + if (preg_match('/phpinfo/', ini_get('disable_functions'))) |
|
611 | + { |
|
612 | + if ($user_ver == 2) |
|
613 | + { |
|
593 | 614 | $gd_ver = 2; |
594 | 615 | return 2; |
595 | - } else { |
|
616 | + } |
|
617 | + else |
|
618 | + { |
|
596 | 619 | $gd_ver = 1; |
597 | 620 | return 1; |
598 | 621 | } |
@@ -601,6 +624,9 @@ discard block |
||
601 | 624 | ob_start(); |
602 | 625 | phpinfo(8); |
603 | 626 | $info = stristr(ob_get_clean(), 'gd version'); |
604 | - if (preg_match('/\d/', $info, $match)) $gd_ver = $match[0]; |
|
627 | + if (preg_match('/\d/', $info, $match)) |
|
628 | + { |
|
629 | + $gd_ver = $match[0]; |
|
630 | + } |
|
605 | 631 | return $match[0]; |
606 | 632 | } |
@@ -150,7 +150,7 @@ |
||
150 | 150 | * Get a list of the user's portlets, and their associated values & settings, for display |
151 | 151 | * |
152 | 152 | * Actual portlet content is provided by each portlet. |
153 | - * @param template etemplate so attributes can be set |
|
153 | + * @param template etemplate_new so attributes can be set |
|
154 | 154 | */ |
155 | 155 | protected function get_user_portlets(etemplate_new &$template) |
156 | 156 | { |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | $content = array( |
46 | 46 | 'portlets' => $this->get_user_portlets($template) |
47 | 47 | ); |
48 | - $template->setElementAttribute('home.index','actions',$this->get_actions()); |
|
48 | + $template->setElementAttribute('home.index', 'actions', $this->get_actions()); |
|
49 | 49 | |
50 | 50 | $GLOBALS['egw_info']['flags']['app_header'] = lang('home'); |
51 | 51 | $GLOBALS['egw_info']['flags']['currentapp'] = 'home'; |
52 | 52 | |
53 | 53 | // Main screen message |
54 | 54 | translation::add_app('mainscreen'); |
55 | - $greeting = translation::translate('mainscreen_message',false,''); |
|
55 | + $greeting = translation::translate('mainscreen_message', false, ''); |
|
56 | 56 | |
57 | - if($greeting == 'mainscreen_message'|| empty($greeting)) |
|
57 | + if ($greeting == 'mainscreen_message' || empty($greeting)) |
|
58 | 58 | { |
59 | - translation::add_app('mainscreen','en'); // trying the en one |
|
60 | - $greeting = translation::translate('mainscreen_message',false,''); |
|
59 | + translation::add_app('mainscreen', 'en'); // trying the en one |
|
60 | + $greeting = translation::translate('mainscreen_message', false, ''); |
|
61 | 61 | } |
62 | - if(!($greeting == 'mainscreen_message'|| empty($greeting))) |
|
62 | + if (!($greeting == 'mainscreen_message' || empty($greeting))) |
|
63 | 63 | { |
64 | 64 | $content['mainscreen_message'] = $greeting; |
65 | 65 | } |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | $template->exec('home.home_ui.index', $content); |
68 | 68 | |
69 | 69 | // Now run the portlets themselves |
70 | - foreach($content['portlets'] as $portlet => $p_data) |
|
70 | + foreach ($content['portlets'] as $portlet => $p_data) |
|
71 | 71 | { |
72 | 72 | $id = $p_data['id']; |
73 | 73 | |
74 | - if(!$id) continue; |
|
74 | + if (!$id) continue; |
|
75 | 75 | $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); |
76 | 76 | } |
77 | 77 | |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | $add_portlets = $portlets; |
90 | 90 | $change_for_add = function(&$add_portlets) use (&$change_for_add) |
91 | 91 | { |
92 | - foreach($add_portlets as $id => &$add) |
|
92 | + foreach ($add_portlets as $id => &$add) |
|
93 | 93 | { |
94 | - if(is_array($add['children'])) |
|
94 | + if (is_array($add['children'])) |
|
95 | 95 | { |
96 | 96 | $change_for_add($add['children']); |
97 | 97 | } |
98 | - if($id && !$add['children']) |
|
98 | + if ($id && !$add['children']) |
|
99 | 99 | { |
100 | - $add['id'] = 'add_' . $id; |
|
100 | + $add['id'] = 'add_'.$id; |
|
101 | 101 | $add['class'] = 'add_'.$id; |
102 | 102 | } |
103 | 103 | } |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | |
117 | 117 | // Add all known portlets as drop actions too. If there are multiple matches, there will be a menu |
118 | 118 | $drop_execute = 'javaScript:app.home.add_from_drop'; |
119 | - foreach($portlets as $app => &$children) |
|
119 | + foreach ($portlets as $app => &$children) |
|
120 | 120 | { |
121 | 121 | // Home portlets - uses link system, so all apps that support that are accepted |
122 | - if(!$children['children']) |
|
122 | + if (!$children['children']) |
|
123 | 123 | { |
124 | 124 | $children['class'] = $app; |
125 | 125 | $children['onExecute'] = $drop_execute; |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | else |
130 | 130 | { |
131 | - foreach($children['children'] as $portlet => $app_portlet) |
|
131 | + foreach ($children['children'] as $portlet => $app_portlet) |
|
132 | 132 | { |
133 | - if(!is_array($app_portlet)) continue; |
|
133 | + if (!is_array($app_portlet)) continue; |
|
134 | 134 | $app_portlet['class'] = $portlet; |
135 | - $app_portlet['id'] = 'drop_' . $app_portlet['id']; |
|
135 | + $app_portlet['id'] = 'drop_'.$app_portlet['id']; |
|
136 | 136 | $app_portlet['onExecute'] = $drop_execute; |
137 | 137 | $app_portlet['acceptedTypes'] = $app; |
138 | 138 | $app_portlet['type'] = 'drop'; |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | * Actual portlet content is provided by each portlet. |
153 | 153 | * @param template etemplate so attributes can be set |
154 | 154 | */ |
155 | - protected function get_user_portlets(etemplate_new &$template) |
|
155 | + protected function get_user_portlets(etemplate_new&$template) |
|
156 | 156 | { |
157 | 157 | $portlets = array(); |
158 | 158 | |
159 | - foreach((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context) |
|
159 | + foreach ((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context) |
|
160 | 160 | { |
161 | - if(strpos($id,'portlet_') !== 0 || // Not a portlet |
|
161 | + if (strpos($id, 'portlet_') !== 0 || // Not a portlet |
|
162 | 162 | in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here |
163 | 163 | !is_array($context) // Not a valid portlet (probably user deleted a default) |
164 | 164 | ) continue; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | // Get settings |
175 | 175 | // Exclude common attributes changed through UI and settings lacking a type |
176 | 176 | $settings = $portlet->get_properties(); |
177 | - foreach($settings as $key => $setting) |
|
177 | + foreach ($settings as $key => $setting) |
|
178 | 178 | { |
179 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
179 | + if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]); |
|
180 | 180 | } |
181 | 181 | $settings += $context; |
182 | - foreach(home_portlet::$common_attributes as $attr) |
|
182 | + foreach (home_portlet::$common_attributes as $attr) |
|
183 | 183 | { |
184 | 184 | unset($settings[$attr]); |
185 | 185 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | // Add in default for admins |
193 | 193 | self::create_default_actions($actions, $id); |
194 | 194 | |
195 | - $template->setElementAttribute("portlets[" . count($portlets) . "[$id]", 'actions', $actions); |
|
195 | + $template->setElementAttribute("portlets[".count($portlets)."[$id]", 'actions', $actions); |
|
196 | 196 | |
197 | 197 | $portlets[] = $portlet_content; |
198 | 198 | } |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | */ |
217 | 217 | protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false) |
218 | 218 | { |
219 | - if(!$context['class']) $context['class'] = 'home_link_portlet'; |
|
219 | + if (!$context['class']) $context['class'] = 'home_link_portlet'; |
|
220 | 220 | |
221 | 221 | // This should be set already, but just in case the execution path |
222 | 222 | // is different from normal... |
223 | - if(egw_json_response::isJSONResponse()) |
|
223 | + if (egw_json_response::isJSONResponse()) |
|
224 | 224 | { |
225 | 225 | $GLOBALS['egw']->framework->response = egw_json_response::get(); |
226 | 226 | } |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | |
236 | 236 | // Exclude common attributes changed through UI and settings lacking a type |
237 | 237 | $settings = $portlet->get_properties(); |
238 | - foreach($settings as $key => $setting) |
|
238 | + foreach ($settings as $key => $setting) |
|
239 | 239 | { |
240 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
240 | + if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]); |
|
241 | 241 | } |
242 | 242 | $settings += $context; |
243 | - foreach(home_portlet::$common_attributes as $attr) |
|
243 | + foreach (home_portlet::$common_attributes as $attr) |
|
244 | 244 | { |
245 | 245 | unset($settings[$attr]); |
246 | 246 | } |
@@ -255,31 +255,31 @@ discard block |
||
255 | 255 | self::create_default_actions($attributes['actions'], $id); |
256 | 256 | |
257 | 257 | // Set any provided common attributes (size, etc) |
258 | - foreach(home_portlet::$common_attributes as $name) |
|
258 | + foreach (home_portlet::$common_attributes as $name) |
|
259 | 259 | { |
260 | - if(array_key_exists($name, $context)) |
|
260 | + if (array_key_exists($name, $context)) |
|
261 | 261 | { |
262 | 262 | $attributes[$name] = $context[$name]; |
263 | 263 | } |
264 | 264 | } |
265 | - foreach($attributes as $attr => $value) |
|
265 | + foreach ($attributes as $attr => $value) |
|
266 | 266 | { |
267 | 267 | $etemplate->setElementAttribute($id, $attr, $value); |
268 | 268 | } |
269 | 269 | |
270 | 270 | // Make sure custom javascript is loaded |
271 | 271 | $appname = $context['appname']; |
272 | - if(!$appname) |
|
272 | + if (!$appname) |
|
273 | 273 | { |
274 | - list($app) = explode('_',$classname); |
|
275 | - if($GLOBALS['egw_info']['apps'][$app]) |
|
274 | + list($app) = explode('_', $classname); |
|
275 | + if ($GLOBALS['egw_info']['apps'][$app]) |
|
276 | 276 | { |
277 | 277 | $appname = $app; |
278 | 278 | } |
279 | 279 | } |
280 | 280 | egw_framework::validate_file('', $classname, $appname ? $appname : 'home'); |
281 | 281 | |
282 | - if($full_exec) |
|
282 | + if ($full_exec) |
|
283 | 283 | { |
284 | 284 | $content = $portlet->exec($id, $etemplate, $full_exec ? 2 : -1); |
285 | 285 | } |
@@ -296,23 +296,23 @@ discard block |
||
296 | 296 | protected function get_legacy_portlets(&$content, &$attributes) |
297 | 297 | { |
298 | 298 | $sorted_apps = array_keys($GLOBALS['egw_info']['user']['apps']); |
299 | - $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated', 'homepage_display'); |
|
299 | + $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents', 'homeShowLatest', 'mainscreen_showmail', 'mainscreen_showbirthdays', 'mainscreen_show_new_updated', 'homepage_display'); |
|
300 | 300 | |
301 | - foreach($sorted_apps as $appname) |
|
301 | + foreach ($sorted_apps as $appname) |
|
302 | 302 | { |
303 | 303 | // If there's already [new] settings, or no preference, skip it |
304 | - if($content[$appname]) continue; |
|
304 | + if ($content[$appname]) continue; |
|
305 | 305 | $no_pref = true; |
306 | - foreach($portal_oldvarnames as $varcheck) |
|
306 | + foreach ($portal_oldvarnames as $varcheck) |
|
307 | 307 | { |
308 | 308 | $thisd = $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]; |
309 | - if($thisd) |
|
309 | + if ($thisd) |
|
310 | 310 | { |
311 | 311 | $no_pref = false; |
312 | 312 | break; |
313 | 313 | } |
314 | 314 | } |
315 | - if($no_pref || !$GLOBALS['egw']->hooks->hook_exists('home', $appname)) |
|
315 | + if ($no_pref || !$GLOBALS['egw']->hooks->hook_exists('home', $appname)) |
|
316 | 316 | { |
317 | 317 | continue; |
318 | 318 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $_content = ''; |
324 | 324 | $_attributes = array(); |
325 | 325 | $this->get_portlet($appname, $context, $_content, $_attributes); |
326 | - if(trim($_content)) |
|
326 | + if (trim($_content)) |
|
327 | 327 | { |
328 | 328 | $content[$appname] = $_content; |
329 | 329 | $attributes[$appname] = $_attributes; |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | // Ignore some problem files and base classes that shouldn't be options |
344 | 344 | $ignore = array( |
345 | - '.','..', |
|
345 | + '.', '..', |
|
346 | 346 | 'class.home_portlet.inc.php', |
347 | 347 | 'class.home_legacy_portlet.inc.php', |
348 | 348 | 'class.home_favorite_portlet.inc.php', |
@@ -350,18 +350,18 @@ discard block |
||
350 | 350 | 'class.home_weather_portlet.inc.php' |
351 | 351 | ); |
352 | 352 | // Look through all known classes for portlets - for now, they need 'portlet' in the file name |
353 | - foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname) |
|
353 | + foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname) |
|
354 | 354 | { |
355 | - if(in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
356 | - $files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/'); |
|
357 | - if(!$files) continue; |
|
355 | + if (in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
356 | + $files = (array)@scandir(EGW_SERVER_ROOT.'/'.$appname.'/inc/'); |
|
357 | + if (!$files) continue; |
|
358 | 358 | |
359 | - foreach($files as $entry) |
|
359 | + foreach ($files as $entry) |
|
360 | 360 | { |
361 | - if (!in_array($entry, $ignore) && substr($entry,-8) == '.inc.php' && strpos($entry,'portlet')) |
|
361 | + if (!in_array($entry, $ignore) && substr($entry, -8) == '.inc.php' && strpos($entry, 'portlet')) |
|
362 | 362 | { |
363 | 363 | list(,$classname) = explode('.', $entry); |
364 | - if(class_exists($classname) && |
|
364 | + if (class_exists($classname) && |
|
365 | 365 | in_array('home_portlet', class_parents($classname, false))) |
366 | 366 | { |
367 | 367 | $classes[$appname][] = $classname; |
@@ -373,19 +373,19 @@ discard block |
||
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | - if(!$classes[$appname]) continue; |
|
376 | + if (!$classes[$appname]) continue; |
|
377 | 377 | |
378 | 378 | // Build 'Add' actions for each discovered portlet. |
379 | 379 | // Portlets from other apps go in sub-actions |
380 | - $add_to =& $list; |
|
381 | - if($classes[$appname] && $appname != 'home') |
|
380 | + $add_to = & $list; |
|
381 | + if ($classes[$appname] && $appname != 'home') |
|
382 | 382 | { |
383 | 383 | $list[$appname] = array( |
384 | 384 | 'caption' => lang($appname), |
385 | 385 | ); |
386 | - $add_to =& $list[$appname]['children']; |
|
386 | + $add_to = & $list[$appname]['children']; |
|
387 | 387 | } |
388 | - foreach($classes[$appname] as $portlet) |
|
388 | + foreach ($classes[$appname] as $portlet) |
|
389 | 389 | { |
390 | 390 | $instance = new $portlet(); |
391 | 391 | $desc = $instance->get_description(); |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | }, array(), 60); |
406 | 406 | |
407 | 407 | // Filter list by current user's permissions |
408 | - foreach($list as $appname => $children) |
|
408 | + foreach ($list as $appname => $children) |
|
409 | 409 | { |
410 | - if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
411 | - if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
410 | + if (in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
411 | + if (!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
412 | 412 | { |
413 | 413 | unset($list[$appname]); |
414 | 414 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | protected static function create_default_actions(&$actions, $portlet_id = null) |
427 | 427 | { |
428 | - if($GLOBALS['egw_info']['user']['apps']['admin']) |
|
428 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
429 | 429 | { |
430 | 430 | $actions['add_default'] = array( |
431 | 431 | 'type' => 'popup', |
@@ -435,25 +435,25 @@ discard block |
||
435 | 435 | 'icon' => 'preference' |
436 | 436 | ); |
437 | 437 | // Customize for the given portlet |
438 | - if($portlet_id !== null) |
|
438 | + if ($portlet_id !== null) |
|
439 | 439 | { |
440 | - foreach(array('forced','group','default') as $location) |
|
440 | + foreach (array('forced', 'group', 'default') as $location) |
|
441 | 441 | { |
442 | 442 | $loc = $GLOBALS['egw']->preferences->$location; |
443 | 443 | |
444 | - if($loc['home'][$portlet_id]) |
|
444 | + if ($loc['home'][$portlet_id]) |
|
445 | 445 | { |
446 | 446 | // If it's forced, no point in setting default |
447 | - if($location == 'forced') |
|
447 | + if ($location == 'forced') |
|
448 | 448 | { |
449 | 449 | unset($actions['add_default']); |
450 | 450 | } |
451 | 451 | // If it's a group, we'd like to know which |
452 | - if($location == 'group') |
|
452 | + if ($location == 'group') |
|
453 | 453 | { |
454 | 454 | $options = array('account_type' => $type); |
455 | - $groups = accounts::link_query('',$options); |
|
456 | - foreach($groups as $gid => $name) |
|
455 | + $groups = accounts::link_query('', $options); |
|
456 | + foreach ($groups as $gid => $name) |
|
457 | 457 | { |
458 | 458 | $prefs = new preferences($gid); |
459 | 459 | $prefs->read_repository(); |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | } |
467 | 467 | $actions['remove_default_'.$location] = array( |
468 | 468 | 'type' => 'popup', |
469 | - 'caption' => lang('Remove default %1',is_numeric($location) ? accounts::id2name($location) : $location), |
|
469 | + 'caption' => lang('Remove default %1', is_numeric($location) ? accounts::id2name($location) : $location), |
|
470 | 470 | 'onExecute' => 'javaScript:app.home.set_default', |
471 | 471 | 'group' => 'Admins', |
472 | 472 | 'portlet_group' => $location |
@@ -477,14 +477,14 @@ discard block |
||
477 | 477 | } |
478 | 478 | |
479 | 479 | // Change action for forced |
480 | - if($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
480 | + if ($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
481 | 481 | { |
482 | 482 | // No one can remove it |
483 | 483 | $actions['remove_portlet']['enabled'] = false; |
484 | - $actions['remove_portlet']['caption'] .= ' ('.lang('Forced') .')'; |
|
484 | + $actions['remove_portlet']['caption'] .= ' ('.lang('Forced').')'; |
|
485 | 485 | |
486 | 486 | // Non-admins can't edit it |
487 | - if($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
487 | + if ($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
488 | 488 | { |
489 | 489 | $actions['edit_settings']['enabled'] = false; |
490 | 490 | $actions['edit_settings']['visible'] = false; |
@@ -503,14 +503,14 @@ discard block |
||
503 | 503 | public function ajax_set_properties($portlet_id, $attributes, $values, $group = false) |
504 | 504 | { |
505 | 505 | //error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)"); |
506 | - if(!$attributes) |
|
506 | + if (!$attributes) |
|
507 | 507 | { |
508 | 508 | $attributes = array(); |
509 | 509 | } |
510 | 510 | |
511 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
511 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
512 | 512 | { |
513 | - if($group == 'forced') |
|
513 | + if ($group == 'forced') |
|
514 | 514 | { |
515 | 515 | // Quietly reject |
516 | 516 | return; |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | // Not an admin, can only override. |
519 | 519 | $group = false; |
520 | 520 | } |
521 | - if($group && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
521 | + if ($group && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
522 | 522 | { |
523 | 523 | $prefs = new preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
524 | 524 | } |
@@ -532,23 +532,23 @@ discard block |
||
532 | 532 | |
533 | 533 | $response = egw_json_response::get(); |
534 | 534 | |
535 | - if($values =='~reload~') |
|
535 | + if ($values == '~reload~') |
|
536 | 536 | { |
537 | 537 | $full_exec = true; |
538 | 538 | $values = array(); |
539 | 539 | } |
540 | - if($values == '~remove~') |
|
540 | + if ($values == '~remove~') |
|
541 | 541 | { |
542 | 542 | // Already removed client side, needs to be removed permanently |
543 | - $default = $prefs->default_prefs('home',$portlet_id) || $prefs->group['home'][$portlet_id]; |
|
543 | + $default = $prefs->default_prefs('home', $portlet_id) || $prefs->group['home'][$portlet_id]; |
|
544 | 544 | |
545 | - if($default) |
|
545 | + if ($default) |
|
546 | 546 | { |
547 | 547 | // Can't delete forced - not a UI option though |
548 | - if(!$GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
548 | + if (!$GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
549 | 549 | { |
550 | 550 | // Set a flag to override default instead of just delete |
551 | - $GLOBALS['egw']->preferences->add('home',$portlet_id, 'deleted'); |
|
551 | + $GLOBALS['egw']->preferences->add('home', $portlet_id, 'deleted'); |
|
552 | 552 | $GLOBALS['egw']->preferences->save_repository(); |
553 | 553 | } |
554 | 554 | } |
@@ -565,19 +565,19 @@ discard block |
||
565 | 565 | // Remove some constant stuff that winds up here |
566 | 566 | unset($values['edit_template']); |
567 | 567 | unset($values['readonly']); |
568 | - unset($values['disabled']);unset($values['no_lang']); |
|
568 | + unset($values['disabled']); unset($values['no_lang']); |
|
569 | 569 | unset($values['actions']); |
570 | 570 | unset($values['statustext']); |
571 | - unset($values['type']);unset($values['label']);unset($values['status']); |
|
572 | - unset($values['value']);unset($values['align']); |
|
571 | + unset($values['type']); unset($values['label']); unset($values['status']); |
|
572 | + unset($values['value']); unset($values['align']); |
|
573 | 573 | |
574 | 574 | // Get portlet settings, and merge new with old |
575 | 575 | $context = array_merge((array)$portlets[$portlet_id], $values); |
576 | 576 | $context['group'] = $group; |
577 | 577 | |
578 | 578 | // Handle add IDs |
579 | - $classname =& $context['class']; |
|
580 | - if(strpos($classname,'add_') == 0 && !class_exists($classname)) |
|
579 | + $classname = & $context['class']; |
|
580 | + if (strpos($classname, 'add_') == 0 && !class_exists($classname)) |
|
581 | 581 | { |
582 | 582 | $add = true; |
583 | 583 | $classname = substr($classname, 4); |
@@ -585,13 +585,13 @@ discard block |
||
585 | 585 | $portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec); |
586 | 586 | |
587 | 587 | $context['class'] = get_class($portlet); |
588 | - foreach($portlet->get_properties() as $property) |
|
588 | + foreach ($portlet->get_properties() as $property) |
|
589 | 589 | { |
590 | - if($values[$property['name']]) |
|
590 | + if ($values[$property['name']]) |
|
591 | 591 | { |
592 | 592 | $context[$property['name']] = $values[$property['name']]; |
593 | 593 | } |
594 | - elseif($portlets[$portlet_id][$property['name']]) |
|
594 | + elseif ($portlets[$portlet_id][$property['name']]) |
|
595 | 595 | { |
596 | 596 | $context[$property['name']] = $portlets[$portlet_id][$property['name']]; |
597 | 597 | } |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | $update = array('attributes' => $attributes); |
602 | 602 | |
603 | 603 | // New portlet? Flag going straight to edit mode |
604 | - if($add) |
|
604 | + if ($add) |
|
605 | 605 | { |
606 | 606 | $update['edit_settings'] = true; |
607 | 607 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | } |
614 | 614 | |
615 | 615 | // Save updated preferences |
616 | - $prefs->save_repository(True,$type); |
|
616 | + $prefs->save_repository(True, $type); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
@@ -626,10 +626,10 @@ discard block |
||
626 | 626 | public static function ajax_set_default($action, $portlet_ids, $group) |
627 | 627 | { |
628 | 628 | // Admins only |
629 | - if(!$GLOBALS['egw_info']['apps']['admin']) return; |
|
629 | + if (!$GLOBALS['egw_info']['apps']['admin']) return; |
|
630 | 630 | |
631 | 631 | // Load the appropriate group |
632 | - if($group) |
|
632 | + if ($group) |
|
633 | 633 | { |
634 | 634 | $prefs = new preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
635 | 635 | } |
@@ -641,30 +641,30 @@ discard block |
||
641 | 641 | |
642 | 642 | $type = is_numeric($group) ? "user" : $group; |
643 | 643 | |
644 | - if($action == 'add') |
|
644 | + if ($action == 'add') |
|
645 | 645 | { |
646 | - foreach($portlet_ids as $id) |
|
646 | + foreach ($portlet_ids as $id) |
|
647 | 647 | { |
648 | 648 | egw_json_response::get()->call('egw.message', lang("Set default")); |
649 | 649 | // Current user is setting the default, copy their settings |
650 | 650 | $settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id]; |
651 | 651 | $settings['group'] = $group; |
652 | - $prefs->add('home',$id,$settings,$type); |
|
652 | + $prefs->add('home', $id, $settings, $type); |
|
653 | 653 | |
654 | 654 | // Remove user's copy |
655 | - $GLOBALS['egw']->preferences->delete('home',$id); |
|
655 | + $GLOBALS['egw']->preferences->delete('home', $id); |
|
656 | 656 | $GLOBALS['egw']->preferences->save_repository(true); |
657 | 657 | } |
658 | 658 | } |
659 | 659 | else if ($action == "delete") |
660 | 660 | { |
661 | - foreach($portlet_ids as $id) |
|
661 | + foreach ($portlet_ids as $id) |
|
662 | 662 | { |
663 | 663 | egw_json_response::get()->call('egw.message', lang("Removed default")); |
664 | - $prefs->delete('home',$id, $type); |
|
664 | + $prefs->delete('home', $id, $type); |
|
665 | 665 | } |
666 | 666 | } |
667 | - $prefs->save_repository(false,$type); |
|
667 | + $prefs->save_repository(false, $type); |
|
668 | 668 | |
669 | 669 | // Update preferences client side for consistency |
670 | 670 | $prefs = $GLOBALS['egw']->preferences; |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | 'state' => array( |
718 | 718 | 'cat_id' => '0', |
719 | 719 | 'filter' => 'default', |
720 | - 'owner' => 0, // current user |
|
720 | + 'owner' => 0, // current user |
|
721 | 721 | 'sortby' => 'user', |
722 | 722 | 'planner_days' => '0', |
723 | 723 | 'view' => 'week', |
@@ -766,9 +766,9 @@ discard block |
||
766 | 766 | { |
767 | 767 | unset($app_prefs['home']['portlet_setup142n']); |
768 | 768 | } |
769 | - foreach($app_prefs as $app => $prefs) |
|
769 | + foreach ($app_prefs as $app => $prefs) |
|
770 | 770 | { |
771 | - foreach($prefs as $name => $value) |
|
771 | + foreach ($prefs as $name => $value) |
|
772 | 772 | { |
773 | 773 | preferences::delete_preference($app, $name, 'default'); |
774 | 774 | $preferences->add($app, $name, $value, 'default'); |
@@ -789,10 +789,10 @@ discard block |
||
789 | 789 | */ |
790 | 790 | public static function setup_default_home() |
791 | 791 | { |
792 | - switch($GLOBALS['egw_info']['server'][self::HOME_VERSION]) |
|
792 | + switch ($GLOBALS['egw_info']['server'][self::HOME_VERSION]) |
|
793 | 793 | { |
794 | 794 | case self::CURRENT_HOME_VERSION: |
795 | - return; // already up to date --> nothing to do |
|
795 | + return; // already up to date --> nothing to do |
|
796 | 796 | |
797 | 797 | default: |
798 | 798 | call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION))); |
@@ -71,7 +71,10 @@ discard block |
||
71 | 71 | { |
72 | 72 | $id = $p_data['id']; |
73 | 73 | |
74 | - if(!$id) continue; |
|
74 | + if(!$id) |
|
75 | + { |
|
76 | + continue; |
|
77 | + } |
|
75 | 78 | $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); |
76 | 79 | } |
77 | 80 | |
@@ -130,7 +133,10 @@ discard block |
||
130 | 133 | { |
131 | 134 | foreach($children['children'] as $portlet => $app_portlet) |
132 | 135 | { |
133 | - if(!is_array($app_portlet)) continue; |
|
136 | + if(!is_array($app_portlet)) |
|
137 | + { |
|
138 | + continue; |
|
139 | + } |
|
134 | 140 | $app_portlet['class'] = $portlet; |
135 | 141 | $app_portlet['id'] = 'drop_' . $app_portlet['id']; |
136 | 142 | $app_portlet['onExecute'] = $drop_execute; |
@@ -161,7 +167,10 @@ discard block |
||
161 | 167 | if(strpos($id,'portlet_') !== 0 || // Not a portlet |
162 | 168 | in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here |
163 | 169 | !is_array($context) // Not a valid portlet (probably user deleted a default) |
164 | - ) continue; |
|
170 | + ) |
|
171 | + { |
|
172 | + continue; |
|
173 | + } |
|
165 | 174 | |
166 | 175 | $classname = $context['class']; |
167 | 176 | $portlet = new $classname($context); |
@@ -176,7 +185,10 @@ discard block |
||
176 | 185 | $settings = $portlet->get_properties(); |
177 | 186 | foreach($settings as $key => $setting) |
178 | 187 | { |
179 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
188 | + if(is_array($setting) && !array_key_exists('type',$setting)) |
|
189 | + { |
|
190 | + unset($settings[$key]); |
|
191 | + } |
|
180 | 192 | } |
181 | 193 | $settings += $context; |
182 | 194 | foreach(home_portlet::$common_attributes as $attr) |
@@ -216,7 +228,10 @@ discard block |
||
216 | 228 | */ |
217 | 229 | protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false) |
218 | 230 | { |
219 | - if(!$context['class']) $context['class'] = 'home_link_portlet'; |
|
231 | + if(!$context['class']) |
|
232 | + { |
|
233 | + $context['class'] = 'home_link_portlet'; |
|
234 | + } |
|
220 | 235 | |
221 | 236 | // This should be set already, but just in case the execution path |
222 | 237 | // is different from normal... |
@@ -237,7 +252,10 @@ discard block |
||
237 | 252 | $settings = $portlet->get_properties(); |
238 | 253 | foreach($settings as $key => $setting) |
239 | 254 | { |
240 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
255 | + if(is_array($setting) && !array_key_exists('type',$setting)) |
|
256 | + { |
|
257 | + unset($settings[$key]); |
|
258 | + } |
|
241 | 259 | } |
242 | 260 | $settings += $context; |
243 | 261 | foreach(home_portlet::$common_attributes as $attr) |
@@ -301,7 +319,10 @@ discard block |
||
301 | 319 | foreach($sorted_apps as $appname) |
302 | 320 | { |
303 | 321 | // If there's already [new] settings, or no preference, skip it |
304 | - if($content[$appname]) continue; |
|
322 | + if($content[$appname]) |
|
323 | + { |
|
324 | + continue; |
|
325 | + } |
|
305 | 326 | $no_pref = true; |
306 | 327 | foreach($portal_oldvarnames as $varcheck) |
307 | 328 | { |
@@ -336,7 +357,8 @@ discard block |
||
336 | 357 | */ |
337 | 358 | protected function get_portlet_list() |
338 | 359 | { |
339 | - $list = egw_cache::getTree('home', 'portlet_classes', function() { |
|
360 | + $list = egw_cache::getTree('home', 'portlet_classes', function() |
|
361 | + { |
|
340 | 362 | $list = array(); |
341 | 363 | $classes = array(); |
342 | 364 | |
@@ -352,9 +374,15 @@ discard block |
||
352 | 374 | // Look through all known classes for portlets - for now, they need 'portlet' in the file name |
353 | 375 | foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname) |
354 | 376 | { |
355 | - if(in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
377 | + if(in_array($appname, array('phpgwapi', 'felamimail'))) |
|
378 | + { |
|
379 | + continue; |
|
380 | + } |
|
356 | 381 | $files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/'); |
357 | - if(!$files) continue; |
|
382 | + if(!$files) |
|
383 | + { |
|
384 | + continue; |
|
385 | + } |
|
358 | 386 | |
359 | 387 | foreach($files as $entry) |
360 | 388 | { |
@@ -373,7 +401,10 @@ discard block |
||
373 | 401 | } |
374 | 402 | } |
375 | 403 | |
376 | - if(!$classes[$appname]) continue; |
|
404 | + if(!$classes[$appname]) |
|
405 | + { |
|
406 | + continue; |
|
407 | + } |
|
377 | 408 | |
378 | 409 | // Build 'Add' actions for each discovered portlet. |
379 | 410 | // Portlets from other apps go in sub-actions |
@@ -407,7 +438,8 @@ discard block |
||
407 | 438 | // Filter list by current user's permissions |
408 | 439 | foreach($list as $appname => $children) |
409 | 440 | { |
410 | - if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
441 | + if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) |
|
442 | + { |
|
411 | 443 | if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
412 | 444 | { |
413 | 445 | unset($list[$appname]); |
@@ -626,7 +658,10 @@ discard block |
||
626 | 658 | public static function ajax_set_default($action, $portlet_ids, $group) |
627 | 659 | { |
628 | 660 | // Admins only |
629 | - if(!$GLOBALS['egw_info']['apps']['admin']) return; |
|
661 | + if(!$GLOBALS['egw_info']['apps']['admin']) |
|
662 | + { |
|
663 | + return; |
|
664 | + } |
|
630 | 665 | |
631 | 666 | // Load the appropriate group |
632 | 667 | if($group) |
@@ -689,7 +724,10 @@ discard block |
||
689 | 724 | $preferences = $GLOBALS['egw']->preferences; |
690 | 725 | $preferences->read_repository(); |
691 | 726 | $lang = $preferences->default['common']['lang']; |
692 | - if (empty($lang)) $lang = 'en'; |
|
727 | + if (empty($lang)) |
|
728 | + { |
|
729 | + $lang = 'en'; |
|
730 | + } |
|
693 | 731 | |
694 | 732 | translation::add_app('calendar', $lang); |
695 | 733 | $weekview = lang('Weekview'); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * Currently we only return an own infolog |
71 | 71 | * |
72 | - * @param int $account=null account_id of addressbook or null to get array of all addressbooks |
|
72 | + * @param int $account account_id of addressbook or null to get array of all addressbooks |
|
73 | 73 | * @return string|array folder name of array with int account_id => folder name pairs |
74 | 74 | */ |
75 | 75 | private function get_folders($account=null) |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * will work OK apart from that. |
184 | 184 | * |
185 | 185 | * @param string $id folder id |
186 | - * @param int $cutoffdate=null |
|
186 | + * @param int $cutoffdate |
|
187 | 187 | * @return array |
188 | 188 | */ |
189 | 189 | function GetMessageList($id, $cutoffdate=NULL) |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param string $id |
221 | 221 | * @param int $truncsize |
222 | 222 | * @param int $bodypreference |
223 | - * @param bool $mimesupport |
|
223 | + * @param integer $mimesupport |
|
224 | 224 | * @return $messageobject|boolean false on error |
225 | 225 | */ |
226 | 226 | public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
@@ -177,7 +177,7 @@ |
||
177 | 177 | * @param int $cutoffdate =null |
178 | 178 | * @param array $not_uids =null uids NOT to return for meeting requests |
179 | 179 | * @return array |
180 | - */ |
|
180 | + */ |
|
181 | 181 | function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
182 | 182 | { |
183 | 183 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | */ |
35 | 35 | static public $mapping = array( |
36 | 36 | 'body' => 'info_des', |
37 | - 'categories' => 'info_cat', // infolog supports only a single category |
|
38 | - 'complete' => 'info_status', // 0 or 1 <--> 'done', .... |
|
37 | + 'categories' => 'info_cat', // infolog supports only a single category |
|
38 | + 'complete' => 'info_status', // 0 or 1 <--> 'done', .... |
|
39 | 39 | 'datecompleted' => 'info_datecompleted', |
40 | 40 | 'duedate' => 'info_enddate', |
41 | - 'importance' => 'info_priority', // 0=Low, 1=Normal, 2=High (EGW additional 3=Urgent) |
|
42 | - 'sensitivity' => 'info_access', // 0=Normal, 1=Personal, 2=Private, 3=Confiential <--> 'public', 'private' |
|
41 | + 'importance' => 'info_priority', // 0=Low, 1=Normal, 2=High (EGW additional 3=Urgent) |
|
42 | + 'sensitivity' => 'info_access', // 0=Normal, 1=Personal, 2=Private, 3=Confiential <--> 'public', 'private' |
|
43 | 43 | 'startdate' => 'info_startdate', |
44 | 44 | 'subject' => 'info_subject', |
45 | 45 | //'recurrence' => EGroupware InfoLog does NOT support recuring tasks |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param int $account=null account_id of addressbook or null to get array of all addressbooks |
73 | 73 | * @return string|array folder name of array with int account_id => folder name pairs |
74 | 74 | */ |
75 | - private function get_folders($account=null) |
|
75 | + private function get_folders($account = null) |
|
76 | 76 | { |
77 | 77 | $folders = array( |
78 | 78 | $GLOBALS['egw_info']['user']['account_id'] => lang('InfoLog'), |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | foreach ($this->get_folders() as $account => $label) |
93 | 93 | { |
94 | 94 | $folderlist[] = array( |
95 | - 'id' => $this->backend->createID('infolog',$account), |
|
95 | + 'id' => $this->backend->createID('infolog', $account), |
|
96 | 96 | 'mod' => $label, |
97 | 97 | 'parent'=> '0', |
98 | 98 | ); |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | * @param int $cutoffdate=null |
187 | 187 | * @return array |
188 | 188 | */ |
189 | - function GetMessageList($id, $cutoffdate=NULL) |
|
189 | + function GetMessageList($id, $cutoffdate = NULL) |
|
190 | 190 | { |
191 | 191 | if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
192 | 192 | |
193 | - $this->backend->splitID($id,$type,$user); |
|
193 | + $this->backend->splitID($id, $type, $user); |
|
194 | 194 | if (!($infolog_types = $GLOBALS['egw_info']['user']['preferences']['activesync']['infolog-types'])) |
195 | 195 | { |
196 | 196 | $infolog_types = 'task'; |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | ); |
203 | 203 | |
204 | 204 | $messagelist = array(); |
205 | - if (($infologs =& $this->infolog->search($filter))) |
|
205 | + if (($infologs = & $this->infolog->search($filter))) |
|
206 | 206 | { |
207 | - foreach($infologs as $infolog) |
|
207 | + foreach ($infologs as $infolog) |
|
208 | 208 | { |
209 | 209 | $messagelist[] = $this->StatMessage($id, $infolog); |
210 | 210 | } |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | * @param bool $mimesupport |
224 | 224 | * @return $messageobject|boolean false on error |
225 | 225 | */ |
226 | - public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
226 | + public function GetMessage($folderid, $id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
227 | 227 | { |
228 | 228 | if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
229 | 229 | |
230 | - debugLog (__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); |
|
230 | + debugLog(__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); |
|
231 | 231 | $this->backend->splitID($folderid, $type, $account); |
232 | 232 | if ($type != 'infolog' || !($infolog = $this->infolog->read($id, true, 'server'))) |
233 | 233 | { |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | return false; |
236 | 236 | } |
237 | 237 | $message = new SyncTask(); |
238 | - foreach(self::$mapping as $key => $attr) |
|
238 | + foreach (self::$mapping as $key => $attr) |
|
239 | 239 | { |
240 | 240 | switch ($attr) |
241 | 241 | { |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | - if (strlen ($infolog[$attr]) > 0) |
|
251 | + if (strlen($infolog[$attr]) > 0) |
|
252 | 252 | { |
253 | 253 | debugLog("airsyncbasebody!"); |
254 | 254 | $message->airsyncbasebody = new SyncAirSyncBaseBody(); |
255 | - $message->airsyncbasenativebodytype=1; |
|
255 | + $message->airsyncbasenativebodytype = 1; |
|
256 | 256 | $this->backend->note2messagenote($infolog[$attr], $bodypreference, $message->airsyncbasebody); |
257 | 257 | } |
258 | 258 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | case 'info_cat': |
263 | 263 | $message->$key = array(); |
264 | - foreach($infolog[$attr] ? explode(',',$infolog[$attr]) : array() as $cat_id) |
|
264 | + foreach ($infolog[$attr] ? explode(',', $infolog[$attr]) : array() as $cat_id) |
|
265 | 265 | { |
266 | 266 | $message->categories[] = categories::id2name($cat_id); |
267 | 267 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | break; |
277 | 277 | |
278 | 278 | case 'info_priority': |
279 | - if ($infolog[$attr] > 2) $infolog[$attr] = 2; // AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High) |
|
279 | + if ($infolog[$attr] > 2) $infolog[$attr] = 2; // AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High) |
|
280 | 280 | // fall through |
281 | 281 | default: |
282 | 282 | if (!empty($infolog[$attr])) $message->$key = $infolog[$attr]; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | case 'info_cat': |
396 | 396 | if (is_array($message->$key)) |
397 | 397 | { |
398 | - $infolog[$attr] = implode(',', array_filter($this->infolog->find_or_add_categories($message->$key, $id),'strlen')); |
|
398 | + $infolog[$attr] = implode(',', array_filter($this->infolog->find_or_add_categories($message->$key, $id), 'strlen')); |
|
399 | 399 | } |
400 | 400 | break; |
401 | 401 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | break; |
413 | 413 | |
414 | 414 | case 'info_priority': // AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High) |
415 | - if ($infolog[$attr] == 3 && $message->$key == 2) break; // --> do NOT change Urgent, if AS reports High |
|
415 | + if ($infolog[$attr] == 3 && $message->$key == 2) break; // --> do NOT change Urgent, if AS reports High |
|
416 | 416 | // fall through |
417 | 417 | default: |
418 | 418 | $infolog[$attr] = $message->$key; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | 'info_type' => explode(',', $infolog_types), |
528 | 528 | )); |
529 | 529 | |
530 | - $changes = array(); // no change |
|
530 | + $changes = array(); // no change |
|
531 | 531 | $syncstate_was = $syncstate; |
532 | 532 | |
533 | 533 | if ($ctag !== $syncstate) |
@@ -188,7 +188,10 @@ discard block |
||
188 | 188 | */ |
189 | 189 | function GetMessageList($id, $cutoffdate=NULL) |
190 | 190 | { |
191 | - if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
|
191 | + if (!isset($this->infolog)) |
|
192 | + { |
|
193 | + $this->infolog = new infolog_bo(); |
|
194 | + } |
|
192 | 195 | |
193 | 196 | $this->backend->splitID($id,$type,$user); |
194 | 197 | if (!($infolog_types = $GLOBALS['egw_info']['user']['preferences']['activesync']['infolog-types'])) |
@@ -225,7 +228,10 @@ discard block |
||
225 | 228 | */ |
226 | 229 | public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
227 | 230 | { |
228 | - if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
|
231 | + if (!isset($this->infolog)) |
|
232 | + { |
|
233 | + $this->infolog = new infolog_bo(); |
|
234 | + } |
|
229 | 235 | |
230 | 236 | debugLog (__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)"); |
231 | 237 | $this->backend->splitID($folderid, $type, $account); |
@@ -276,10 +282,17 @@ discard block |
||
276 | 282 | break; |
277 | 283 | |
278 | 284 | case 'info_priority': |
279 | - if ($infolog[$attr] > 2) $infolog[$attr] = 2; // AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High) |
|
285 | + if ($infolog[$attr] > 2) |
|
286 | + { |
|
287 | + $infolog[$attr] = 2; |
|
288 | + } |
|
289 | + // AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High) |
|
280 | 290 | // fall through |
281 | 291 | default: |
282 | - if (!empty($infolog[$attr])) $message->$key = $infolog[$attr]; |
|
292 | + if (!empty($infolog[$attr])) |
|
293 | + { |
|
294 | + $message->$key = $infolog[$attr]; |
|
295 | + } |
|
283 | 296 | } |
284 | 297 | } |
285 | 298 | //debugLog(__METHOD__."(folder='$folderid',$id,...) returning ".array2string($message)); |
@@ -300,9 +313,15 @@ discard block |
||
300 | 313 | */ |
301 | 314 | public function StatMessage($folderid, $infolog) |
302 | 315 | { |
303 | - if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
|
316 | + if (!isset($this->infolog)) |
|
317 | + { |
|
318 | + $this->infolog = new infolog_bo(); |
|
319 | + } |
|
304 | 320 | |
305 | - if (!is_array($infolog)) $infolog = $this->infolog->read($infolog, true, 'server'); |
|
321 | + if (!is_array($infolog)) |
|
322 | + { |
|
323 | + $infolog = $this->infolog->read($infolog, true, 'server'); |
|
324 | + } |
|
306 | 325 | |
307 | 326 | if (!$infolog) |
308 | 327 | { |
@@ -370,20 +389,29 @@ discard block |
||
370 | 389 | */ |
371 | 390 | public function ChangeMessage($folderid, $id, $message) |
372 | 391 | { |
373 | - if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
|
392 | + if (!isset($this->infolog)) |
|
393 | + { |
|
394 | + $this->infolog = new infolog_bo(); |
|
395 | + } |
|
374 | 396 | |
375 | 397 | $this->backend->splitID($folderid, $type, $account); |
376 | 398 | //debugLog(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid); |
377 | - if ($type != 'infolog') // || !($infolog = $this->addressbook->read($id))) |
|
399 | + if ($type != 'infolog') |
|
400 | + { |
|
401 | + // || !($infolog = $this->addressbook->read($id))) |
|
378 | 402 | { |
379 | 403 | debugLog(__METHOD__." Folder wrong or infolog not existing"); |
404 | + } |
|
380 | 405 | return false; |
381 | 406 | } |
382 | 407 | $infolog = array(); |
383 | 408 | if (empty($id) && $this->infolog->check_access(0, EGW_ACL_EDIT, $account) || |
384 | 409 | ($infolog = $this->infolog->read($id)) && $this->infolog->check_access($infolog, EGW_ACL_EDIT)) |
385 | 410 | { |
386 | - if (!$infolog) $infolog = array(); |
|
411 | + if (!$infolog) |
|
412 | + { |
|
413 | + $infolog = array(); |
|
414 | + } |
|
387 | 415 | foreach (self::$mapping as $key => $attr) |
388 | 416 | { |
389 | 417 | switch ($attr) |
@@ -407,12 +435,19 @@ discard block |
||
407 | 435 | if ((in_array($infolog[$attr], self::$done_status) !== (boolean)$message->$key) || !isset($infolog[$attr])) |
408 | 436 | { |
409 | 437 | $infolog[$attr] = $message->$key ? 'done' : 'not-started'; |
410 | - if (!(boolean)$message->$key) $infolog['info_percent'] = 0; |
|
438 | + if (!(boolean)$message->$key) |
|
439 | + { |
|
440 | + $infolog['info_percent'] = 0; |
|
441 | + } |
|
411 | 442 | } |
412 | 443 | break; |
413 | 444 | |
414 | 445 | case 'info_priority': // AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High) |
415 | - if ($infolog[$attr] == 3 && $message->$key == 2) break; // --> do NOT change Urgent, if AS reports High |
|
446 | + if ($infolog[$attr] == 3 && $message->$key == 2) |
|
447 | + { |
|
448 | + break; |
|
449 | + } |
|
450 | + // --> do NOT change Urgent, if AS reports High |
|
416 | 451 | // fall through |
417 | 452 | default: |
418 | 453 | $infolog[$attr] = $message->$key; |
@@ -420,7 +455,10 @@ discard block |
||
420 | 455 | } |
421 | 456 | } |
422 | 457 | // $infolog['info_owner'] = $account; |
423 | - if (!empty($id)) $infolog['info_id'] = $id; |
|
458 | + if (!empty($id)) |
|
459 | + { |
|
460 | + $infolog['info_id'] = $id; |
|
461 | + } |
|
424 | 462 | $newid = $this->infolog->write($infolog); |
425 | 463 | debugLog(__METHOD__."($folderid,$id) infolog(".array2string($infolog).") returning ".array2string($newid)); |
426 | 464 | return $this->StatMessage($folderid, $newid); |
@@ -465,7 +503,10 @@ discard block |
||
465 | 503 | */ |
466 | 504 | public function DeleteMessage($folderid, $id) |
467 | 505 | { |
468 | - if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
|
506 | + if (!isset($this->infolog)) |
|
507 | + { |
|
508 | + $this->infolog = new infolog_bo(); |
|
509 | + } |
|
469 | 510 | |
470 | 511 | $ret = $this->infolog->delete($id); |
471 | 512 | debugLog(__METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -513,9 +554,15 @@ discard block |
||
513 | 554 | { |
514 | 555 | $this->backend->splitID($folderid, $type, $owner); |
515 | 556 | |
516 | - if ($type != 'infolog') return false; |
|
557 | + if ($type != 'infolog') |
|
558 | + { |
|
559 | + return false; |
|
560 | + } |
|
517 | 561 | |
518 | - if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
|
562 | + if (!isset($this->infolog)) |
|
563 | + { |
|
564 | + $this->infolog = new infolog_bo(); |
|
565 | + } |
|
519 | 566 | |
520 | 567 | if (!($infolog_types = $GLOBALS['egw_info']['user']['preferences']['activesync']['infolog-types'])) |
521 | 568 | { |
@@ -547,8 +594,14 @@ discard block |
||
547 | 594 | */ |
548 | 595 | function settings($hook_data) |
549 | 596 | { |
550 | - if (!$hook_data['setup']) translation::add_app('infolog'); |
|
551 | - if (!isset($this->infolog)) $this->infolog = new infolog_bo(); |
|
597 | + if (!$hook_data['setup']) |
|
598 | + { |
|
599 | + translation::add_app('infolog'); |
|
600 | + } |
|
601 | + if (!isset($this->infolog)) |
|
602 | + { |
|
603 | + $this->infolog = new infolog_bo(); |
|
604 | + } |
|
552 | 605 | |
553 | 606 | if (!($types = $this->infolog->enums['type'])) |
554 | 607 | { |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param array &$options |
139 | 139 | * @param array &$files |
140 | 140 | * @param int $user account_id |
141 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
141 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
142 | 142 | */ |
143 | 143 | function propfind($path,&$options,&$files,$user,$id='') |
144 | 144 | { |
@@ -217,7 +217,6 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @param string $path |
219 | 219 | * @param array $filter |
220 | - * @param array|boolean $start=false false=return all or array(start,num) |
|
221 | 220 | * @return array with "files" array with values for keys path and props |
222 | 221 | */ |
223 | 222 | function &propfind_callback($path,array $filter,$start=false) |
@@ -517,8 +516,7 @@ discard block |
||
517 | 516 | * |
518 | 517 | * @param array &$options |
519 | 518 | * @param int $id |
520 | - * @param int $user=null account_id |
|
521 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
519 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
522 | 520 | */ |
523 | 521 | function get(&$options,$id,$user=null) |
524 | 522 | { |
@@ -539,9 +537,8 @@ discard block |
||
539 | 537 | * |
540 | 538 | * @param array &$options |
541 | 539 | * @param int $id |
542 | - * @param int $user=null account_id of owner, default null |
|
543 | - * @param string $prefix=null user prefix from path (eg. /ralf from /ralf/addressbook) |
|
544 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
540 | + * @param string $prefix user prefix from path (eg. /ralf from /ralf/addressbook) |
|
541 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
545 | 542 | */ |
546 | 543 | function put(&$options,$id,$user=null,$prefix=null) |
547 | 544 | { |
@@ -609,7 +606,7 @@ discard block |
||
609 | 606 | * Callback for infolog_ical::importVTODO to implement infolog-cat-action |
610 | 607 | * |
611 | 608 | * @param array $task |
612 | - * @param array $oldTask=null |
|
609 | + * @param array $oldTask |
|
613 | 610 | * @return array modified task data |
614 | 611 | */ |
615 | 612 | public function cat_action(array $task, $oldTask=null) |
@@ -675,7 +672,7 @@ discard block |
||
675 | 672 | * |
676 | 673 | * @param array &$options |
677 | 674 | * @param int $id |
678 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
675 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
679 | 676 | */ |
680 | 677 | function delete(&$options,$id) |
681 | 678 | { |
@@ -750,7 +747,7 @@ discard block |
||
750 | 747 | * etag currently uses the modifcation time (info_datemodified), 1.9.002 adds etag column, but it's not yet used! |
751 | 748 | * |
752 | 749 | * @param array|int $info array with infolog entry or info_id |
753 | - * @return string|boolean string with etag or false |
|
750 | + * @return false|string string with etag or false |
|
754 | 751 | */ |
755 | 752 | function get_etag($info) |
756 | 753 | { |
@@ -768,10 +765,8 @@ discard block |
||
768 | 765 | /** |
769 | 766 | * Add extra properties for calendar collections |
770 | 767 | * |
771 | - * @param array $props=array() regular props by the groupdav handler |
|
772 | 768 | * @param string $displayname |
773 | - * @param string $base_uri=null base url of handler |
|
774 | - * @param int $user=null account_id of owner of collection |
|
769 | + * @param string $base_uri base url of handler |
|
775 | 770 | * @return array |
776 | 771 | */ |
777 | 772 | public function extra_properties(array $props=array(), $displayname, $base_uri=null,$user=null) |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | if ($path == '/infolog/') |
111 | 111 | { |
112 | - $task_filter= 'own'; |
|
112 | + $task_filter = 'own'; |
|
113 | 113 | } |
114 | 114 | else |
115 | 115 | { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | else |
121 | 121 | { |
122 | - $task_filter = 'user' . $user; |
|
122 | + $task_filter = 'user'.$user; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param int $user account_id |
141 | 141 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
142 | 142 | */ |
143 | - function propfind($path,&$options,&$files,$user,$id='') |
|
143 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
144 | 144 | { |
145 | 145 | // todo add a filter to limit how far back entries from the past get synced |
146 | 146 | $filter = $this->get_infolog_filter($path, $user); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | // enable time-range filter for tests via propfind / autoindex |
156 | 156 | //$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z')); |
157 | 157 | |
158 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
158 | + if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
159 | 159 | |
160 | 160 | if ($this->debug > 1) |
161 | 161 | { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | if (!($filter['calendar_data'] = $options['props'] == 'all' && |
168 | 168 | $options['root']['ns'] == groupdav::CALDAV) && is_array($options['props'])) |
169 | 169 | { |
170 | - foreach($options['props'] as $prop) |
|
170 | + foreach ($options['props'] as $prop) |
|
171 | 171 | { |
172 | 172 | if ($prop['name'] == 'calendar-data') |
173 | 173 | { |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | $this->sync_collection_token = null; |
189 | 189 | |
190 | - $filter['order'] = 'info_datemodified ASC'; // return oldest modifications first |
|
190 | + $filter['order'] = 'info_datemodified ASC'; // return oldest modifications first |
|
191 | 191 | $filter['sync-collection'] = true; |
192 | 192 | } |
193 | 193 | |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
202 | 202 | { |
203 | 203 | --$this->sync_collection_token; |
204 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
204 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | else |
208 | 208 | { |
209 | 209 | // return iterator, calling ourself to return result in chunks |
210 | - $files['files'] = new groupdav_propfind_iterator($this,$path,$filter,$files['files']); |
|
210 | + $files['files'] = new groupdav_propfind_iterator($this, $path, $filter, $files['files']); |
|
211 | 211 | } |
212 | 212 | return true; |
213 | 213 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param array|boolean $start=false false=return all or array(start,num) |
221 | 221 | * @return array with "files" array with values for keys path and props |
222 | 222 | */ |
223 | - function &propfind_callback($path,array $filter,$start=false) |
|
223 | + function &propfind_callback($path, array $filter, $start = false) |
|
224 | 224 | { |
225 | 225 | if ($this->debug) $starttime = microtime(true); |
226 | 226 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | 'filter' => $task_filter, |
247 | 247 | 'date_format' => 'server', |
248 | 248 | 'col_filter' => $filter, |
249 | - 'custom_fields' => true, // otherwise custom fields get NOT loaded! |
|
249 | + 'custom_fields' => true, // otherwise custom fields get NOT loaded! |
|
250 | 250 | ); |
251 | 251 | |
252 | 252 | if (!$calendar_data) |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | |
269 | 269 | $files = array(); |
270 | 270 | // ToDo: add parameter to only return id & etag |
271 | - $tasks =& $this->bo->search($query); |
|
271 | + $tasks = & $this->bo->search($query); |
|
272 | 272 | if ($tasks && $offset == $query['start']) |
273 | 273 | { |
274 | - foreach($tasks as $task) |
|
274 | + foreach ($tasks as $task) |
|
275 | 275 | { |
276 | 276 | // remove task from requested multiget ids, to be able to report not found urls |
277 | 277 | if ($requested_multiget_ids && ($k = array_search($task[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -285,15 +285,15 @@ discard block |
||
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | $props = array( |
288 | - 'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise |
|
288 | + 'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise |
|
289 | 289 | 'getlastmodified' => $task['info_datemodified'], |
290 | 290 | 'displayname' => $task['info_subject'], |
291 | 291 | ); |
292 | 292 | if ($calendar_data) |
293 | 293 | { |
294 | - $content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
294 | + $content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
295 | 295 | $props['getcontentlength'] = bytes($content); |
296 | - $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data',$content); |
|
296 | + $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-data', $content); |
|
297 | 297 | } |
298 | 298 | $files[] = $this->add_resource($path, $task, $props); |
299 | 299 | } |
@@ -301,13 +301,13 @@ discard block |
||
301 | 301 | // report not found multiget urls |
302 | 302 | if ($requested_multiget_ids) |
303 | 303 | { |
304 | - foreach($requested_multiget_ids as $id) |
|
304 | + foreach ($requested_multiget_ids as $id) |
|
305 | 305 | { |
306 | 306 | $files[] = array('path' => $path.$id.self::$path_extension); |
307 | 307 | } |
308 | 308 | } |
309 | 309 | // sync-collection report --> return modified of last contact as sync-token |
310 | - $sync_collection_report = $filter['sync-collection']; |
|
310 | + $sync_collection_report = $filter['sync-collection']; |
|
311 | 311 | if ($sync_collection_report) |
312 | 312 | { |
313 | 313 | $this->sync_collection_token = $task['date_modified']; |
@@ -333,20 +333,20 @@ discard block |
||
333 | 333 | * @param int &$nresult on return limit for number or results or unchanged/null |
334 | 334 | * @return boolean true if filter could be processed |
335 | 335 | */ |
336 | - function _report_filters($options,&$cal_filters,$id, &$nresults) |
|
336 | + function _report_filters($options, &$cal_filters, $id, &$nresults) |
|
337 | 337 | { |
338 | 338 | if ($options['filters']) |
339 | 339 | { |
340 | - $cal_filters_in = $cal_filters; // remember filter, to be able to reset standard open-filter, if client sets own filters |
|
340 | + $cal_filters_in = $cal_filters; // remember filter, to be able to reset standard open-filter, if client sets own filters |
|
341 | 341 | |
342 | - foreach($options['filters'] as $filter) |
|
342 | + foreach ($options['filters'] as $filter) |
|
343 | 343 | { |
344 | - switch($filter['name']) |
|
344 | + switch ($filter['name']) |
|
345 | 345 | { |
346 | 346 | case 'comp-filter': |
347 | 347 | if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
348 | 348 | |
349 | - switch($filter['attrs']['name']) |
|
349 | + switch ($filter['attrs']['name']) |
|
350 | 350 | { |
351 | 351 | case 'VTODO': |
352 | 352 | case 'VCALENDAR': |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | <B:nresults>10</B:nresults> |
390 | 390 | </B:limit> |
391 | 391 | */ |
392 | - foreach((array)$options['other'] as $option) |
|
392 | + foreach ((array)$options['other'] as $option) |
|
393 | 393 | { |
394 | - switch($option['name']) |
|
394 | + switch ($option['name']) |
|
395 | 395 | { |
396 | 396 | case 'nresults': |
397 | 397 | $nresults = (int)$option['data']; |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | case 'limit': |
401 | 401 | break; |
402 | 402 | case 'href': |
403 | - break; // from addressbook-multiget, handled below |
|
403 | + break; // from addressbook-multiget, handled below |
|
404 | 404 | // rfc 6578 sync-report |
405 | 405 | case 'sync-token': |
406 | 406 | if (!empty($option['data'])) |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $parts = explode('/', $option['data']); |
409 | 409 | $sync_token = array_pop($parts); |
410 | 410 | $cal_filters[] = 'info_datemodified>'.(int)$sync_token; |
411 | - $cal_filters['filter'] .= '+deleted'; // to return deleted entries too |
|
411 | + $cal_filters['filter'] .= '+deleted'; // to return deleted entries too |
|
412 | 412 | } |
413 | 413 | break; |
414 | 414 | case 'sync-level': |
@@ -430,24 +430,24 @@ discard block |
||
430 | 430 | if ($id) |
431 | 431 | { |
432 | 432 | $cal_filters[self::$path_attr] = groupdav_handler::$path_extension ? |
433 | - basename($id,groupdav_handler::$path_extension) : $id; |
|
433 | + basename($id, groupdav_handler::$path_extension) : $id; |
|
434 | 434 | } |
435 | 435 | else // fetch all given url's |
436 | 436 | { |
437 | - foreach($options['other'] as $option) |
|
437 | + foreach ($options['other'] as $option) |
|
438 | 438 | { |
439 | 439 | if ($option['name'] == 'href') |
440 | 440 | { |
441 | - $parts = explode('/',$option['data']); |
|
441 | + $parts = explode('/', $option['data']); |
|
442 | 442 | if (($id = basename(urldecode(array_pop($parts))))) |
443 | 443 | { |
444 | 444 | $cal_filters[self::$path_attr][] = groupdav_handler::$path_extension ? |
445 | - basename($id,groupdav_handler::$path_extension) : $id; |
|
445 | + basename($id, groupdav_handler::$path_extension) : $id; |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 | } |
449 | 449 | } |
450 | - if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
450 | + if ($this->debug > 1) error_log(__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids)); |
|
451 | 451 | } |
452 | 452 | return true; |
453 | 453 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | elseif (empty($attrs['start'])) |
476 | 476 | { |
477 | 477 | $this->groupdav->log(__METHOD__.'('.array2string($attrs).') minimum one of start or end is required!'); |
478 | - return '1'; // to not give sql error, but simply not filter out anything |
|
478 | + return '1'; // to not give sql error, but simply not filter out anything |
|
479 | 479 | } |
480 | 480 | // we dont need to care for DURATION line in rfc4791#section-9.9, as we always put that in DUE/info_enddate |
481 | 481 | |
@@ -505,10 +505,10 @@ discard block |
||
505 | 505 | "info_datecompleted > 0".(isset($start) ? " AND ($start <= info_datecompleted OR $start <= info_created)" : ''). |
506 | 506 | (isset($end) ? " AND (info_datecompleted <= $end OR info_created <= $end)" : '').' OR '. |
507 | 507 | // we have no completed date, but always a created date |
508 | - "NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : ''). |
|
508 | + "NOT info_datecompleted > 0".(isset($end) ? " AND info_created < $end" : ''). |
|
509 | 509 | ')'; |
510 | 510 | $sql = '('.implode(' OR ', $to_or).')'; |
511 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range={$filter['attrs']['start']}-{$filter['attrs']['end']} --> $sql"); |
|
511 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__.'('.array2string($attrs).") time-range={$filter['attrs']['start']}-{$filter['attrs']['end']} --> $sql"); |
|
512 | 512 | return $sql; |
513 | 513 | } |
514 | 514 | |
@@ -520,14 +520,14 @@ discard block |
||
520 | 520 | * @param int $user=null account_id |
521 | 521 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
522 | 522 | */ |
523 | - function get(&$options,$id,$user=null) |
|
523 | + function get(&$options, $id, $user = null) |
|
524 | 524 | { |
525 | - if (!is_array($task = $this->_common_get_put_delete('GET',$options,$id))) |
|
525 | + if (!is_array($task = $this->_common_get_put_delete('GET', $options, $id))) |
|
526 | 526 | { |
527 | 527 | return $task; |
528 | 528 | } |
529 | 529 | $handler = $this->_get_handler(); |
530 | - $options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
530 | + $options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
531 | 531 | $options['mimetype'] = 'text/calendar; charset=utf-8'; |
532 | 532 | header('Content-Encoding: identity'); |
533 | 533 | header('ETag: "'.$this->get_etag($task).'"'); |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | * @param string $prefix=null user prefix from path (eg. /ralf from /ralf/addressbook) |
544 | 544 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
545 | 545 | */ |
546 | - function put(&$options,$id,$user=null,$prefix=null) |
|
546 | + function put(&$options, $id, $user = null, $prefix = null) |
|
547 | 547 | { |
548 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
548 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
549 | 549 | |
550 | - $oldTask = $this->_common_get_put_delete('PUT',$options,$id); |
|
550 | + $oldTask = $this->_common_get_put_delete('PUT', $options, $id); |
|
551 | 551 | if (!is_null($oldTask) && !is_array($oldTask)) |
552 | 552 | { |
553 | 553 | return $oldTask; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | * @param array $oldTask=null |
613 | 613 | * @return array modified task data |
614 | 614 | */ |
615 | - public function cat_action(array $task, $oldTask=null) |
|
615 | + public function cat_action(array $task, $oldTask = null) |
|
616 | 616 | { |
617 | 617 | $action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action']; |
618 | 618 | |
@@ -643,13 +643,13 @@ discard block |
||
643 | 643 | { |
644 | 644 | unset($task['info_responsible'][$key]); |
645 | 645 | } |
646 | - switch($action) |
|
646 | + switch ($action) |
|
647 | 647 | { |
648 | 648 | case 'set': |
649 | 649 | $task['info_responsible'] = array(); |
650 | 650 | // fall through |
651 | 651 | case 'set-user': |
652 | - foreach($task['info_responsible'] as $key => $account_id) |
|
652 | + foreach ($task['info_responsible'] as $key => $account_id) |
|
653 | 653 | { |
654 | 654 | if ($GLOBALS['egw']->accounts->get_type($account_id) == 'u') |
655 | 655 | { |
@@ -677,9 +677,9 @@ discard block |
||
677 | 677 | * @param int $id |
678 | 678 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
679 | 679 | */ |
680 | - function delete(&$options,$id) |
|
680 | + function delete(&$options, $id) |
|
681 | 681 | { |
682 | - if (!is_array($task = $this->_common_get_put_delete('DELETE',$options,$id))) |
|
682 | + if (!is_array($task = $this->_common_get_put_delete('DELETE', $options, $id))) |
|
683 | 683 | { |
684 | 684 | return $task; |
685 | 685 | } |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | */ |
698 | 698 | function read($id) |
699 | 699 | { |
700 | - return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"),false,'server'); |
|
700 | + return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"), false, 'server'); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
@@ -720,15 +720,15 @@ discard block |
||
720 | 720 | * @param array|int $task task-array or id |
721 | 721 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
722 | 722 | */ |
723 | - function check_access($acl,$task) |
|
723 | + function check_access($acl, $task) |
|
724 | 724 | { |
725 | 725 | if (is_null($task)) return true; |
726 | 726 | |
727 | - $access = $this->bo->check_access($task,$acl); |
|
727 | + $access = $this->bo->check_access($task, $acl); |
|
728 | 728 | |
729 | 729 | if (!$access && $acl == EGW_ACL_EDIT && $this->bo->is_responsible($task)) |
730 | 730 | { |
731 | - $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
|
731 | + $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
|
732 | 732 | } |
733 | 733 | if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
734 | 734 | return $access; |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | * |
740 | 740 | * @return string |
741 | 741 | */ |
742 | - public function getctag($path,$user) |
|
742 | + public function getctag($path, $user) |
|
743 | 743 | { |
744 | 744 | return $this->bo->getctag($this->get_infolog_filter($path, $user)); |
745 | 745 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | { |
757 | 757 | if (!is_array($info)) |
758 | 758 | { |
759 | - $info = $this->bo->read($info,true,'server'); |
|
759 | + $info = $this->bo->read($info, true, 'server'); |
|
760 | 760 | } |
761 | 761 | if (!is_array($info) || !isset($info['info_id']) || !isset($info['info_datemodified'])) |
762 | 762 | { |
@@ -774,37 +774,37 @@ discard block |
||
774 | 774 | * @param int $user=null account_id of owner of collection |
775 | 775 | * @return array |
776 | 776 | */ |
777 | - public function extra_properties(array $props=array(), $displayname, $base_uri=null,$user=null) |
|
777 | + public function extra_properties(array $props = array(), $displayname, $base_uri = null, $user = null) |
|
778 | 778 | { |
779 | 779 | // calendar description |
780 | - $displayname = translation::convert(lang('Tasks of'),translation::charset(),'utf-8').' '.$displayname; |
|
781 | - $props['calendar-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-description',$displayname); |
|
780 | + $displayname = translation::convert(lang('Tasks of'), translation::charset(), 'utf-8').' '.$displayname; |
|
781 | + $props['calendar-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-description', $displayname); |
|
782 | 782 | // supported components, currently only VEVENT |
783 | - $props['supported-calendar-component-set'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-component-set',array( |
|
784 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VCALENDAR')), |
|
785 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VTODO')), |
|
783 | + $props['supported-calendar-component-set'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'supported-calendar-component-set', array( |
|
784 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'comp', array('name' => 'VCALENDAR')), |
|
785 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'comp', array('name' => 'VTODO')), |
|
786 | 786 | )); |
787 | 787 | // supported reports |
788 | 788 | $props['supported-report-set'] = array( |
789 | - 'calendar-query' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
790 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
791 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-query',''))))), |
|
792 | - 'calendar-multiget' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
793 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
794 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-multiget',''))))), |
|
789 | + 'calendar-query' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
790 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
791 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-query', ''))))), |
|
792 | + 'calendar-multiget' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
793 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
794 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-multiget', ''))))), |
|
795 | 795 | ); |
796 | 796 | // only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
797 | 797 | $config = config::read('infolog'); |
798 | 798 | if ($config['history']) |
799 | 799 | { |
800 | - $props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
801 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
802 | - HTTP_WebDAV_Server::mkprop('sync-collection',''))))); |
|
800 | + $props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
801 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
802 | + HTTP_WebDAV_Server::mkprop('sync-collection', ''))))); |
|
803 | 803 | } |
804 | 804 | // get timezone of calendar |
805 | 805 | if ($this->groupdav->prop_requested('calendar-timezone')) |
806 | 806 | { |
807 | - $props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-timezone', |
|
807 | + $props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-timezone', |
|
808 | 808 | calendar_timezones::user_timezone($user)); |
809 | 809 | } |
810 | 810 | return $props; |
@@ -818,8 +818,8 @@ discard block |
||
818 | 818 | private function _get_handler() |
819 | 819 | { |
820 | 820 | $handler = new infolog_ical(); |
821 | - $handler->tzid = false; // as we read server-time timestamps (!= null=user-time), exports UTC times |
|
822 | - $handler->setSupportedFields('GroupDAV',$this->agent); |
|
821 | + $handler->tzid = false; // as we read server-time timestamps (!= null=user-time), exports UTC times |
|
822 | + $handler->setSupportedFields('GroupDAV', $this->agent); |
|
823 | 823 | |
824 | 824 | return $handler; |
825 | 825 | } |
@@ -88,7 +88,10 @@ discard block |
||
88 | 88 | } |
89 | 89 | else |
90 | 90 | { |
91 | - if (!is_array($info)) $info = $this->bo->read($info); |
|
91 | + if (!is_array($info)) |
|
92 | + { |
|
93 | + $info = $this->bo->read($info); |
|
94 | + } |
|
92 | 95 | $name = $info[self::$path_attr]; |
93 | 96 | } |
94 | 97 | return $name.groupdav_handler::$path_extension; |
@@ -155,7 +158,11 @@ discard block |
||
155 | 158 | // enable time-range filter for tests via propfind / autoindex |
156 | 159 | //$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z')); |
157 | 160 | |
158 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
161 | + if ($id) |
|
162 | + { |
|
163 | + $path = dirname($path).'/'; |
|
164 | + } |
|
165 | + // caldav_name get's added anyway in the callback |
|
159 | 166 | |
160 | 167 | if ($this->debug > 1) |
161 | 168 | { |
@@ -222,7 +229,10 @@ discard block |
||
222 | 229 | */ |
223 | 230 | function &propfind_callback($path,array $filter,$start=false) |
224 | 231 | { |
225 | - if ($this->debug) $starttime = microtime(true); |
|
232 | + if ($this->debug) |
|
233 | + { |
|
234 | + $starttime = microtime(true); |
|
235 | + } |
|
226 | 236 | |
227 | 237 | if (($calendar_data = $filter['calendar_data'])) |
228 | 238 | { |
@@ -237,7 +247,10 @@ discard block |
||
237 | 247 | if (preg_match('/^([a-z0-9_]+)( DESC| ASC)?$/i', $filter['order'], $matches)) |
238 | 248 | { |
239 | 249 | $order = $matches[1]; |
240 | - if ($matches[2]) $sort = $matches[2]; |
|
250 | + if ($matches[2]) |
|
251 | + { |
|
252 | + $sort = $matches[2]; |
|
253 | + } |
|
241 | 254 | unset($filter['order']); |
242 | 255 | } |
243 | 256 | $query = array( |
@@ -320,7 +333,10 @@ discard block |
||
320 | 333 | --$this->sync_collection_token; |
321 | 334 | } |
322 | 335 | } |
323 | - if ($this->debug) error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
336 | + if ($this->debug) |
|
337 | + { |
|
338 | + error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
339 | + } |
|
324 | 340 | return $files; |
325 | 341 | } |
326 | 342 | |
@@ -344,7 +360,10 @@ discard block |
||
344 | 360 | switch($filter['name']) |
345 | 361 | { |
346 | 362 | case 'comp-filter': |
347 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
363 | + if ($this->debug > 1) |
|
364 | + { |
|
365 | + error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
366 | + } |
|
348 | 367 | |
349 | 368 | switch($filter['attrs']['name']) |
350 | 369 | { |
@@ -356,14 +375,23 @@ discard block |
||
356 | 375 | } |
357 | 376 | break; |
358 | 377 | case 'prop-filter': |
359 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
378 | + if ($this->debug > 1) |
|
379 | + { |
|
380 | + error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
381 | + } |
|
360 | 382 | $prop_filter = $filter['attrs']['name']; |
361 | 383 | break; |
362 | 384 | case 'text-match': |
363 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
385 | + if ($this->debug > 1) |
|
386 | + { |
|
387 | + error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
388 | + } |
|
364 | 389 | if (!isset($this->filter_prop2infolog[strtoupper($prop_filter)])) |
365 | 390 | { |
366 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
391 | + if ($this->debug) |
|
392 | + { |
|
393 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
394 | + } |
|
367 | 395 | } |
368 | 396 | else |
369 | 397 | { |
@@ -372,13 +400,19 @@ discard block |
||
372 | 400 | unset($prop_filter); |
373 | 401 | break; |
374 | 402 | case 'param-filter': |
375 | - if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
403 | + if ($this->debug) |
|
404 | + { |
|
405 | + error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
406 | + } |
|
376 | 407 | break; |
377 | 408 | case 'time-range': |
378 | 409 | $cal_filters[] = $this->_time_range_filter($filter['attrs']); |
379 | 410 | break; |
380 | 411 | default: |
381 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
412 | + if ($this->debug) |
|
413 | + { |
|
414 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
415 | + } |
|
382 | 416 | break; |
383 | 417 | } |
384 | 418 | } |
@@ -447,7 +481,10 @@ discard block |
||
447 | 481 | } |
448 | 482 | } |
449 | 483 | } |
450 | - if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
484 | + if ($this->debug > 1) |
|
485 | + { |
|
486 | + error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
487 | + } |
|
451 | 488 | } |
452 | 489 | return true; |
453 | 490 | } |
@@ -508,7 +545,10 @@ discard block |
||
508 | 545 | "NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : ''). |
509 | 546 | ')'; |
510 | 547 | $sql = '('.implode(' OR ', $to_or).')'; |
511 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range={$filter['attrs']['start']}-{$filter['attrs']['end']} --> $sql"); |
|
548 | + if ($this->debug > 1) |
|
549 | + { |
|
550 | + error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range={$filter['attrs']['start']}-{$filter['attrs']['end']} --> $sql"); |
|
551 | + } |
|
512 | 552 | return $sql; |
513 | 553 | } |
514 | 554 | |
@@ -545,7 +585,10 @@ discard block |
||
545 | 585 | */ |
546 | 586 | function put(&$options,$id,$user=null,$prefix=null) |
547 | 587 | { |
548 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
588 | + if ($this->debug) |
|
589 | + { |
|
590 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
591 | + } |
|
549 | 592 | |
550 | 593 | $oldTask = $this->_common_get_put_delete('PUT',$options,$id); |
551 | 594 | if (!is_null($oldTask) && !is_array($oldTask)) |
@@ -573,7 +616,10 @@ discard block |
||
573 | 616 | } |
574 | 617 | if (!($infoId = $handler->importVTODO($vTodo, $taskId, false, $user, null, $id, $callback_data))) |
575 | 618 | { |
576 | - if ($this->debug) error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false"); |
|
619 | + if ($this->debug) |
|
620 | + { |
|
621 | + error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false"); |
|
622 | + } |
|
577 | 623 | return '403 Forbidden'; |
578 | 624 | } |
579 | 625 | |
@@ -600,7 +646,10 @@ discard block |
||
600 | 646 | */ |
601 | 647 | public function update_tags($entry) |
602 | 648 | { |
603 | - if (!is_array($entry)) $entry = $this->read($entry); |
|
649 | + if (!is_array($entry)) |
|
650 | + { |
|
651 | + $entry = $this->read($entry); |
|
652 | + } |
|
604 | 653 | |
605 | 654 | $this->bo->write($entry, true); |
606 | 655 | } |
@@ -722,7 +771,10 @@ discard block |
||
722 | 771 | */ |
723 | 772 | function check_access($acl,$task) |
724 | 773 | { |
725 | - if (is_null($task)) return true; |
|
774 | + if (is_null($task)) |
|
775 | + { |
|
776 | + return true; |
|
777 | + } |
|
726 | 778 | |
727 | 779 | $access = $this->bo->check_access($task,$acl); |
728 | 780 | |
@@ -730,7 +782,10 @@ discard block |
||
730 | 782 | { |
731 | 783 | $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
732 | 784 | } |
733 | - if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
|
785 | + if ($this->debug > 1) |
|
786 | + { |
|
787 | + error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
|
788 | + } |
|
734 | 789 | return $access; |
735 | 790 | } |
736 | 791 |