@@ -20,9 +20,9 @@ |
||
| 20 | 20 | 'name' => 'eGroupware core team', |
| 21 | 21 | 'email' => '[email protected]' |
| 22 | 22 | ); |
| 23 | -$setup_info['importexport']['autoinstall'] = true; // install automatically on update |
|
| 23 | +$setup_info['importexport']['autoinstall'] = true; // install automatically on update |
|
| 24 | 24 | |
| 25 | -$setup_info['importexport']['license'] = 'GPL'; |
|
| 25 | +$setup_info['importexport']['license'] = 'GPL'; |
|
| 26 | 26 | $setup_info['importexport']['description'] = |
| 27 | 27 | ''; |
| 28 | 28 | $setup_info['importexport']['note'] = |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | /* Dependencies for this app to work */ |
| 38 | 38 | $setup_info['importexport']['depends'][] = array( |
| 39 | 39 | 'appname' => 'api', |
| 40 | - 'versions' => Array('16.1') |
|
| 40 | + 'versions' => array('16.1') |
|
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | // installation checks for importexport |
@@ -12,15 +12,15 @@ |
||
| 12 | 12 | $phpgw_baseline = array( |
| 13 | 13 | 'egw_importexport_definitions' => array( |
| 14 | 14 | 'fd' => array( |
| 15 | - 'definition_id' => array('type' => 'auto','nullable' => False), |
|
| 16 | - 'name' => array('type' => 'varchar','precision' => '255'), |
|
| 17 | - 'application' => array('type' => 'varchar','precision' => '50'), |
|
| 18 | - 'plugin' => array('type' => 'varchar','precision' => '100'), |
|
| 19 | - 'type' => array('type' => 'varchar','precision' => '20'), |
|
| 20 | - 'allowed_users' => array('type' => 'varchar','meta' => 'account-commasep','precision' => '255'), |
|
| 15 | + 'definition_id' => array('type' => 'auto', 'nullable' => False), |
|
| 16 | + 'name' => array('type' => 'varchar', 'precision' => '255'), |
|
| 17 | + 'application' => array('type' => 'varchar', 'precision' => '50'), |
|
| 18 | + 'plugin' => array('type' => 'varchar', 'precision' => '100'), |
|
| 19 | + 'type' => array('type' => 'varchar', 'precision' => '20'), |
|
| 20 | + 'allowed_users' => array('type' => 'varchar', 'meta' => 'account-commasep', 'precision' => '255'), |
|
| 21 | 21 | 'plugin_options' => array('type' => 'longtext'), |
| 22 | - 'owner' => array('type' => 'int','meta' => 'account','precision' => '4'), |
|
| 23 | - 'description' => array('type' => 'varchar','precision' => '255'), |
|
| 22 | + 'owner' => array('type' => 'int', 'meta' => 'account', 'precision' => '4'), |
|
| 23 | + 'description' => array('type' => 'varchar', 'precision' => '255'), |
|
| 24 | 24 | 'modified' => array('type' => 'timestamp'), |
| 25 | 25 | 'filter' => array('type' => 'longtext') |
| 26 | 26 | ), |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | function importexport_upgrade0_002() |
| 15 | 15 | { |
| 16 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_importexport_definitions','description',array( |
|
| 16 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_importexport_definitions', 'description', array( |
|
| 17 | 17 | 'type' => 'varchar', |
| 18 | 18 | 'precision' => '255' |
| 19 | 19 | )); |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | function importexport_upgrade1_8() |
| 46 | 46 | { |
| 47 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_importexport_definitions','definition_id',array( |
|
| 47 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_importexport_definitions', 'definition_id', array( |
|
| 48 | 48 | 'type' => 'auto', |
| 49 | 49 | 'nullable' => False |
| 50 | 50 | )); |
| 51 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_importexport_definitions','modified',array( |
|
| 51 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_importexport_definitions', 'modified', array( |
|
| 52 | 52 | 'type' => 'timestamp' |
| 53 | 53 | )); |
| 54 | 54 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | function importexport_upgrade1_9_002() |
| 65 | 65 | { |
| 66 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_importexport_definitions','filter',array( |
|
| 66 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_importexport_definitions', 'filter', array( |
|
| 67 | 67 | 'type' => 'longtext' |
| 68 | 68 | )); |
| 69 | 69 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | // import i/e defintions |
| 75 | 75 | if (extension_loaded('dom')) |
| 76 | 76 | { |
| 77 | - require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.importexport_definitions_bo.inc.php'); |
|
| 77 | + require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.importexport_definitions_bo.inc.php'); |
|
| 78 | 78 | |
| 79 | 79 | // This sets up $GLOBALS['egw']->accounts and $GLOBALS['egw']->db |
| 80 | 80 | $GLOBALS['egw_setup']->setup_account_object(); |
@@ -82,18 +82,18 @@ discard block |
||
| 82 | 82 | // step through every source code intstalled app |
| 83 | 83 | $egwdir = dir(EGW_INCLUDE_ROOT); |
| 84 | 84 | while (false !== ($appdir = $egwdir->read())) { |
| 85 | - $defdir = EGW_INCLUDE_ROOT. "/$appdir/setup/"; |
|
| 86 | - if ( !is_dir( $defdir ) ) continue; |
|
| 85 | + $defdir = EGW_INCLUDE_ROOT."/$appdir/setup/"; |
|
| 86 | + if (!is_dir($defdir)) continue; |
|
| 87 | 87 | |
| 88 | 88 | // step through each file in defdir of app |
| 89 | 89 | $d = dir($defdir); |
| 90 | 90 | while (false !== ($entry = $d->read())) { |
| 91 | 91 | try |
| 92 | 92 | { |
| 93 | - $file = $defdir. '/'. $entry; |
|
| 94 | - list( $filename, $extension) = explode('.',$entry); |
|
| 95 | - if ( $extension != 'xml' ) continue; |
|
| 96 | - importexport_definitions_bo::import( $file ); |
|
| 93 | + $file = $defdir.'/'.$entry; |
|
| 94 | + list($filename, $extension) = explode('.', $entry); |
|
| 95 | + if ($extension != 'xml') continue; |
|
| 96 | + importexport_definitions_bo::import($file); |
|
| 97 | 97 | } |
| 98 | 98 | catch (Exception $e) |
| 99 | 99 | { |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | // give Default and Admins group rights for ImportExport |
| 107 | - foreach(array('Default' => 'Default','Admins' => 'Admin') as $account_lid => $name) |
|
| 107 | + foreach (array('Default' => 'Default', 'Admins' => 'Admin') as $account_lid => $name) |
|
| 108 | 108 | { |
| 109 | - $account_id = $GLOBALS['egw_setup']->add_account($account_lid,$name,'Group',False,False); |
|
| 110 | - $GLOBALS['egw_setup']->add_acl('importexport','run',$account_id); |
|
| 109 | + $account_id = $GLOBALS['egw_setup']->add_account($account_lid, $name, 'Group', False, False); |
|
| 110 | + $GLOBALS['egw_setup']->add_acl('importexport', 'run', $account_id); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | return $GLOBALS['setup_info']['importexport']['currentver'] = '1.9.004'; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | function importexport_upgrade1_9_003() |
| 117 | 117 | { |
| 118 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_importexport_definitions','filter',array( |
|
| 118 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_importexport_definitions', 'filter', array( |
|
| 119 | 119 | 'type' => 'longtext' |
| 120 | 120 | )); |
| 121 | 121 | |
@@ -81,18 +81,26 @@ |
||
| 81 | 81 | |
| 82 | 82 | // step through every source code intstalled app |
| 83 | 83 | $egwdir = dir(EGW_INCLUDE_ROOT); |
| 84 | - while (false !== ($appdir = $egwdir->read())) { |
|
| 84 | + while (false !== ($appdir = $egwdir->read())) |
|
| 85 | + { |
|
| 85 | 86 | $defdir = EGW_INCLUDE_ROOT. "/$appdir/setup/"; |
| 86 | - if ( !is_dir( $defdir ) ) continue; |
|
| 87 | + if ( !is_dir( $defdir ) ) |
|
| 88 | + { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 87 | 91 | |
| 88 | 92 | // step through each file in defdir of app |
| 89 | 93 | $d = dir($defdir); |
| 90 | - while (false !== ($entry = $d->read())) { |
|
| 94 | + while (false !== ($entry = $d->read())) |
|
| 95 | + { |
|
| 91 | 96 | try |
| 92 | 97 | { |
| 93 | 98 | $file = $defdir. '/'. $entry; |
| 94 | 99 | list( $filename, $extension) = explode('.',$entry); |
| 95 | - if ( $extension != 'xml' ) continue; |
|
| 100 | + if ( $extension != 'xml' ) |
|
| 101 | + { |
|
| 102 | + continue; |
|
| 103 | + } |
|
| 96 | 104 | importexport_definitions_bo::import( $file ); |
| 97 | 105 | } |
| 98 | 106 | catch (Exception $e) |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | if (!extension_loaded('dom')) |
| 13 | 13 | { |
| 14 | 14 | echo "<p>Required PHP DOM extension missing, installation of ImportExport definitions aborted.</p>\n"; |
| 15 | - return; // otherwise we mess up the whole eGroupware install process |
|
| 15 | + return; // otherwise we mess up the whole eGroupware install process |
|
| 16 | 16 | } |
| 17 | -require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.importexport_definitions_bo.inc.php'); |
|
| 17 | +require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.importexport_definitions_bo.inc.php'); |
|
| 18 | 18 | |
| 19 | 19 | // This sets up $GLOBALS['egw']->accounts and $GLOBALS['egw']->db |
| 20 | 20 | $GLOBALS['egw_setup']->setup_account_object(); |
@@ -22,22 +22,22 @@ discard block |
||
| 22 | 22 | // step through every source code intstalled app |
| 23 | 23 | $egwdir = dir(EGW_INCLUDE_ROOT); |
| 24 | 24 | while (false !== ($appdir = $egwdir->read())) { |
| 25 | - $defdir = EGW_INCLUDE_ROOT. "/$appdir/setup/"; |
|
| 26 | - if ( !is_dir( $defdir ) ) continue; |
|
| 25 | + $defdir = EGW_INCLUDE_ROOT."/$appdir/setup/"; |
|
| 26 | + if (!is_dir($defdir)) continue; |
|
| 27 | 27 | |
| 28 | 28 | // step through each file in defdir of app |
| 29 | 29 | $d = dir($defdir); |
| 30 | 30 | while (false !== ($entry = $d->read())) { |
| 31 | - $file = $defdir. '/'. $entry; |
|
| 32 | - list( $filename, $extension) = explode('.',$entry); |
|
| 33 | - if ( $extension != 'xml' ) continue; |
|
| 34 | - importexport_definitions_bo::import( $file ); |
|
| 31 | + $file = $defdir.'/'.$entry; |
|
| 32 | + list($filename, $extension) = explode('.', $entry); |
|
| 33 | + if ($extension != 'xml') continue; |
|
| 34 | + importexport_definitions_bo::import($file); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // give Default and Admins group rights for ImportExport |
| 39 | -foreach(array('Default' => 'Default','Admins' => 'Admin') as $account_lid => $name) |
|
| 39 | +foreach (array('Default' => 'Default', 'Admins' => 'Admin') as $account_lid => $name) |
|
| 40 | 40 | { |
| 41 | - $account_id = $GLOBALS['egw_setup']->add_account($account_lid,$name,'Group',False,False); |
|
| 42 | - $GLOBALS['egw_setup']->add_acl('importexport','run',$account_id); |
|
| 41 | + $account_id = $GLOBALS['egw_setup']->add_account($account_lid, $name, 'Group', False, False); |
|
| 42 | + $GLOBALS['egw_setup']->add_acl('importexport', 'run', $account_id); |
|
| 43 | 43 | } |
@@ -21,16 +21,24 @@ |
||
| 21 | 21 | |
| 22 | 22 | // step through every source code intstalled app |
| 23 | 23 | $egwdir = dir(EGW_INCLUDE_ROOT); |
| 24 | -while (false !== ($appdir = $egwdir->read())) { |
|
| 24 | +while (false !== ($appdir = $egwdir->read())) |
|
| 25 | +{ |
|
| 25 | 26 | $defdir = EGW_INCLUDE_ROOT. "/$appdir/setup/"; |
| 26 | - if ( !is_dir( $defdir ) ) continue; |
|
| 27 | + if ( !is_dir( $defdir ) ) |
|
| 28 | + { |
|
| 29 | + continue; |
|
| 30 | + } |
|
| 27 | 31 | |
| 28 | 32 | // step through each file in defdir of app |
| 29 | 33 | $d = dir($defdir); |
| 30 | - while (false !== ($entry = $d->read())) { |
|
| 34 | + while (false !== ($entry = $d->read())) |
|
| 35 | + { |
|
| 31 | 36 | $file = $defdir. '/'. $entry; |
| 32 | 37 | list( $filename, $extension) = explode('.',$entry); |
| 33 | - if ( $extension != 'xml' ) continue; |
|
| 38 | + if ( $extension != 'xml' ) |
|
| 39 | + { |
|
| 40 | + continue; |
|
| 41 | + } |
|
| 34 | 42 | importexport_definitions_bo::import( $file ); |
| 35 | 43 | } |
| 36 | 44 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | if (!defined('IMPORTEXPORT_APP')) |
| 16 | 16 | { |
| 17 | - define('IMPORTEXPORT_APP','importexport'); |
|
| 17 | + define('IMPORTEXPORT_APP', 'importexport'); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | class importexport_admin_prefs_sidebox_hooks |
@@ -35,40 +35,40 @@ discard block |
||
| 35 | 35 | array( |
| 36 | 36 | 'text' => 'Import', |
| 37 | 37 | 'link' => "javascript:egw_openWindowCentered2('". |
| 38 | - Egw::link('/index.php','menuaction=importexport.importexport_import_ui.import_dialog',false). |
|
| 38 | + Egw::link('/index.php', 'menuaction=importexport.importexport_import_ui.import_dialog', false). |
|
| 39 | 39 | "','_blank',850,440,'yes')", |
| 40 | 40 | 'icon' => 'import' |
| 41 | 41 | ), |
| 42 | 42 | ); |
| 43 | 43 | $export_limit = Api\Storage\Merge::getExportLimit($appname); |
| 44 | 44 | //error_log(__METHOD__.__LINE__.' app:'.$appname.' limit:'.$export_limit); |
| 45 | - if(Api\Storage\Merge::is_export_limit_excepted() || $export_limit !== 'no') |
|
| 45 | + if (Api\Storage\Merge::is_export_limit_excepted() || $export_limit !== 'no') |
|
| 46 | 46 | { |
| 47 | 47 | $file[] = array( |
| 48 | 48 | 'text' => 'Export', |
| 49 | 49 | 'link' => "javascript:egw_openWindowCentered2('". |
| 50 | - Egw::link('/index.php','menuaction=importexport.importexport_export_ui.export_dialog',false). |
|
| 50 | + Egw::link('/index.php', 'menuaction=importexport.importexport_export_ui.export_dialog', false). |
|
| 51 | 51 | "','_blank',850,440,'yes')", |
| 52 | 52 | 'icon' => 'export' |
| 53 | 53 | ); |
| 54 | 54 | } |
| 55 | 55 | $config = Api\Config::read($appname); |
| 56 | - if($config['users_create_definitions']) |
|
| 56 | + if ($config['users_create_definitions']) |
|
| 57 | 57 | { |
| 58 | - $file['Define imports|exports'] = Egw::link('/index.php',array( |
|
| 58 | + $file['Define imports|exports'] = Egw::link('/index.php', array( |
|
| 59 | 59 | 'menuaction' => 'importexport.importexport_definitions_ui.index', |
| 60 | 60 | 'ajax' => 'true' |
| 61 | - ),$GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
|
| 61 | + ), $GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
|
| 62 | 62 | } |
| 63 | - display_sidebox($appname,lang($appname),$file); |
|
| 63 | + display_sidebox($appname, lang($appname), $file); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
| 67 | 67 | { |
| 68 | 68 | $file = Array( |
| 69 | - 'Site Configuration' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.site_config'), |
|
| 70 | - 'Import definitions' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.import_definition'), |
|
| 71 | - 'Define imports|exports' => Egw::link('/index.php',array( |
|
| 69 | + 'Site Configuration' => Egw::link('/index.php', 'menuaction=importexport.importexport_definitions_ui.site_config'), |
|
| 70 | + 'Import definitions' => Egw::link('/index.php', 'menuaction=importexport.importexport_definitions_ui.import_definition'), |
|
| 71 | + 'Define imports|exports' => Egw::link('/index.php', array( |
|
| 72 | 72 | 'menuaction' => 'importexport.importexport_definitions_ui.index', |
| 73 | 73 | 'ajax' => 'true' |
| 74 | 74 | )), |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | ); |
| 79 | 79 | if ($location == 'admin') |
| 80 | 80 | { |
| 81 | - display_section($appname,$file); |
|
| 81 | + display_section($appname, $file); |
|
| 82 | 82 | } |
| 83 | 83 | else |
| 84 | 84 | { |
| 85 | - display_sidebox($appname,lang('Admin'),$file); |
|
| 85 | + display_sidebox($appname, lang('Admin'), $file); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | * Called from framework so Import / Export can add links into other apps' sidebox. |
| 92 | 92 | */ |
| 93 | 93 | public static function other_apps() { |
| 94 | - if(!$GLOBALS['egw_info']['user']['apps']['importexport']) return array(); |
|
| 95 | - if($GLOBALS['egw_info']['flags']['no_importexport'] === true) return array(); |
|
| 94 | + if (!$GLOBALS['egw_info']['user']['apps']['importexport']) return array(); |
|
| 95 | + if ($GLOBALS['egw_info']['flags']['no_importexport'] === true) return array(); |
|
| 96 | 96 | |
| 97 | 97 | $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 98 | 98 | $cache = Api\Cache::getCache(Api\Cache::SESSION, 'importexport', 'sidebox_links'); |
| 99 | 99 | |
| 100 | - if(!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) { |
|
| 100 | + if (!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) { |
|
| 101 | 101 | $cache[$appname]['import'] = importexport_helper_functions::has_definitions($appname, 'import'); |
| 102 | 102 | $cache[$appname]['export'] = importexport_helper_functions::has_definitions($appname, 'export'); |
| 103 | 103 | Api\Cache::setCache(Api\Cache::SESSION, 'importexport', 'sidebox_links', $cache); |
@@ -106,51 +106,51 @@ discard block |
||
| 106 | 106 | // Add in import / export, if available |
| 107 | 107 | $file = array(); |
| 108 | 108 | $plugins = importexport_helper_functions::get_plugins($appname); |
| 109 | - if($cache[$appname]['import']) |
|
| 109 | + if ($cache[$appname]['import']) |
|
| 110 | 110 | { |
| 111 | 111 | $file['Import CSV'] = array('link' => "javascript:egw_openWindowCentered2('". |
| 112 | - Egw::link('/index.php',array( |
|
| 112 | + Egw::link('/index.php', array( |
|
| 113 | 113 | 'menuaction' => 'importexport.importexport_import_ui.import_dialog', |
| 114 | 114 | 'appname'=>$appname |
| 115 | - ),false)."','_blank',850,440,'yes')", |
|
| 115 | + ), false)."','_blank',850,440,'yes')", |
|
| 116 | 116 | 'icon' => 'import', |
| 117 | 117 | 'app' => 'importexport', |
| 118 | 118 | 'text' => in_array($appname, array('sitemgr')) || count($plugins[$appname]['import']) > 1 ? 'Import' : 'Import CSV' |
| 119 | 119 | ); |
| 120 | - if($GLOBALS['egw_info']['flags']['disable_importexport']['import']) { |
|
| 120 | + if ($GLOBALS['egw_info']['flags']['disable_importexport']['import']) { |
|
| 121 | 121 | $file['Import CSV']['link'] = ''; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | $export_limit = Api\Storage\Merge::getExportLimit($appname); |
| 125 | 125 | //error_log(__METHOD__.__LINE__.' app:'.$appname.' limit:'.$export_limit); |
| 126 | - if ((Api\Storage\Merge::is_export_limit_excepted() || Api\Storage\Merge::hasExportLimit($export_limit,'ISALLOWED')) && $cache[$appname]['export']) |
|
| 126 | + if ((Api\Storage\Merge::is_export_limit_excepted() || Api\Storage\Merge::hasExportLimit($export_limit, 'ISALLOWED')) && $cache[$appname]['export']) |
|
| 127 | 127 | { |
| 128 | 128 | $file['Export CSV'] = array('link' => "javascript:egw_openWindowCentered2('". |
| 129 | - Egw::link('/index.php',array( |
|
| 129 | + Egw::link('/index.php', array( |
|
| 130 | 130 | 'menuaction' => 'importexport.importexport_export_ui.export_dialog', |
| 131 | 131 | 'appname'=>$appname |
| 132 | - ),false)."','_blank',850,440,'yes')", |
|
| 132 | + ), false)."','_blank',850,440,'yes')", |
|
| 133 | 133 | 'icon' => 'export', |
| 134 | 134 | 'app' => 'importexport', |
| 135 | 135 | 'text' => in_array($appname, array('sitemgr')) || count($plugins[$appname]['export']) > 1 ? 'Export' : 'Export CSV' |
| 136 | 136 | ); |
| 137 | - if($GLOBALS['egw_info']['flags']['disable_importexport']['export']) { |
|
| 137 | + if ($GLOBALS['egw_info']['flags']['disable_importexport']['export']) { |
|
| 138 | 138 | $file['Export CSV']['link'] = ''; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $config = Api\Config::read('importexport'); |
| 143 | - if($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) && |
|
| 143 | + if ($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) && |
|
| 144 | 144 | count(importexport_helper_functions::get_plugins($appname)) > 0 |
| 145 | 145 | ) |
| 146 | 146 | { |
| 147 | - $file['Define imports|exports'] = Egw::link('/index.php',array( |
|
| 147 | + $file['Define imports|exports'] = Egw::link('/index.php', array( |
|
| 148 | 148 | 'menuaction' => 'importexport.importexport_definitions_ui.index', |
| 149 | 149 | 'application' => $appname, |
| 150 | 150 | 'ajax' => 'true' |
| 151 | - ),$GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
|
| 151 | + ), $GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
|
| 152 | 152 | } |
| 153 | - if($file) display_sidebox($appname,lang('importexport'),$file); |
|
| 153 | + if ($file) display_sidebox($appname, lang('importexport'), $file); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -90,14 +90,22 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * Called from framework so Import / Export can add links into other apps' sidebox. |
| 92 | 92 | */ |
| 93 | - public static function other_apps() { |
|
| 94 | - if(!$GLOBALS['egw_info']['user']['apps']['importexport']) return array(); |
|
| 95 | - if($GLOBALS['egw_info']['flags']['no_importexport'] === true) return array(); |
|
| 93 | + public static function other_apps() |
|
| 94 | + { |
|
| 95 | + if(!$GLOBALS['egw_info']['user']['apps']['importexport']) |
|
| 96 | + { |
|
| 97 | + return array(); |
|
| 98 | + } |
|
| 99 | + if($GLOBALS['egw_info']['flags']['no_importexport'] === true) |
|
| 100 | + { |
|
| 101 | + return array(); |
|
| 102 | + } |
|
| 96 | 103 | |
| 97 | 104 | $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 98 | 105 | $cache = Api\Cache::getCache(Api\Cache::SESSION, 'importexport', 'sidebox_links'); |
| 99 | 106 | |
| 100 | - if(!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) { |
|
| 107 | + if(!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) |
|
| 108 | + { |
|
| 101 | 109 | $cache[$appname]['import'] = importexport_helper_functions::has_definitions($appname, 'import'); |
| 102 | 110 | $cache[$appname]['export'] = importexport_helper_functions::has_definitions($appname, 'export'); |
| 103 | 111 | Api\Cache::setCache(Api\Cache::SESSION, 'importexport', 'sidebox_links', $cache); |
@@ -117,7 +125,8 @@ discard block |
||
| 117 | 125 | 'app' => 'importexport', |
| 118 | 126 | 'text' => in_array($appname, array('sitemgr')) || count($plugins[$appname]['import']) > 1 ? 'Import' : 'Import CSV' |
| 119 | 127 | ); |
| 120 | - if($GLOBALS['egw_info']['flags']['disable_importexport']['import']) { |
|
| 128 | + if($GLOBALS['egw_info']['flags']['disable_importexport']['import']) |
|
| 129 | + { |
|
| 121 | 130 | $file['Import CSV']['link'] = ''; |
| 122 | 131 | } |
| 123 | 132 | } |
@@ -134,7 +143,8 @@ discard block |
||
| 134 | 143 | 'app' => 'importexport', |
| 135 | 144 | 'text' => in_array($appname, array('sitemgr')) || count($plugins[$appname]['export']) > 1 ? 'Export' : 'Export CSV' |
| 136 | 145 | ); |
| 137 | - if($GLOBALS['egw_info']['flags']['disable_importexport']['export']) { |
|
| 146 | + if($GLOBALS['egw_info']['flags']['disable_importexport']['export']) |
|
| 147 | + { |
|
| 138 | 148 | $file['Export CSV']['link'] = ''; |
| 139 | 149 | } |
| 140 | 150 | } |
@@ -142,15 +152,17 @@ discard block |
||
| 142 | 152 | $config = Api\Config::read('importexport'); |
| 143 | 153 | if($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) && |
| 144 | 154 | count(importexport_helper_functions::get_plugins($appname)) > 0 |
| 145 | - ) |
|
| 146 | - { |
|
| 155 | + ) { |
|
| 147 | 156 | $file['Define imports|exports'] = Egw::link('/index.php',array( |
| 148 | 157 | 'menuaction' => 'importexport.importexport_definitions_ui.index', |
| 149 | 158 | 'application' => $appname, |
| 150 | 159 | 'ajax' => 'true' |
| 151 | 160 | ),$GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
| 152 | 161 | } |
| 153 | - if($file) display_sidebox($appname,lang('importexport'),$file); |
|
| 162 | + if($file) |
|
| 163 | + { |
|
| 164 | + display_sidebox($appname,lang('importexport'),$file); |
|
| 165 | + } |
|
| 154 | 166 | } |
| 155 | 167 | |
| 156 | 168 | /** |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | |
| 66 | 66 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
| 67 | 67 | { |
| 68 | - $file = Array( |
|
| 68 | + $file = array( |
|
| 69 | 69 | 'Site Configuration' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.site_config'), |
| 70 | 70 | 'Import definitions' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.import_definition'), |
| 71 | 71 | 'Define imports|exports' => Egw::link('/index.php',array( |
@@ -30,39 +30,39 @@ discard block |
||
| 30 | 30 | * @param DOMElement $_node |
| 31 | 31 | * @return string XML string |
| 32 | 32 | */ |
| 33 | - public static function array2xml ( $_data, $_name = 'root', $_node=null ) {
|
|
| 33 | + public static function array2xml($_data, $_name = 'root', $_node = null) {
|
|
| 34 | 34 | $returnXML = false; |
| 35 | - if ( $_node === null ) {
|
|
| 36 | - $_node = new DOMDocument( '1.0', 'utf-8' ); |
|
| 35 | + if ($_node === null) {
|
|
| 36 | + $_node = new DOMDocument('1.0', 'utf-8');
|
|
| 37 | 37 | $_node->formatOutput = true; |
| 38 | 38 | $returnXML = true; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $datatype = gettype( $_data ); |
|
| 42 | - switch ( $datatype ) {
|
|
| 41 | + $datatype = gettype($_data); |
|
| 42 | + switch ($datatype) {
|
|
| 43 | 43 | case 'array' : |
| 44 | - $subnode = new DOMElement( 'entry' ); |
|
| 45 | - $_node->appendChild( $subnode ); |
|
| 46 | - $subnode->setAttribute( 'type', $datatype ); |
|
| 47 | - $subnode->setAttribute( 'name' , $_name ); |
|
| 44 | + $subnode = new DOMElement('entry');
|
|
| 45 | + $_node->appendChild($subnode); |
|
| 46 | + $subnode->setAttribute('type', $datatype);
|
|
| 47 | + $subnode->setAttribute('name', $_name);
|
|
| 48 | 48 | |
| 49 | - foreach ( $_data as $ikey => $ivalue ) {
|
|
| 50 | - self::array2xml( $ivalue, $ikey, $subnode ); |
|
| 49 | + foreach ($_data as $ikey => $ivalue) {
|
|
| 50 | + self::array2xml($ivalue, $ikey, $subnode); |
|
| 51 | 51 | } |
| 52 | 52 | break; |
| 53 | 53 | |
| 54 | 54 | default : |
| 55 | - switch ( $datatype ) {
|
|
| 55 | + switch ($datatype) {
|
|
| 56 | 56 | case 'boolean' : |
| 57 | 57 | $data = $_data !== false ? 'TRUE' : 'FALSE'; |
| 58 | 58 | break; |
| 59 | 59 | default: |
| 60 | 60 | $data = &$_data; |
| 61 | 61 | } |
| 62 | - $subnode = new DOMElement( 'entry' , $data ); |
|
| 63 | - $_node->appendChild( $subnode ); |
|
| 64 | - $subnode->setAttribute( 'type', $datatype ); |
|
| 65 | - $subnode->setAttribute( 'name' , $_name ); |
|
| 62 | + $subnode = new DOMElement('entry', $data);
|
|
| 63 | + $_node->appendChild($subnode); |
|
| 64 | + $subnode->setAttribute('type', $datatype);
|
|
| 65 | + $subnode->setAttribute('name', $_name);
|
|
| 66 | 66 | break; |
| 67 | 67 | } |
| 68 | 68 | return $returnXML ? $_node->saveXML() : ''; |
@@ -74,28 +74,28 @@ discard block |
||
| 74 | 74 | * @param string $_xml |
| 75 | 75 | * @return array |
| 76 | 76 | */ |
| 77 | - public static function xml2array( $_xml ) {
|
|
| 78 | - if ( $_xml instanceof DOMElement ) {
|
|
| 77 | + public static function xml2array($_xml) {
|
|
| 78 | + if ($_xml instanceof DOMElement) {
|
|
| 79 | 79 | $n = &$_xml; |
| 80 | 80 | } else {
|
| 81 | 81 | $n = new DOMDocument; |
| 82 | 82 | $loaded = $n->loadXML($_xml); |
| 83 | - if(!$loaded) return array(); |
|
| 83 | + if (!$loaded) return array(); |
|
| 84 | 84 | } |
| 85 | 85 | $xml_array = array(); |
| 86 | 86 | |
| 87 | - foreach($n->childNodes as $nc) {
|
|
| 87 | + foreach ($n->childNodes as $nc) {
|
|
| 88 | 88 | |
| 89 | - if ( $nc->nodeType != XML_ELEMENT_NODE ) continue; |
|
| 89 | + if ($nc->nodeType != XML_ELEMENT_NODE) continue; |
|
| 90 | 90 | |
| 91 | 91 | $name = $nc->attributes->getNamedItem('name')->nodeValue;
|
| 92 | 92 | $type = $nc->attributes->getNamedItem('type')->nodeValue;
|
| 93 | 93 | |
| 94 | 94 | //echo $nc->nodeType. "(length ): ". $nc->nodeName. " => ". $nc->nodeValue. "; Attriubtes: name=$name, type=$type \n "; |
| 95 | - if( $nc->childNodes->length >= 2) {
|
|
| 95 | + if ($nc->childNodes->length >= 2) {
|
|
| 96 | 96 | $xml_array[$name] = self::xml2array($nc); |
| 97 | 97 | } else {
|
| 98 | - switch ( $type ) {
|
|
| 98 | + switch ($type) {
|
|
| 99 | 99 | case 'boolean' : |
| 100 | 100 | $value = $nc->nodeValue == 'FALSE' ? false : true; |
| 101 | 101 | break; |
@@ -20,7 +20,8 @@ discard block |
||
| 20 | 20 | * @todo deal with other types like objects |
| 21 | 21 | * @static only namespace here |
| 22 | 22 | */ |
| 23 | -class importexport_arrayxml {
|
|
| 23 | +class importexport_arrayxml |
|
| 24 | +{ |
|
| 24 | 25 | |
| 25 | 26 | /** |
| 26 | 27 | * converts a php array to an xml string |
@@ -30,29 +31,34 @@ discard block |
||
| 30 | 31 | * @param DOMElement $_node |
| 31 | 32 | * @return string XML string |
| 32 | 33 | */ |
| 33 | - public static function array2xml ( $_data, $_name = 'root', $_node=null ) {
|
|
| 34 | + public static function array2xml ( $_data, $_name = 'root', $_node=null ) |
|
| 35 | + { |
|
| 34 | 36 | $returnXML = false; |
| 35 | - if ( $_node === null ) {
|
|
| 37 | + if ( $_node === null ) |
|
| 38 | + { |
|
| 36 | 39 | $_node = new DOMDocument( '1.0', 'utf-8' ); |
| 37 | 40 | $_node->formatOutput = true; |
| 38 | 41 | $returnXML = true; |
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | $datatype = gettype( $_data ); |
| 42 | - switch ( $datatype ) {
|
|
| 45 | + switch ( $datatype ) |
|
| 46 | + { |
|
| 43 | 47 | case 'array' : |
| 44 | 48 | $subnode = new DOMElement( 'entry' ); |
| 45 | 49 | $_node->appendChild( $subnode ); |
| 46 | 50 | $subnode->setAttribute( 'type', $datatype ); |
| 47 | 51 | $subnode->setAttribute( 'name' , $_name ); |
| 48 | 52 | |
| 49 | - foreach ( $_data as $ikey => $ivalue ) {
|
|
| 53 | + foreach ( $_data as $ikey => $ivalue ) |
|
| 54 | + { |
|
| 50 | 55 | self::array2xml( $ivalue, $ikey, $subnode ); |
| 51 | 56 | } |
| 52 | 57 | break; |
| 53 | 58 | |
| 54 | 59 | default : |
| 55 | - switch ( $datatype ) {
|
|
| 60 | + switch ( $datatype ) |
|
| 61 | + { |
|
| 56 | 62 | case 'boolean' : |
| 57 | 63 | $data = $_data !== false ? 'TRUE' : 'FALSE'; |
| 58 | 64 | break; |
@@ -74,28 +80,43 @@ discard block |
||
| 74 | 80 | * @param string $_xml |
| 75 | 81 | * @return array |
| 76 | 82 | */ |
| 77 | - public static function xml2array( $_xml ) {
|
|
| 78 | - if ( $_xml instanceof DOMElement ) {
|
|
| 83 | + public static function xml2array( $_xml ) |
|
| 84 | + { |
|
| 85 | + if ( $_xml instanceof DOMElement ) |
|
| 86 | + { |
|
| 79 | 87 | $n = &$_xml; |
| 80 | - } else {
|
|
| 88 | + } |
|
| 89 | + else |
|
| 90 | + { |
|
| 81 | 91 | $n = new DOMDocument; |
| 82 | 92 | $loaded = $n->loadXML($_xml); |
| 83 | - if(!$loaded) return array(); |
|
| 93 | + if(!$loaded) |
|
| 94 | + { |
|
| 95 | + return array(); |
|
| 96 | + } |
|
| 84 | 97 | } |
| 85 | 98 | $xml_array = array(); |
| 86 | 99 | |
| 87 | - foreach($n->childNodes as $nc) {
|
|
| 100 | + foreach($n->childNodes as $nc) |
|
| 101 | + { |
|
| 88 | 102 | |
| 89 | - if ( $nc->nodeType != XML_ELEMENT_NODE ) continue; |
|
| 103 | + if ( $nc->nodeType != XML_ELEMENT_NODE ) |
|
| 104 | + { |
|
| 105 | + continue; |
|
| 106 | + } |
|
| 90 | 107 | |
| 91 | 108 | $name = $nc->attributes->getNamedItem('name')->nodeValue;
|
| 92 | 109 | $type = $nc->attributes->getNamedItem('type')->nodeValue;
|
| 93 | 110 | |
| 94 | 111 | //echo $nc->nodeType. "(length ): ". $nc->nodeName. " => ". $nc->nodeValue. "; Attriubtes: name=$name, type=$type \n "; |
| 95 | - if( $nc->childNodes->length >= 2) {
|
|
| 112 | + if( $nc->childNodes->length >= 2) |
|
| 113 | + { |
|
| 96 | 114 | $xml_array[$name] = self::xml2array($nc); |
| 97 | - } else {
|
|
| 98 | - switch ( $type ) {
|
|
| 115 | + } |
|
| 116 | + else |
|
| 117 | + { |
|
| 118 | + switch ( $type ) |
|
| 119 | + { |
|
| 99 | 120 | case 'boolean' : |
| 100 | 121 | $value = $nc->nodeValue == 'FALSE' ? false : true; |
| 101 | 122 | break; |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
| 199 | - * Get options for select boxes |
|
| 200 | - */ |
|
| 199 | + * Get options for select boxes |
|
| 200 | + */ |
|
| 201 | 201 | public static function get_select_options(Array $data) |
| 202 | 202 | { |
| 203 | 203 | $options = array( |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | - * Generate a async key |
|
| 265 | - */ |
|
| 264 | + * Generate a async key |
|
| 265 | + */ |
|
| 266 | 266 | public static function generate_id($data) |
| 267 | 267 | { |
| 268 | 268 | |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | - * Check that the target is valid for the type (readable or writable) |
|
| 282 | - * and that they're not trying to write directly to the filesystem |
|
| 283 | - * |
|
| 284 | - * $data should contain target & type |
|
| 285 | - */ |
|
| 281 | + * Check that the target is valid for the type (readable or writable) |
|
| 282 | + * and that they're not trying to write directly to the filesystem |
|
| 283 | + * |
|
| 284 | + * $data should contain target & type |
|
| 285 | + */ |
|
| 286 | 286 | public static function check_target(Array $data) { |
| 287 | 287 | $scheme = parse_url($data['target'], PHP_URL_SCHEME); |
| 288 | 288 | if($scheme == '' || $scheme == 'file') |
@@ -329,11 +329,11 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | - * Writable that checks the folder too, in case the file does not exist yet |
|
| 333 | - * http://ca3.php.net/manual/en/function.is-writable.php#73596 |
|
| 334 | - * |
|
| 335 | - * @param path Path to check |
|
| 336 | - */ |
|
| 332 | + * Writable that checks the folder too, in case the file does not exist yet |
|
| 333 | + * http://ca3.php.net/manual/en/function.is-writable.php#73596 |
|
| 334 | + * |
|
| 335 | + * @param path Path to check |
|
| 336 | + */ |
|
| 337 | 337 | private static function is__writable($path) |
| 338 | 338 | { |
| 339 | 339 | if ($path{strlen($path)-1}=='/') |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | - * Execute a scheduled import or export |
|
| 369 | - */ |
|
| 368 | + * Execute a scheduled import or export |
|
| 369 | + */ |
|
| 370 | 370 | public static function exec($data) |
| 371 | 371 | { |
| 372 | 372 | ob_start(); |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | public function index($content = array()) |
| 38 | 38 | { |
| 39 | 39 | $async = new Api\Asyncservice(); |
| 40 | - if(is_array($content['scheduled'])) |
|
| 40 | + if (is_array($content['scheduled'])) |
|
| 41 | 41 | { |
| 42 | - foreach($content['scheduled'] as $row) |
|
| 42 | + foreach ($content['scheduled'] as $row) |
|
| 43 | 43 | { |
| 44 | - if($row['delete']) |
|
| 44 | + if ($row['delete']) |
|
| 45 | 45 | { |
| 46 | 46 | $key = urldecode(key($row['delete'])); |
| 47 | 47 | $async->cancel_timer($key); |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | $async_list = $async->read('importexport%'); |
| 52 | 52 | $data = array(); |
| 53 | - if(is_array($async_list)) |
|
| 53 | + if (is_array($async_list)) |
|
| 54 | 54 | { |
| 55 | - foreach($async_list as $id => $async) |
|
| 55 | + foreach ($async_list as $id => $async) |
|
| 56 | 56 | { |
| 57 | - foreach(array('errors', 'warnings', 'result') as $messages) |
|
| 57 | + foreach (array('errors', 'warnings', 'result') as $messages) |
|
| 58 | 58 | { |
| 59 | - if(is_array($async['data'][$messages])) |
|
| 59 | + if (is_array($async['data'][$messages])) |
|
| 60 | 60 | { |
| 61 | 61 | $list = array(); |
| 62 | - foreach($async['data'][$messages] as $target => $message) |
|
| 62 | + foreach ($async['data'][$messages] as $target => $message) |
|
| 63 | 63 | { |
| 64 | 64 | $list[] = array( |
| 65 | 65 | 'target' => (is_numeric($target) ? '' : $target), |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $async['data'][$messages] = $list; |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - if(is_numeric($async['data']['record_count'])) |
|
| 72 | + if (is_numeric($async['data']['record_count'])) |
|
| 73 | 73 | { |
| 74 | 74 | $async['data']['record_count'] = lang('%1 records processed', $async['data']['record_count']); |
| 75 | 75 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $data = $content; |
| 101 | 101 | |
| 102 | 102 | // Deal with incoming |
| 103 | - if($content['save'] && self::check_target($content) === true) |
|
| 103 | + if ($content['save'] && self::check_target($content) === true) |
|
| 104 | 104 | { |
| 105 | 105 | unset($content['save']); |
| 106 | 106 | $async->cancel_timer($id); |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | unset($content['schedule']); |
| 112 | 112 | |
| 113 | 113 | // Remove any left blank |
| 114 | - foreach($schedule as $key => &$value) |
|
| 114 | + foreach ($schedule as $key => &$value) |
|
| 115 | 115 | { |
| 116 | - if($value == '') unset($schedule[$key]); |
|
| 116 | + if ($value == '') unset($schedule[$key]); |
|
| 117 | 117 | } |
| 118 | 118 | $result = $async->set_timer( |
| 119 | 119 | $schedule, |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | 'importexport.importexport_schedule_ui.exec', |
| 122 | 122 | $content |
| 123 | 123 | ); |
| 124 | - if($result) |
|
| 124 | + if ($result) |
|
| 125 | 125 | { |
| 126 | - Framework::refresh_opener('', 'admin',$id,'update','admin'); |
|
| 126 | + Framework::refresh_opener('', 'admin', $id, 'update', 'admin'); |
|
| 127 | 127 | Framework::window_close(); |
| 128 | 128 | } |
| 129 | 129 | else |
@@ -133,19 +133,19 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if($id) |
|
| 136 | + if ($id) |
|
| 137 | 137 | { |
| 138 | 138 | |
| 139 | 139 | $preserve['id'] = $id; |
| 140 | 140 | $async = $async->read($id); |
| 141 | - if(is_array($async[$id]['data'])) |
|
| 141 | + if (is_array($async[$id]['data'])) |
|
| 142 | 142 | { |
| 143 | 143 | $data += $async[$id]['data']; |
| 144 | 144 | $data['schedule'] = $async[$id]['times']; |
| 145 | 145 | unset($data['times']); |
| 146 | 146 | |
| 147 | 147 | // Async sometimes changes minutes to an array - show user what they typed |
| 148 | - if(is_array($data['schedule']['min'])) |
|
| 148 | + if (is_array($data['schedule']['min'])) |
|
| 149 | 149 | { |
| 150 | 150 | $data['schedule']['min'] = $data['min']; |
| 151 | 151 | } |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $data['type'] = $content['type'] ? $content['type'] : 'import'; |
| 161 | 161 | |
| 162 | - if((int)$definition_id) |
|
| 162 | + if ((int)$definition_id) |
|
| 163 | 163 | { |
| 164 | 164 | $bo = new importexport_definitions_bo(); |
| 165 | 165 | $definition = $bo->read($definition_id); |
| 166 | - if($definition['definition_id']) |
|
| 166 | + if ($definition['definition_id']) |
|
| 167 | 167 | { |
| 168 | 168 | $data['type'] = $definition['type']; |
| 169 | 169 | $data['appname'] = $definition['application']; |
@@ -173,12 +173,12 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if($data['target'] && $data['type']) |
|
| 176 | + if ($data['target'] && $data['type']) |
|
| 177 | 177 | { |
| 178 | 178 | $file_check = self::check_target($data); |
| 179 | - if($file_check !== true) |
|
| 179 | + if ($file_check !== true) |
|
| 180 | 180 | { |
| 181 | - $data['message'] .= ($data['message'] ? "\n" . $file_check : $file_check); |
|
| 181 | + $data['message'] .= ($data['message'] ? "\n".$file_check : $file_check); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $data['current_time'] = time(); |
| 189 | 189 | |
| 190 | 190 | $sel_options = self::get_select_options($data); |
| 191 | - Framework::includeJS('.','importexport','importexport'); |
|
| 191 | + Framework::includeJS('.', 'importexport', 'importexport'); |
|
| 192 | 192 | |
| 193 | 193 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Schedule import / export'); |
| 194 | 194 | $this->template->read('importexport.schedule_edit'); |
@@ -208,21 +208,21 @@ discard block |
||
| 208 | 208 | ); |
| 209 | 209 | |
| 210 | 210 | (array)$apps = importexport_helper_functions::get_apps($data['type'] ? $data['type'] : 'all'); |
| 211 | - if(count($apps)) |
|
| 211 | + if (count($apps)) |
|
| 212 | 212 | { |
| 213 | - $options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
|
| 213 | + $options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $plugins = importexport_helper_functions::get_plugins($data['appname'] ? $data['appname'] : 'all', $data['type']); |
| 217 | - if(is_array($plugins)) |
|
| 217 | + if (is_array($plugins)) |
|
| 218 | 218 | { |
| 219 | - foreach($plugins as $types) |
|
| 219 | + foreach ($plugins as $types) |
|
| 220 | 220 | { |
| 221 | - if(!is_array($types[$data['type']])) |
|
| 221 | + if (!is_array($types[$data['type']])) |
|
| 222 | 222 | { |
| 223 | 223 | continue; |
| 224 | 224 | } |
| 225 | - foreach($types[$data['type']] as $key => $title) |
|
| 225 | + foreach ($types[$data['type']] as $key => $title) |
|
| 226 | 226 | { |
| 227 | 227 | $options['plugin'][$key] = $title; |
| 228 | 228 | } |
@@ -285,27 +285,27 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | public static function check_target(Array $data) { |
| 287 | 287 | $scheme = parse_url($data['target'], PHP_URL_SCHEME); |
| 288 | - if($scheme == '' || $scheme == 'file') |
|
| 288 | + if ($scheme == '' || $scheme == 'file') |
|
| 289 | 289 | { |
| 290 | 290 | return 'Direct file access not allowed'; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) { |
|
| 293 | + if ($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) { |
|
| 294 | 294 | stream_wrapper_register(Vfs::SCHEME, 'vfs_stream_wrapper', STREAM_IS_URL); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | if ($data['type'] == 'import' && ($scheme == Vfs::SCHEME && !Vfs::is_readable($data['target']))) |
| 298 | 298 | { |
| 299 | - return lang('%1 is not readable',$data['target']); |
|
| 299 | + return lang('%1 is not readable', $data['target']); |
|
| 300 | 300 | } |
| 301 | - elseif ($data['type'] == 'import' && in_array($scheme, array('http','https'))) |
|
| 301 | + elseif ($data['type'] == 'import' && in_array($scheme, array('http', 'https'))) |
|
| 302 | 302 | { |
| 303 | 303 | // Not supported by is_readable, try headers... |
| 304 | 304 | stream_context_set_default(array('http'=>array( |
| 305 | 305 | 'method' => 'HEAD', |
| 306 | 306 | 'ignore_errors' => 1 |
| 307 | 307 | ))); |
| 308 | - $headers = get_headers($data['target'],1); |
|
| 308 | + $headers = get_headers($data['target'], 1); |
|
| 309 | 309 | |
| 310 | 310 | // Reset... |
| 311 | 311 | stream_context_set_default(array('http'=>array( |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | 'ignore_errors' => 0 |
| 314 | 314 | ))); |
| 315 | 315 | // Response code has an integer key, but redirects may add more responses |
| 316 | - for($i = 0; $i < count($headers); $i++) |
|
| 316 | + for ($i = 0; $i < count($headers); $i++) |
|
| 317 | 317 | { |
| 318 | - if(!$headers[$i]) break; |
|
| 319 | - if(strpos($headers[$i],'200') !== false) return true; |
|
| 318 | + if (!$headers[$i]) break; |
|
| 319 | + if (strpos($headers[$i], '200') !== false) return true; |
|
| 320 | 320 | } |
| 321 | - return lang('%1 is not readable',$data['target']); |
|
| 321 | + return lang('%1 is not readable', $data['target']); |
|
| 322 | 322 | } |
| 323 | 323 | elseif ($data['type'] == 'export' && !self::is__writable($data['target'])) |
| 324 | 324 | { |
| 325 | - return lang('%1 is not writable',$data['target']); |
|
| 325 | + return lang('%1 is not writable', $data['target']); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | return true; |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | */ |
| 337 | 337 | private static function is__writable($path) |
| 338 | 338 | { |
| 339 | - if ($path{strlen($path)-1}=='/') |
|
| 339 | + if ($path{strlen($path) - 1} == '/') |
|
| 340 | 340 | { |
| 341 | 341 | // recursively return a temporary file path |
| 342 | 342 | return self::is__writable($path.uniqid(mt_rand()).'.tmp'); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | $rm = file_exists($path); |
| 351 | 351 | $f = @fopen($path, 'a'); |
| 352 | 352 | |
| 353 | - if ($f===false) |
|
| 353 | + if ($f === false) |
|
| 354 | 354 | { |
| 355 | 355 | return false; |
| 356 | 356 | } |
@@ -376,10 +376,10 @@ discard block |
||
| 376 | 376 | unset($data['warnings']); |
| 377 | 377 | unset($data['result']); |
| 378 | 378 | |
| 379 | - if($data['lock']) |
|
| 379 | + if ($data['lock']) |
|
| 380 | 380 | { |
| 381 | 381 | // Lock expires |
| 382 | - if($data['lock'] < time()) |
|
| 382 | + if ($data['lock'] < time()) |
|
| 383 | 383 | { |
| 384 | 384 | unset($data['lock']); |
| 385 | 385 | $data['warnings'][][] = lang('Lock expired on previous run'); |
@@ -400,25 +400,25 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | // check file |
| 402 | 402 | $file_check = self::check_target($data); |
| 403 | - if($file_check !== true) |
|
| 403 | + if ($file_check !== true) |
|
| 404 | 404 | { |
| 405 | 405 | $data['errors'] = array($file_check=>''); |
| 406 | 406 | // Update job with results |
| 407 | 407 | self::update_job($data); |
| 408 | 408 | |
| 409 | - error_log('importexport_schedule: ' . date('c') . ": $file_check \n"); |
|
| 409 | + error_log('importexport_schedule: '.date('c').": $file_check \n"); |
|
| 410 | 410 | error_log(ob_get_flush()); |
| 411 | 411 | return; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | $definition = new importexport_definition($data['definition']); |
| 415 | - if( $definition->get_identifier() < 1 ) |
|
| 415 | + if ($definition->get_identifier() < 1) |
|
| 416 | 416 | { |
| 417 | 417 | $data['errors'] = array('Definition not found!'); |
| 418 | 418 | // Update job with results |
| 419 | 419 | self::update_job($data); |
| 420 | 420 | |
| 421 | - error_log('importexport_schedule: ' . date('c') . ": Definition not found! \n"); |
|
| 421 | + error_log('importexport_schedule: '.date('c').": Definition not found! \n"); |
|
| 422 | 422 | return; |
| 423 | 423 | } |
| 424 | 424 | $GLOBALS['egw_info']['flags']['currentapp'] = $definition->application; |
@@ -427,30 +427,30 @@ discard block |
||
| 427 | 427 | |
| 428 | 428 | $type = $data['type']; |
| 429 | 429 | |
| 430 | - if(is_dir($data['target'])) |
|
| 430 | + if (is_dir($data['target'])) |
|
| 431 | 431 | { |
| 432 | - if($data['type'] == 'import') |
|
| 432 | + if ($data['type'] == 'import') |
|
| 433 | 433 | { |
| 434 | 434 | $targets = array(); |
| 435 | - foreach(scandir($data['target']) as $target) |
|
| 435 | + foreach (scandir($data['target']) as $target) |
|
| 436 | 436 | { |
| 437 | 437 | if ($target == '.' || $target == '..') |
| 438 | 438 | { |
| 439 | 439 | continue; |
| 440 | 440 | } |
| 441 | - $target = $data['target'].(substr($data['target'],-1) == '/' ? '' : '/').$target; |
|
| 441 | + $target = $data['target'].(substr($data['target'], -1) == '/' ? '' : '/').$target; |
|
| 442 | 442 | |
| 443 | 443 | // Check modification time, make sure it's not currently being written |
| 444 | 444 | // Skip files modified in the last 10 seconds |
| 445 | 445 | $mod_time = filemtime($target); |
| 446 | - if($mod_time >= time() - 10) |
|
| 446 | + if ($mod_time >= time() - 10) |
|
| 447 | 447 | { |
| 448 | 448 | $data['result'][$target] = lang('Skipped'); |
| 449 | 449 | continue; |
| 450 | 450 | } |
| 451 | 451 | $targets[$mod_time.$target] = $target; |
| 452 | 452 | } |
| 453 | - if($targets) |
|
| 453 | + if ($targets) |
|
| 454 | 454 | { |
| 455 | 455 | ksort($targets); |
| 456 | 456 | } |
@@ -466,27 +466,27 @@ discard block |
||
| 466 | 466 | $targets = array($data['target']); |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - if($type == 'export') |
|
| 469 | + if ($type == 'export') |
|
| 470 | 470 | { |
| 471 | 471 | // Set to export all or filter, if set |
| 472 | 472 | $selection = array('selection' => 'all'); |
| 473 | - if($definition->filter) |
|
| 473 | + if ($definition->filter) |
|
| 474 | 474 | { |
| 475 | 475 | $fields = importexport_helper_functions::get_filter_fields($definition->application, $po); |
| 476 | 476 | $selection = array('selection' => 'filter'); |
| 477 | 477 | $filters = array(); |
| 478 | - foreach($definition->filter as $field => $value) |
|
| 478 | + foreach ($definition->filter as $field => $value) |
|
| 479 | 479 | { |
| 480 | 480 | // Handle multiple values |
| 481 | - if(!is_array($value) && strpos($value,',') !== false) |
|
| 481 | + if (!is_array($value) && strpos($value, ',') !== false) |
|
| 482 | 482 | { |
| 483 | - $value = explode(',',$value); |
|
| 483 | + $value = explode(',', $value); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | $filters[$field] = $value; |
| 487 | 487 | |
| 488 | 488 | // Process relative dates into the current absolute date |
| 489 | - if($filters[$field] && strpos($fields[$field]['type'],'date') === 0) |
|
| 489 | + if ($filters[$field] && strpos($fields[$field]['type'], 'date') === 0) |
|
| 490 | 490 | { |
| 491 | 491 | $filters[$field] = importexport_helper_functions::date_rel2abs($value); |
| 492 | 492 | } |
@@ -494,14 +494,14 @@ discard block |
||
| 494 | 494 | // Update filter to use current absolute dates |
| 495 | 495 | $definition->filter = $filters; |
| 496 | 496 | } |
| 497 | - if(!is_array($definition->plugin_options)) |
|
| 497 | + if (!is_array($definition->plugin_options)) |
|
| 498 | 498 | { |
| 499 | 499 | $definition->plugin_options = array(); |
| 500 | 500 | } |
| 501 | 501 | $definition->plugin_options = array_merge($definition->plugin_options, $selection); |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - foreach($targets as $target) |
|
| 504 | + foreach ($targets as $target) |
|
| 505 | 505 | { |
| 506 | 506 | // Update lock timeout |
| 507 | 507 | $data['lock'] = time() + 3600; |
@@ -510,16 +510,16 @@ discard block |
||
| 510 | 510 | $resource = null; |
| 511 | 511 | try |
| 512 | 512 | { |
| 513 | - if (($resource = @fopen( $target, $data['type'] == 'import' ? 'rb' : 'wb' ))) |
|
| 513 | + if (($resource = @fopen($target, $data['type'] == 'import' ? 'rb' : 'wb'))) |
|
| 514 | 514 | { |
| 515 | - $result = $po->$type( $resource, $definition ); |
|
| 515 | + $result = $po->$type($resource, $definition); |
|
| 516 | 516 | |
| 517 | 517 | fclose($resource); |
| 518 | 518 | } |
| 519 | 519 | else |
| 520 | 520 | { |
| 521 | - error_log('importexport_schedule: ' . date('c') . ": File $target not readable! \n"); |
|
| 522 | - $data['errors'][$target][] = lang('%1 is not readable',$target); |
|
| 521 | + error_log('importexport_schedule: '.date('c').": File $target not readable! \n"); |
|
| 522 | + $data['errors'][$target][] = lang('%1 is not readable', $target); |
|
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | catch (Exception $i_ex) |
@@ -529,20 +529,20 @@ discard block |
||
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | |
| 532 | - if(method_exists($po, 'get_warnings') && $po->get_warnings()) |
|
| 532 | + if (method_exists($po, 'get_warnings') && $po->get_warnings()) |
|
| 533 | 533 | { |
| 534 | - $buffer = 'importexport_schedule: ' . date('c') . ": Import warnings:\n#\tWarning\n"; |
|
| 535 | - foreach($po->get_warnings() as $record => $msg) |
|
| 534 | + $buffer = 'importexport_schedule: '.date('c').": Import warnings:\n#\tWarning\n"; |
|
| 535 | + foreach ($po->get_warnings() as $record => $msg) |
|
| 536 | 536 | { |
| 537 | 537 | $data['warnings'][$target][] = "#$record: $msg"; |
| 538 | 538 | $buffer += "$record\t$msg\n"; |
| 539 | 539 | } |
| 540 | 540 | error_log($buffer); |
| 541 | 541 | } |
| 542 | - if(method_exists($po, 'get_errors') && $po->get_errors()) |
|
| 542 | + if (method_exists($po, 'get_errors') && $po->get_errors()) |
|
| 543 | 543 | { |
| 544 | - $buffer = 'importexport_schedule: ' . date('c') . ": Import errors:\n#\tError\n"; |
|
| 545 | - foreach($po->get_errors() as $record => $error) |
|
| 544 | + $buffer = 'importexport_schedule: '.date('c').": Import errors:\n#\tError\n"; |
|
| 545 | + foreach ($po->get_errors() as $record => $error) |
|
| 546 | 546 | { |
| 547 | 547 | $data['errors'][$target][] = "#$record: $error"; |
| 548 | 548 | $buffer += "$record\t$error\n"; |
@@ -550,22 +550,22 @@ discard block |
||
| 550 | 550 | error_log($buffer); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - if($po instanceof importexport_iface_import_plugin) |
|
| 553 | + if ($po instanceof importexport_iface_import_plugin) |
|
| 554 | 554 | { |
| 555 | - if(is_numeric($result)) |
|
| 555 | + if (is_numeric($result)) |
|
| 556 | 556 | { |
| 557 | 557 | $data['record_count'] += $result; |
| 558 | 558 | $data['result'][$target][] = lang('%1 records processed', $result); |
| 559 | 559 | } |
| 560 | 560 | $data['result'][$target] = array(); |
| 561 | - foreach($po->get_results() as $action => $count) |
|
| 561 | + foreach ($po->get_results() as $action => $count) |
|
| 562 | 562 | { |
| 563 | - $data['result'][$target][] = lang($action) . ": $count"; |
|
| 563 | + $data['result'][$target][] = lang($action).": $count"; |
|
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | else |
| 567 | 567 | { |
| 568 | - if($result instanceof importexport_iface_export_record) |
|
| 568 | + if ($result instanceof importexport_iface_export_record) |
|
| 569 | 569 | { |
| 570 | 570 | $data['record_count'] += $result->get_num_of_records(); |
| 571 | 571 | $data['result'][$target][] = lang('%1 records processed', $result->get_num_of_records()); |
@@ -574,23 +574,23 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | // Delete file? |
| 577 | - if($data['delete_files'] && $type == 'import' && !$data['errors']) |
|
| 577 | + if ($data['delete_files'] && $type == 'import' && !$data['errors']) |
|
| 578 | 578 | { |
| 579 | - foreach($targets as $target) |
|
| 579 | + foreach ($targets as $target) |
|
| 580 | 580 | { |
| 581 | - if(unlink($target)) |
|
| 581 | + if (unlink($target)) |
|
| 582 | 582 | { |
| 583 | - $data['result'][$target][] .= "\n..." . lang('deleted'); |
|
| 583 | + $data['result'][$target][] .= "\n...".lang('deleted'); |
|
| 584 | 584 | } |
| 585 | 585 | else |
| 586 | 586 | { |
| 587 | - $data['errors'][$target][] .= "\n..." . lang('Unable to delete'); |
|
| 587 | + $data['errors'][$target][] .= "\n...".lang('Unable to delete'); |
|
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | // Run time in minutes |
| 593 | - $data['run_time'] = round((time() - $data['last_run']) / 60,1); |
|
| 593 | + $data['run_time'] = round((time() - $data['last_run']) / 60, 1); |
|
| 594 | 594 | |
| 595 | 595 | // Clear lock |
| 596 | 596 | $data['lock'] = 0; |
@@ -601,9 +601,9 @@ discard block |
||
| 601 | 601 | $contents = ob_get_contents(); |
| 602 | 602 | |
| 603 | 603 | // Log to error log |
| 604 | - if($contents) |
|
| 604 | + if ($contents) |
|
| 605 | 605 | { |
| 606 | - error_log('importexport_schedule: ' . date('c') . ": \n".$contents); |
|
| 606 | + error_log('importexport_schedule: '.date('c').": \n".$contents); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | ob_end_clean(); |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | $jobs = $async->read($id); |
| 621 | 621 | $job = $jobs[$id]; |
| 622 | 622 | |
| 623 | - if(is_array($job)) |
|
| 623 | + if (is_array($job)) |
|
| 624 | 624 | { |
| 625 | 625 | $async->cancel_timer($id); |
| 626 | 626 | $result = $async->set_timer( |
@@ -630,37 +630,37 @@ discard block |
||
| 630 | 630 | $data |
| 631 | 631 | ); |
| 632 | 632 | } |
| 633 | - if($no_notification) |
|
| 633 | + if ($no_notification) |
|
| 634 | 634 | { |
| 635 | 635 | return $result; |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | // Send notification to user |
| 639 | - if($data['warnings'] || $data['errors']) |
|
| 639 | + if ($data['warnings'] || $data['errors']) |
|
| 640 | 640 | { |
| 641 | 641 | $notify = new notifications(); |
| 642 | 642 | $notify->set_sender($data['account_id']); |
| 643 | 643 | $notify->add_receiver($data['account_id']); |
| 644 | - $notify->set_subject(lang('Schedule import | export'). ' ' . lang('errors')); |
|
| 644 | + $notify->set_subject(lang('Schedule import | export').' '.lang('errors')); |
|
| 645 | 645 | $contents = ''; |
| 646 | 646 | |
| 647 | - if($data['warnings']) |
|
| 647 | + if ($data['warnings']) |
|
| 648 | 648 | { |
| 649 | - $contents .= lang($data['type']) . ' ' . lang('Warnings') . ' ' . Api\DateTime::to() . ':'; |
|
| 650 | - foreach($data['warnings'] as $target => $message) |
|
| 649 | + $contents .= lang($data['type']).' '.lang('Warnings').' '.Api\DateTime::to().':'; |
|
| 650 | + foreach ($data['warnings'] as $target => $message) |
|
| 651 | 651 | { |
| 652 | - $contents .= "\n". (is_numeric($target) ? '' : $target."\n"); |
|
| 653 | - $contents .= is_array($message) ? implode("\n",$message) : $message; |
|
| 652 | + $contents .= "\n".(is_numeric($target) ? '' : $target."\n"); |
|
| 653 | + $contents .= is_array($message) ? implode("\n", $message) : $message; |
|
| 654 | 654 | } |
| 655 | 655 | $contents .= "\n"; |
| 656 | 656 | } |
| 657 | - if($data['errors']) |
|
| 657 | + if ($data['errors']) |
|
| 658 | 658 | { |
| 659 | - $contents .= lang($data['type']) . ' ' . lang('Errors') . ' ' . Api\DateTime::to() . ':'; |
|
| 660 | - foreach($data['errors'] as $target => $errors) |
|
| 659 | + $contents .= lang($data['type']).' '.lang('Errors').' '.Api\DateTime::to().':'; |
|
| 660 | + foreach ($data['errors'] as $target => $errors) |
|
| 661 | 661 | { |
| 662 | - $contents .= "\n". (is_numeric($target) ? '' : $target."\n"); |
|
| 663 | - $contents .= is_array($errors) ? implode("\n",$errors) : $errors; |
|
| 662 | + $contents .= "\n".(is_numeric($target) ? '' : $target."\n"); |
|
| 663 | + $contents .= is_array($errors) ? implode("\n", $errors) : $errors; |
|
| 664 | 664 | } |
| 665 | 665 | $contents .= "\n"; |
| 666 | 666 | } |
@@ -113,7 +113,10 @@ discard block |
||
| 113 | 113 | // Remove any left blank |
| 114 | 114 | foreach($schedule as $key => &$value) |
| 115 | 115 | { |
| 116 | - if($value == '') unset($schedule[$key]); |
|
| 116 | + if($value == '') |
|
| 117 | + { |
|
| 118 | + unset($schedule[$key]); |
|
| 119 | + } |
|
| 117 | 120 | } |
| 118 | 121 | $result = $async->set_timer( |
| 119 | 122 | $schedule, |
@@ -283,14 +286,16 @@ discard block |
||
| 283 | 286 | * |
| 284 | 287 | * $data should contain target & type |
| 285 | 288 | */ |
| 286 | - public static function check_target(Array $data) { |
|
| 289 | + public static function check_target(Array $data) |
|
| 290 | + { |
|
| 287 | 291 | $scheme = parse_url($data['target'], PHP_URL_SCHEME); |
| 288 | 292 | if($scheme == '' || $scheme == 'file') |
| 289 | 293 | { |
| 290 | 294 | return 'Direct file access not allowed'; |
| 291 | 295 | } |
| 292 | 296 | |
| 293 | - if($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) { |
|
| 297 | + if($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) |
|
| 298 | + { |
|
| 294 | 299 | stream_wrapper_register(Vfs::SCHEME, 'vfs_stream_wrapper', STREAM_IS_URL); |
| 295 | 300 | } |
| 296 | 301 | |
@@ -315,8 +320,14 @@ discard block |
||
| 315 | 320 | // Response code has an integer key, but redirects may add more responses |
| 316 | 321 | for($i = 0; $i < count($headers); $i++) |
| 317 | 322 | { |
| 318 | - if(!$headers[$i]) break; |
|
| 319 | - if(strpos($headers[$i],'200') !== false) return true; |
|
| 323 | + if(!$headers[$i]) |
|
| 324 | + { |
|
| 325 | + break; |
|
| 326 | + } |
|
| 327 | + if(strpos($headers[$i],'200') !== false) |
|
| 328 | + { |
|
| 329 | + return true; |
|
| 330 | + } |
|
| 320 | 331 | } |
| 321 | 332 | return lang('%1 is not readable',$data['target']); |
| 322 | 333 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | /** |
| 199 | 199 | * Get options for select boxes |
| 200 | 200 | */ |
| 201 | - public static function get_select_options(Array $data) |
|
| 201 | + public static function get_select_options(array $data) |
|
| 202 | 202 | { |
| 203 | 203 | $options = array( |
| 204 | 204 | 'type' => array( |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * $data should contain target & type |
| 285 | 285 | */ |
| 286 | - public static function check_target(Array $data) { |
|
| 286 | + public static function check_target(array $data) { |
|
| 287 | 287 | $scheme = parse_url($data['target'], PHP_URL_SCHEME); |
| 288 | 288 | if($scheme == '' || $scheme == 'file') |
| 289 | 289 | { |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | const TEMPLATE_MARKER = '-eTemplate-'; |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * List of steps. Key is the function, value is the translated title. |
|
| 27 | - */ |
|
| 26 | + * List of steps. Key is the function, value is the translated title. |
|
| 27 | + */ |
|
| 28 | 28 | public $steps; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
| 32 | - */ |
|
| 31 | + * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
| 32 | + */ |
|
| 33 | 33 | protected $step_templates = array( |
| 34 | 34 | 'wizard_step30' => 'importexport.wizard_basic_export_csv.choose_fields', |
| 35 | 35 | 'wizard_step40' => 'importexport.wizard_basic_export_csv.choosesepncharset', |
@@ -38,19 +38,19 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * Destination fields for the export |
|
| 42 | - * Key is the field name, value is the human version |
|
| 43 | - */ |
|
| 41 | + * Destination fields for the export |
|
| 42 | + * Key is the field name, value is the human version |
|
| 43 | + */ |
|
| 44 | 44 | protected $export_fields = array(); |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * List of conditions your plugin supports |
|
| 48 | - */ |
|
| 47 | + * List of conditions your plugin supports |
|
| 48 | + */ |
|
| 49 | 49 | protected $conditions = array(); |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * List of actions your plugin supports |
|
| 53 | - */ |
|
| 52 | + * List of actions your plugin supports |
|
| 53 | + */ |
|
| 54 | 54 | protected $actions = array(); |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * Choose fields to export |
|
| 73 | - */ |
|
| 72 | + * Choose fields to export |
|
| 73 | + */ |
|
| 74 | 74 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
| 75 | 75 | { |
| 76 | 76 | if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | ); |
| 207 | 207 | $sel_options['charset'] = Api\Translation::get_installed_charsets()+ |
| 208 | 208 | array( |
| 209 | - 'user' => lang('User preference'), |
|
| 210 | - ); |
|
| 209 | + 'user' => lang('User preference'), |
|
| 210 | + ); |
|
| 211 | 211 | |
| 212 | - // Add in extra allowed charsets |
|
| 213 | - $config = Api\Config::read('importexport'); |
|
| 214 | - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
| 215 | - if($extra_charsets) |
|
| 216 | - { |
|
| 217 | - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
| 218 | - } |
|
| 212 | + // Add in extra allowed charsets |
|
| 213 | + $config = Api\Config::read('importexport'); |
|
| 214 | + $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
| 215 | + if($extra_charsets) |
|
| 216 | + { |
|
| 217 | + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
| 218 | + } |
|
| 219 | 219 | $sel_options['convert'] = array( |
| 220 | 220 | 0 => lang('Database values'), |
| 221 | 221 | 1 => lang('Human friendly values') |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | 'wizard_step80' => lang('Filters'), |
| 65 | 65 | ); |
| 66 | 66 | list($appname, $part2) = explode('_', get_class($this)); |
| 67 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name |
|
| 67 | + if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name |
|
| 68 | 68 | Api\Translation::add_app($appname); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
| 75 | 75 | { |
| 76 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 76 | + if ($this->debug) error_log(get_class($this).'::wizard_step30->$content '.print_r($content, true)); |
|
| 77 | 77 | // return from step30 |
| 78 | 78 | if ($content['step'] == 'wizard_step30') |
| 79 | 79 | { |
| 80 | - foreach($content['fields']['export'] as $field_name) |
|
| 80 | + foreach ($content['fields']['export'] as $field_name) |
|
| 81 | 81 | { |
| 82 | 82 | // Preserve original field names, where available |
| 83 | - if($content['plugin_options']['no_header_translation'] && $content['plugin_options']['mapping'][$field_name]) |
|
| 83 | + if ($content['plugin_options']['no_header_translation'] && $content['plugin_options']['mapping'][$field_name]) |
|
| 84 | 84 | { |
| 85 | 85 | $content['mapping'][$field_name] = $content['plugin_options']['mapping'][$field_name]; |
| 86 | 86 | } |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | $content['mapping'][$field_name] = $field_name; |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | - if($content['mapping']['all_custom_fields']) { |
|
| 92 | + if ($content['mapping']['all_custom_fields']) { |
|
| 93 | 93 | // Need the appname during actual export, to fetch the fields |
| 94 | 94 | $parts = explode('_', get_class($this)); |
| 95 | 95 | $appname = $parts[0]; |
| 96 | - foreach($parts as $name_part) { |
|
| 97 | - if($GLOBALS['egw_info']['apps'][$appname]) break; |
|
| 96 | + foreach ($parts as $name_part) { |
|
| 97 | + if ($GLOBALS['egw_info']['apps'][$appname]) break; |
|
| 98 | 98 | $appname .= '_'.$name_part; // Handle apps with _ in the name |
| 99 | 99 | } |
| 100 | 100 | $content['mapping']['all_custom_fields'] = $appname; |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | switch (array_search('pressed', $content['button'])) |
| 106 | 106 | { |
| 107 | 107 | case 'next': |
| 108 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 108 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 109 | 109 | case 'previous' : |
| 110 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 110 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 111 | 111 | case 'finish': |
| 112 | 112 | return 'wizard_finish'; |
| 113 | 113 | default : |
| 114 | - return $this->wizard_step30($content,$sel_options,$readonlys,$preserv); |
|
| 114 | + return $this->wizard_step30($content, $sel_options, $readonlys, $preserv); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | // init step30 |
@@ -125,15 +125,15 @@ discard block |
||
| 125 | 125 | unset ($preserv['button']); |
| 126 | 126 | unset ($preserv['fields']); |
| 127 | 127 | $content['fields'] = array(''); |
| 128 | - if(!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping']; |
|
| 128 | + if (!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping']; |
|
| 129 | 129 | |
| 130 | 130 | $row = 1; |
| 131 | - foreach($this->export_fields as $field => $name) { |
|
| 131 | + foreach ($this->export_fields as $field => $name) { |
|
| 132 | 132 | $content['fields'][] = array( |
| 133 | 133 | 'field' => $field, |
| 134 | 134 | 'name' => lang($name), |
| 135 | 135 | ); |
| 136 | - if($content['mapping'][$field]) { |
|
| 136 | + if ($content['mapping'][$field]) { |
|
| 137 | 137 | $content['fields']['export'][$row] = $field; |
| 138 | 138 | } |
| 139 | 139 | $row++; |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
| 157 | 157 | { |
| 158 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 158 | + if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true)); |
|
| 159 | 159 | // return from step40 |
| 160 | 160 | if ($content['step'] == 'wizard_step40') { |
| 161 | - if($content['begin_with_fieldnames'] == 'label') { |
|
| 162 | - foreach($content['mapping'] as $field => &$label) { |
|
| 161 | + if ($content['begin_with_fieldnames'] == 'label') { |
|
| 162 | + foreach ($content['mapping'] as $field => &$label) { |
|
| 163 | 163 | // Check first, to avoid clearing any pseudo-columns (ex: All custom fields) |
| 164 | 164 | $label = $this->export_fields[$field] ? $this->export_fields[$field] : $label; |
| 165 | 165 | } |
@@ -167,13 +167,13 @@ discard block |
||
| 167 | 167 | switch (array_search('pressed', $content['button'])) |
| 168 | 168 | { |
| 169 | 169 | case 'next': |
| 170 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 170 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 171 | 171 | case 'previous' : |
| 172 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 172 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 173 | 173 | case 'finish': |
| 174 | 174 | return 'wizard_finish'; |
| 175 | 175 | default : |
| 176 | - return $this->wizard_step40($content,$sel_options,$readonlys,$preserv); |
|
| 176 | + return $this->wizard_step40($content, $sel_options, $readonlys, $preserv); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | // init step40 |
@@ -183,18 +183,18 @@ discard block |
||
| 183 | 183 | $content['step'] = 'wizard_step40'; |
| 184 | 184 | |
| 185 | 185 | // If editing an existing definition, these will be in plugin_options |
| 186 | - if(!$content['delimiter'] && $content['plugin_options']['delimiter']) { |
|
| 186 | + if (!$content['delimiter'] && $content['plugin_options']['delimiter']) { |
|
| 187 | 187 | $content['delimiter'] = $content['plugin_options']['delimiter']; |
| 188 | 188 | } elseif (!$content['delimiter']) { |
| 189 | 189 | $content['delimiter'] = ';'; |
| 190 | 190 | } |
| 191 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 191 | + if (!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 192 | 192 | $content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user'; |
| 193 | 193 | } |
| 194 | - if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) { |
|
| 194 | + if (!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) { |
|
| 195 | 195 | $content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames']; |
| 196 | 196 | } |
| 197 | - if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 197 | + if (!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 198 | 198 | $content['convert'] = $content['plugin_options']['convert']; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -204,17 +204,17 @@ discard block |
||
| 204 | 204 | 1 => lang('Field names'), |
| 205 | 205 | 'label' => lang('Field labels') |
| 206 | 206 | ); |
| 207 | - $sel_options['charset'] = Api\Translation::get_installed_charsets()+ |
|
| 207 | + $sel_options['charset'] = Api\Translation::get_installed_charsets() + |
|
| 208 | 208 | array( |
| 209 | 209 | 'user' => lang('User preference'), |
| 210 | 210 | ); |
| 211 | 211 | |
| 212 | 212 | // Add in extra allowed charsets |
| 213 | 213 | $config = Api\Config::read('importexport'); |
| 214 | - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
| 215 | - if($extra_charsets) |
|
| 214 | + $extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings()); |
|
| 215 | + if ($extra_charsets) |
|
| 216 | 216 | { |
| 217 | - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
| 217 | + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets)); |
|
| 218 | 218 | } |
| 219 | 219 | $sel_options['convert'] = array( |
| 220 | 220 | 0 => lang('Database values'), |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | function wizard_step80(&$content, &$sel_options, &$readonlys, &$preserv) |
| 240 | 240 | { |
| 241 | - if($this->debug) error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true)); |
|
| 241 | + if ($this->debug) error_log(get_class($this).'::'.__METHOD__.'->$content '.print_r($content, true)); |
|
| 242 | 242 | // return from submit |
| 243 | 243 | if ($content['step'] == 'wizard_step80') { |
| 244 | 244 | // Process submitted |
| 245 | 245 | unset($content['filter']); |
| 246 | 246 | unset($content['set_filter']['fields']); |
| 247 | - foreach($content['set_filter'] as $key => $value) |
|
| 247 | + foreach ($content['set_filter'] as $key => $value) |
|
| 248 | 248 | { |
| 249 | - if($value) { |
|
| 249 | + if ($value) { |
|
| 250 | 250 | $content['filter'][$key] = $value; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | switch (array_search('pressed', $content['button'])) |
| 257 | 257 | { |
| 258 | 258 | case 'next': |
| 259 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 259 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 260 | 260 | case 'previous' : |
| 261 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 261 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 262 | 262 | case 'finish': |
| 263 | 263 | return 'wizard_finish'; |
| 264 | 264 | default : |
| 265 | - return $this->wizard_step80($content,$sel_options,$readonlys,$preserv); |
|
| 265 | + return $this->wizard_step80($content, $sel_options, $readonlys, $preserv); |
|
| 266 | 266 | } |
| 267 | 267 | } else { |
| 268 | 268 | |
@@ -273,15 +273,15 @@ discard block |
||
| 273 | 273 | unset ($preserv['button']); |
| 274 | 274 | |
| 275 | 275 | $content['set_filter']['fields'] = importexport_helper_functions::get_filter_fields( |
| 276 | - $content['application'],$content['plugin'],$this |
|
| 276 | + $content['application'], $content['plugin'], $this |
|
| 277 | 277 | ); |
| 278 | 278 | // Load existing filter from either content or definition |
| 279 | - foreach($content['set_filter']['fields'] as $field => $settings) |
|
| 279 | + foreach ($content['set_filter']['fields'] as $field => $settings) |
|
| 280 | 280 | { |
| 281 | 281 | $content['set_filter'][$field] = $content['filter'][$field]; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if(!$content['set_filter']['fields']) |
|
| 284 | + if (!$content['set_filter']['fields']) |
|
| 285 | 285 | { |
| 286 | 286 | // No fields |
| 287 | 287 | return importexport_definitions_ui::SKIP; |
@@ -64,7 +64,11 @@ discard block |
||
| 64 | 64 | 'wizard_step80' => lang('Filters'), |
| 65 | 65 | ); |
| 66 | 66 | list($appname, $part2) = explode('_', get_class($this)); |
| 67 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name |
|
| 67 | + if(!$GLOBALS['egw_info']['apps'][$appname]) |
|
| 68 | + { |
|
| 69 | + $appname .= '_'.$part2; |
|
| 70 | + } |
|
| 71 | + // Handle apps with _ in the name |
|
| 68 | 72 | Api\Translation::add_app($appname); |
| 69 | 73 | } |
| 70 | 74 | |
@@ -73,7 +77,10 @@ discard block |
||
| 73 | 77 | */ |
| 74 | 78 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
| 75 | 79 | { |
| 76 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 80 | + if($this->debug) |
|
| 81 | + { |
|
| 82 | + error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 83 | + } |
|
| 77 | 84 | // return from step30 |
| 78 | 85 | if ($content['step'] == 'wizard_step30') |
| 79 | 86 | { |
@@ -89,12 +96,17 @@ discard block |
||
| 89 | 96 | $content['mapping'][$field_name] = $field_name; |
| 90 | 97 | } |
| 91 | 98 | } |
| 92 | - if($content['mapping']['all_custom_fields']) { |
|
| 99 | + if($content['mapping']['all_custom_fields']) |
|
| 100 | + { |
|
| 93 | 101 | // Need the appname during actual export, to fetch the fields |
| 94 | 102 | $parts = explode('_', get_class($this)); |
| 95 | 103 | $appname = $parts[0]; |
| 96 | - foreach($parts as $name_part) { |
|
| 97 | - if($GLOBALS['egw_info']['apps'][$appname]) break; |
|
| 104 | + foreach($parts as $name_part) |
|
| 105 | + { |
|
| 106 | + if($GLOBALS['egw_info']['apps'][$appname]) |
|
| 107 | + { |
|
| 108 | + break; |
|
| 109 | + } |
|
| 98 | 110 | $appname .= '_'.$name_part; // Handle apps with _ in the name |
| 99 | 111 | } |
| 100 | 112 | $content['mapping']['all_custom_fields'] = $appname; |
@@ -125,15 +137,20 @@ discard block |
||
| 125 | 137 | unset ($preserv['button']); |
| 126 | 138 | unset ($preserv['fields']); |
| 127 | 139 | $content['fields'] = array(''); |
| 128 | - if(!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping']; |
|
| 140 | + if(!$content['mapping']) |
|
| 141 | + { |
|
| 142 | + $content['mapping'] = $content['plugin_options']['mapping']; |
|
| 143 | + } |
|
| 129 | 144 | |
| 130 | 145 | $row = 1; |
| 131 | - foreach($this->export_fields as $field => $name) { |
|
| 146 | + foreach($this->export_fields as $field => $name) |
|
| 147 | + { |
|
| 132 | 148 | $content['fields'][] = array( |
| 133 | 149 | 'field' => $field, |
| 134 | 150 | 'name' => lang($name), |
| 135 | 151 | ); |
| 136 | - if($content['mapping'][$field]) { |
|
| 152 | + if($content['mapping'][$field]) |
|
| 153 | + { |
|
| 137 | 154 | $content['fields']['export'][$row] = $field; |
| 138 | 155 | } |
| 139 | 156 | $row++; |
@@ -155,11 +172,17 @@ discard block |
||
| 155 | 172 | */ |
| 156 | 173 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
| 157 | 174 | { |
| 158 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 175 | + if($this->debug) |
|
| 176 | + { |
|
| 177 | + error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 178 | + } |
|
| 159 | 179 | // return from step40 |
| 160 | - if ($content['step'] == 'wizard_step40') { |
|
| 161 | - if($content['begin_with_fieldnames'] == 'label') { |
|
| 162 | - foreach($content['mapping'] as $field => &$label) { |
|
| 180 | + if ($content['step'] == 'wizard_step40') |
|
| 181 | + { |
|
| 182 | + if($content['begin_with_fieldnames'] == 'label') |
|
| 183 | + { |
|
| 184 | + foreach($content['mapping'] as $field => &$label) |
|
| 185 | + { |
|
| 163 | 186 | // Check first, to avoid clearing any pseudo-columns (ex: All custom fields) |
| 164 | 187 | $label = $this->export_fields[$field] ? $this->export_fields[$field] : $label; |
| 165 | 188 | } |
@@ -183,18 +206,24 @@ discard block |
||
| 183 | 206 | $content['step'] = 'wizard_step40'; |
| 184 | 207 | |
| 185 | 208 | // If editing an existing definition, these will be in plugin_options |
| 186 | - if(!$content['delimiter'] && $content['plugin_options']['delimiter']) { |
|
| 209 | + if(!$content['delimiter'] && $content['plugin_options']['delimiter']) |
|
| 210 | + { |
|
| 187 | 211 | $content['delimiter'] = $content['plugin_options']['delimiter']; |
| 188 | - } elseif (!$content['delimiter']) { |
|
| 212 | + } |
|
| 213 | + elseif (!$content['delimiter']) |
|
| 214 | + { |
|
| 189 | 215 | $content['delimiter'] = ';'; |
| 190 | 216 | } |
| 191 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 217 | + if(!$content['charset'] && $content['plugin_options']['charset']) |
|
| 218 | + { |
|
| 192 | 219 | $content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user'; |
| 193 | 220 | } |
| 194 | - if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) { |
|
| 221 | + if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) |
|
| 222 | + { |
|
| 195 | 223 | $content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames']; |
| 196 | 224 | } |
| 197 | - if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 225 | + if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) |
|
| 226 | + { |
|
| 198 | 227 | $content['convert'] = $content['plugin_options']['convert']; |
| 199 | 228 | } |
| 200 | 229 | |
@@ -238,15 +267,20 @@ discard block |
||
| 238 | 267 | */ |
| 239 | 268 | function wizard_step80(&$content, &$sel_options, &$readonlys, &$preserv) |
| 240 | 269 | { |
| 241 | - if($this->debug) error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true)); |
|
| 270 | + if($this->debug) |
|
| 271 | + { |
|
| 272 | + error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true)); |
|
| 273 | + } |
|
| 242 | 274 | // return from submit |
| 243 | - if ($content['step'] == 'wizard_step80') { |
|
| 275 | + if ($content['step'] == 'wizard_step80') |
|
| 276 | + { |
|
| 244 | 277 | // Process submitted |
| 245 | 278 | unset($content['filter']); |
| 246 | 279 | unset($content['set_filter']['fields']); |
| 247 | 280 | foreach($content['set_filter'] as $key => $value) |
| 248 | 281 | { |
| 249 | - if($value) { |
|
| 282 | + if($value) |
|
| 283 | + { |
|
| 250 | 284 | $content['filter'][$key] = $value; |
| 251 | 285 | } |
| 252 | 286 | } |
@@ -264,7 +298,9 @@ discard block |
||
| 264 | 298 | default : |
| 265 | 299 | return $this->wizard_step80($content,$sel_options,$readonlys,$preserv); |
| 266 | 300 | } |
| 267 | - } else { |
|
| 301 | + } |
|
| 302 | + else |
|
| 303 | + { |
|
| 268 | 304 | |
| 269 | 305 | // Step 50 - filters |
| 270 | 306 | $content['text'] = $this->steps['wizard_step80']; |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | const TEMPLATE_MARKER = '-eTemplate-'; |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * List of steps. Key is the function, value is the translated title. |
|
| 27 | - */ |
|
| 26 | + * List of steps. Key is the function, value is the translated title. |
|
| 27 | + */ |
|
| 28 | 28 | public $steps; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
| 32 | - */ |
|
| 31 | + * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
| 32 | + */ |
|
| 33 | 33 | protected $step_templates = array( |
| 34 | 34 | 'wizard_step30' => 'importexport.wizard_basic_import_csv.sample_file', |
| 35 | 35 | 'wizard_step40' => 'importexport.wizard_basic_import_csv.choosesepncharset', |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Destination fields for the mapping |
|
| 43 | - * Key is the field name, value is the human version |
|
| 44 | - */ |
|
| 42 | + * Destination fields for the mapping |
|
| 43 | + * Key is the field name, value is the human version |
|
| 44 | + */ |
|
| 45 | 45 | protected $mapping_fields = array(); |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * List of conditions your plugin supports |
|
| 49 | - */ |
|
| 48 | + * List of conditions your plugin supports |
|
| 49 | + */ |
|
| 50 | 50 | protected $conditions = array(); |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * List of actions your plugin supports |
|
| 54 | - */ |
|
| 53 | + * List of actions your plugin supports |
|
| 54 | + */ |
|
| 55 | 55 | protected $actions = array(); |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Take a sample CSV file. It will be processed in later steps |
|
| 72 | - */ |
|
| 71 | + * Take a sample CSV file. It will be processed in later steps |
|
| 72 | + */ |
|
| 73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
| 74 | 74 | { |
| 75 | 75 | if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | - * Process the sample file, get the fields out of it, then allow them to be mapped onto |
|
| 267 | - * the fields the destination understands. Also, set any translations to be done to the field. |
|
| 268 | - * |
|
| 269 | - * You can use the eTemplate |
|
| 270 | - */ |
|
| 266 | + * Process the sample file, get the fields out of it, then allow them to be mapped onto |
|
| 267 | + * the fields the destination understands. Also, set any translations to be done to the field. |
|
| 268 | + * |
|
| 269 | + * You can use the eTemplate |
|
| 270 | + */ |
|
| 271 | 271 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
| 272 | 272 | { |
| 273 | 273 | if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
| 351 | - * Edit conditions |
|
| 352 | - */ |
|
| 351 | + * Edit conditions |
|
| 352 | + */ |
|
| 353 | 353 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
| 354 | 354 | { |
| 355 | 355 | if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
| 74 | 74 | { |
| 75 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 75 | + if ($this->debug) error_log(get_class($this).'::wizard_step30->$content '.print_r($content, true)); |
|
| 76 | 76 | // return from step30 |
| 77 | 77 | if ($content['step'] == 'wizard_step30') |
| 78 | 78 | { |
@@ -80,17 +80,17 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | case 'next': |
| 82 | 82 | // Move sample file to temp |
| 83 | - if($content['file']['tmp_name']) { |
|
| 83 | + if ($content['file']['tmp_name']) { |
|
| 84 | 84 | Api\Cache::setSession($content['application'], 'csvfile', $content['file']['tmp_name']); |
| 85 | 85 | } |
| 86 | 86 | unset($content['file']); |
| 87 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 87 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 88 | 88 | case 'previous' : |
| 89 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 89 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 90 | 90 | case 'finish': |
| 91 | 91 | return 'wizard_finish'; |
| 92 | 92 | default : |
| 93 | - return $this->wizard_step30($content,$sel_options,$readonlys,$preserv); |
|
| 93 | + return $this->wizard_step30($content, $sel_options, $readonlys, $preserv); |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | // init step30 |
@@ -117,57 +117,57 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
| 119 | 119 | { |
| 120 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 120 | + if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true)); |
|
| 121 | 121 | // return from step40 |
| 122 | 122 | if ($content['step'] == 'wizard_step40') { |
| 123 | 123 | switch (array_search('pressed', $content['button'])) |
| 124 | 124 | { |
| 125 | 125 | case 'next': |
| 126 | 126 | // Process sample file for fields |
| 127 | - if (Api\Cache::getSession($content['application'],'csvfile') && |
|
| 128 | - ($handle = fopen(Api\Cache::getSession($content['application'],'csvfile'), "rb")) !== FALSE |
|
| 127 | + if (Api\Cache::getSession($content['application'], 'csvfile') && |
|
| 128 | + ($handle = fopen(Api\Cache::getSession($content['application'], 'csvfile'), "rb")) !== FALSE |
|
| 129 | 129 | ) { |
| 130 | 130 | $data = fgetcsv($handle, 8000, $content['fieldsep']); |
| 131 | 131 | //error_log(array2string($data)); |
| 132 | 132 | fclose($handle); |
| 133 | 133 | |
| 134 | 134 | // Remove & forget file |
| 135 | - unlink(Api\Cache::getSession($content['application'],'csvfile')); |
|
| 135 | + unlink(Api\Cache::getSession($content['application'], 'csvfile')); |
|
| 136 | 136 | Api\Cache::setSession($content['application'], 'csvfile', ''); |
| 137 | - $content['csv_fields'] = Api\Translation::convert($data,$content['charset']); |
|
| 137 | + $content['csv_fields'] = Api\Translation::convert($data, $content['charset']); |
|
| 138 | 138 | |
| 139 | 139 | // Reset field mapping for new file |
| 140 | 140 | $content['field_mapping'] = array(); |
| 141 | 141 | |
| 142 | 142 | // Try to match automatically |
| 143 | 143 | $english = array(); |
| 144 | - foreach($content['csv_fields'] as $index => $field) { |
|
| 145 | - if($content['field_mapping'][$index]) continue; |
|
| 144 | + foreach ($content['csv_fields'] as $index => $field) { |
|
| 145 | + if ($content['field_mapping'][$index]) continue; |
|
| 146 | 146 | $best_match = ''; |
| 147 | 147 | $best_match_value = 0; |
| 148 | - foreach($this->mapping_fields as $key => $field_name) { |
|
| 149 | - if(is_array($field_name)) continue; |
|
| 150 | - if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) { |
|
| 148 | + foreach ($this->mapping_fields as $key => $field_name) { |
|
| 149 | + if (is_array($field_name)) continue; |
|
| 150 | + if (strcasecmp($field, $field_name) == 0 || strcasecmp($field, $key) == 0) { |
|
| 151 | 151 | $content['field_mapping'][$index] = $key; |
| 152 | 152 | continue 2; |
| 153 | 153 | } |
| 154 | 154 | // Check english also |
| 155 | - if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
| 155 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
| 156 | 156 | $msg_id = Api\Translation::get_message_id($field_name, $content['application']); |
| 157 | 157 | } |
| 158 | - if($msg_id) { |
|
| 158 | + if ($msg_id) { |
|
| 159 | 159 | $english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id); |
| 160 | 160 | } else { |
| 161 | 161 | $english[$field_name] = false; |
| 162 | 162 | } |
| 163 | - if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
| 163 | + if ($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
| 164 | 164 | $content['field_mapping'][$index] = $key; |
| 165 | 165 | continue 2; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Check for similar but slightly different |
| 169 | 169 | $match = 0; |
| 170 | - if(similar_text(strtolower($field), strtolower($field_name), $match) && |
|
| 170 | + if (similar_text(strtolower($field), strtolower($field_name), $match) && |
|
| 171 | 171 | $match > 85 && |
| 172 | 172 | $match > $best_match_value |
| 173 | 173 | ) { |
@@ -176,20 +176,20 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | } |
| 179 | - if($best_match) { |
|
| 179 | + if ($best_match) { |
|
| 180 | 180 | $content['field_mapping'][$index] = $best_match; |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | - } elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
| 183 | + } elseif (!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
| 184 | 184 | $content['csv_fields'] = $content['plugin_options']['csv_fields']; |
| 185 | 185 | } |
| 186 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 186 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 187 | 187 | case 'previous' : |
| 188 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 188 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 189 | 189 | case 'finish': |
| 190 | 190 | return 'wizard_finish'; |
| 191 | 191 | default : |
| 192 | - return $this->wizard_step40($content,$sel_options,$readonlys,$preserv); |
|
| 192 | + return $this->wizard_step40($content, $sel_options, $readonlys, $preserv); |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | // init step40 |
@@ -199,17 +199,17 @@ discard block |
||
| 199 | 199 | $content['step'] = 'wizard_step40'; |
| 200 | 200 | |
| 201 | 201 | // If editing an existing definition, these will be in plugin_options |
| 202 | - if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
| 202 | + if (!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
| 203 | 203 | $content['fieldsep'] = $content['plugin_options']['fieldsep']; |
| 204 | 204 | } elseif (!$content['fieldsep']) { |
| 205 | 205 | $content['fieldsep'] = ';'; |
| 206 | 206 | } |
| 207 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 207 | + if (!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 208 | 208 | $content['charset'] = $content['plugin_options']['charset']; |
| 209 | 209 | } |
| 210 | - if(!array_key_exists('num_header_lines', $content)) |
|
| 210 | + if (!array_key_exists('num_header_lines', $content)) |
|
| 211 | 211 | { |
| 212 | - if(is_array($content['plugin_options']) && array_key_exists('num_header_lines', $content['plugin_options'])) |
|
| 212 | + if (is_array($content['plugin_options']) && array_key_exists('num_header_lines', $content['plugin_options'])) |
|
| 213 | 213 | { |
| 214 | 214 | $content['num_header_lines'] = $content['plugin_options']['num_header_lines']; |
| 215 | 215 | } |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | $content['num_header_lines'] = 1; |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | - if(!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
| 222 | + if (!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
| 223 | 223 | $content['update_cats'] = $content['plugin_options']['update_cats']; |
| 224 | 224 | } |
| 225 | - if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 225 | + if (!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 226 | 226 | $content['convert'] = $content['plugin_options']['convert']; |
| 227 | 227 | } |
| 228 | 228 | else |
@@ -231,24 +231,24 @@ discard block |
||
| 231 | 231 | $content['convert'] = 1; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $sel_options['charset'] = Api\Translation::get_installed_charsets()+ |
|
| 234 | + $sel_options['charset'] = Api\Translation::get_installed_charsets() + |
|
| 235 | 235 | array( |
| 236 | 236 | 'user' => lang('User preference'), |
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | 239 | // Add in extra allowed charsets |
| 240 | 240 | $config = Api\Config::read('importexport'); |
| 241 | - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
| 242 | - if($extra_charsets) |
|
| 241 | + $extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings()); |
|
| 242 | + if ($extra_charsets) |
|
| 243 | 243 | { |
| 244 | - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
| 244 | + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets)); |
|
| 245 | 245 | } |
| 246 | 246 | $sel_options['convert'] = array( |
| 247 | 247 | 0 => lang('Database values'), |
| 248 | 248 | 1 => lang('Human friendly values') |
| 249 | 249 | ); |
| 250 | 250 | $preserv = $content; |
| 251 | - if($this->mapping_fields['cat_id']) { |
|
| 251 | + if ($this->mapping_fields['cat_id']) { |
|
| 252 | 252 | $sel_options['update_cats'] = array( |
| 253 | 253 | 'add' => lang('Add'), |
| 254 | 254 | 'replace'=> lang('Replace') |
@@ -270,18 +270,18 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
| 272 | 272 | { |
| 273 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
| 273 | + if ($this->debug) error_log(get_class($this).'::wizard_step50->$content '.print_r($content, true)); |
|
| 274 | 274 | // return from step50 |
| 275 | 275 | if ($content['step'] == 'wizard_step50') |
| 276 | 276 | { |
| 277 | 277 | unset($content['field_mapping']); |
| 278 | 278 | unset($content['field_conversion']); |
| 279 | - foreach($content['mapping'] as $field) |
|
| 279 | + foreach ($content['mapping'] as $field) |
|
| 280 | 280 | { |
| 281 | 281 | $index = $field['index']; |
| 282 | - foreach(array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest) |
|
| 282 | + foreach (array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest) |
|
| 283 | 283 | { |
| 284 | - if(trim($field[$id]) != '' && $field[$id] !== '--NONE--') |
|
| 284 | + if (trim($field[$id]) != '' && $field[$id] !== '--NONE--') |
|
| 285 | 285 | { |
| 286 | 286 | $content[$dest][$index] = trim($field[$id]); |
| 287 | 287 | } |
@@ -291,13 +291,13 @@ discard block |
||
| 291 | 291 | switch (array_search('pressed', $content['button'])) |
| 292 | 292 | { |
| 293 | 293 | case 'next': |
| 294 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 294 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 295 | 295 | case 'previous' : |
| 296 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 296 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 297 | 297 | case 'finish': |
| 298 | 298 | return 'wizard_finish'; |
| 299 | 299 | default : |
| 300 | - return $this->wizard_step50($content,$sel_options,$readonlys,$preserv); |
|
| 300 | + return $this->wizard_step50($content, $sel_options, $readonlys, $preserv); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | // init step50 |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $content['step'] = 'wizard_step50'; |
| 308 | 308 | |
| 309 | 309 | $content['mapping'] = array(false); |
| 310 | - if(array_key_exists('field_mapping', $content)) |
|
| 310 | + if (array_key_exists('field_mapping', $content)) |
|
| 311 | 311 | { |
| 312 | 312 | $field = $content['field_mapping']; |
| 313 | 313 | $conversion = $content['field_conversion']; |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $conversion = $content['plugin_options']['field_conversion']; |
| 319 | 319 | } |
| 320 | 320 | $empties = 1; |
| 321 | - foreach($content['csv_fields'] as $index => $title) |
|
| 321 | + foreach ($content['csv_fields'] as $index => $title) |
|
| 322 | 322 | { |
| 323 | 323 | $content['mapping'][] = array( |
| 324 | 324 | 'index' => $index, |
@@ -326,15 +326,15 @@ discard block |
||
| 326 | 326 | 'field' => $field[$index], |
| 327 | 327 | 'conversion' => $conversion[$index] |
| 328 | 328 | ); |
| 329 | - if(strstr($title,lang('Extra %1'))) $empties++; |
|
| 329 | + if (strstr($title, lang('Extra %1'))) $empties++; |
|
| 330 | 330 | } |
| 331 | - while($empties <= 3) |
|
| 331 | + while ($empties <= 3) |
|
| 332 | 332 | { |
| 333 | 333 | $content['mapping'][] = array( |
| 334 | 334 | 'index' => $index + $empties, |
| 335 | 335 | 'title' => lang('Extra %1', $empties), |
| 336 | - 'field' => $field[$index+$empties], |
|
| 337 | - 'conversion' => $conversion[$index+$empties] |
|
| 336 | + 'field' => $field[$index + $empties], |
|
| 337 | + 'conversion' => $conversion[$index + $empties] |
|
| 338 | 338 | ); |
| 339 | 339 | $empties++; |
| 340 | 340 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
| 354 | 354 | { |
| 355 | - if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
| 355 | + if ($this->debug) error_log(get_class($this).'::wizard_step55->$content '.print_r($content, true)); |
|
| 356 | 356 | |
| 357 | 357 | // return from step55 |
| 358 | 358 | if ($content['step'] == 'wizard_step55') |
@@ -360,8 +360,8 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | // Clear conditions that don't do anything |
| 362 | 362 | array_shift($content['conditions']); |
| 363 | - foreach($content['conditions'] as $key => &$condition) { |
|
| 364 | - if(($condition['true']['action'] == 'none' || !$condition['true']['action']) |
|
| 363 | + foreach ($content['conditions'] as $key => &$condition) { |
|
| 364 | + if (($condition['true']['action'] == 'none' || !$condition['true']['action']) |
|
| 365 | 365 | && ($condition['false']['action'] == 'none' || !$condition['false']['action']) && |
| 366 | 366 | !$condition['string'] |
| 367 | 367 | ) { |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | // Check for true without false, or false without true - set to 'none' |
| 373 | - elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
|
| 373 | + elseif ($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
|
| 374 | 374 | $condition['true']['action'] != '' && $condition['false']['action'] == '' || |
| 375 | 375 | !$condition['true'] || !$condition['false'] |
| 376 | 376 | ) |
@@ -382,9 +382,9 @@ discard block |
||
| 382 | 382 | switch (array_search('pressed', $content['button'])) |
| 383 | 383 | { |
| 384 | 384 | case 'next': |
| 385 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 385 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 386 | 386 | case 'previous' : |
| 387 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 387 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 388 | 388 | case 'finish': |
| 389 | 389 | return 'wizard_finish'; |
| 390 | 390 | case 'add': |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | $content['conditions'][] = array('string' => ''); |
| 394 | 394 | return 'wizard_step55'; |
| 395 | 395 | default : |
| 396 | - return $this->wizard_step55($content,$sel_options,$readonlys,$preserv); |
|
| 396 | + return $this->wizard_step55($content, $sel_options, $readonlys, $preserv); |
|
| 397 | 397 | break; |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -401,18 +401,18 @@ discard block |
||
| 401 | 401 | $content['text'] = $this->steps['wizard_step55']; |
| 402 | 402 | $content['step'] = 'wizard_step55'; |
| 403 | 403 | |
| 404 | - if(!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
| 404 | + if (!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
| 405 | 405 | $content['conditions'] = $content['plugin_options']['conditions']; |
| 406 | 406 | } |
| 407 | 407 | $preserv = $content; |
| 408 | 408 | |
| 409 | - foreach($content['field_mapping'] as $field) { |
|
| 409 | + foreach ($content['field_mapping'] as $field) { |
|
| 410 | 410 | $sel_options['string'][$field] = $this->mapping_fields[$field]; |
| 411 | - if(!$sel_options['string'][$field]) |
|
| 411 | + if (!$sel_options['string'][$field]) |
|
| 412 | 412 | { |
| 413 | - foreach($this->mapping_fields as $fields) |
|
| 413 | + foreach ($this->mapping_fields as $fields) |
|
| 414 | 414 | { |
| 415 | - if(is_array($fields) && $fields[$field]) |
|
| 415 | + if (is_array($fields) && $fields[$field]) |
|
| 416 | 416 | { |
| 417 | 417 | $sel_options['string'][$field] = $fields[$field]; |
| 418 | 418 | } |
@@ -72,7 +72,10 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
| 74 | 74 | { |
| 75 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 75 | + if($this->debug) |
|
| 76 | + { |
|
| 77 | + error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 78 | + } |
|
| 76 | 79 | // return from step30 |
| 77 | 80 | if ($content['step'] == 'wizard_step30') |
| 78 | 81 | { |
@@ -80,7 +83,8 @@ discard block |
||
| 80 | 83 | { |
| 81 | 84 | case 'next': |
| 82 | 85 | // Move sample file to temp |
| 83 | - if($content['file']['tmp_name']) { |
|
| 86 | + if($content['file']['tmp_name']) |
|
| 87 | + { |
|
| 84 | 88 | Api\Cache::setSession($content['application'], 'csvfile', $content['file']['tmp_name']); |
| 85 | 89 | } |
| 86 | 90 | unset($content['file']); |
@@ -117,9 +121,13 @@ discard block |
||
| 117 | 121 | */ |
| 118 | 122 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
| 119 | 123 | { |
| 120 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 124 | + if($this->debug) |
|
| 125 | + { |
|
| 126 | + error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 127 | + } |
|
| 121 | 128 | // return from step40 |
| 122 | - if ($content['step'] == 'wizard_step40') { |
|
| 129 | + if ($content['step'] == 'wizard_step40') |
|
| 130 | + { |
|
| 123 | 131 | switch (array_search('pressed', $content['button'])) |
| 124 | 132 | { |
| 125 | 133 | case 'next': |
@@ -141,26 +149,40 @@ discard block |
||
| 141 | 149 | |
| 142 | 150 | // Try to match automatically |
| 143 | 151 | $english = array(); |
| 144 | - foreach($content['csv_fields'] as $index => $field) { |
|
| 145 | - if($content['field_mapping'][$index]) continue; |
|
| 152 | + foreach($content['csv_fields'] as $index => $field) |
|
| 153 | + { |
|
| 154 | + if($content['field_mapping'][$index]) |
|
| 155 | + { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 146 | 158 | $best_match = ''; |
| 147 | 159 | $best_match_value = 0; |
| 148 | - foreach($this->mapping_fields as $key => $field_name) { |
|
| 149 | - if(is_array($field_name)) continue; |
|
| 150 | - if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) { |
|
| 160 | + foreach($this->mapping_fields as $key => $field_name) |
|
| 161 | + { |
|
| 162 | + if(is_array($field_name)) |
|
| 163 | + { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 166 | + if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) |
|
| 167 | + { |
|
| 151 | 168 | $content['field_mapping'][$index] = $key; |
| 152 | 169 | continue 2; |
| 153 | 170 | } |
| 154 | 171 | // Check english also |
| 155 | - if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
| 172 | + if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) |
|
| 173 | + { |
|
| 156 | 174 | $msg_id = Api\Translation::get_message_id($field_name, $content['application']); |
| 157 | 175 | } |
| 158 | - if($msg_id) { |
|
| 176 | + if($msg_id) |
|
| 177 | + { |
|
| 159 | 178 | $english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id); |
| 160 | - } else { |
|
| 179 | + } |
|
| 180 | + else |
|
| 181 | + { |
|
| 161 | 182 | $english[$field_name] = false; |
| 162 | 183 | } |
| 163 | - if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
| 184 | + if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) |
|
| 185 | + { |
|
| 164 | 186 | $content['field_mapping'][$index] = $key; |
| 165 | 187 | continue 2; |
| 166 | 188 | } |
@@ -176,11 +198,14 @@ discard block |
||
| 176 | 198 | } |
| 177 | 199 | |
| 178 | 200 | } |
| 179 | - if($best_match) { |
|
| 201 | + if($best_match) |
|
| 202 | + { |
|
| 180 | 203 | $content['field_mapping'][$index] = $best_match; |
| 181 | 204 | } |
| 182 | 205 | } |
| 183 | - } elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
| 206 | + } |
|
| 207 | + elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) |
|
| 208 | + { |
|
| 184 | 209 | $content['csv_fields'] = $content['plugin_options']['csv_fields']; |
| 185 | 210 | } |
| 186 | 211 | return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
@@ -199,12 +224,16 @@ discard block |
||
| 199 | 224 | $content['step'] = 'wizard_step40'; |
| 200 | 225 | |
| 201 | 226 | // If editing an existing definition, these will be in plugin_options |
| 202 | - if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
| 227 | + if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) |
|
| 228 | + { |
|
| 203 | 229 | $content['fieldsep'] = $content['plugin_options']['fieldsep']; |
| 204 | - } elseif (!$content['fieldsep']) { |
|
| 230 | + } |
|
| 231 | + elseif (!$content['fieldsep']) |
|
| 232 | + { |
|
| 205 | 233 | $content['fieldsep'] = ';'; |
| 206 | 234 | } |
| 207 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 235 | + if(!$content['charset'] && $content['plugin_options']['charset']) |
|
| 236 | + { |
|
| 208 | 237 | $content['charset'] = $content['plugin_options']['charset']; |
| 209 | 238 | } |
| 210 | 239 | if(!array_key_exists('num_header_lines', $content)) |
@@ -219,10 +248,12 @@ discard block |
||
| 219 | 248 | $content['num_header_lines'] = 1; |
| 220 | 249 | } |
| 221 | 250 | } |
| 222 | - if(!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
| 251 | + if(!$content['update_cats'] && $content['plugin_options']['update_cats']) |
|
| 252 | + { |
|
| 223 | 253 | $content['update_cats'] = $content['plugin_options']['update_cats']; |
| 224 | 254 | } |
| 225 | - if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 255 | + if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) |
|
| 256 | + { |
|
| 226 | 257 | $content['convert'] = $content['plugin_options']['convert']; |
| 227 | 258 | } |
| 228 | 259 | else |
@@ -248,12 +279,15 @@ discard block |
||
| 248 | 279 | 1 => lang('Human friendly values') |
| 249 | 280 | ); |
| 250 | 281 | $preserv = $content; |
| 251 | - if($this->mapping_fields['cat_id']) { |
|
| 282 | + if($this->mapping_fields['cat_id']) |
|
| 283 | + { |
|
| 252 | 284 | $sel_options['update_cats'] = array( |
| 253 | 285 | 'add' => lang('Add'), |
| 254 | 286 | 'replace'=> lang('Replace') |
| 255 | 287 | ); |
| 256 | - } else { |
|
| 288 | + } |
|
| 289 | + else |
|
| 290 | + { |
|
| 257 | 291 | $content['no_cats'] = true; |
| 258 | 292 | } |
| 259 | 293 | unset ($preserv['button']); |
@@ -270,7 +304,10 @@ discard block |
||
| 270 | 304 | */ |
| 271 | 305 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
| 272 | 306 | { |
| 273 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
| 307 | + if($this->debug) |
|
| 308 | + { |
|
| 309 | + error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
| 310 | + } |
|
| 274 | 311 | // return from step50 |
| 275 | 312 | if ($content['step'] == 'wizard_step50') |
| 276 | 313 | { |
@@ -326,7 +363,10 @@ discard block |
||
| 326 | 363 | 'field' => $field[$index], |
| 327 | 364 | 'conversion' => $conversion[$index] |
| 328 | 365 | ); |
| 329 | - if(strstr($title,lang('Extra %1'))) $empties++; |
|
| 366 | + if(strstr($title,lang('Extra %1'))) |
|
| 367 | + { |
|
| 368 | + $empties++; |
|
| 369 | + } |
|
| 330 | 370 | } |
| 331 | 371 | while($empties <= 3) |
| 332 | 372 | { |
@@ -352,7 +392,10 @@ discard block |
||
| 352 | 392 | */ |
| 353 | 393 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
| 354 | 394 | { |
| 355 | - if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
| 395 | + if($this->debug) |
|
| 396 | + { |
|
| 397 | + error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
| 398 | + } |
|
| 356 | 399 | |
| 357 | 400 | // return from step55 |
| 358 | 401 | if ($content['step'] == 'wizard_step55') |
@@ -360,7 +403,8 @@ discard block |
||
| 360 | 403 | |
| 361 | 404 | // Clear conditions that don't do anything |
| 362 | 405 | array_shift($content['conditions']); |
| 363 | - foreach($content['conditions'] as $key => &$condition) { |
|
| 406 | + foreach($content['conditions'] as $key => &$condition) |
|
| 407 | + { |
|
| 364 | 408 | if(($condition['true']['action'] == 'none' || !$condition['true']['action']) |
| 365 | 409 | && ($condition['false']['action'] == 'none' || !$condition['false']['action']) && |
| 366 | 410 | !$condition['string'] |
@@ -373,8 +417,7 @@ discard block |
||
| 373 | 417 | elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
| 374 | 418 | $condition['true']['action'] != '' && $condition['false']['action'] == '' || |
| 375 | 419 | !$condition['true'] || !$condition['false'] |
| 376 | - ) |
|
| 377 | - { |
|
| 420 | + ) { |
|
| 378 | 421 | $condition[$condition['true']['action'] == '' ? 'true' : 'false']['action'] = "none"; |
| 379 | 422 | } |
| 380 | 423 | } |
@@ -401,12 +444,14 @@ discard block |
||
| 401 | 444 | $content['text'] = $this->steps['wizard_step55']; |
| 402 | 445 | $content['step'] = 'wizard_step55'; |
| 403 | 446 | |
| 404 | - if(!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
| 447 | + if(!$content['conditions'] && $content['plugin_options']['conditions']) |
|
| 448 | + { |
|
| 405 | 449 | $content['conditions'] = $content['plugin_options']['conditions']; |
| 406 | 450 | } |
| 407 | 451 | $preserv = $content; |
| 408 | 452 | |
| 409 | - foreach($content['field_mapping'] as $field) { |
|
| 453 | + foreach($content['field_mapping'] as $field) |
|
| 454 | + { |
|
| 410 | 455 | $sel_options['string'][$field] = $this->mapping_fields[$field]; |
| 411 | 456 | if(!$sel_options['string'][$field]) |
| 412 | 457 | { |