From 9786f03980306c4ca5844f47a54f0096f076937d Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 26 Apr 2011 20:30:26 +0000 Subject: [PATCH] Add a link to list of spreadsheets available for merging into --- ...rtexport_admin_prefs_sidebox_hooks.inc.php | 73 ++++++++++++++++--- importexport/setup/etemplates.inc.php | 4 +- 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/importexport/inc/class.importexport_admin_prefs_sidebox_hooks.inc.php b/importexport/inc/class.importexport_admin_prefs_sidebox_hooks.inc.php index e63f3d8c19..f264201109 100644 --- a/importexport/inc/class.importexport_admin_prefs_sidebox_hooks.inc.php +++ b/importexport/inc/class.importexport_admin_prefs_sidebox_hooks.inc.php @@ -16,6 +16,11 @@ if (!defined('IMPORTEXPORT_APP')) class importexport_admin_prefs_sidebox_hooks { + + public $public_functions = array( + 'spreadsheet_list' => true + ); + static function all_hooks($args) { $appname = IMPORTEXPORT_APP; @@ -124,17 +129,16 @@ class importexport_admin_prefs_sidebox_hooks 'text' => 'Export CSV' ); } - /* - if($GLOBALS['egw_info']['user']['apps']['filemanager']) { - $file['Export Spreadsheet'] = array('link' => egw::link('/index.php',array( - 'menuaction' => 'filemanager.filemanager_ui.index', - ),false)."','_blank',850,440,'yes')", - //'icon' => 'filemanager/navbar', - 'app' => 'filemanager', - 'text' => 'Export Spreadsheet' - ); - } - */ + + $file['Export Spreadsheet'] = array('link' => egw::link('/index.php',array( + 'menuaction' => 'importexport.importexport_admin_prefs_sidebox_hooks.spreadsheet_list', + 'app' => $appname + )), + //'icon' => 'filemanager/navbar', + 'app' => 'importexport', + 'text' => 'Export Spreadsheet' + ); + $config = config::read('importexport'); if($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) && count(importexport_helper_functions::get_plugins($appname)) > 0 @@ -146,4 +150,51 @@ class importexport_admin_prefs_sidebox_hooks } if($file) display_sidebox($appname,lang('importexport'),$file); } + + public function spreadsheet_list() { + $config = config::read('importexport'); + $config_dirs = $config['export_spreadsheet_folder'] ? explode(',',$config['export_spreadsheet_folder']) : array('user','stylite'); + $appname = $_GET['app']; + $stylite_dir = '/stylite/templates/merge'; + $dir_list = array(); + $file_list = array(); + $mimes = array( + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + ); + + if(in_array('user', $config_dirs)) { + $dir_list[] = $GLOBALS['egw_info']['user']['preferences'][$appname]['document_dir']; + } + if(in_array('stylite', $config_dirs) && is_dir($stylite_dir)) { + $dir_list[] = $stylite_dir; + } + + foreach($dir_list as $dir) { + if ($dir && ($files = egw_vfs::find($dir,array( + 'need_mime' => true, + 'order' => 'fs_name', + 'sort' => 'ASC', + ),true))) + { + foreach($files as $file) { + if($dir != $GLOBALS['egw_info']['user']['preferences'][$appname]['document_dir']) { + // Stylite files have a naming convention that must be adhered to + list($export, $application, $name) = explode('-', $file['name'], 3); + } + if(($dir == $GLOBALS['egw_info']['user']['preferences'][$appname]['document_dir'] || ($export == 'export' && $application == $appname)) && in_array($file['mime'], $mimes)) { + $file_list[] = array( + 'name' => $name ? $name : $file['name'], + 'path' => $file['path'], + 'mime' => $file['mime'] + ); + } + } + } + } + + $GLOBALS['egw_info']['flags']['app_header'] = lang('Export (merge) spreadsheets'); + $tmpl = new etemplate('importexport.spreadsheet_list'); + $tmpl->exec('importexport.importexport_admin_hooks.spreadsheet_list', array('files' => $file_list)); + } } diff --git a/importexport/setup/etemplates.inc.php b/importexport/setup/etemplates.inc.php index 84fd2878a5..abdb6d8391 100644 --- a/importexport/setup/etemplates.inc.php +++ b/importexport/setup/etemplates.inc.php @@ -2,7 +2,7 @@ /** * eGroupWare - eTemplates for Application importexport * http://www.egroupware.org - * generated by soetemplate::dump4setup() 2011-04-20 08:17 + * generated by soetemplate::dump4setup() 2011-04-26 14:29 * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package importexport @@ -66,6 +66,8 @@ $templ_data[] = array('name' => 'importexport.schedule_edit','template' => '','l $templ_data[] = array('name' => 'importexport.schedule_index','template' => '','lang' => '','group' => '0','version' => '1.7.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:1:{s:2:"h1";s:6:",!@msg";}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:4:"@msg";}}i:2;a:1:{s:1:"A";a:6:{s:4:"type";s:4:"grid";s:4:"name";s:9:"scheduled";s:7:"options";a:0:{}s:4:"data";a:3:{i:0;a:2:{s:2:"c1";s:2:"th";s:2:"c2";s:4:",top";}i:1;a:8:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Type";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Plugin";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:10:"Definition";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Target";}s:1:"F";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Last Run";}s:1:"G";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:6:"2,,0,0";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Next Run";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Schedule";}}s:1:"H";a:1:{s:4:"type";s:5:"label";}}i:2;a:8:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[type]";}s:1:"B";a:3:{s:4:"type";s:10:"select-app";s:4:"name";s:15:"${row}[appname]";s:8:"readonly";s:1:"1";}s:1:"C";a:4:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:14:"${row}[plugin]";s:8:"readonly";s:1:"1";}s:1:"D";a:3:{s:4:"type";s:6:"select";s:4:"name";s:18:"${row}[definition]";s:8:"readonly";s:1:"1";}s:1:"E";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:14:"${row}[target]";}s:1:"F";a:6:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"4";i:1;a:3:{s:4:"type";s:9:"date-time";s:4:"name";s:16:"${row}[last_run]";s:8:"readonly";s:1:"1";}i:2;a:3:{s:4:"type";s:5:"label";s:4:"name";s:20:"${row}[record_count]";s:7:"no_lang";s:1:"1";}i:3;a:3:{s:4:"type";s:5:"label";s:4:"name";s:14:"${row}[result]";s:7:"no_lang";s:1:"1";}i:4;a:2:{s:4:"type";s:5:"label";s:4:"name";s:14:"${row}[errors]";}}s:1:"G";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:6:"2,,0,0";i:1;a:3:{s:4:"type";s:9:"date-time";s:4:"name";s:12:"${row}[next]";s:8:"readonly";s:1:"1";}i:2;a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:13:"${row}[times]";}}s:1:"H";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:6:"2,,0,0";i:1;a:4:{s:4:"type";s:6:"button";s:4:"size";s:4:"edit";s:4:"name";s:21:"edit[${row_cont[id]}]";s:7:"onclick";s:198:"window.open(egw::link(\'/index.php\',\'menuaction=importexport.importexport_schedule_ui.edit&id={$row_cont[id]}\'),\'_blank\',\'dependent=yes,width=600,height=450,scrollbars=yes,status=yes\'); return false;";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"size";s:6:"delete";s:4:"name";s:23:"delete[{$row_cont[id]}]";}}}}s:4:"rows";i:2;s:4:"cols";i:8;}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"1";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"add";s:4:"name";s:3:"add";s:7:"onclick";s:179:"window.open(egw::link(\'/index.php\',\'menuaction=importexport.importexport_schedule_ui.edit\'),\'_blank\',\'dependent=yes,width=600,height=450,scrollbars=yes,status=yes\'); return false;";}}}}s:4:"rows";i:3;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1267034207',); +$templ_data[] = array('name' => 'importexport.spreadsheet_list','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}i:2;a:1:{s:1:"A";a:6:{s:4:"type";s:4:"grid";s:4:"name";s:5:"files";s:7:"options";a:0:{}s:4:"data";a:2:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:8:"vfs-mime";s:4:"name";s:6:"${row}";}s:1:"B";a:2:{s:4:"type";s:3:"vfs";s:4:"name";s:6:"${row}";}}}s:4:"rows";i:1;s:4:"cols";i:2;}}}s:4:"rows";i:2;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1303847340',); + $templ_data[] = array('name' => 'importexport.wizardbox','template' => '','lang' => '','group' => '0','version' => '0.0.1','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:3:{s:2:"c2";s:7:",bottom";s:2:"c1";s:4:",top";s:1:"A";s:4:"100%";}i:1;a:1:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:7:"no_lang";s:1:"1";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:4:"hbox";s:7:"no_lang";s:1:"1";s:4:"size";s:1:"1";i:1;a:3:{s:4:"type";s:5:"image";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"importexport";}}i:2;a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";i:1;a:2:{s:4:"type";s:8:"template";s:4:"name";s:14:"wizard_content";}s:4:"span";s:15:",wizard_content";}}}i:2;a:1:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";s:4:"span";s:3:"all";i:1;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:4:{s:4:"type";s:6:"button";s:4:"name";s:16:"button[previous]";s:5:"label";s:8:"previous";s:7:"onclick";s:37:"xajax_eT_wrapper(this); return false;";}i:2;a:4:{s:4:"type";s:6:"button";s:4:"name";s:12:"button[next]";s:5:"label";s:4:"next";s:7:"onclick";s:37:"xajax_eT_wrapper(this); return false;";}i:3;a:4:{s:4:"type";s:6:"button";s:4:"name";s:14:"button[finish]";s:5:"label";s:6:"finish";s:7:"onclick";s:37:"xajax_eT_wrapper(this); return false;";}}i:2;a:5:{s:4:"type";s:6:"button";s:4:"name";s:14:"button[cancel]";s:5:"label";s:6:"cancel";s:7:"onclick";s:29:"window.close(); return false;";s:5:"align";s:5:"right";}s:5:"align";s:5:"right";}}}s:4:"rows";i:2;s:4:"cols";i:1;s:4:"size";s:4:",400";s:7:"options";a:1:{i:1;s:3:"400";}}}','size' => ',400','style' => '.wizard_content fieldset { height: 347px; width: 250px;