@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @version $Id$ |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
| 14 | +chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
| 15 | 15 | |
| 16 | 16 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
| 17 | 17 | { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | $ids = explode(',', $_SERVER['argv'][0]); |
| 41 | 41 | $change = array(); |
| 42 | -while($ids) |
|
| 42 | +while ($ids) |
|
| 43 | 43 | { |
| 44 | 44 | $from = (int)array_shift($ids); |
| 45 | 45 | $to = (int)array_shift($ids); |
@@ -66,24 +66,24 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | chown_grp($path, null, $recursive); |
| 68 | 68 | |
| 69 | -function chown_grp($path, array $stat=null, $recursive=false) |
|
| 69 | +function chown_grp($path, array $stat = null, $recursive = false) |
|
| 70 | 70 | { |
| 71 | 71 | global $change; |
| 72 | 72 | |
| 73 | 73 | if (is_null($stat) && !($stat = stat($path))) return false; |
| 74 | 74 | |
| 75 | - if (isset($change[$stat['uid']]) && !chown($path, $uid=$change[$stat['uid']])) |
|
| 75 | + if (isset($change[$stat['uid']]) && !chown($path, $uid = $change[$stat['uid']])) |
|
| 76 | 76 | { |
| 77 | 77 | echo "Faild to set new owner #$uid for $path\n"; |
| 78 | 78 | } |
| 79 | - if (isset($change[-$stat['gid']]) && !chgrp($path, $gid=-$change[-$stat['gid']])) |
|
| 79 | + if (isset($change[-$stat['gid']]) && !chgrp($path, $gid = -$change[-$stat['gid']])) |
|
| 80 | 80 | { |
| 81 | 81 | echo "Faild to set new group #$gid for $path\n"; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if ($recursive && is_dir($path)) |
| 85 | 85 | { |
| 86 | - foreach(new DirectoryIterator($path) as $child) |
|
| 86 | + foreach (new DirectoryIterator($path) as $child) |
|
| 87 | 87 | { |
| 88 | 88 | if (!$child->isDot()) |
| 89 | 89 | chown_grp($child->getPathname(), array( |
@@ -13,10 +13,13 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | chdir(dirname(__FILE__)); // to enable our relative pathes to work |
| 15 | 15 | |
| 16 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
|
| 16 | +if (php_sapi_name() !== 'cli') |
|
| 17 | +{ |
|
| 18 | + // security precaution: forbit calling as web-page |
|
| 17 | 19 | { |
| 18 | 20 | die('<h1>setup/doc/chown.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 19 | 21 | } |
| 22 | +} |
|
| 20 | 23 | |
| 21 | 24 | $recursive = false; |
| 22 | 25 | |
@@ -70,7 +73,10 @@ discard block |
||
| 70 | 73 | { |
| 71 | 74 | global $change; |
| 72 | 75 | |
| 73 | - if (is_null($stat) && !($stat = stat($path))) return false; |
|
| 76 | + if (is_null($stat) && !($stat = stat($path))) |
|
| 77 | + { |
|
| 78 | + return false; |
|
| 79 | + } |
|
| 74 | 80 | |
| 75 | 81 | if (isset($change[$stat['uid']]) && !chown($path, $uid=$change[$stat['uid']])) |
| 76 | 82 | { |
@@ -86,10 +92,12 @@ discard block |
||
| 86 | 92 | foreach(new DirectoryIterator($path) as $child) |
| 87 | 93 | { |
| 88 | 94 | if (!$child->isDot()) |
| 89 | - chown_grp($child->getPathname(), array( |
|
| 95 | + { |
|
| 96 | + chown_grp($child->getPathname(), array( |
|
| 90 | 97 | 'uid' => $child->getOwner(), |
| 91 | 98 | 'gid' => $child->getGroup(), |
| 92 | 99 | ), $recursive); |
| 100 | + } |
|
| 93 | 101 | } |
| 94 | 102 | } |
| 95 | 103 | } |
@@ -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,11 +37,11 @@ |
||
| 37 | 37 | /* Dependencies for this app to work */ |
| 38 | 38 | $setup_info['importexport']['depends'][] = array( |
| 39 | 39 | 'appname' => 'phpgwapi', |
| 40 | - 'versions' => Array('14.1') |
|
| 40 | + 'versions' => array('14.1') |
|
| 41 | 41 | ); |
| 42 | 42 | $setup_info['importexport']['depends'][] = array( |
| 43 | 43 | 'appname' => 'etemplate', |
| 44 | - 'versions' => Array('14.1') |
|
| 44 | + 'versions' => array('14.1') |
|
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | 47 | // 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 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param array $_options options for specific backends |
| 34 | 34 | * @return bool |
| 35 | 35 | */ |
| 36 | - public function __construct( $_stream, array $_options ); |
|
| 36 | + public function __construct($_stream, array $_options); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * exports a record into resource of handle |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param object of interface egw_record _record |
| 42 | 42 | * @return bool |
| 43 | 43 | */ |
| 44 | - public function export_record( importexport_iface_egw_record $_record ); |
|
| 44 | + public function export_record(importexport_iface_egw_record $_record); |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Retruns total number of exported records. |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * cleanup |
| 34 | 34 | * |
| 35 | 35 | * @return |
| 36 | - */ |
|
| 36 | + void |
|
| 37 | 37 | public function __destruct( ); |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -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; |
@@ -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)); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
| 72 | 72 | { |
| 73 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 73 | + if ($this->debug) error_log(get_class($this).'::wizard_step30->$content '.print_r($content, true)); |
|
| 74 | 74 | // return from step30 |
| 75 | 75 | if ($content['step'] == 'wizard_step30') |
| 76 | 76 | { |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | case 'next': |
| 80 | 80 | // Move sample file to temp |
| 81 | - if($content['file']['tmp_name']) { |
|
| 82 | - $GLOBALS['egw']->session->appsession('csvfile',$content['application'],$content['file']['tmp_name']); |
|
| 81 | + if ($content['file']['tmp_name']) { |
|
| 82 | + $GLOBALS['egw']->session->appsession('csvfile', $content['application'], $content['file']['tmp_name']); |
|
| 83 | 83 | } |
| 84 | 84 | unset($content['file']); |
| 85 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 85 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 86 | 86 | case 'previous' : |
| 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 'finish': |
| 89 | 89 | return 'wizard_finish'; |
| 90 | 90 | default : |
| 91 | - return $this->wizard_step30($content,$sel_options,$readonlys,$preserv); |
|
| 91 | + return $this->wizard_step30($content, $sel_options, $readonlys, $preserv); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | // init step30 |
@@ -115,55 +115,55 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
| 117 | 117 | { |
| 118 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 118 | + if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true)); |
|
| 119 | 119 | // return from step40 |
| 120 | 120 | if ($content['step'] == 'wizard_step40') { |
| 121 | 121 | switch (array_search('pressed', $content['button'])) |
| 122 | 122 | { |
| 123 | 123 | case 'next': |
| 124 | 124 | // Process sample file for fields |
| 125 | - if (($handle = fopen($GLOBALS['egw']->session->appsession('csvfile',$content['application']), "rb")) !== FALSE) { |
|
| 125 | + if (($handle = fopen($GLOBALS['egw']->session->appsession('csvfile', $content['application']), "rb")) !== FALSE) { |
|
| 126 | 126 | $data = fgetcsv($handle, 8000, $content['fieldsep']); |
| 127 | 127 | //error_log(array2string($data)); |
| 128 | 128 | fclose($handle); |
| 129 | 129 | |
| 130 | 130 | // Remove & forget file |
| 131 | - unlink($GLOBALS['egw']->session->appsession('csvfile',$content['application'])); |
|
| 131 | + unlink($GLOBALS['egw']->session->appsession('csvfile', $content['application'])); |
|
| 132 | 132 | egw_cache::setSession($content['application'], 'csvfile', ''); |
| 133 | - $content['csv_fields'] = translation::convert($data,$content['charset']); |
|
| 133 | + $content['csv_fields'] = translation::convert($data, $content['charset']); |
|
| 134 | 134 | |
| 135 | 135 | // Reset field mapping for new file |
| 136 | 136 | $content['field_mapping'] = array(); |
| 137 | 137 | |
| 138 | 138 | // Try to match automatically |
| 139 | 139 | $english = array(); |
| 140 | - foreach($content['csv_fields'] as $index => $field) { |
|
| 141 | - if($content['field_mapping'][$index]) continue; |
|
| 140 | + foreach ($content['csv_fields'] as $index => $field) { |
|
| 141 | + if ($content['field_mapping'][$index]) continue; |
|
| 142 | 142 | $best_match = ''; |
| 143 | 143 | $best_match_value = 0; |
| 144 | - foreach($this->mapping_fields as $key => $field_name) { |
|
| 145 | - if(is_array($field_name)) continue; |
|
| 146 | - if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) { |
|
| 144 | + foreach ($this->mapping_fields as $key => $field_name) { |
|
| 145 | + if (is_array($field_name)) continue; |
|
| 146 | + if (strcasecmp($field, $field_name) == 0 || strcasecmp($field, $key) == 0) { |
|
| 147 | 147 | $content['field_mapping'][$index] = $key; |
| 148 | 148 | continue 2; |
| 149 | 149 | } |
| 150 | 150 | // Check english also |
| 151 | - if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
| 151 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
| 152 | 152 | $msg_id = translation::get_message_id($field_name, $content['application']); |
| 153 | 153 | } |
| 154 | - if($msg_id) { |
|
| 154 | + if ($msg_id) { |
|
| 155 | 155 | $english[$field_name] = translation::read('en', $content['application'], $msg_id); |
| 156 | 156 | } else { |
| 157 | 157 | $english[$field_name] = false; |
| 158 | 158 | } |
| 159 | - if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
| 159 | + if ($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
| 160 | 160 | $content['field_mapping'][$index] = $key; |
| 161 | 161 | continue 2; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // Check for similar but slightly different |
| 165 | 165 | $match = 0; |
| 166 | - if(similar_text(strtolower($field), strtolower($field_name), $match) && |
|
| 166 | + if (similar_text(strtolower($field), strtolower($field_name), $match) && |
|
| 167 | 167 | $match > 85 && |
| 168 | 168 | $match > $best_match_value |
| 169 | 169 | ) { |
@@ -172,20 +172,20 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | } |
| 175 | - if($best_match) { |
|
| 175 | + if ($best_match) { |
|
| 176 | 176 | $content['field_mapping'][$index] = $best_match; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | - } elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
| 179 | + } elseif (!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
| 180 | 180 | $content['csv_fields'] = $content['plugin_options']['csv_fields']; |
| 181 | 181 | } |
| 182 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 182 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 183 | 183 | case 'previous' : |
| 184 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 184 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 185 | 185 | case 'finish': |
| 186 | 186 | return 'wizard_finish'; |
| 187 | 187 | default : |
| 188 | - return $this->wizard_step40($content,$sel_options,$readonlys,$preserv); |
|
| 188 | + return $this->wizard_step40($content, $sel_options, $readonlys, $preserv); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | // init step40 |
@@ -195,17 +195,17 @@ discard block |
||
| 195 | 195 | $content['step'] = 'wizard_step40'; |
| 196 | 196 | |
| 197 | 197 | // If editing an existing definition, these will be in plugin_options |
| 198 | - if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
| 198 | + if (!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
| 199 | 199 | $content['fieldsep'] = $content['plugin_options']['fieldsep']; |
| 200 | 200 | } elseif (!$content['fieldsep']) { |
| 201 | 201 | $content['fieldsep'] = ';'; |
| 202 | 202 | } |
| 203 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 203 | + if (!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 204 | 204 | $content['charset'] = $content['plugin_options']['charset']; |
| 205 | 205 | } |
| 206 | - if(!array_key_exists('num_header_lines', $content)) |
|
| 206 | + if (!array_key_exists('num_header_lines', $content)) |
|
| 207 | 207 | { |
| 208 | - if(array_key_exists('num_header_lines', $content['plugin_options'])) |
|
| 208 | + if (array_key_exists('num_header_lines', $content['plugin_options'])) |
|
| 209 | 209 | { |
| 210 | 210 | $content['num_header_lines'] = $content['plugin_options']['num_header_lines']; |
| 211 | 211 | } |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | $content['num_header_lines'] = 1; |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | - if(!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
| 218 | + if (!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
| 219 | 219 | $content['update_cats'] = $content['plugin_options']['update_cats']; |
| 220 | 220 | } |
| 221 | - if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 221 | + if (!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 222 | 222 | $content['convert'] = $content['plugin_options']['convert']; |
| 223 | 223 | } |
| 224 | 224 | else |
@@ -227,24 +227,24 @@ discard block |
||
| 227 | 227 | $content['convert'] = 1; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+ |
|
| 230 | + $sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets() + |
|
| 231 | 231 | array( |
| 232 | 232 | 'user' => lang('User preference'), |
| 233 | 233 | ); |
| 234 | 234 | |
| 235 | 235 | // Add in extra allowed charsets |
| 236 | 236 | $config = config::read('importexport'); |
| 237 | - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
| 238 | - if($extra_charsets) |
|
| 237 | + $extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings()); |
|
| 238 | + if ($extra_charsets) |
|
| 239 | 239 | { |
| 240 | - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
| 240 | + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets)); |
|
| 241 | 241 | } |
| 242 | 242 | $sel_options['convert'] = array( |
| 243 | 243 | 0 => lang('Database values'), |
| 244 | 244 | 1 => lang('Human friendly values') |
| 245 | 245 | ); |
| 246 | 246 | $preserv = $content; |
| 247 | - if($this->mapping_fields['cat_id']) { |
|
| 247 | + if ($this->mapping_fields['cat_id']) { |
|
| 248 | 248 | $sel_options['update_cats'] = array( |
| 249 | 249 | 'add' => lang('Add'), |
| 250 | 250 | 'replace'=> lang('Replace') |
@@ -266,18 +266,18 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
| 268 | 268 | { |
| 269 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
| 269 | + if ($this->debug) error_log(get_class($this).'::wizard_step50->$content '.print_r($content, true)); |
|
| 270 | 270 | // return from step50 |
| 271 | 271 | if ($content['step'] == 'wizard_step50') |
| 272 | 272 | { |
| 273 | 273 | unset($content['field_mapping']); |
| 274 | 274 | unset($content['field_conversion']); |
| 275 | - foreach($content['mapping'] as $field) |
|
| 275 | + foreach ($content['mapping'] as $field) |
|
| 276 | 276 | { |
| 277 | 277 | $index = $field['index']; |
| 278 | - foreach(array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest) |
|
| 278 | + foreach (array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest) |
|
| 279 | 279 | { |
| 280 | - if(trim($field[$id]) != '' && $field[$id] !== '--NONE--') |
|
| 280 | + if (trim($field[$id]) != '' && $field[$id] !== '--NONE--') |
|
| 281 | 281 | { |
| 282 | 282 | $content[$dest][$index] = trim($field[$id]); |
| 283 | 283 | } |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | switch (array_search('pressed', $content['button'])) |
| 288 | 288 | { |
| 289 | 289 | case 'next': |
| 290 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 290 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 291 | 291 | case 'previous' : |
| 292 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 292 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 293 | 293 | case 'finish': |
| 294 | 294 | return 'wizard_finish'; |
| 295 | 295 | default : |
| 296 | - return $this->wizard_step50($content,$sel_options,$readonlys,$preserv); |
|
| 296 | + return $this->wizard_step50($content, $sel_options, $readonlys, $preserv); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | // init step50 |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | $content['step'] = 'wizard_step50'; |
| 304 | 304 | |
| 305 | 305 | $content['mapping'] = array(false); |
| 306 | - if(array_key_exists('field_mapping', $content)) |
|
| 306 | + if (array_key_exists('field_mapping', $content)) |
|
| 307 | 307 | { |
| 308 | 308 | $field = $content['field_mapping']; |
| 309 | 309 | $conversion = $content['field_conversion']; |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $conversion = $content['plugin_options']['field_conversion']; |
| 315 | 315 | } |
| 316 | 316 | $empties = 1; |
| 317 | - foreach($content['csv_fields'] as $index => $title) |
|
| 317 | + foreach ($content['csv_fields'] as $index => $title) |
|
| 318 | 318 | { |
| 319 | 319 | $content['mapping'][] = array( |
| 320 | 320 | 'index' => $index, |
@@ -322,15 +322,15 @@ discard block |
||
| 322 | 322 | 'field' => $field[$index], |
| 323 | 323 | 'conversion' => $conversion[$index] |
| 324 | 324 | ); |
| 325 | - if(strstr($title,lang('Extra %1'))) $empties++; |
|
| 325 | + if (strstr($title, lang('Extra %1'))) $empties++; |
|
| 326 | 326 | } |
| 327 | - while($empties <= 3) |
|
| 327 | + while ($empties <= 3) |
|
| 328 | 328 | { |
| 329 | 329 | $content['mapping'][] = array( |
| 330 | 330 | 'index' => $index + $empties, |
| 331 | 331 | 'title' => lang('Extra %1', $empties), |
| 332 | - 'field' => $field[$index+$empties], |
|
| 333 | - 'conversion' => $conversion[$index+$empties] |
|
| 332 | + 'field' => $field[$index + $empties], |
|
| 333 | + 'conversion' => $conversion[$index + $empties] |
|
| 334 | 334 | ); |
| 335 | 335 | $empties++; |
| 336 | 336 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | */ |
| 349 | 349 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
| 350 | 350 | { |
| 351 | - if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
| 351 | + if ($this->debug) error_log(get_class($this).'::wizard_step55->$content '.print_r($content, true)); |
|
| 352 | 352 | |
| 353 | 353 | // return from step55 |
| 354 | 354 | if ($content['step'] == 'wizard_step55') |
@@ -356,8 +356,8 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | // Clear conditions that don't do anything |
| 358 | 358 | array_shift($content['conditions']); |
| 359 | - foreach($content['conditions'] as $key => &$condition) { |
|
| 360 | - if(($condition['true']['action'] == 'none' || !$condition['true']['action']) |
|
| 359 | + foreach ($content['conditions'] as $key => &$condition) { |
|
| 360 | + if (($condition['true']['action'] == 'none' || !$condition['true']['action']) |
|
| 361 | 361 | && ($condition['false']['action'] == 'none' || !$condition['false']['action']) && |
| 362 | 362 | !$condition['string'] |
| 363 | 363 | ) { |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Check for true without false, or false without true - set to 'none' |
| 369 | - elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
|
| 369 | + elseif ($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
|
| 370 | 370 | $condition['true']['action'] != '' && $condition['false']['action'] == '' || |
| 371 | 371 | !$condition['true'] || !$condition['false'] |
| 372 | 372 | ) |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | switch (array_search('pressed', $content['button'])) |
| 379 | 379 | { |
| 380 | 380 | case 'next': |
| 381 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
| 381 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
| 382 | 382 | case 'previous' : |
| 383 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
| 383 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
| 384 | 384 | case 'finish': |
| 385 | 385 | return 'wizard_finish'; |
| 386 | 386 | case 'add': |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | $content['conditions'][] = array('string' => ''); |
| 390 | 390 | return 'wizard_step55'; |
| 391 | 391 | default : |
| 392 | - return $this->wizard_step55($content,$sel_options,$readonlys,$preserv); |
|
| 392 | + return $this->wizard_step55($content, $sel_options, $readonlys, $preserv); |
|
| 393 | 393 | break; |
| 394 | 394 | } |
| 395 | 395 | } |
@@ -397,18 +397,18 @@ discard block |
||
| 397 | 397 | $content['text'] = $this->steps['wizard_step55']; |
| 398 | 398 | $content['step'] = 'wizard_step55'; |
| 399 | 399 | |
| 400 | - if(!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
| 400 | + if (!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
| 401 | 401 | $content['conditions'] = $content['plugin_options']['conditions']; |
| 402 | 402 | } |
| 403 | 403 | $preserv = $content; |
| 404 | 404 | |
| 405 | - foreach($content['field_mapping'] as $field) { |
|
| 405 | + foreach ($content['field_mapping'] as $field) { |
|
| 406 | 406 | $sel_options['string'][$field] = $this->mapping_fields[$field]; |
| 407 | - if(!$sel_options['string'][$field]) |
|
| 407 | + if (!$sel_options['string'][$field]) |
|
| 408 | 408 | { |
| 409 | - foreach($this->mapping_fields as $fields) |
|
| 409 | + foreach ($this->mapping_fields as $fields) |
|
| 410 | 410 | { |
| 411 | - if(is_array($fields) && $fields[$field]) |
|
| 411 | + if (is_array($fields) && $fields[$field]) |
|
| 412 | 412 | { |
| 413 | 413 | $sel_options['string'][$field] = $fields[$field]; |
| 414 | 414 | } |
@@ -70,7 +70,10 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
| 72 | 72 | { |
| 73 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 73 | + if($this->debug) |
|
| 74 | + { |
|
| 75 | + error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
| 76 | + } |
|
| 74 | 77 | // return from step30 |
| 75 | 78 | if ($content['step'] == 'wizard_step30') |
| 76 | 79 | { |
@@ -78,7 +81,8 @@ discard block |
||
| 78 | 81 | { |
| 79 | 82 | case 'next': |
| 80 | 83 | // Move sample file to temp |
| 81 | - if($content['file']['tmp_name']) { |
|
| 84 | + if($content['file']['tmp_name']) |
|
| 85 | + { |
|
| 82 | 86 | $GLOBALS['egw']->session->appsession('csvfile',$content['application'],$content['file']['tmp_name']); |
| 83 | 87 | } |
| 84 | 88 | unset($content['file']); |
@@ -115,14 +119,19 @@ discard block |
||
| 115 | 119 | */ |
| 116 | 120 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
| 117 | 121 | { |
| 118 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 122 | + if($this->debug) |
|
| 123 | + { |
|
| 124 | + error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
| 125 | + } |
|
| 119 | 126 | // return from step40 |
| 120 | - if ($content['step'] == 'wizard_step40') { |
|
| 127 | + if ($content['step'] == 'wizard_step40') |
|
| 128 | + { |
|
| 121 | 129 | switch (array_search('pressed', $content['button'])) |
| 122 | 130 | { |
| 123 | 131 | case 'next': |
| 124 | 132 | // Process sample file for fields |
| 125 | - if (($handle = fopen($GLOBALS['egw']->session->appsession('csvfile',$content['application']), "rb")) !== FALSE) { |
|
| 133 | + if (($handle = fopen($GLOBALS['egw']->session->appsession('csvfile',$content['application']), "rb")) !== FALSE) |
|
| 134 | + { |
|
| 126 | 135 | $data = fgetcsv($handle, 8000, $content['fieldsep']); |
| 127 | 136 | //error_log(array2string($data)); |
| 128 | 137 | fclose($handle); |
@@ -137,26 +146,40 @@ discard block |
||
| 137 | 146 | |
| 138 | 147 | // Try to match automatically |
| 139 | 148 | $english = array(); |
| 140 | - foreach($content['csv_fields'] as $index => $field) { |
|
| 141 | - if($content['field_mapping'][$index]) continue; |
|
| 149 | + foreach($content['csv_fields'] as $index => $field) |
|
| 150 | + { |
|
| 151 | + if($content['field_mapping'][$index]) |
|
| 152 | + { |
|
| 153 | + continue; |
|
| 154 | + } |
|
| 142 | 155 | $best_match = ''; |
| 143 | 156 | $best_match_value = 0; |
| 144 | - foreach($this->mapping_fields as $key => $field_name) { |
|
| 145 | - if(is_array($field_name)) continue; |
|
| 146 | - if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) { |
|
| 157 | + foreach($this->mapping_fields as $key => $field_name) |
|
| 158 | + { |
|
| 159 | + if(is_array($field_name)) |
|
| 160 | + { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 163 | + if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) |
|
| 164 | + { |
|
| 147 | 165 | $content['field_mapping'][$index] = $key; |
| 148 | 166 | continue 2; |
| 149 | 167 | } |
| 150 | 168 | // Check english also |
| 151 | - if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
| 169 | + if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) |
|
| 170 | + { |
|
| 152 | 171 | $msg_id = translation::get_message_id($field_name, $content['application']); |
| 153 | 172 | } |
| 154 | - if($msg_id) { |
|
| 173 | + if($msg_id) |
|
| 174 | + { |
|
| 155 | 175 | $english[$field_name] = translation::read('en', $content['application'], $msg_id); |
| 156 | - } else { |
|
| 176 | + } |
|
| 177 | + else |
|
| 178 | + { |
|
| 157 | 179 | $english[$field_name] = false; |
| 158 | 180 | } |
| 159 | - if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
| 181 | + if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) |
|
| 182 | + { |
|
| 160 | 183 | $content['field_mapping'][$index] = $key; |
| 161 | 184 | continue 2; |
| 162 | 185 | } |
@@ -172,11 +195,14 @@ discard block |
||
| 172 | 195 | } |
| 173 | 196 | |
| 174 | 197 | } |
| 175 | - if($best_match) { |
|
| 198 | + if($best_match) |
|
| 199 | + { |
|
| 176 | 200 | $content['field_mapping'][$index] = $best_match; |
| 177 | 201 | } |
| 178 | 202 | } |
| 179 | - } elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
| 203 | + } |
|
| 204 | + elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) |
|
| 205 | + { |
|
| 180 | 206 | $content['csv_fields'] = $content['plugin_options']['csv_fields']; |
| 181 | 207 | } |
| 182 | 208 | return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
@@ -195,12 +221,16 @@ discard block |
||
| 195 | 221 | $content['step'] = 'wizard_step40'; |
| 196 | 222 | |
| 197 | 223 | // If editing an existing definition, these will be in plugin_options |
| 198 | - if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
| 224 | + if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) |
|
| 225 | + { |
|
| 199 | 226 | $content['fieldsep'] = $content['plugin_options']['fieldsep']; |
| 200 | - } elseif (!$content['fieldsep']) { |
|
| 227 | + } |
|
| 228 | + elseif (!$content['fieldsep']) |
|
| 229 | + { |
|
| 201 | 230 | $content['fieldsep'] = ';'; |
| 202 | 231 | } |
| 203 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
| 232 | + if(!$content['charset'] && $content['plugin_options']['charset']) |
|
| 233 | + { |
|
| 204 | 234 | $content['charset'] = $content['plugin_options']['charset']; |
| 205 | 235 | } |
| 206 | 236 | if(!array_key_exists('num_header_lines', $content)) |
@@ -215,10 +245,12 @@ discard block |
||
| 215 | 245 | $content['num_header_lines'] = 1; |
| 216 | 246 | } |
| 217 | 247 | } |
| 218 | - if(!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
| 248 | + if(!$content['update_cats'] && $content['plugin_options']['update_cats']) |
|
| 249 | + { |
|
| 219 | 250 | $content['update_cats'] = $content['plugin_options']['update_cats']; |
| 220 | 251 | } |
| 221 | - if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
| 252 | + if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) |
|
| 253 | + { |
|
| 222 | 254 | $content['convert'] = $content['plugin_options']['convert']; |
| 223 | 255 | } |
| 224 | 256 | else |
@@ -244,12 +276,15 @@ discard block |
||
| 244 | 276 | 1 => lang('Human friendly values') |
| 245 | 277 | ); |
| 246 | 278 | $preserv = $content; |
| 247 | - if($this->mapping_fields['cat_id']) { |
|
| 279 | + if($this->mapping_fields['cat_id']) |
|
| 280 | + { |
|
| 248 | 281 | $sel_options['update_cats'] = array( |
| 249 | 282 | 'add' => lang('Add'), |
| 250 | 283 | 'replace'=> lang('Replace') |
| 251 | 284 | ); |
| 252 | - } else { |
|
| 285 | + } |
|
| 286 | + else |
|
| 287 | + { |
|
| 253 | 288 | $content['no_cats'] = true; |
| 254 | 289 | } |
| 255 | 290 | unset ($preserv['button']); |
@@ -266,7 +301,10 @@ discard block |
||
| 266 | 301 | */ |
| 267 | 302 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
| 268 | 303 | { |
| 269 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
| 304 | + if($this->debug) |
|
| 305 | + { |
|
| 306 | + error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
| 307 | + } |
|
| 270 | 308 | // return from step50 |
| 271 | 309 | if ($content['step'] == 'wizard_step50') |
| 272 | 310 | { |
@@ -322,7 +360,10 @@ discard block |
||
| 322 | 360 | 'field' => $field[$index], |
| 323 | 361 | 'conversion' => $conversion[$index] |
| 324 | 362 | ); |
| 325 | - if(strstr($title,lang('Extra %1'))) $empties++; |
|
| 363 | + if(strstr($title,lang('Extra %1'))) |
|
| 364 | + { |
|
| 365 | + $empties++; |
|
| 366 | + } |
|
| 326 | 367 | } |
| 327 | 368 | while($empties <= 3) |
| 328 | 369 | { |
@@ -348,7 +389,10 @@ discard block |
||
| 348 | 389 | */ |
| 349 | 390 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
| 350 | 391 | { |
| 351 | - if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
| 392 | + if($this->debug) |
|
| 393 | + { |
|
| 394 | + error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
| 395 | + } |
|
| 352 | 396 | |
| 353 | 397 | // return from step55 |
| 354 | 398 | if ($content['step'] == 'wizard_step55') |
@@ -356,7 +400,8 @@ discard block |
||
| 356 | 400 | |
| 357 | 401 | // Clear conditions that don't do anything |
| 358 | 402 | array_shift($content['conditions']); |
| 359 | - foreach($content['conditions'] as $key => &$condition) { |
|
| 403 | + foreach($content['conditions'] as $key => &$condition) |
|
| 404 | + { |
|
| 360 | 405 | if(($condition['true']['action'] == 'none' || !$condition['true']['action']) |
| 361 | 406 | && ($condition['false']['action'] == 'none' || !$condition['false']['action']) && |
| 362 | 407 | !$condition['string'] |
@@ -369,8 +414,7 @@ discard block |
||
| 369 | 414 | elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
| 370 | 415 | $condition['true']['action'] != '' && $condition['false']['action'] == '' || |
| 371 | 416 | !$condition['true'] || !$condition['false'] |
| 372 | - ) |
|
| 373 | - { |
|
| 417 | + ) { |
|
| 374 | 418 | $condition[$condition['true']['action'] == '' ? 'true' : 'false']['action'] = "none"; |
| 375 | 419 | } |
| 376 | 420 | } |
@@ -397,12 +441,14 @@ discard block |
||
| 397 | 441 | $content['text'] = $this->steps['wizard_step55']; |
| 398 | 442 | $content['step'] = 'wizard_step55'; |
| 399 | 443 | |
| 400 | - if(!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
| 444 | + if(!$content['conditions'] && $content['plugin_options']['conditions']) |
|
| 445 | + { |
|
| 401 | 446 | $content['conditions'] = $content['plugin_options']['conditions']; |
| 402 | 447 | } |
| 403 | 448 | $preserv = $content; |
| 404 | 449 | |
| 405 | - foreach($content['field_mapping'] as $field) { |
|
| 450 | + foreach($content['field_mapping'] as $field) |
|
| 451 | + { |
|
| 406 | 452 | $sel_options['string'][$field] = $this->mapping_fields[$field]; |
| 407 | 453 | if(!$sel_options['string'][$field]) |
| 408 | 454 | { |
@@ -29,23 +29,23 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp')) |
| 31 | 31 | { |
| 32 | - ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir |
|
| 32 | + ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Include PEAR::Console_Getopt |
| 36 | 36 | require_once 'Console/Getopt.php'; |
| 37 | 37 | |
| 38 | 38 | // Define exit codes for errors |
| 39 | -define('HEADER_NOT_FOUND',9); |
|
| 40 | -define('NO_ARGS',10); |
|
| 41 | -define('INVALID_OPTION',11); |
|
| 39 | +define('HEADER_NOT_FOUND', 9); |
|
| 40 | +define('NO_ARGS', 10); |
|
| 41 | +define('INVALID_OPTION', 11); |
|
| 42 | 42 | |
| 43 | 43 | // Reading the incoming arguments - same as $argv |
| 44 | 44 | $args = Console_Getopt::readPHPArgv(); |
| 45 | 45 | |
| 46 | 46 | // Make sure we got them (for non CLI binaries) |
| 47 | 47 | if (PEAR::isError($args)) { |
| 48 | - fwrite(STDERR,"importexport_cli: ".$args->getMessage()."\n".$usage); |
|
| 48 | + fwrite(STDERR, "importexport_cli: ".$args->getMessage()."\n".$usage); |
|
| 49 | 49 | exit(NO_ARGS); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | // Convert the arguments to options - check for the first argument |
| 66 | -if ( realpath($_SERVER['argv'][0]) == __FILE__ ) { |
|
| 67 | - $options = Console_Getopt::getOpt($args,$short_opts,$long_opts); |
|
| 66 | +if (realpath($_SERVER['argv'][0]) == __FILE__) { |
|
| 67 | + $options = Console_Getopt::getOpt($args, $short_opts, $long_opts); |
|
| 68 | 68 | } else { |
| 69 | - $options = Console_Getopt::getOpt2($args,$short_opts,$long_opts); |
|
| 69 | + $options = Console_Getopt::getOpt2($args, $short_opts, $long_opts); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Check the options are valid |
| 73 | 73 | if (PEAR::isError($options)) { |
| 74 | - fwrite(STDERR,"importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
|
| 74 | + fwrite(STDERR, "importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
|
| 75 | 75 | exit(INVALID_OPTION); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | $dryrun = true; |
| 99 | 99 | break; |
| 100 | 100 | default : |
| 101 | - fwrite (STDERR,$usage."\n"); |
|
| 101 | + fwrite(STDERR, $usage."\n"); |
|
| 102 | 102 | exit(INVALID_OPTION); |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | // check file |
| 106 | -if ( !$user || !$password ) { |
|
| 107 | - fwrite(STDERR,'importexport_cli: You have to supply a username / password'."\n".$usage); |
|
| 106 | +if (!$user || !$password) { |
|
| 107 | + fwrite(STDERR, 'importexport_cli: You have to supply a username / password'."\n".$usage); |
|
| 108 | 108 | exit(INVALID_OPTION); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | 'nonavbar' => True, |
| 118 | 118 | 'currentapp' => 'importexport', |
| 119 | 119 | 'autocreate_session_callback' => 'import_export_access', |
| 120 | - 'login' => $user . '@' . $domain, |
|
| 120 | + 'login' => $user.'@'.$domain, |
|
| 121 | 121 | 'passwd' => $password, |
| 122 | 122 | ); |
| 123 | 123 | if (!is_readable($path_to_egroupware.'/header.inc.php')) |
| 124 | 124 | { |
| 125 | - fwrite(STDERR,"importexport.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n"); |
|
| 125 | + fwrite(STDERR, "importexport.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n"); |
|
| 126 | 126 | exit(HEADER_NOT_FOUND); |
| 127 | 127 | } |
| 128 | 128 | include($path_to_egroupware.'/header.inc.php'); |
@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | // check file |
| 131 | 131 | if (!is_readable($file)) |
| 132 | 132 | { |
| 133 | - fwrite(STDERR,"importexport_cli: ". $file. ' is not readable'."\n"); |
|
| 133 | + fwrite(STDERR, "importexport_cli: ".$file.' is not readable'."\n"); |
|
| 134 | 134 | exit(INVALID_OPTION); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $definition = new importexport_definition($definition); |
| 138 | -if( $definition->get_identifier() < 1 ) { |
|
| 139 | - fwrite(STDERR,"importexport_cli: Definition not found! \n"); |
|
| 138 | +if ($definition->get_identifier() < 1) { |
|
| 139 | + fwrite(STDERR, "importexport_cli: Definition not found! \n"); |
|
| 140 | 140 | exit(INVALID_OPTION); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | $po = new $definition->plugin; |
| 149 | 149 | |
| 150 | -$resource = fopen( $file, 'r' ); |
|
| 151 | -$po->$type( $resource, $definition ); |
|
| 150 | +$resource = fopen($file, 'r'); |
|
| 151 | +$po->$type($resource, $definition); |
|
| 152 | 152 | |
| 153 | 153 | exit(); |
| 154 | 154 | |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | --dry-run no real action, just console output |
| 24 | 24 | \n"; |
| 25 | 25 | |
| 26 | -if (php_sapi_name() != 'cli') { |
|
| 26 | +if (php_sapi_name() != 'cli') |
|
| 27 | +{ |
|
| 27 | 28 | die('This script only runs form command line'); |
| 28 | 29 | } |
| 29 | 30 | |
@@ -44,7 +45,8 @@ discard block |
||
| 44 | 45 | $args = Console_Getopt::readPHPArgv(); |
| 45 | 46 | |
| 46 | 47 | // Make sure we got them (for non CLI binaries) |
| 47 | -if (PEAR::isError($args)) { |
|
| 48 | +if (PEAR::isError($args)) |
|
| 49 | +{ |
|
| 48 | 50 | fwrite(STDERR,"importexport_cli: ".$args->getMessage()."\n".$usage); |
| 49 | 51 | exit(NO_ARGS); |
| 50 | 52 | } |
@@ -63,22 +65,28 @@ discard block |
||
| 63 | 65 | ); |
| 64 | 66 | |
| 65 | 67 | // Convert the arguments to options - check for the first argument |
| 66 | -if ( realpath($_SERVER['argv'][0]) == __FILE__ ) { |
|
| 68 | +if ( realpath($_SERVER['argv'][0]) == __FILE__ ) |
|
| 69 | +{ |
|
| 67 | 70 | $options = Console_Getopt::getOpt($args,$short_opts,$long_opts); |
| 68 | -} else { |
|
| 71 | +} |
|
| 72 | +else |
|
| 73 | +{ |
|
| 69 | 74 | $options = Console_Getopt::getOpt2($args,$short_opts,$long_opts); |
| 70 | 75 | } |
| 71 | 76 | |
| 72 | 77 | // Check the options are valid |
| 73 | -if (PEAR::isError($options)) { |
|
| 78 | +if (PEAR::isError($options)) |
|
| 79 | +{ |
|
| 74 | 80 | fwrite(STDERR,"importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
| 75 | 81 | exit(INVALID_OPTION); |
| 76 | 82 | } |
| 77 | 83 | |
| 78 | 84 | $domain = 'default'; |
| 79 | 85 | $dryrun = false; |
| 80 | -foreach ($options[0] as $option) { |
|
| 81 | - switch ($option[0]) { |
|
| 86 | +foreach ($options[0] as $option) |
|
| 87 | +{ |
|
| 88 | + switch ($option[0]) |
|
| 89 | + { |
|
| 82 | 90 | case '--file' : |
| 83 | 91 | $file = $option[1]; |
| 84 | 92 | break; |
@@ -103,7 +111,8 @@ discard block |
||
| 103 | 111 | } |
| 104 | 112 | } |
| 105 | 113 | // check file |
| 106 | -if ( !$user || !$password ) { |
|
| 114 | +if ( !$user || !$password ) |
|
| 115 | +{ |
|
| 107 | 116 | fwrite(STDERR,'importexport_cli: You have to supply a username / password'."\n".$usage); |
| 108 | 117 | exit(INVALID_OPTION); |
| 109 | 118 | } |
@@ -135,7 +144,8 @@ discard block |
||
| 135 | 144 | } |
| 136 | 145 | |
| 137 | 146 | $definition = new importexport_definition($definition); |
| 138 | -if( $definition->get_identifier() < 1 ) { |
|
| 147 | +if( $definition->get_identifier() < 1 ) |
|
| 148 | +{ |
|
| 139 | 149 | fwrite(STDERR,"importexport_cli: Definition not found! \n"); |
| 140 | 150 | exit(INVALID_OPTION); |
| 141 | 151 | } |