@@ -36,46 +36,46 @@ discard block |
||
| 36 | 36 | private $export_plugins; |
| 37 | 37 | |
| 38 | 38 | public function __construct() { |
| 39 | - Framework::includeJS('.','export_dialog','importexport'); |
|
| 40 | - Framework::includeJS('.','importexport','importexport'); |
|
| 39 | + Framework::includeJS('.', 'export_dialog', 'importexport'); |
|
| 40 | + Framework::includeJS('.', 'importexport', 'importexport'); |
|
| 41 | 41 | $this->user = $GLOBALS['egw_info']['user']['user_id']; |
| 42 | - $this->export_plugins = importexport_helper_functions::get_plugins('all','export'); |
|
| 42 | + $this->export_plugins = importexport_helper_functions::get_plugins('all', 'export'); |
|
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function export_dialog($_content=array()) { |
|
| 46 | + public function export_dialog($_content = array()) { |
|
| 47 | 47 | $tabs = 'general_tab|selection_tab|options_tab'; |
| 48 | 48 | $sel_options = array(); |
| 49 | 49 | $readonlys = array(); |
| 50 | 50 | $preserv = array(); |
| 51 | 51 | |
| 52 | - $et = new Etemplate(self::_appname. '.export_dialog'); |
|
| 52 | + $et = new Etemplate(self::_appname.'.export_dialog'); |
|
| 53 | 53 | $_appname = $_content['appname'] ? $_content['appname'] : $_GET['appname']; |
| 54 | 54 | $_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition']; |
| 55 | 55 | $_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin']; |
| 56 | 56 | // Select all from context menu, means use all search results, not just selected |
| 57 | - if($_GET['select_all'] == 'true') $_GET['selection'] = 'search'; |
|
| 57 | + if ($_GET['select_all'] == 'true') $_GET['selection'] = 'search'; |
|
| 58 | 58 | $_selection = $_content['selection'] ? $_content['selection'] : $_GET['selection']; |
| 59 | - if($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true; |
|
| 59 | + if ($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true; |
|
| 60 | 60 | |
| 61 | 61 | // Check global setting |
| 62 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 62 | + if (!Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 63 | 63 | $export_limit = Api\Storage\Merge::getExportLimit($_appname); |
| 64 | - if($export_limit == 'no') { |
|
| 64 | + if ($export_limit == 'no') { |
|
| 65 | 65 | die(lang('Admin disabled exporting')); |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | //error_log(__FILE__.__FUNCTION__. '::$_GET[\'appname\']='. $_appname. ',$_GET[\'definition\']='. $_definition. ',$_GET[\'plugin\']='.$_plugin. ',$_GET[\'selection\']='.$_selection); |
| 69 | 69 | // if appname is given and valid, list available definitions (if no definition is given) |
| 70 | - $readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run',1,$_appname)); |
|
| 70 | + $readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run', 1, $_appname)); |
|
| 71 | 71 | $content['appname'] = $_appname; |
| 72 | 72 | $preserv['appname'] = $_appname; |
| 73 | - if(empty($_appname)) { |
|
| 74 | - $et->setElementAttribute('select_definition','disabled',true); |
|
| 73 | + if (empty($_appname)) { |
|
| 74 | + $et->setElementAttribute('select_definition', 'disabled', true); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // Check for preferred definition |
| 78 | - if(!$_definition && $_appname) { |
|
| 78 | + if (!$_definition && $_appname) { |
|
| 79 | 79 | $_definition = $GLOBALS['egw_info']['user']['preferences'][$_appname]['nextmatch-export-definition']; |
| 80 | 80 | } |
| 81 | 81 | // fill definitions |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | unset($definition); |
| 99 | 99 | } |
| 100 | - if(count($sel_options['definition']) == 2 && !$content['definition']) { |
|
| 100 | + if (count($sel_options['definition']) == 2 && !$content['definition']) { |
|
| 101 | 101 | $content['definition'] = end($sel_options['definition']); |
| 102 | 102 | unset($sel_options['definition']['']); |
| 103 | 103 | } |
| 104 | 104 | unset($definitions); |
| 105 | 105 | //$sel_options['definition']['expert'] = lang('Expert options'); |
| 106 | 106 | |
| 107 | - if(isset($_definition) && array_key_exists($_definition,$sel_options['definition'])) { |
|
| 107 | + if (isset($_definition) && array_key_exists($_definition, $sel_options['definition'])) { |
|
| 108 | 108 | $content['definition'] = $_definition; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | $sel_options['plugin'] = $this->export_plugins[$_appname]['export']; |
| 113 | 113 | |
| 114 | 114 | // show definitions or plugins in ui? |
| 115 | - if($content['definition'] == 'expert') { |
|
| 116 | - if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) { |
|
| 115 | + if ($content['definition'] == 'expert') { |
|
| 116 | + if (isset($_plugin) && array_key_exists($_plugin, $sel_options['plugin'])) { |
|
| 117 | 117 | $content['plugin'] = $_plugin; |
| 118 | 118 | $selected_plugin = $_plugin; |
| 119 | 119 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $readonlys['save_definition'] = true; |
| 132 | 132 | |
| 133 | 133 | $definition = new importexport_definition($content['definition']); |
| 134 | - if($definition) { |
|
| 134 | + if ($definition) { |
|
| 135 | 135 | $content += (array)$definition->plugin_options; |
| 136 | 136 | $selected_plugin = $definition->plugin; |
| 137 | 137 | $content['description'] = $definition->description; |
@@ -148,27 +148,27 @@ discard block |
||
| 148 | 148 | '|' => '|', |
| 149 | 149 | '' => lang('Other') |
| 150 | 150 | ); |
| 151 | - if(!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; |
|
| 152 | - $sel_options['delimiter'][$content['delimiter']] = lang('Use default') . ' "' . $sel_options['delimiter'][$content['delimiter']] . '"'; |
|
| 151 | + if (!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; |
|
| 152 | + $sel_options['delimiter'][$content['delimiter']] = lang('Use default').' "'.$sel_options['delimiter'][$content['delimiter']].'"'; |
|
| 153 | 153 | |
| 154 | - if(!$_content['delimiter']) $et->setElementAttribute('other_delimiter','disabled',true); |
|
| 154 | + if (!$_content['delimiter']) $et->setElementAttribute('other_delimiter', 'disabled', true); |
|
| 155 | 155 | |
| 156 | 156 | // Other delimiter (options) |
| 157 | - if($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter']; |
|
| 157 | + if ($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter']; |
|
| 158 | 158 | |
| 159 | 159 | // handle selector |
| 160 | - if($selected_plugin) { |
|
| 160 | + if ($selected_plugin) { |
|
| 161 | 161 | $content['plugin'] = $selected_plugin; |
| 162 | 162 | $plugin_object = new $selected_plugin; |
| 163 | 163 | |
| 164 | 164 | $content['description'] = $plugin_object->get_description(); |
| 165 | 165 | |
| 166 | 166 | // fill options tab |
| 167 | - if(method_exists($plugin_object, 'get_selectors_html')) { |
|
| 167 | + if (method_exists($plugin_object, 'get_selectors_html')) { |
|
| 168 | 168 | $content['plugin_options_html'] = $plugin_object->get_options_html(); |
| 169 | 169 | } else { |
| 170 | 170 | $options = $plugin_object->get_options_etpl($definition); |
| 171 | - if(is_array($options)) { |
|
| 171 | + if (is_array($options)) { |
|
| 172 | 172 | $content['plugin_options_template'] = $options['name']; |
| 173 | 173 | $content += (array)$options['content']; |
| 174 | 174 | $sel_options += (array)$options['sel_options']; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // fill selection tab |
| 184 | - if($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) { |
|
| 184 | + if ($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) { |
|
| 185 | 185 | $_selection = $definition->plugin_options['selection']; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | $preserv['selection'] = $_selection; |
| 192 | 192 | } |
| 193 | 193 | elseif ($plugin_object) { |
| 194 | - if(method_exists($plugin_object, 'get_selectors_html')) { |
|
| 194 | + if (method_exists($plugin_object, 'get_selectors_html')) { |
|
| 195 | 195 | $content['plugin_selectors_html'] = $plugin_object->get_selectors_html(); |
| 196 | 196 | } else { |
| 197 | 197 | $options = $plugin_object->get_selectors_etpl($definition); |
| 198 | - if(is_array($options)) { |
|
| 198 | + if (is_array($options)) { |
|
| 199 | 199 | $content += is_array($options['content']) ? $options['content'] : array('selection' => $options['content']); |
| 200 | 200 | $sel_options += (array)$options['sel_options']; |
| 201 | 201 | $readonlys['selection'] = (array)$options['readonlys']; |
@@ -205,12 +205,12 @@ discard block |
||
| 205 | 205 | $content['plugin_selectors_template'] = $options; |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | - if(!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) { |
|
| 208 | + if (!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) { |
|
| 209 | 209 | $readonlys[$tabs]['selection_tab'] = true; |
| 210 | 210 | } |
| 211 | 211 | $content['filter'] = (Array)$definition->filter; |
| 212 | 212 | $content['filter']['fields'] = importexport_helper_functions::get_filter_fields($_appname, $selected_plugin); |
| 213 | - if(!$content['filter']['fields']) |
|
| 213 | + if (!$content['filter']['fields']) |
|
| 214 | 214 | { |
| 215 | 215 | $content['no_filter'] = true; |
| 216 | 216 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | { |
| 229 | 229 | $content['selection'] = 'filter'; |
| 230 | 230 | } |
| 231 | - if(!$content['selection']) |
|
| 231 | + if (!$content['selection']) |
|
| 232 | 232 | { |
| 233 | 233 | $content['selection'] = 'search'; |
| 234 | 234 | } |
@@ -239,33 +239,33 @@ discard block |
||
| 239 | 239 | //error_log(__METHOD__.__LINE__.array2string($apps)); |
| 240 | 240 | if (empty($apps)) throw new Exception('Error: no application profiles available for export'); |
| 241 | 241 | if (!is_array($apps) && $apps) $apps = (array)$apps; |
| 242 | - $sel_options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
|
| 243 | - if(!$_application && !$selected_plugin) { |
|
| 242 | + $sel_options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps); |
|
| 243 | + if (!$_application && !$selected_plugin) { |
|
| 244 | 244 | $content['plugin_selectors_html'] = $content['plugin_options_html'] = |
| 245 | 245 | lang('You need to select an app and format first!'); |
| 246 | 246 | $readonlys[$tabs] = array('selection_tab' => true, 'options_tab' => true); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if($_content['preview'] || $_content['export']) |
|
| 249 | + if ($_content['preview'] || $_content['export']) |
|
| 250 | 250 | { |
| 251 | 251 | //error_log(__LINE__.__FILE__.'$_content: '.print_r($_content,true)); |
| 252 | 252 | $response = Api\Json\Response::get(); |
| 253 | 253 | |
| 254 | 254 | if ($_content['definition'] == 'expert') { |
| 255 | 255 | $definition = new importexport_definition(); |
| 256 | - $definition->definition_id = $_content['definition_id'] ? $_content['definition_id'] : ''; |
|
| 256 | + $definition->definition_id = $_content['definition_id'] ? $_content['definition_id'] : ''; |
|
| 257 | 257 | $definition->name = $_content['name'] ? $_content['name'] : ''; |
| 258 | - $definition->application = $_content['appname']; |
|
| 259 | - $definition->plugin = $_content['plugin']; |
|
| 258 | + $definition->application = $_content['appname']; |
|
| 259 | + $definition->plugin = $_content['plugin']; |
|
| 260 | 260 | $definition->type = 'export'; |
| 261 | - $definition->allowed_users = $_content['allowed_users'] ? $_content['allowed_users'] : $this->user; |
|
| 262 | - $definition->owner = $_content['owner'] ? $_content['owner'] : $this->user; |
|
| 261 | + $definition->allowed_users = $_content['allowed_users'] ? $_content['allowed_users'] : $this->user; |
|
| 262 | + $definition->owner = $_content['owner'] ? $_content['owner'] : $this->user; |
|
| 263 | 263 | } |
| 264 | 264 | else { |
| 265 | 265 | $definition = new importexport_definition($_content['definition']); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if(!is_array($definition->plugin_options)) { |
|
| 268 | + if (!is_array($definition->plugin_options)) { |
|
| 269 | 269 | $definition->plugin_options = array( |
| 270 | 270 | 'mapping' => array() |
| 271 | 271 | ); |
@@ -275,30 +275,30 @@ discard block |
||
| 275 | 275 | // Note that because not all dates are DB dates, the plugin has to handle them |
| 276 | 276 | $filter = array(); |
| 277 | 277 | $_content['filter'] = $_content['filter_html'] ? $_content['filter_html'] : $_content['filter_tpl']; |
| 278 | - if(is_array($_content['filter'])) |
|
| 278 | + if (is_array($_content['filter'])) |
|
| 279 | 279 | { |
| 280 | - foreach($_content['filter'] as $key => $value) |
|
| 280 | + foreach ($_content['filter'] as $key => $value) |
|
| 281 | 281 | { |
| 282 | 282 | // Handle multiple values |
| 283 | - if(!is_array($value) && strpos($value,',') !== false) $value = explode(',',$value); |
|
| 283 | + if (!is_array($value) && strpos($value, ',') !== false) $value = explode(',', $value); |
|
| 284 | 284 | |
| 285 | 285 | $filter[$key] = $value; |
| 286 | 286 | |
| 287 | 287 | // Skip empty values or empty ranges |
| 288 | - if($value == "" || is_null($value) || (is_array($value) && count($value) == 0) || is_array($value) && array_key_exists('from',$value) && !$value['from'] && !$value['to'] ) |
|
| 288 | + if ($value == "" || is_null($value) || (is_array($value) && count($value) == 0) || is_array($value) && array_key_exists('from', $value) && !$value['from'] && !$value['to']) |
|
| 289 | 289 | { |
| 290 | 290 | unset($filter[$key]); |
| 291 | 291 | } |
| 292 | - if(is_array($value) && array_key_exists('from', $value) && $value['from']) |
|
| 292 | + if (is_array($value) && array_key_exists('from', $value) && $value['from']) |
|
| 293 | 293 | { |
| 294 | - $filter[$key]['from'] = Api\DateTime::to($value['from'],'ts'); |
|
| 294 | + $filter[$key]['from'] = Api\DateTime::to($value['from'], 'ts'); |
|
| 295 | 295 | } |
| 296 | 296 | // If user selects an end date, they most likely want entries including that date |
| 297 | - if(is_array($value) && array_key_exists('to',$value) && $value['to'] ) |
|
| 297 | + if (is_array($value) && array_key_exists('to', $value) && $value['to']) |
|
| 298 | 298 | { |
| 299 | 299 | // Adjust time to 23:59:59 |
| 300 | 300 | $filter[$key]['to'] = new Api\DateTime($value['to']); |
| 301 | - $filter[$key]['to']->setTime(23,59,59); |
|
| 301 | + $filter[$key]['to']->setTime(23, 59, 59); |
|
| 302 | 302 | $filter[$key]['to'] = $filter[$key]['to']->format('ts'); |
| 303 | 303 | } |
| 304 | 304 | } |
@@ -312,19 +312,19 @@ discard block |
||
| 312 | 312 | $_content |
| 313 | 313 | ); |
| 314 | 314 | |
| 315 | - if(!$definition->plugin_options['selection']) { |
|
| 316 | - $response->alert( lang('No records selected')); |
|
| 315 | + if (!$definition->plugin_options['selection']) { |
|
| 316 | + $response->alert(lang('No records selected')); |
|
| 317 | 317 | return; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'export'); |
|
| 320 | + $tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'export'); |
|
| 321 | 321 | $file = fopen($tmpfname, "w+"); |
| 322 | - if (! $charset = $definition->plugin_options['charset']) { |
|
| 322 | + if (!$charset = $definition->plugin_options['charset']) { |
|
| 323 | 323 | $charset = Api\Translation::charset(); |
| 324 | 324 | } |
| 325 | - if($charset == 'user') |
|
| 325 | + if ($charset == 'user') |
|
| 326 | 326 | { |
| 327 | - switch($definition->plugin) |
|
| 327 | + switch ($definition->plugin) |
|
| 328 | 328 | { |
| 329 | 329 | case 'addressbook_export_vcard': |
| 330 | 330 | $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | $plugin_object = new $definition->plugin; |
| 337 | - $result = $plugin_object->export( $file, $definition ); |
|
| 337 | + $result = $plugin_object->export($file, $definition); |
|
| 338 | 338 | |
| 339 | - if(is_object($result) && method_exists($result, 'get_num_of_records')) |
|
| 339 | + if (is_object($result) && method_exists($result, 'get_num_of_records')) |
|
| 340 | 340 | { |
| 341 | 341 | $record_count = $result->get_num_of_records(); |
| 342 | 342 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | // Store charset to use in header |
| 345 | 345 | Api\Cache::setSession('importexport', $tmpfname, $charset, 100); |
| 346 | 346 | |
| 347 | - if($_content['export'] == 'pressed') { |
|
| 347 | + if ($_content['export'] == 'pressed') { |
|
| 348 | 348 | fclose($file); |
| 349 | 349 | $filename = pathinfo($tmpfname, PATHINFO_FILENAME); |
| 350 | 350 | $link_query = array( |
@@ -356,25 +356,25 @@ discard block |
||
| 356 | 356 | ); |
| 357 | 357 | |
| 358 | 358 | // Allow plugins to suggest a file name - return false if they have no suggestion |
| 359 | - if(method_exists($plugin_object, 'get_filename') && $plugin_filename = $plugin_object->get_filename()) |
|
| 359 | + if (method_exists($plugin_object, 'get_filename') && $plugin_filename = $plugin_object->get_filename()) |
|
| 360 | 360 | { |
| 361 | 361 | $link_query['filename'] = $plugin_filename; |
| 362 | 362 | } |
| 363 | - $response->redirect( $GLOBALS['egw']->link('/index.php',$link_query),true); |
|
| 363 | + $response->redirect($GLOBALS['egw']->link('/index.php', $link_query), true); |
|
| 364 | 364 | Framework::window_close(); |
| 365 | 365 | return; |
| 366 | 366 | } |
| 367 | - elseif($_content['preview'] == 'pressed') { |
|
| 367 | + elseif ($_content['preview'] == 'pressed') { |
|
| 368 | 368 | fseek($file, 0); |
| 369 | 369 | $item_count = 1; |
| 370 | 370 | $preview = ''; |
| 371 | - $search = array('[\016]','[\017]', |
|
| 372 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 373 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 371 | + $search = array('[\016]', '[\017]', |
|
| 372 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 373 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 374 | 374 | $replace = $preview = ''; |
| 375 | 375 | |
| 376 | - while(!feof($file) && $item_count < 30) { |
|
| 377 | - $preview .= preg_replace($search,$replace,fgets($file,1024)); |
|
| 376 | + while (!feof($file) && $item_count < 30) { |
|
| 377 | + $preview .= preg_replace($search, $replace, fgets($file, 1024)); |
|
| 378 | 378 | $item_count++; |
| 379 | 379 | } |
| 380 | 380 | |
@@ -382,12 +382,12 @@ discard block |
||
| 382 | 382 | unlink($tmpfname); |
| 383 | 383 | |
| 384 | 384 | // Convert back to system charset for display |
| 385 | - $preview = Api\Translation::convert( $preview, |
|
| 385 | + $preview = Api\Translation::convert($preview, |
|
| 386 | 386 | $charset, |
| 387 | 387 | Api\Translation::charset() |
| 388 | 388 | ); |
| 389 | 389 | |
| 390 | - $preview = "<div class='header'>".lang('Preview') . "<span class='count'>".(int)$record_count."</span></div>".$preview; |
|
| 390 | + $preview = "<div class='header'>".lang('Preview')."<span class='count'>".(int)$record_count."</span></div>".$preview; |
|
| 391 | 391 | |
| 392 | 392 | $et->setElementAttribute('preview-box', 'value', nl2br($preview)); |
| 393 | 393 | return; |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $readonlys[$tabs]['selection'] = false; |
| 400 | 400 | } |
| 401 | 401 | //error_log(print_r($content,true)); |
| 402 | - return $et->exec(self::_appname. '.importexport_export_ui.export_dialog',$content,$sel_options,$readonlys,$preserv,2); |
|
| 402 | + return $et->exec(self::_appname.'.importexport_export_ui.export_dialog', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | public function ajax_get_definition_description($_definition) { |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | } |
| 415 | 415 | unset ($_object); |
| 416 | 416 | } |
| 417 | - $_response->assign('importexport-export_dialog_plugin_description','innerHTML',$description); |
|
| 417 | + $_response->assign('importexport-export_dialog_plugin_description', 'innerHTML', $description); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | public function ajax_get_plugin_description($_plugin) { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | if (is_a($plugin_object, 'importexport_iface_export_plugin')) { |
| 425 | 425 | $description = $plugin_object->get_description(); |
| 426 | 426 | } |
| 427 | - $_response->addAssign('importexport-export_dialog_plugin_description','innerHTML',$description); |
|
| 427 | + $_response->addAssign('importexport-export_dialog_plugin_description', 'innerHTML', $description); |
|
| 428 | 428 | |
| 429 | 429 | unset ($plugin_object); |
| 430 | 430 | } |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | public function download($_tmpfname = '') { |
| 439 | 439 | $tmpfname = $_tmpfname ? $_tmpfname : $_GET['_filename']; |
| 440 | - $tmpfname = $GLOBALS['egw_info']['server']['temp_dir'] .'/'. $tmpfname; |
|
| 440 | + $tmpfname = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpfname; |
|
| 441 | 441 | if (!is_readable($tmpfname)) die(); |
| 442 | 442 | |
| 443 | 443 | $appname = $_GET['_appname']; |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | // Turn off all output buffering |
| 447 | 447 | while (@ob_end_clean()); |
| 448 | 448 | |
| 449 | - $file = fopen($tmpfname,'rb'); |
|
| 449 | + $file = fopen($tmpfname, 'rb'); |
|
| 450 | 450 | |
| 451 | 451 | // Get charset |
| 452 | 452 | $charset = Api\Cache::getSession('importexport', $tmpfname); |
| 453 | 453 | |
| 454 | 454 | Api\Header\Content::type($nicefname.'.'.$_GET['_suffix'], |
| 455 | - ($_GET['_type'] ? $_GET['_type'] : 'application/text') . ($charset ? '; charset='.$charset : ''), |
|
| 455 | + ($_GET['_type'] ? $_GET['_type'] : 'application/text').($charset ? '; charset='.$charset : ''), |
|
| 456 | 456 | filesize($tmpfname)); |
| 457 | 457 | fpassthru($file); |
| 458 | 458 | |
@@ -18,7 +18,8 @@ discard block |
||
| 18 | 18 | * userinterface for exports |
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | -class importexport_export_ui { |
|
| 21 | +class importexport_export_ui |
|
| 22 | +{ |
|
| 22 | 23 | const _appname = 'importexport'; |
| 23 | 24 | |
| 24 | 25 | public $public_functions = array( |
@@ -35,7 +36,8 @@ discard block |
||
| 35 | 36 | */ |
| 36 | 37 | private $export_plugins; |
| 37 | 38 | |
| 38 | - public function __construct() { |
|
| 39 | + public function __construct() |
|
| 40 | + { |
|
| 39 | 41 | Framework::includeJS('.','export_dialog','importexport'); |
| 40 | 42 | Framework::includeJS('.','importexport','importexport'); |
| 41 | 43 | $this->user = $GLOBALS['egw_info']['user']['user_id']; |
@@ -43,7 +45,8 @@ discard block |
||
| 43 | 45 | |
| 44 | 46 | } |
| 45 | 47 | |
| 46 | - public function export_dialog($_content=array()) { |
|
| 48 | + public function export_dialog($_content=array()) |
|
| 49 | + { |
|
| 47 | 50 | $tabs = 'general_tab|selection_tab|options_tab'; |
| 48 | 51 | $sel_options = array(); |
| 49 | 52 | $readonlys = array(); |
@@ -54,14 +57,22 @@ discard block |
||
| 54 | 57 | $_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition']; |
| 55 | 58 | $_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin']; |
| 56 | 59 | // Select all from context menu, means use all search results, not just selected |
| 57 | - if($_GET['select_all'] == 'true') $_GET['selection'] = 'search'; |
|
| 60 | + if($_GET['select_all'] == 'true') |
|
| 61 | + { |
|
| 62 | + $_GET['selection'] = 'search'; |
|
| 63 | + } |
|
| 58 | 64 | $_selection = $_content['selection'] ? $_content['selection'] : $_GET['selection']; |
| 59 | - if($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true; |
|
| 65 | + if($_GET['selection'] || $_content['selection_passed']) |
|
| 66 | + { |
|
| 67 | + $content['selection_passed'] = $preserv['selection_passed'] = true; |
|
| 68 | + } |
|
| 60 | 69 | |
| 61 | 70 | // Check global setting |
| 62 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 71 | + if(!Api\Storage\Merge::is_export_limit_excepted()) |
|
| 72 | + { |
|
| 63 | 73 | $export_limit = Api\Storage\Merge::getExportLimit($_appname); |
| 64 | - if($export_limit == 'no') { |
|
| 74 | + if($export_limit == 'no') |
|
| 75 | + { |
|
| 65 | 76 | die(lang('Admin disabled exporting')); |
| 66 | 77 | } |
| 67 | 78 | } |
@@ -70,12 +81,14 @@ discard block |
||
| 70 | 81 | $readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run',1,$_appname)); |
| 71 | 82 | $content['appname'] = $_appname; |
| 72 | 83 | $preserv['appname'] = $_appname; |
| 73 | - if(empty($_appname)) { |
|
| 84 | + if(empty($_appname)) |
|
| 85 | + { |
|
| 74 | 86 | $et->setElementAttribute('select_definition','disabled',true); |
| 75 | 87 | } |
| 76 | 88 | |
| 77 | 89 | // Check for preferred definition |
| 78 | - if(!$_definition && $_appname) { |
|
| 90 | + if(!$_definition && $_appname) |
|
| 91 | + { |
|
| 79 | 92 | $_definition = $GLOBALS['egw_info']['user']['preferences'][$_appname]['nextmatch-export-definition']; |
| 80 | 93 | } |
| 81 | 94 | // fill definitions |
@@ -85,26 +98,31 @@ discard block |
||
| 85 | 98 | 'application' => isset($content['appname']) ? $content['appname'] : '*', |
| 86 | 99 | 'plugin' => $_plugin ? $_plugin : '*' |
| 87 | 100 | )); |
| 88 | - foreach ((array)$definitions->get_definitions() as $identifier) { |
|
| 101 | + foreach ((array)$definitions->get_definitions() as $identifier) |
|
| 102 | + { |
|
| 89 | 103 | try { |
| 90 | 104 | $definition = new importexport_definition($identifier); |
| 91 | - } catch (Exception $e) { |
|
| 105 | + } |
|
| 106 | + catch (Exception $e) { |
|
| 92 | 107 | // permission error |
| 93 | 108 | continue; |
| 94 | 109 | } |
| 95 | - if ($title = $definition->get_title()) { |
|
| 110 | + if ($title = $definition->get_title()) |
|
| 111 | + { |
|
| 96 | 112 | $sel_options['definition'][$definition->get_identifier()] = $title; |
| 97 | 113 | } |
| 98 | 114 | unset($definition); |
| 99 | 115 | } |
| 100 | - if(count($sel_options['definition']) == 2 && !$content['definition']) { |
|
| 116 | + if(count($sel_options['definition']) == 2 && !$content['definition']) |
|
| 117 | + { |
|
| 101 | 118 | $content['definition'] = end($sel_options['definition']); |
| 102 | 119 | unset($sel_options['definition']['']); |
| 103 | 120 | } |
| 104 | 121 | unset($definitions); |
| 105 | 122 | //$sel_options['definition']['expert'] = lang('Expert options'); |
| 106 | 123 | |
| 107 | - if(isset($_definition) && array_key_exists($_definition,$sel_options['definition'])) { |
|
| 124 | + if(isset($_definition) && array_key_exists($_definition,$sel_options['definition'])) |
|
| 125 | + { |
|
| 108 | 126 | $content['definition'] = $_definition; |
| 109 | 127 | } |
| 110 | 128 | |
@@ -112,8 +130,10 @@ discard block |
||
| 112 | 130 | $sel_options['plugin'] = $this->export_plugins[$_appname]['export']; |
| 113 | 131 | |
| 114 | 132 | // show definitions or plugins in ui? |
| 115 | - if($content['definition'] == 'expert') { |
|
| 116 | - if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) { |
|
| 133 | + if($content['definition'] == 'expert') |
|
| 134 | + { |
|
| 135 | + if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) |
|
| 136 | + { |
|
| 117 | 137 | $content['plugin'] = $_plugin; |
| 118 | 138 | $selected_plugin = $_plugin; |
| 119 | 139 | } |
@@ -126,12 +146,14 @@ discard block |
||
| 126 | 146 | */ |
| 127 | 147 | } |
| 128 | 148 | } |
| 129 | - else { |
|
| 149 | + else |
|
| 150 | + { |
|
| 130 | 151 | $readonlys['plugin'] = true; |
| 131 | 152 | $readonlys['save_definition'] = true; |
| 132 | 153 | |
| 133 | 154 | $definition = new importexport_definition($content['definition']); |
| 134 | - if($definition) { |
|
| 155 | + if($definition) |
|
| 156 | + { |
|
| 135 | 157 | $content += (array)$definition->plugin_options; |
| 136 | 158 | $selected_plugin = $definition->plugin; |
| 137 | 159 | $content['description'] = $definition->description; |
@@ -148,64 +170,90 @@ discard block |
||
| 148 | 170 | '|' => '|', |
| 149 | 171 | '' => lang('Other') |
| 150 | 172 | ); |
| 151 | - if(!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; |
|
| 173 | + if(!$sel_options['delimiter'][$content['delimiter']]) |
|
| 174 | + { |
|
| 175 | + $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; |
|
| 176 | + } |
|
| 152 | 177 | $sel_options['delimiter'][$content['delimiter']] = lang('Use default') . ' "' . $sel_options['delimiter'][$content['delimiter']] . '"'; |
| 153 | 178 | |
| 154 | - if(!$_content['delimiter']) $et->setElementAttribute('other_delimiter','disabled',true); |
|
| 179 | + if(!$_content['delimiter']) |
|
| 180 | + { |
|
| 181 | + $et->setElementAttribute('other_delimiter','disabled',true); |
|
| 182 | + } |
|
| 155 | 183 | |
| 156 | 184 | // Other delimiter (options) |
| 157 | - if($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter']; |
|
| 185 | + if($_content['other_delimiter']) |
|
| 186 | + { |
|
| 187 | + $_content['delimiter'] = $_content['other_delimiter']; |
|
| 188 | + } |
|
| 158 | 189 | |
| 159 | 190 | // handle selector |
| 160 | - if($selected_plugin) { |
|
| 191 | + if($selected_plugin) |
|
| 192 | + { |
|
| 161 | 193 | $content['plugin'] = $selected_plugin; |
| 162 | 194 | $plugin_object = new $selected_plugin; |
| 163 | 195 | |
| 164 | 196 | $content['description'] = $plugin_object->get_description(); |
| 165 | 197 | |
| 166 | 198 | // fill options tab |
| 167 | - if(method_exists($plugin_object, 'get_selectors_html')) { |
|
| 199 | + if(method_exists($plugin_object, 'get_selectors_html')) |
|
| 200 | + { |
|
| 168 | 201 | $content['plugin_options_html'] = $plugin_object->get_options_html(); |
| 169 | - } else { |
|
| 202 | + } |
|
| 203 | + else |
|
| 204 | + { |
|
| 170 | 205 | $options = $plugin_object->get_options_etpl($definition); |
| 171 | - if(is_array($options)) { |
|
| 206 | + if(is_array($options)) |
|
| 207 | + { |
|
| 172 | 208 | $content['plugin_options_template'] = $options['name']; |
| 173 | 209 | $content += (array)$options['content']; |
| 174 | 210 | $sel_options += (array)$options['sel_options']; |
| 175 | 211 | $readonlys += (array)$options['readonlys']; |
| 176 | 212 | $preserv += (array)$options['preserv']; |
| 177 | - } else { |
|
| 213 | + } |
|
| 214 | + else |
|
| 215 | + { |
|
| 178 | 216 | $content['plugin_options_template'] = $options; |
| 179 | 217 | } |
| 180 | 218 | } |
| 181 | 219 | } |
| 182 | 220 | |
| 183 | 221 | // fill selection tab |
| 184 | - if($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) { |
|
| 222 | + if($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) |
|
| 223 | + { |
|
| 185 | 224 | $_selection = $definition->plugin_options['selection']; |
| 186 | 225 | } |
| 187 | 226 | |
| 188 | - if ($_selection && ($content['old_definition'] == $content['definition'] || $content['selection_passed'])) { |
|
| 227 | + if ($_selection && ($content['old_definition'] == $content['definition'] || $content['selection_passed'])) |
|
| 228 | + { |
|
| 189 | 229 | $readonlys[$tabs]['selection_tab'] = true; |
| 190 | 230 | $content['selection'] = $_selection; |
| 191 | 231 | $preserv['selection'] = $_selection; |
| 192 | 232 | } |
| 193 | - elseif ($plugin_object) { |
|
| 194 | - if(method_exists($plugin_object, 'get_selectors_html')) { |
|
| 233 | + elseif ($plugin_object) |
|
| 234 | + { |
|
| 235 | + if(method_exists($plugin_object, 'get_selectors_html')) |
|
| 236 | + { |
|
| 195 | 237 | $content['plugin_selectors_html'] = $plugin_object->get_selectors_html(); |
| 196 | - } else { |
|
| 238 | + } |
|
| 239 | + else |
|
| 240 | + { |
|
| 197 | 241 | $options = $plugin_object->get_selectors_etpl($definition); |
| 198 | - if(is_array($options)) { |
|
| 242 | + if(is_array($options)) |
|
| 243 | + { |
|
| 199 | 244 | $content += is_array($options['content']) ? $options['content'] : array('selection' => $options['content']); |
| 200 | 245 | $sel_options += (array)$options['sel_options']; |
| 201 | 246 | $readonlys['selection'] = (array)$options['readonlys']; |
| 202 | 247 | $preserv['selection'] = (array)$options['preserv']; |
| 203 | 248 | $content['plugin_selectors_template'] = $options['name']; |
| 204 | - } else { |
|
| 249 | + } |
|
| 250 | + else |
|
| 251 | + { |
|
| 205 | 252 | $content['plugin_selectors_template'] = $options; |
| 206 | 253 | } |
| 207 | 254 | } |
| 208 | - if(!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) { |
|
| 255 | + if(!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) |
|
| 256 | + { |
|
| 209 | 257 | $readonlys[$tabs]['selection_tab'] = true; |
| 210 | 258 | } |
| 211 | 259 | $content['filter'] = (Array)$definition->filter; |
@@ -237,10 +285,17 @@ discard block |
||
| 237 | 285 | unset ($plugin_object); |
| 238 | 286 | $apps = importexport_helper_functions::get_apps('export'); |
| 239 | 287 | //error_log(__METHOD__.__LINE__.array2string($apps)); |
| 240 | - if (empty($apps)) throw new Exception('Error: no application profiles available for export'); |
|
| 241 | - if (!is_array($apps) && $apps) $apps = (array)$apps; |
|
| 288 | + if (empty($apps)) |
|
| 289 | + { |
|
| 290 | + throw new Exception('Error: no application profiles available for export'); |
|
| 291 | + } |
|
| 292 | + if (!is_array($apps) && $apps) |
|
| 293 | + { |
|
| 294 | + $apps = (array)$apps; |
|
| 295 | + } |
|
| 242 | 296 | $sel_options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
| 243 | - if(!$_application && !$selected_plugin) { |
|
| 297 | + if(!$_application && !$selected_plugin) |
|
| 298 | + { |
|
| 244 | 299 | $content['plugin_selectors_html'] = $content['plugin_options_html'] = |
| 245 | 300 | lang('You need to select an app and format first!'); |
| 246 | 301 | $readonlys[$tabs] = array('selection_tab' => true, 'options_tab' => true); |
@@ -251,7 +306,8 @@ discard block |
||
| 251 | 306 | //error_log(__LINE__.__FILE__.'$_content: '.print_r($_content,true)); |
| 252 | 307 | $response = Api\Json\Response::get(); |
| 253 | 308 | |
| 254 | - if ($_content['definition'] == 'expert') { |
|
| 309 | + if ($_content['definition'] == 'expert') |
|
| 310 | + { |
|
| 255 | 311 | $definition = new importexport_definition(); |
| 256 | 312 | $definition->definition_id = $_content['definition_id'] ? $_content['definition_id'] : ''; |
| 257 | 313 | $definition->name = $_content['name'] ? $_content['name'] : ''; |
@@ -261,11 +317,13 @@ discard block |
||
| 261 | 317 | $definition->allowed_users = $_content['allowed_users'] ? $_content['allowed_users'] : $this->user; |
| 262 | 318 | $definition->owner = $_content['owner'] ? $_content['owner'] : $this->user; |
| 263 | 319 | } |
| 264 | - else { |
|
| 320 | + else |
|
| 321 | + { |
|
| 265 | 322 | $definition = new importexport_definition($_content['definition']); |
| 266 | 323 | } |
| 267 | 324 | |
| 268 | - if(!is_array($definition->plugin_options)) { |
|
| 325 | + if(!is_array($definition->plugin_options)) |
|
| 326 | + { |
|
| 269 | 327 | $definition->plugin_options = array( |
| 270 | 328 | 'mapping' => array() |
| 271 | 329 | ); |
@@ -280,7 +338,10 @@ discard block |
||
| 280 | 338 | foreach($_content['filter'] as $key => $value) |
| 281 | 339 | { |
| 282 | 340 | // Handle multiple values |
| 283 | - if(!is_array($value) && strpos($value,',') !== false) $value = explode(',',$value); |
|
| 341 | + if(!is_array($value) && strpos($value,',') !== false) |
|
| 342 | + { |
|
| 343 | + $value = explode(',',$value); |
|
| 344 | + } |
|
| 284 | 345 | |
| 285 | 346 | $filter[$key] = $value; |
| 286 | 347 | |
@@ -312,14 +373,16 @@ discard block |
||
| 312 | 373 | $_content |
| 313 | 374 | ); |
| 314 | 375 | |
| 315 | - if(!$definition->plugin_options['selection']) { |
|
| 376 | + if(!$definition->plugin_options['selection']) |
|
| 377 | + { |
|
| 316 | 378 | $response->alert( lang('No records selected')); |
| 317 | 379 | return; |
| 318 | 380 | } |
| 319 | 381 | |
| 320 | 382 | $tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'export'); |
| 321 | 383 | $file = fopen($tmpfname, "w+"); |
| 322 | - if (! $charset = $definition->plugin_options['charset']) { |
|
| 384 | + if (! $charset = $definition->plugin_options['charset']) |
|
| 385 | + { |
|
| 323 | 386 | $charset = Api\Translation::charset(); |
| 324 | 387 | } |
| 325 | 388 | if($charset == 'user') |
@@ -344,7 +407,8 @@ discard block |
||
| 344 | 407 | // Store charset to use in header |
| 345 | 408 | Api\Cache::setSession('importexport', $tmpfname, $charset, 100); |
| 346 | 409 | |
| 347 | - if($_content['export'] == 'pressed') { |
|
| 410 | + if($_content['export'] == 'pressed') |
|
| 411 | + { |
|
| 348 | 412 | fclose($file); |
| 349 | 413 | $filename = pathinfo($tmpfname, PATHINFO_FILENAME); |
| 350 | 414 | $link_query = array( |
@@ -364,7 +428,8 @@ discard block |
||
| 364 | 428 | Framework::window_close(); |
| 365 | 429 | return; |
| 366 | 430 | } |
| 367 | - elseif($_content['preview'] == 'pressed') { |
|
| 431 | + elseif($_content['preview'] == 'pressed') |
|
| 432 | + { |
|
| 368 | 433 | fseek($file, 0); |
| 369 | 434 | $item_count = 1; |
| 370 | 435 | $preview = ''; |
@@ -373,7 +438,8 @@ discard block |
||
| 373 | 438 | '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
| 374 | 439 | $replace = $preview = ''; |
| 375 | 440 | |
| 376 | - while(!feof($file) && $item_count < 30) { |
|
| 441 | + while(!feof($file) && $item_count < 30) |
|
| 442 | + { |
|
| 377 | 443 | $preview .= preg_replace($search,$replace,fgets($file,1024)); |
| 378 | 444 | $item_count++; |
| 379 | 445 | } |
@@ -394,7 +460,9 @@ discard block |
||
| 394 | 460 | } |
| 395 | 461 | //nothing else expected! |
| 396 | 462 | throw new Exception('Error: unexpected submit in export_dialog!'); |
| 397 | - } else { |
|
| 463 | + } |
|
| 464 | + else |
|
| 465 | + { |
|
| 398 | 466 | $readonlys[$tabs]['selection'] = true; |
| 399 | 467 | $readonlys[$tabs]['selection'] = false; |
| 400 | 468 | } |
@@ -402,14 +470,16 @@ discard block |
||
| 402 | 470 | return $et->exec(self::_appname. '.importexport_export_ui.export_dialog',$content,$sel_options,$readonlys,$preserv,2); |
| 403 | 471 | } |
| 404 | 472 | |
| 405 | - public function ajax_get_definition_description($_definition) { |
|
| 473 | + public function ajax_get_definition_description($_definition) |
|
| 474 | + { |
|
| 406 | 475 | |
| 407 | 476 | $_response = Api\Json\Response::get(); |
| 408 | 477 | $description = ''; |
| 409 | 478 | if ($_definition) |
| 410 | 479 | { |
| 411 | 480 | $_object = new importexport_definition($_definition); |
| 412 | - if (is_a($_object, 'importexport_definition')) { |
|
| 481 | + if (is_a($_object, 'importexport_definition')) |
|
| 482 | + { |
|
| 413 | 483 | $description = $_object->description; |
| 414 | 484 | } |
| 415 | 485 | unset ($_object); |
@@ -417,11 +487,13 @@ discard block |
||
| 417 | 487 | $_response->assign('importexport-export_dialog_plugin_description','innerHTML',$description); |
| 418 | 488 | } |
| 419 | 489 | |
| 420 | - public function ajax_get_plugin_description($_plugin) { |
|
| 490 | + public function ajax_get_plugin_description($_plugin) |
|
| 491 | + { |
|
| 421 | 492 | $_respone = Api\Json\Response::get(); |
| 422 | 493 | |
| 423 | 494 | $plugin_object = new $_plugin; |
| 424 | - if (is_a($plugin_object, 'importexport_iface_export_plugin')) { |
|
| 495 | + if (is_a($plugin_object, 'importexport_iface_export_plugin')) |
|
| 496 | + { |
|
| 425 | 497 | $description = $plugin_object->get_description(); |
| 426 | 498 | } |
| 427 | 499 | $_response->addAssign('importexport-export_dialog_plugin_description','innerHTML',$description); |
@@ -435,10 +507,14 @@ discard block |
||
| 435 | 507 | * @param sting $_tmpfname |
| 436 | 508 | * @todo we need a suffix atibute in plugins e.g. .csv |
| 437 | 509 | */ |
| 438 | - public function download($_tmpfname = '') { |
|
| 510 | + public function download($_tmpfname = '') |
|
| 511 | + { |
|
| 439 | 512 | $tmpfname = $_tmpfname ? $_tmpfname : $_GET['_filename']; |
| 440 | 513 | $tmpfname = $GLOBALS['egw_info']['server']['temp_dir'] .'/'. $tmpfname; |
| 441 | - if (!is_readable($tmpfname)) die(); |
|
| 514 | + if (!is_readable($tmpfname)) |
|
| 515 | + { |
|
| 516 | + die(); |
|
| 517 | + } |
|
| 442 | 518 | |
| 443 | 519 | $appname = $_GET['_appname']; |
| 444 | 520 | $nicefname = $_GET['filename'] ? $_GET['filename'] : 'egw_export_'.$appname.'-'.date('Y-m-d'); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param boolean $clear_includes =false true: clear all previous includes |
| 35 | 35 | * @return boolean false: css file not found, true: file found |
| 36 | 36 | */ |
| 37 | - public static function add($app, $name=null, $append=true, $clear_includes=false) |
|
| 37 | + public static function add($app, $name = null, $append = true, $clear_includes = false) |
|
| 38 | 38 | { |
| 39 | 39 | if ($clear_includes) |
| 40 | 40 | { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | if (!is_null($name)) |
| 45 | 45 | { |
| 46 | - foreach($GLOBALS['egw']->framework->template_dirs as $dir) |
|
| 46 | + foreach ($GLOBALS['egw']->framework->template_dirs as $dir) |
|
| 47 | 47 | { |
| 48 | 48 | if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/templates/'.$dir.'/'.$name.'.css'))) |
| 49 | 49 | { |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $path = $app; |
| 57 | 57 | } |
| 58 | - if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT . parse_url($path,PHP_URL_PATH))) |
|
| 58 | + if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT.parse_url($path, PHP_URL_PATH))) |
|
| 59 | 59 | { |
| 60 | 60 | //error_log(__METHOD__."($app,$name) $path NOT found!"); |
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | - if (!in_array($path,self::$files)) |
|
| 63 | + if (!in_array($path, self::$files)) |
|
| 64 | 64 | { |
| 65 | 65 | if ($append) |
| 66 | 66 | { |
@@ -79,16 +79,16 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - public static function get($resolve=false) |
|
| 82 | + public static function get($resolve = false) |
|
| 83 | 83 | { |
| 84 | 84 | if (!$resolve) |
| 85 | 85 | { |
| 86 | 86 | return self::$files; |
| 87 | 87 | } |
| 88 | 88 | $files = array(); |
| 89 | - foreach(self::$files as $path) |
|
| 89 | + foreach (self::$files as $path) |
|
| 90 | 90 | { |
| 91 | - foreach(self::resolve_css_includes($path) as $path) |
|
| 91 | + foreach (self::resolve_css_includes($path) as $path) |
|
| 92 | 92 | { |
| 93 | 93 | $files[] = $path; |
| 94 | 94 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | $base_path = $GLOBALS['egw_info']['server']['webserver_url']; |
| 110 | 110 | if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH); |
| 111 | 111 | $css_files = ''; |
| 112 | - foreach(self::$files as $path) |
|
| 112 | + foreach (self::$files as $path) |
|
| 113 | 113 | { |
| 114 | - foreach(self::resolve_css_includes($path) as $path) |
|
| 114 | + foreach (self::resolve_css_includes($path) as $path) |
|
| 115 | 115 | { |
| 116 | - list($file,$query) = explode('?',$path,2); |
|
| 116 | + list($file, $query) = explode('?', $path, 2); |
|
| 117 | 117 | if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod; |
| 118 | 118 | |
| 119 | 119 | // do NOT include app.css or categories.php, as it changes from app to app |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css |
| 148 | 148 | * @return array parsed pathes (EGroupware relative) including $path itself |
| 149 | 149 | */ |
| 150 | - protected static function resolve_css_includes($path, &$pathes=array()) |
|
| 150 | + protected static function resolve_css_includes($path, &$pathes = array()) |
|
| 151 | 151 | { |
| 152 | 152 | $matches = null; |
| 153 | 153 | |
| 154 | - list($file) = explode('?',$path,2); |
|
| 155 | - if (($to_check = file_get_contents (EGW_SERVER_ROOT.$file, false, null, 0, 1024)) && |
|
| 154 | + list($file) = explode('?', $path, 2); |
|
| 155 | + if (($to_check = file_get_contents(EGW_SERVER_ROOT.$file, false, null, 0, 1024)) && |
|
| 156 | 156 | stripos($to_check, '/*@import') !== false && preg_match_all('|/\*@import url\("([^"]+)"|i', $to_check, $matches)) |
| 157 | 157 | { |
| 158 | - foreach($matches[1] as $import_path) |
|
| 158 | + foreach ($matches[1] as $import_path) |
|
| 159 | 159 | { |
| 160 | 160 | if ($import_path[0] != '/') |
| 161 | 161 | { |
| 162 | 162 | $dir = dirname($path); |
| 163 | - while(substr($import_path,0,3) == '../') |
|
| 163 | + while (substr($import_path, 0, 3) == '../') |
|
| 164 | 164 | { |
| 165 | 165 | $dir = dirname($dir); |
| 166 | 166 | $import_path = substr($import_path, 3); |