bringing importexport to egw 1.4

This commit is contained in:
Cornelius Weiß 2007-06-11 12:37:56 +00:00
commit 99cbb28d32
25 changed files with 683 additions and 534 deletions

View File

@ -1,25 +1,47 @@
= importexport = = importexport =
Importexport is a framework for egroupware to handle imports and exports. Importexport is a framework for egroupware to handle imports and exports.
The idea behind importexport is to have a common userinterface in all apps regarding The idea behind importexport is to have a common userinterface in all apps
import and export stuff AND to have common backends whitch handle the stuff. regarding import and export stuff AND to have common backends whitch
Importexport can nothing without the plugins of the applications. handle the stuff. Importexport can nothing without the plugins of the
applications and its specific definitions.
== plugins ==
Attending importeport framework with you application is pretty easy. Attending importeport framework with you application is pretty easy.
You just need to have your plugins in files which start with You just need to have your plugins in files which start with
class.import_<type> or class.import_<name> or
class.export_<type> class.export_<name>
in in
EGW_INCLUDE_ROOT/YourApp/inc/ EGW_INCLUDE_ROOT/YourApp/importexport/
These pulugins only need to implement the corresponding interface
EGW_INCLUDE_ROOT/importexport/inc/class.iface_import_plugin.inc.php or
EGW_INCLUDE_ROOT/importexport/inc/class.iface_export_plugin.inc.php
Thats all, pretty easy, isn't it?
== definitions == == definitions ==
The bases of all imports and exports is the '''definition'''. The bases of all imports and exports is the '''definition'''.
A definition defines all nessesary parameters to perform the desired action. A definition defines all nessesary parameters to perform the desired action.
Moreover definitions can be stored and thus the same import / export can be redone Moreover definitions can be stored and thus the same import / export can be redone
by loading the definition. Definitions are also reachable by the importexport by loading the definition. Definitions are also reachable by the importexport
'''command line interface'''. '''command line interface'''.
An important point is, that the ACLs for import/export actions are given by the definitions.
That means, that your plugin can not work w.o. a definition. However, your plugin don't
need to parse that definition. This is up to you.
Definitions can be created in admin->importexport->define{im|ex}ports. They are stored
in the databasae but could be {im|ex}ported itselve.
Definitions (as xml files) residing in the folder <yourapp/importexport/definitions>
will be imported at apps installation time automatically.
== import ==
== export == == export ==
Starting an export is as easy as just putting a button in your app with: Starting an export is as easy as just putting a button in your app with:
onClick="importexport.uiexport.export_dialog&appname=<appname>&have_selection=<{true|false}>" onClick="importexport.uiexport.export_dialog&appname=<appname>&have_selection=<{true|false}>"

View File

@ -19,8 +19,7 @@
--password <password for user> --password <password for user>
--domain <domain name> \n"; --domain <domain name> \n";
if (php_sapi_name() != 'cli') if (php_sapi_name() != 'cli') {
{
die('This script only runs form command line'); die('This script only runs form command line');
} }
@ -67,10 +66,8 @@
} }
$domain = 'default'; $domain = 'default';
foreach ($options[0] as $option) foreach ($options[0] as $option) {
{ switch ($option[0]) {
switch ($option[0])
{
case '--file' : case '--file' :
$file = $option[1]; $file = $option[1];
break; break;
@ -92,8 +89,7 @@
} }
} }
// check file // check file
if (!$user || !$password) if ( !$user || !$password ) {
{
fwrite(STDERR,'importexport_cli: You have to supply a username / password'."\n".$usage); fwrite(STDERR,'importexport_cli: You have to supply a username / password'."\n".$usage);
exit(INVALID_OPTION); exit(INVALID_OPTION);
} }
@ -134,7 +130,7 @@
exit(INVALID_OPTION); exit(INVALID_OPTION);
} }
require_once('./inc/class.definition.inc.php'); require_once('inc/class.definition.inc.php');
try { try {
$definition = new definition($definition); $definition = new definition($definition);
} }
@ -143,10 +139,12 @@
exit(INVALID_OPTION); exit(INVALID_OPTION);
} }
require_once("$path_to_egroupware/$definition->application/inc/class.$definition->plugin.inc.php"); require_once("$path_to_egroupware/$definition->application/importexport/class.$definition->plugin.inc.php");
$po = new $definition->plugin; $po = new $definition->plugin;
$type = $definition->type; $type = $definition->type;
$po->$type($definition,array('file' => $file));
$resource = fopen( $file, 'r' );
$po->$type( $resource, $definition );
$GLOBALS['egw']->common->phpgw_exit(); $GLOBALS['egw']->common->phpgw_exit();

View File

@ -0,0 +1,111 @@
<?php
/**
* eGroupWare
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package importexport
* @link http://www.egroupware.org
* @author Cornelius Weiss <nelius@cwtech.de>
* @copyright Cornelius Weiss <nelius@cwtech.de>
* @version $Id: $
*/
/**
* class arrayxml
* easy to use array2xml and xml2array functions. Presumably this is the n+1
* class of this kind out there, but i wasn't able to find a wokring one...
*
* @abstract PHP allowes array keys to be numeric while XML prohibits this.
* Therefore the XML structur of this class is a bit uncommon but nessesary!
* @todo deal with other types like objects
* @static only namespace here
*/
class arrayxml {
/**
* converts a php array to an xml string
*
* @param mixed $_data
* @param string $_name
* @param DOMElement $_node
* @return string XML string
*/
public static function array2xml ( $_data, $_name = 'root', $_node=null ) {
$returnXML = false;
if ( $_node === null ) {
$_node = new DOMDocument( '1.0', 'utf-8' );
$_node->formatOutput = true;
$returnXML = true;
}
$datatype = gettype( $_data );
switch ( $datatype ) {
case 'array' :
$subnode = new DOMElement( 'entry' );
$_node->appendChild( $subnode );
$subnode->setAttribute( 'type', $datatype );
$subnode->setAttribute( 'name' , $_name );
foreach ( $_data as $ikey => $ivalue ) {
self::array2xml( $ivalue, $ikey, $subnode );
}
break;
default :
switch ( $datatype ) {
case 'boolean' :
$data = $_data !== false ? 'TRUE' : 'FALSE';
break;
default:
$data = &$_data;
}
$subnode = new DOMElement( 'entry' , $data );
$_node->appendChild( $subnode );
$subnode->setAttribute( 'type', $datatype );
$subnode->setAttribute( 'name' , $_name );
break;
}
return $returnXML ? $_node->saveXML() : '';
}
/**
* converts XML string into php array
*
* @param string $_xml
* @return array
*/
public static function xml2array( $_xml ) {
if ( $_xml instanceof DOMElement ) {
$n = &$_xml;
} else {
$n = new DOMDocument;
$n->loadXML($_xml);
}
$xml_array = array();
foreach($n->childNodes as $nc) {
if ( $nc->nodeType != XML_ELEMENT_NODE ) continue;
$name = $nc->attributes->getNamedItem('name')->nodeValue;
$type = $nc->attributes->getNamedItem('type')->nodeValue;
//echo $nc->nodeType. "(length ): ". $nc->nodeName. " => ". $nc->nodeValue. "; Attriubtes: name=$name, type=$type \n ";
if( $nc->childNodes->length >= 2) {
$xml_array[$name] = self::xml2array($nc);
} else {
switch ( $type ) {
case 'boolean' :
$value = $nc->nodeValue == 'FALSE' ? false : true;
break;
default :
$value = $nc->nodeValue;
}
$xml_array[$name] = $value;
}
}
return $xml_array;
}
}
?>

View File

@ -11,6 +11,8 @@
*/ */
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.definition.inc.php'); require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.definition.inc.php');
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.arrayxml.inc.php');
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.import_export_helper_functions.inc.php');
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php'); require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
/** bo to define {im|ex}ports /** bo to define {im|ex}ports
@ -23,11 +25,13 @@ class bodefinitions {
const _defintion_talbe = 'egw_importexport_definitions'; const _defintion_talbe = 'egw_importexport_definitions';
/** /**
* holds so_sql * @var so_sql holds so_sql
*
* @var so_sql
*/ */
private $so_sql; private $so_sql;
/**
* @var array hold definitions
*/
private $definitions; private $definitions;
public function __construct($_query=false) public function __construct($_query=false)
@ -41,6 +45,11 @@ class bodefinitions {
} }
} }
/**
* gets array of definition ids
*
* @return array
*/
public function get_definitions() { public function get_definitions() {
return $this->definitions; return $this->definitions;
} }
@ -48,11 +57,11 @@ class bodefinitions {
/** /**
* reads a definition from database * reads a definition from database
* *
* @deprecated see class.definition.inc.php
* @param mixed &$definition * @param mixed &$definition
* @return bool success or not * @return bool success or not
*/ */
public function read(&$definition) public function read(&$definition) {
{
if(is_int($definition)) $definition = array('definition_id' => $definition); if(is_int($definition)) $definition = array('definition_id' => $definition);
elseif(is_string($definition)) $definition = array('name' => $definition); elseif(is_string($definition)) $definition = array('name' => $definition);
if(!$definition = $this->so_sql->read($definition)) return false; if(!$definition = $this->so_sql->read($definition)) return false;
@ -61,45 +70,14 @@ class bodefinitions {
return true; return true;
} }
public function save($content) /**
{ * deletes a defintion
$plugin = $content['plugin']; *
if (!$plugin) return false; * @param array $keys
*/
$definition = array_intersect_key($content,array_flip($this->so_sql->db_cols)); public function delete($keys) {
if(is_object($this->plugin) && $this->plugin->plugin_info['plugin'] == $plugin)
{
$plugin_options = array_intersect_key($content,array_flip($this->plugin->plugin_options));
}
else
{
// we come eg. from definition import
$file = EGW_SERVER_ROOT . SEP . $definition['application'] . SEP . 'inc' . SEP . 'importexport'. SEP . 'class.'.$definition['plugin'].'.inc.php';
if (is_file($file))
{
@include_once($file);
$obj = new $plugin;
$plugin_options = array_intersect_key($content,array_flip($obj->plugin_options));
unset($obj);
}
else
{
foreach ($this->so_sql->db_cols as $col) unset($content[$col]);
$plugin_options = $content;
}
}
$definition['plugin_options'] = serialize($plugin_options);
$this->so_sql->data = $definition;
//print_r($definition);
return $this->so_sql->save();
}
public function delete($keys)
{
$this->so_sql->delete(array('definition_id' => $keys)); $this->so_sql->delete(array('definition_id' => $keys));
// clear private cach // clear private cache
foreach ($keys as $key) { foreach ($keys as $key) {
unset($this->definitions[array_search($key,$this->definitions)]); unset($this->definitions[array_search($key,$this->definitions)]);
} }
@ -126,36 +104,6 @@ class bodefinitions {
return in_array($this_user_id,$alluser) ? true : false; return in_array($this_user_id,$alluser) ? true : false;
} }
/**
* searches and registers plugins from all apps
*
* @deprecated see import_export_helperfunctions::get_plugins
* @return array $info info about existing plugins
*/
static public function plugins()
{
if (!key_exists('apps',$GLOBALS['egw_info'])) return false;
foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname)
{
$dir = EGW_INCLUDE_ROOT . "/$appname/inc";
if(!$d = @opendir($dir)) continue;
while (false !== ($file = readdir($d)))
{
//echo $file."\n";
$pnparts = explode('.',$file);
if(!is_file($file = "$dir/$file") || substr($pnparts[1],0,7) != 'wizzard' || $pnparts[count($pnparts)-1] != 'php') continue;
$plugin_classname = $pnparts[1];
include_once($file);
if (!is_object($GLOBALS['egw']->$plugin_classname))
$GLOBALS['egw']->$plugin_classname = new $plugin_classname;
$info[$appname][$GLOBALS['egw']->$plugin_classname->plugin_info['plugin']] = $GLOBALS['egw']->$plugin_classname->plugin_info;
}
closedir($d);
}
return $info;
}
/** /**
* exports definitions * exports definitions
* *
@ -169,41 +117,65 @@ class bodefinitions {
'entries' => count($keys), 'entries' => count($keys),
)); ));
foreach ($keys as $definition_id) $export_data['definitions'] = array();
{ foreach ($keys as $definition_id) {
$definition = array('definition_id' => $definition_id); $definition = new definition( $definition_id );
$this->read($definition); $export_data['definitions'][$definition->name] = $definition->get_record_array();
unset($definition['definition_id']); $export_data['definitions'][$definition->name]['allowed_users'] =
$export_data[$definition['name']] = $definition; import_export_helper_functions::account_id2name(
$export_data['definitions'][$definition->name]['allowed_users']
);
$export_data['definitions'][$definition->name]['owner'] =
import_export_helper_functions::account_id2name(
$export_data['definitions'][$definition->name]['owner']
);
unset($export_data['definitions'][$definition->name]['definition_id']);
unset($definition);
} }
/* This is no fun as import -> export cycle in xmltools results in different datas :-(
$xml =& CreateObject('etemplate.xmltool','root');
$xml->import_var('importexport.definitions', $export_data);
$xml_data = $xml->export_xml();
we export serialised arrays in the meantime
$xml = new arrayxml();
return $xml->array2xml($export_data, 'importExportDefinitions');
}
/**
* imports definitions from file
*
* @param string $import_file
* @throws Exeption
* @return void
*/ */
return serialize($export_data); public static function import( $_import_file )
{
if ( !is_file( $_import_file ) ) {
throw new Exception("'$_import_file' is not a valid file" );
} }
public function import($import_file) $data = arrayxml::xml2array( file_get_contents( $_import_file ) );
{
// read given file and check if its a valid definition $metainfo = $data['importExportDefinitions']['metainfo'];
if (!is_file($import_file['tmp_name'])) return false; $definitions = $data['importExportDefinitions']['definitions'];
$f = fopen($import_file['tmp_name'],'r'); unset ( $data );
$data = fread($f,100000);
fclose($f);
if (($data = unserialize($data)) === false) return false;
$metainfo = $data['metainfo'];
unset($data['metainfo']);
// convert charset into internal used charset // convert charset into internal used charset
$data = $GLOBALS['egw']->translation->convert($data,$metainfo['charset'],$GLOBALS['egw']->translation->charset()); $definitions = $GLOBALS['egw']->translation->convert(
$definitions,
$metainfo['charset'],
$GLOBALS['egw']->translation->charset()
);
// save definition(s) into internal table // save definition(s) into internal table
foreach ($data as $name => $definition) foreach ( $definitions as $name => $definition_data )
{ {
$this->save($definition); // convert allowed_user
$definition_data['allowed_users'] = import_export_helper_functions::account_name2id( $definition_data['allowed_users'] );
$definition_data['owner'] = import_export_helper_functions::account_name2id( $definition_data['owner'] );
$definition = new definition( $definition_data['name'] );
$definition_id = $definition->get_identifier() ? $definition->get_identifier() : NULL;
$definition->set_record( $definition_data );
$definition->save( $definition_id );
} }
} }

View File

@ -11,6 +11,7 @@
*/ */
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_egw_record.inc.php'); require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_egw_record.inc.php');
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.arrayxml.inc.php');
require_once(EGW_INCLUDE_ROOT. '/etemplate/inc/class.so_sql.inc.php'); require_once(EGW_INCLUDE_ROOT. '/etemplate/inc/class.so_sql.inc.php');
/** /**
@ -33,36 +34,28 @@ class definition implements iface_egw_record {
'plugin' => 'string', 'plugin' => 'string',
'type' => 'string', 'type' => 'string',
'allowed_users' => 'array', 'allowed_users' => 'array',
'options' => 'array', 'plugin_options' => 'array',
'owner' => 'int', 'owner' => 'int',
'description' => 'string', 'description' => 'string',
); );
/** /**
* holds so_sql object * @var so_sql holds so_sql object
*
* @var so_sql
*/ */
private $so_sql; private $so_sql;
/** /**
* internal representation of definition * @var array internal representation of definition
*
* @var unknown_type
*/ */
private $definition = array(); private $definition = array();
/** /**
* holds current user * @var int holds current user
*
* @var int
*/ */
private $user; private $user;
/** /**
* is current user an admin? * @var bool is current user an admin?
*
* @var bool
*/ */
private $is_admin; private $is_admin;
@ -80,15 +73,15 @@ class definition implements iface_egw_record {
if (is_string($_identifier) && strlen($_identifier) > 3) $_identifier = $this->name2identifier($_identifier); if (is_string($_identifier) && strlen($_identifier) > 3) $_identifier = $this->name2identifier($_identifier);
if ((int)$_identifier != 0) { if ((int)$_identifier != 0) {
$this->so_sql->read(array('definition_id' => $_identifier)); $this->definition = $this->so_sql->read(array('definition_id' => $_identifier));
if (empty($this->so_sql->data)) { if ( empty( $this->definition ) ) {
throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!'); throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!');
} }
if (!(in_array($this->user,$this->get_allowed_users()) || $this->get_owner() == $this->user || $this->is_admin)) { if ( !( in_array( $this->user, $this->get_allowed_users() ) || $this->definition['owner'] == $this->user || $this->is_admin)) {
throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!'); throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!');
$this->definition = $this->so_sql->data;
} }
$this->definition = $this->so_sql->data; $options_data = arrayxml::xml2array( $this->definition['plugin_options'] );
$this->definition['plugin_options'] = $options_data['root'];
} }
} }
@ -113,7 +106,7 @@ class definition implements iface_egw_record {
switch ($_attribute_name) { switch ($_attribute_name) {
case 'allowed_users' : case 'allowed_users' :
return $this->get_allowed_users(); return $this->get_allowed_users();
case 'options' : case 'plugin_options' :
return $this->get_options(); return $this->get_options();
default : default :
return $this->definition[$_attribute_name]; return $this->definition[$_attribute_name];
@ -127,7 +120,7 @@ class definition implements iface_egw_record {
switch ($_attribute_name) { switch ($_attribute_name) {
case 'allowed_users' : case 'allowed_users' :
return $this->set_allowed_users($_data); return $this->set_allowed_users($_data);
case 'options' : case 'plugin_options' :
return $this->set_options($_data); return $this->set_options($_data);
default : default :
$this->definition[$_attribute_name] = $_data; $this->definition[$_attribute_name] = $_data;
@ -159,12 +152,7 @@ class definition implements iface_egw_record {
* @return array * @return array
*/ */
private function get_options() { private function get_options() {
// oh compat funct to be removed! return $this->definition['plugin_options'];
if(array_key_exists('plugin_options',$this->definition)) {
$this->definition['options'] = $this->definition['plugin_options'];
unset($this->definition['plugin_options']);
}
return unserialize($this->definition['options']);
} }
/** /**
@ -172,8 +160,8 @@ class definition implements iface_egw_record {
* *
* @param array $options * @param array $options
*/ */
private function set_options(array $_options) { private function set_options(array $_plugin_options) {
$this->definition['options'] = serialize($_options); $this->definition['plugin_options'] = $_plugin_options;
} }
/** /**
@ -187,7 +175,7 @@ class definition implements iface_egw_record {
public function get_record_array() { public function get_record_array() {
$definition = $this->definition; $definition = $this->definition;
$definition['allowed_users'] = $this->get_allowed_users(); $definition['allowed_users'] = $this->get_allowed_users();
$definition['options'] = $this->get_options(); $definition['plugin_options'] = $this->get_options();
return $definition; return $definition;
} }
@ -206,7 +194,19 @@ class definition implements iface_egw_record {
* @return void * @return void
*/ */
public function set_record( array $_record ) { public function set_record( array $_record ) {
$this->definition = $_record; $this->definition = array_intersect_key( $_record, $this->attributes );
// anything which is not an attribute is perhaps a plugin_option.
// If not, it gets whiped out on save time.
foreach ( $_record as $attribute => $value) {
if ( !array_key_exists( $attribute, $this->attributes ) ) {
$this->definition['plugin_options'][$attribute] = $value;
}
}
// convert plugin_options into internal representation
$this->set_allowed_users( $this->definition['allowed_users'] );
$this->set_options( $this->definition['plugin_options'] );
} }
/** /**
@ -225,12 +225,16 @@ class definition implements iface_egw_record {
* @return string identifier * @return string identifier
*/ */
public function save ( $_dst_identifier ) { public function save ( $_dst_identifier ) {
if ($owner = $this->get_owner() && $owner != $this->user && !$this->is_admin) { if ( strlen($this->definition['name']) < 3 ) {
throw ('Error: User '. $this->user. ' is not allowed to save this definition!'); throw new Exception('Error: Can\'t save definition, no valid name given!');
} }
if ($this->so_sql->save($_dst_identifier)) {
throw('Error: so_sql was not able to save definition: '.$this->get_identifier()); $this->so_sql->data = $this->definition;
$this->so_sql->data['plugin_options'] = arrayxml::array2xml( $this->definition['plugin_options'] );
if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) {
throw new Exception('Error: so_sql was not able to save definition: '.$this->get_identifier());
} }
return $this->definition['definition_id']; return $this->definition['definition_id'];
} }

View File

@ -24,57 +24,43 @@ require_once(EGW_INCLUDE_ROOT. '/phpgwapi/inc/class.translation.inc.php');
*/ */
class export_csv implements iface_export_record class export_csv implements iface_export_record
{ {
/** Aggregations: */
/** Compositions: */
/** /**
* array with field mapping in form egw_field_name => exported_field_name * @var array array with field mapping in form egw_field_name => exported_field_name
* @var array
*/ */
protected $mapping = array(); protected $mapping = array();
/** /**
* array with conversions to be done in form: egw_field_name => conversion_string * @var array array with conversions to be done in form: egw_field_name => conversion_string
* @var array
*/ */
protected $conversion = array(); protected $conversion = array();
/** /**
* array holding the current record * @var array holding the current record
* @access protected
*/ */
protected $record = array(); protected $record = array();
/** /**
* holds (charset) translation object * @var translation holds (charset) translation object
* @var object
*/ */
protected $translation; protected $translation;
/** /**
* charset of csv file * @var string charset of csv file
* @var string
*/ */
protected $csv_charset; protected $csv_charset;
/** /**
* holds number of exported records * @var int holds number of exported records
* @var unknown_type
*/ */
protected $num_of_records = 0; protected $num_of_records = 0;
/** /**
* stream resource of csv file * @var stream stream resource of csv file
* @var resource
*/ */
protected $handle; protected $handle;
/** /**
* csv specific options * @var array csv specific options
*
* @var array
*/ */
protected $csv_options = array( protected $csv_options = array(
'delimiter' => ';', 'delimiter' => ';',
@ -84,19 +70,17 @@ class export_csv implements iface_export_record
/** /**
* constructor * constructor
* *
* @param object _handle resource where records are exported to. * @param stram $_stream resource where records are exported to.
* @param string _charset charset the records are exported to.
* @param array _options options for specific backends * @param array _options options for specific backends
* @return bool * @return bool
* @access public
*/ */
public function __construct( $_handle, $_charset, array $_options=array() ) { public function __construct( $_stream, $_options ) {
if (!is_object($GLOBALS['egw']->translation)) { if (!is_object($GLOBALS['egw']->translation)) {
$GLOBALS['egw']->translation = new translation(); $GLOBALS['egw']->translation = new translation();
} }
$this->translation = &$GLOBALS['egw']->translation; $this->translation = &$GLOBALS['egw']->translation;
$this->handle = $_handle; $this->handle = $_stream;
$this->csv_charset = $_charset; $this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8';
if ( !empty( $_options ) ) { if ( !empty( $_options ) ) {
$this->csv_options = array_merge( $this->csv_options, $_options ); $this->csv_options = array_merge( $this->csv_options, $_options );
} }
@ -111,9 +95,7 @@ class export_csv implements iface_export_record
if ($this->num_of_records > 0) { if ($this->num_of_records > 0) {
throw new Exception('Error: Field mapping can\'t be set during ongoing export!'); throw new Exception('Error: Field mapping can\'t be set during ongoing export!');
} }
foreach ($_mapping as $egw_filed => $csv_field) { $this->mapping = $_mapping;
$this->mapping[$egw_filed] = $this->translation->convert($csv_field, $this->translation->charset(), $this->csv_charset);
}
} }
/** /**
@ -131,45 +113,42 @@ class export_csv implements iface_export_record
* *
* @param iface_egw_record record * @param iface_egw_record record
* @return bool * @return bool
* @access public
*/ */
public function export_record( iface_egw_record $_record ) { public function export_record( iface_egw_record $_record ) {
$record_data = $_record->get_record_array(); $this->record = $_record->get_record_array();
if (empty($this->mapping)) { // begin with fieldnames ?
$this->mapping = array_combine(array_keys($record_data),array_keys($record_data)); if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) {
} $mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record );
$mapping = $this->translation->convert( $mapping, $this->translation->charset(), $this->csv_charset );
// just for debug... fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] );
$this->mapping = $this->translation->convert($this->mapping, 'utf-8', 'iso-8859-1');//$this->translation->charset());
if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] && !empty($this->mapping)) {
fputcsv($this->handle,array_values($this->mapping),$this->csv_options['delimiter'],$this->csv_options['enclosure']);
} }
// do conversions // do conversions
if ($this->conversion[$egw_field]) { if ( !empty( $this->conversion )) {
$record_data[$egw_field] = import_export_helper_functions::conversion($record_data,$this->conversion); $this->record = import_export_helper_functions::conversion( $this->record, $this->conversion );
} }
// do charset translation
$record_data = $this->translation->convert($record_data, $this->translation->charset(), $this->csv_charset);
// do fieldmapping // do fieldmapping
if ( !empty( $this->mapping ) ) {
$record_data = $this->record;
$this->record = array();
foreach ($this->mapping as $egw_field => $csv_field) { foreach ($this->mapping as $egw_field => $csv_field) {
$this->record[$csv_field] = $record_data[$egw_field]; $this->record[$csv_field] = $record_data[$egw_field];
} }
}
// do charset translation
$this->record = $this->translation->convert( $this->record, $this->translation->charset(), $this->csv_charset );
$this->fputcsv( $this->handle, $this->record, $this->csv_options['delimiter'], $this->csv_options['enclosure'] ); $this->fputcsv( $this->handle, $this->record, $this->csv_options['delimiter'], $this->csv_options['enclosure'] );
$this->num_of_records++; $this->num_of_records++;
$this->record = array();
} }
/** /**
* Retruns total number of exported records. * Retruns total number of exported records.
* *
* @return int * @return int
* @access public
*/ */
public function get_num_of_records() { public function get_num_of_records() {
return $this->num_of_records; return $this->num_of_records;
@ -179,7 +158,6 @@ class export_csv implements iface_export_record
* destructor * destructor
* *
* @return * @return
* @access public
*/ */
public function __destruct() { public function __destruct() {

View File

@ -10,14 +10,12 @@
* @version $Id$ * @version $Id$
*/ */
//require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_egw_record.inc.php');
/** /**
* class iface_export_plugin * class iface_export_plugin
* This a the abstract interface for an export plugin of importexport * This a the abstract interface for an export plugin of importexport
* *
* You need to implement this class in * You need to implement this class in
* EGW_INCLUDE_ROOT/appname/inc/class.export_<type>.inc.php * EGW_INCLUDE_ROOT/appname/inc/importexport/class.export_<type>.inc.php
* to attend the importexport framwork with your export. * to attend the importexport framwork with your export.
* *
* NOTE: This is an easy interface, cause plugins live in theire own * NOTE: This is an easy interface, cause plugins live in theire own
@ -41,9 +39,10 @@ interface iface_export_plugin {
/** /**
* exports entries according to given definition object. * exports entries according to given definition object.
* *
* @param stream $_stream
* @param definition $_definition * @param definition $_definition
*/ */
public static function export($_stream, $_charset, definition $_definition); public function export($_stream, definition $_definition);
/** /**
* returns translated name of plugin * returns translated name of plugin
@ -78,14 +77,14 @@ interface iface_export_plugin {
* preserv => array, * preserv => array,
* ) * )
*/ */
public static function get_options_etpl(); public function get_options_etpl();
/** /**
* returns etemplate name for slectors of this plugin * returns etemplate name for slectors of this plugin
* *
* @return string etemplate name * @return string etemplate name
*/ */
public static function get_selectors_etpl(); public function get_selectors_etpl();
} // end of iface_export_plugin } // end of iface_export_plugin
?> ?>

View File

@ -26,28 +26,20 @@
*/ */
interface iface_export_record interface iface_export_record
{ {
/** Aggregations: */
/** Compositions: */
/** /**
* constructor * constructor
* *
* @param object _handle resource where records are exported to. * @param stream $_stream resource where records are exported to.
* @param string _charset charset the records are exported to. * @param array $_options options for specific backends
* @param array _options options for specific backends
* @return bool * @return bool
* @access public
*/ */
public function __construct( $_handle, $_charset, array $_options=array() ); public function __construct( $_stream, array $_options );
/** /**
* exports a record into resource of handle * exports a record into resource of handle
* *
* @param object of interface egw_record _record * @param object of interface egw_record _record
* @return bool * @return bool
* @access public
*/ */
public function export_record( iface_egw_record $_record ); public function export_record( iface_egw_record $_record );
@ -55,7 +47,6 @@ interface iface_export_record
* Retruns total number of exported records. * Retruns total number of exported records.
* *
* @return int * @return int
* @access public
*/ */
public function get_num_of_records( ); public function get_num_of_records( );
@ -63,7 +54,6 @@ interface iface_export_record
* destructor * destructor
* *
* @return * @return
* @access public
*/ */
public function __destruct( ); public function __destruct( );

View File

@ -0,0 +1,80 @@
<?php
/**
* eGroupWare
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package importexport
* @link http://www.egroupware.org
* @author Cornelius Weiss <nelius@cwtech.de>
* @copyright Cornelius Weiss <nelius@cwtech.de>
* @version $Id:$
*/
/**
* class iface_import_plugin
* This a the abstract interface for an import plugin of importexport
*
* You need to implement this class in
* EGW_INCLUDE_ROOT/appname/inc/importexport/class.import_<type>.inc.php
* to attend the importexport framwork with your export.
*
* NOTE: This is an easy interface, cause plugins live in theire own
* space. Means that they are responsible for generating a defintion AND
* working on that definition.
* So this interface just garanties the interaction with userinterfaces. It
* has nothing to do with datatypes.
*/
interface iface_import_plugin {
/**
* imports entries according to given definition object.
*
* @param stram $_stram
* @param definition $_definition
*/
public function import( $_stream, definition $_definition );
/**
* returns translated name of plugin
*
* @return string name
*/
public static function get_name();
/**
* returns translated (user) description of plugin
*
* @return string descriprion
*/
public static function get_description();
/**
* retruns file suffix(s) plugin can handle (e.g. csv)
*
* @return string suffix (comma seperated)
*/
public static function get_filesuffix();
/**
* return etemplate components for options.
* @abstract We can't deal with etemplate objects here, as an uietemplate
* objects itself are scipt orientated and not "dialog objects"
*
* @return array (
* name => string,
* content => array,
* sel_options => array,
* preserv => array,
* )
*/
public function get_options_etpl();
/**
* returns etemplate name for slectors of this plugin
*
* @return string etemplate name
*/
public function get_selectors_etpl();
} // end of iface_export_plugin
?>

View File

@ -20,26 +20,19 @@
*/ */
interface iface_import_record interface iface_import_record
{ {
/** Aggregations: */
/** Compositions: */
/** /**
* Opens resource, returns false if something fails * Opens resource, returns false if something fails
* *
* @param string _resource resource containing data. Differs according to the implementations * @param stream $_stream resource containing data. Differs according to the implementations
* @param array _options options for the resource * @param array $_options options for specific backends
* @return bool * @return bool
* @access public
*/ */
public function __construct( $_resource, $_options ); public function __construct( $_stream, array $_options );
/** /**
* cleanup * cleanup
* *
* @return * @return
* @access public
*/ */
public function __destruct( ); public function __destruct( );
@ -48,7 +41,6 @@ interface iface_import_record
* *
* @param string _position may be: {first|last|next|previous|somenumber} * @param string _position may be: {first|last|next|previous|somenumber}
* @return bool * @return bool
* @access public
*/ */
public function get_record( $_position = 'next' ); public function get_record( $_position = 'next' );
@ -56,7 +48,6 @@ interface iface_import_record
* Retruns total number of records for the open resource. * Retruns total number of records for the open resource.
* *
* @return int * @return int
* @access public
*/ */
public function get_num_of_records( ); public function get_num_of_records( );
@ -64,7 +55,6 @@ interface iface_import_record
* Returns pointer of current position * Returns pointer of current position
* *
* @return int * @return int
* @access public
*/ */
public function get_current_position( ); public function get_current_position( );

View File

@ -19,55 +19,40 @@ require_once('class.import_export_helper_functions.inc.php');
* This a an abstract implementation of interface iface_import_record * This a an abstract implementation of interface iface_import_record
* An record is e.g. a single address or or single event. * An record is e.g. a single address or or single event.
* No mater where the records come from, at the end the get_record method comes out * No mater where the records come from, at the end the get_record method comes out
* @todo Throw away spechial chars and trim() entries ?
* @todo Check for XSS like userinput! (see common_functions)
*/ */
class import_csv implements iface_import_record { //, Iterator { class import_csv implements iface_import_record { //, Iterator {
const csv_max_linelength = 8000; const csv_max_linelength = 8000;
/** Aggregations: */
/** Compositions: */
/** /**
* @static import_export_helper_functions * @var array array with field mapping in form column number => new_field_name
*/
/*** Attributes: ***/
/**
* array with field mapping in form column number => new_field_name
* @access public
*/ */
public $mapping = array(); public $mapping = array();
/** /**
* array with conversions to be done in form: new_field_name => conversion_string * @var array with conversions to be done in form: new_field_name => conversion_string
* @access public
*/ */
public $conversion = array(); public $conversion = array();
/** /**
* array holding the current record * @var array holding the current record
* @access protected
*/ */
protected $record = array(); protected $record = array();
/** /**
* current position counter * @var int current position counter
* @access protected
*/ */
protected $current_position = 0; protected $current_position = 0;
/** /**
* holds total number of records * @var int holds total number of records
* @access private
* @var int
*/ */
protected $num_of_records = 0; protected $num_of_records = 0;
/** /**
* csv resource * @var stream
* @access private
*/ */
private $resource; private $resource;
@ -79,18 +64,16 @@ class import_csv implements iface_import_record { //, Iterator {
private $csv_fieldsep; private $csv_fieldsep;
/** /**
* charset of csv file *
* @var string * @var string charset of csv file
* @access privat
*/ */
private $csv_charset; private $csv_charset;
/** /**
* @param string _resource resource containing data. May be each valid php-stream * @param string $_resource resource containing data. May be each valid php-stream
* @param array _options options for the resource array with keys: charset and fieldsep * @param array $_options options for the resource array with keys: charset and fieldsep
* @access public
*/ */
public function __construct( $_resource, $_options = array() ) { public function __construct( $_resource, $_options ) {
$this->resource = $_resource; $this->resource = $_resource;
$this->csv_fieldsep = $_options['fieldsep']; $this->csv_fieldsep = $_options['fieldsep'];
$this->csv_charset = $_options['charset']; $this->csv_charset = $_options['charset'];
@ -99,9 +82,6 @@ class import_csv implements iface_import_record { //, Iterator {
/** /**
* cleanup * cleanup
*
* @return
* @access public
*/ */
public function __destruct( ) { public function __destruct( ) {
} // end of member function __destruct } // end of member function __destruct
@ -111,21 +91,20 @@ class import_csv implements iface_import_record { //, Iterator {
* *
* @param mixed _position may be: {current|first|last|next|previous|somenumber} * @param mixed _position may be: {current|first|last|next|previous|somenumber}
* @return mixed array with data / false if no furtor records * @return mixed array with data / false if no furtor records
* @access public
*/ */
public function get_record( $_position = 'next' ) { public function get_record( $_position = 'next' ) {
if ($this->get_raw_record( $_position ) === false) { if ($this->get_raw_record( $_position ) === false) {
return false; return false;
} }
if ( !empty( $this->mapping ) ) {
$this->do_fieldmapping();
}
if ( !empty( $this->conversion ) ) { if ( !empty( $this->conversion ) ) {
$this->do_conversions(); $this->do_conversions();
} }
if ( !empty( $this->mapping ) ) {
$this->do_fieldmapping();
}
return $this->record; return $this->record;
} // end of member function get_record } // end of member function get_record
@ -197,7 +176,6 @@ class import_csv implements iface_import_record { //, Iterator {
* Retruns total number of records for the open resource. * Retruns total number of records for the open resource.
* *
* @return int * @return int
* @access public
*/ */
public function get_num_of_records( ) { public function get_num_of_records( ) {
if ($this->num_of_records > 0) { if ($this->num_of_records > 0) {
@ -214,7 +192,6 @@ class import_csv implements iface_import_record { //, Iterator {
* Returns pointer of current position * Returns pointer of current position
* *
* @return int * @return int
* @access public
*/ */
public function get_current_position( ) { public function get_current_position( ) {
@ -227,7 +204,6 @@ class import_csv implements iface_import_record { //, Iterator {
* does fieldmapping according to $this->mapping * does fieldmapping according to $this->mapping
* *
* @return * @return
* @access protected
*/ */
protected function do_fieldmapping( ) { protected function do_fieldmapping( ) {
$record = $this->record; $record = $this->record;
@ -235,14 +211,13 @@ class import_csv implements iface_import_record { //, Iterator {
foreach ($this->mapping as $cvs_idx => $new_idx) { foreach ($this->mapping as $cvs_idx => $new_idx) {
$this->record[$new_idx] = $record[$cvs_idx]; $this->record[$new_idx] = $record[$cvs_idx];
} }
return; return true;
} // end of member function do_fieldmapping } // end of member function do_fieldmapping
/** /**
* does conversions according to $this->conversion * does conversions according to $this->conversion
* *
* @return bool * @return bool
* @access protected
*/ */
protected function do_conversions( ) { protected function do_conversions( ) {
if ( $record = import_export_helper_functions::conversion( $this->record, $this->conversion )) { if ( $record = import_export_helper_functions::conversion( $this->record, $this->conversion )) {

View File

@ -10,20 +10,11 @@
* @version $Id$ * @version $Id$
*/ */
/** /**
* class import_export_helper_functions (only static methods) * class import_export_helper_functions (only static methods)
* use import_export_helper_functions::method * use import_export_helper_functions::method
*/ */
class import_export_helper_functions class import_export_helper_functions {
{
/** Aggregations: */
/** Compositions: */
/*** Attributes: ***/
/** /**
* nothing to construct here, only static functions! * nothing to construct here, only static functions!
@ -32,80 +23,75 @@ class import_export_helper_functions
/** /**
* converts accound_lid to account_id * converts accound_lid to account_id
* *
* @param string _account_lid comma seperated list * @param mixed $_account_lid comma seperated list or array with lids
* @return string comma seperated list * @return mixed comma seperated list or array with ids
* @static
* @access public
*/ */
public static function account_lid2id( $_account_lids ) { public static function account_name2id( $_account_lids ) {
$account_lids = explode( ',', $_account_lids ); $account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids );
foreach ( $account_lids as $account_lid ) { foreach ( $account_lids as $account_lid ) {
if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) { if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) {
$account_ids[] = $account_id; $account_ids[] = $account_id;
} }
} }
return implode( ',', $account_ids ); return is_array( $_account_lids ) ? $account_ids : implode( ',', $account_ids );
} // end of member function account_lid2id } // end of member function account_lid2id
/** /**
* converts account_ids to account_lids * converts account_ids to account_lids
* *
* @param int _account_ids comma seperated list * @param mixed $_account_ids comma seperated list or array with ids
* @return string comma seperated list * @return mixed comma seperated list or array with lids
* @static
* @access public
*/ */
public static function account_id2lid( $_account_id ) { public static function account_id2name( $_account_id ) {
$account_ids = explode( ',', $_account_id ); $account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id );
foreach ( $account_ids as $account_id ) { foreach ( $account_ids as $account_id ) {
if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) { if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) {
$account_lids[] = $account_lid; $account_lids[] = $account_lid;
} }
} }
return implode( ',', $account_lids ); return is_array( $_account_id ) ? $account_lids : implode( ',', $account_lids );
} // end of member function account_id2lid } // end of member function account_id2lid
/** /**
* converts cat_id to a cat_name * converts cat_id to a cat_name
* *
* @param int _cat_ids comma seperated list * @param mixed _cat_ids comma seperated list or array
* @return mixed string cat_name * @return mixed comma seperated list or array with cat_names
* @static
* @access public
*/ */
public static function cat_id2name( $_cat_ids ) { public static function cat_id2name( $_cat_ids ) {
if ( !is_object($GLOBALS['egw']->categories) ) { $cats = &CreateObject( 'phpgwapi.categories' );
$GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories');
} $cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
$cat_ids = explode( ',', $_cat_id );
foreach ( $cat_ids as $cat_id ) { foreach ( $cat_ids as $cat_id ) {
$cat_names[] = $GLOBALS['egw']->categories->id2name( (int)$cat_id ); $cat_names[] = $cats->id2name( (int)$cat_id );
} }
return implode(',',$cat_names); return is_array( $_cat_ids ) ? $cat_names : implode(',',$cat_names);
} // end of member function category_id2name } // end of member function category_id2name
/** /**
* converts cat_name to a cat_id. * converts cat_name to a cat_id.
* If a cat isn't found, it will be created. * If a cat isn't found, it will be created.
* *
* @param string _cat_names comma seperated list. * @param mixed $_cat_names comma seperated list or array.
* @return mixed int / string (comma seperated cat id's) * @return mixed comma seperated list or array with cat_ids
* @static
* @access public
*/ */
public static function cat_name2id( $_cat_names, $_create = true ) { public static function cat_name2id( $_cat_names ) {
if (!is_object($GLOBALS['egw']->categories)) { $cats = &CreateObject( 'phpgwapi.categories' );
$GLOBALS['egw']->categories =& CreateObject( 'phpgwapi.categories' ); $cats->app_name = 'phpgw';
}
$cat_names = explode( ',', $_cat_names ); $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
foreach ( $cat_names as $cat_name ) { foreach ( $cat_names as $cat_name ) {
if ( $cat_id = $GLOBALS['egw']->categories->name2id( addslashes( $cat_name ))) { } if ( $cat_id = $cats->name2id( addslashes( $cat_name ))) { }
elseif ($_create) $cat_id = $GLOBALS['egw']->categories->add( array( 'name' => $cat_name,'descr' => $cat_name )); else $cat_id = $cats->add( array(
else continue; 'name' => $cat_name,
'access' => 'public',
'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')'
));
$cat_ids[] = $cat_id; $cat_ids[] = $cat_id;
} }
return implode( ',', $cat_ids ); return $_cat_names ? $cat_ids : implode( ',', $cat_ids );
} // end of member function category_name2id } // end of member function category_name2id
@ -120,115 +106,90 @@ class import_export_helper_functions
* This will translate a '1' in the _record field to 'privat' and everything else to 'public'. * This will translate a '1' in the _record field to 'privat' and everything else to 'public'.
* *
* In addintion to the fields assign by the pattern of the reg.exp. * In addintion to the fields assign by the pattern of the reg.exp.
* you can use all other _record fields, with the syntax |[FIELDNAME]. * you can use all other _record fields, with the syntax |[FIELDINDEX].
* Example: * Example:
* .+|>|[Company]: |[NFamily], |[NGiven]|||[NFamily], |[NGiven] * Your record is:
* It is used on the _record field 'Company' and constructs a something like * array( 0 => Company, 1 => NFamily, 2 => NGiven
* Your conversion string for field 0 (Company):
* .+|>|[0]: |[1], |[2]|||[1], |[2]
* This constructs something like
* Company: FamilyName, GivenName or FamilyName, GivenName if 'Company' is empty. * Company: FamilyName, GivenName or FamilyName, GivenName if 'Company' is empty.
* *
* Moreover the helper function of this class can be used using the '@' operator. * Moreover the two helper function cat() and account() can be used.
* @cat_name2id(Cat1,...,CatN) returns a (','-separated) list with the cat_id's. If a * cat(Cat1,...,CatN) returns a (','-separated) list with the cat_id's. If a
* category isn't found, it will be automaticaly added. * category isn't found, it will be automaticaly added.
* *
* Patterns as well as the replacement can be regular expressions (the replacement is done * Patterns as well as the replacement can be regular expressions (the replacement is done
* via ereg_replace). * via ereg_replace).
* *
* If, after all replacements, the value starts with an '@' the whole
* value is eval()'ed, so you may use all php, phpgw plus your own functions. This is quiet
* powerfull, but circumvents all ACL. Therefor this feature is only availible to
* Adminstrators.
*
* Example using regular expressions and '@'-eval():
* ||0?([0-9]+)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*).*|>@mktime(|#4,|#5,|#6,|#2,|#3,|#1)
* It will read a date of the form '2001-05-20 08:00:00.00000000000000000' (and many more,
* see the regular expr.). The [ .:-]-separated fields are read and assigned in different
* order to @mktime(). Please note to use |# insted of a backslash (I couldn't get backslash
* through all the involved templates and forms.) plus the field-number of the pattern.
*
* @param array _record reference with record to do the conversion with * @param array _record reference with record to do the conversion with
* @param array _conversion array with conversion description * @param array _conversion array with conversion description
* @param object &$cclass calling class to process the '@ evals' (not impelmeted yet)
* @return bool * @return bool
* @static
* @access public
* @todo replace this function with a function dealing with reg expressions!
*/ */
public static function conversion( $_record, $_conversion ) { public static function conversion( $_record, $_conversion, &$_cclass = null ) {
if (empty( $_conversion ) ) return $_record; if (empty( $_conversion ) ) return $_record;
$values = $_record;
$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion $PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion
$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment $ASep = '|>'; // Assignment-Separator, separats pattern and replacesment
$VPre = '|#'; // Value-Prefix, is expanded to \ for ereg_replace $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value
$CPre = '|['; $CPreReg = '\|\['; // |{_record-fieldname} is expanded to the value of the _record-field
$CPos = ']'; $CPosReg = '\]'; // if used together with @ (replacement is eval-ed) value gets autom. quoted
foreach ( $_record as $record_idx => $record_value ) { foreach ( $_conversion as $idx => $conversion_string ) {
$pat_reps = explode($PSep,stripslashes($_conversion[$record_idx]));
$replaces = ''; $rvalues = ''; if ( empty( $conversion_string ) ) continue;
if($pat_reps[0] != '')
{ // fetch patterns ($rvalues)
foreach($pat_reps as $k => $pat_rep) $pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
{ foreach( $pat_reps as $k => $pat_rep ) {
list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 ); list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
if($replace == '') if( $replace == '' ) {
{
$replace = $pattern; $pattern = '^.*$'; $replace = $pattern; $pattern = '^.*$';
} }
$rvalues[$pattern] = $replace; // replace two with only one, added by the form $rvalues[$pattern] = $replace; // replace two with only one, added by the form
$replaces .= ($replaces != '' ? $PSep : '') . $pattern . $ASep . $replace;
}
//$_conversion[$record_idx] = $rvalues;
$conv_record = $rvalues;
}
else
{
//unset($_conversion[$record_idx] );
} }
$val = $record_value; // conversion list may be longer than $_record (no_csv)
if(!empty($_conversion[$record_idx])) $val = array_key_exists( $idx, $_record ) ? $_record[$idx] : '';
{
//$conv_record = $_conversion[$record_idx];
while(list($pattern,$replace) = each($conv_record))
{
if(ereg((string) $pattern,$val))
{
$val = ereg_replace((string) $pattern,str_replace($VPre,'\\',$replace),(string) $val);
$reg = $CPreReg.'([a-zA-Z_0-9]+)'.$CPosReg; foreach ( $rvalues as $pattern => $replace ) {
while(ereg($reg,$val,$vars)) if( ereg( (string)$pattern, $val) ) {
{ // expand all _record fields
$val = str_replace($CPre . $vars[1] . $CPos, $val[0] == '@' ? "'" $val = ereg_replace( (string)$pattern, $replace, (string)$val );
. addslashes($fields[array_search($vars[1], array_keys($_record))])
. "'" : $fields[array_search($vars[1], array_keys($_record))], $val); $reg = '\|\[([a-zA-Z_0-9]+)\]';
while( ereg( $reg, $val, $vars ) ) {
// expand all _record fields
$val = str_replace(
$CPre . $vars[1] . $CPos,
$_record[array_search($vars[1], array_keys($_record))],
$val
);
} }
if($val[0] == '@')
{ $val = preg_replace_callback( "/(cat|account)\(([^)]+)\)/i", array( self, 'c2_dispatcher') , $val );
if (!$GLOBALS['egw_info']['user']['apps']['admin'])
{
error_log(__FILE__.__LINE__. lang('@-eval() is only availible to admins!!!'));
}
else
{
// removing the $ to close security hole of showing vars, which contain eg. passwords
$val = substr(str_replace('$','',$val),1).';';
$val = 'return '. (substr($val,0,6) == 'cat_id' ? '$this->'.$val : $val);
// echo "<p>eval('$val')=";
$val = eval($val);
// echo "'$val'</p>";
} }
} }
if($pattern[0] != '@' || $val) $values[$idx] = $val;
{
break;
}
}
}
}
$values[$record_idx] = $val;
} }
return $values; return $values;
} // end of member function conversion } // end of member function conversion
/**
* callback for preg_replace_callback from self::conversion.
* This function gets called when 2nd level conversions are made,
* like the cat() and account() statements in the conversions.
*
* @param array $_matches
*/
private static function c2_dispatcher( $_matches ) {
$action = &$_matches[1]; // cat or account ...
$data = &$_matches[2]; // datas for action
$method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' );
return self::$method( $data );
}
/** /**
* returns a list of importexport plugins * returns a list of importexport plugins
* *
@ -236,13 +197,13 @@ class import_export_helper_functions
* @param string $_appname {<appname> | all} * @param string $_appname {<appname> | all}
* @return array(<appname> => array( <type> => array(<plugin> => <title>))) * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
*/ */
public static function get_plugins($_appname, $_type){ public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
$types = $_types == 'all' ? array('import','export') : (array)$_type; $types = $_type == 'all' ? array('import','export') : (array)$_type;
$plugins = array(); $plugins = array();
foreach ($appnames as $appname) { foreach ($appnames as $appname) {
$appdir = EGW_INCLUDE_ROOT. "/$appname/inc"; $appdir = EGW_INCLUDE_ROOT. "/$appname/importexport";
if(!is_dir($appdir)) continue; if(!is_dir($appdir)) continue;
$d = dir($appdir); $d = dir($appdir);
@ -269,6 +230,7 @@ class import_export_helper_functions
} }
$d->close(); $d->close();
} }
//error_log(__CLASS__.__FUNCTION__.print_r($plugins,true));
return $plugins; return $plugins;
} }
@ -282,5 +244,8 @@ class import_export_helper_functions
return array_keys(self::get_plugins('all',$_type)); return array_keys(self::get_plugins('all',$_type));
} }
public static function guess_filetype( $_file ) {
}
} // end of import_export_helper_functions } // end of import_export_helper_functions
?> ?>

View File

@ -13,11 +13,6 @@
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.uietemplate.inc.php'); require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.uietemplate.inc.php');
require_once('class.bodefinitions.inc.php'); require_once('class.bodefinitions.inc.php');
if (!defined('IMPORTEXPORT_APP'))
{
define('IMPORTEXPORT_APP','importexport');
}
/** /**
* Userinterface to define {im|ex}ports * Userinterface to define {im|ex}ports
* *
@ -27,6 +22,8 @@ class uidefinitions
{ {
const _debug = true; const _debug = true;
const _appname = 'importexport';
public $public_functions = array( public $public_functions = array(
'edit' => true, 'edit' => true,
'index' => true, 'index' => true,
@ -59,8 +56,8 @@ class uidefinitions
{ {
// we cant deal with notice and warnings, as we are on ajax! // we cant deal with notice and warnings, as we are on ajax!
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
$GLOBALS['egw']->translation->add_app(IMPORTEXPORT_APP); $GLOBALS['egw']->translation->add_app(self::_appname);
$GLOBALS['egw_info']['flags']['currentapp'] = IMPORTEXPORT_APP; $GLOBALS['egw_info']['flags']['currentapp'] = self::_appname;
$GLOBALS['egw_info']['flags']['include_xajax'] = true; $GLOBALS['egw_info']['flags']['include_xajax'] = true;
if(!@is_object($GLOBALS['egw']->js)) if(!@is_object($GLOBALS['egw']->js))
@ -68,7 +65,7 @@ class uidefinitions
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
} }
$this->etpl =& new etemplate(); $this->etpl =& new etemplate();
$this->clock = $GLOBALS['egw']->html->image(IMPORTEXPORT_APP,'clock'); $this->clock = $GLOBALS['egw']->html->image(self::_appname,'clock');
$this->steps = array( $this->steps = array(
'wizzard_step10' => lang('Choose an application'), 'wizzard_step10' => lang('Choose an application'),
'wizzard_step20' => lang('Choose a plugin'), 'wizzard_step20' => lang('Choose a plugin'),
@ -77,7 +74,7 @@ class uidefinitions
'wizzard_finish' => '', 'wizzard_finish' => '',
); );
//register plugins (depricated) //register plugins (depricated)
$this->plugins = bodefinitions::plugins(); //$this->plugins = bodefinitions::plugins();
} }
/** /**
@ -107,7 +104,7 @@ class uidefinitions
case 'export_selected' : case 'export_selected' :
$mime_type = ($GLOBALS['egw']->html->user_agent == 'msie' || $GLOBALS['egw']->html->user_agent == 'opera') ? $mime_type = ($GLOBALS['egw']->html->user_agent == 'msie' || $GLOBALS['egw']->html->user_agent == 'opera') ?
'application/octetstream' : 'application/octet-stream'; 'application/octetstream' : 'application/octet-stream';
$name = 'importexport.definition'; $name = 'importexport_definition.xml';
header('Content-Type: ' . $mime_type); header('Content-Type: ' . $mime_type);
header('Content-Disposition: attachment; filename="'.$name.'"'); header('Content-Disposition: attachment; filename="'.$name.'"');
echo $bodefinitions->export($selected); echo $bodefinitions->export($selected);
@ -120,7 +117,7 @@ class uidefinitions
} }
} }
$etpl =& new etemplate(IMPORTEXPORT_APP.'.definition_index'); $etpl =& new etemplate(self::_appname.'.definition_index');
// we need an offset because of autocontinued rows in etemplate ... // we need an offset because of autocontinued rows in etemplate ...
$definitions = array('row0'); $definitions = array('row0');
@ -131,7 +128,7 @@ class uidefinitions
unset($definition); unset($definition);
} }
$content = $definitions; $content = $definitions;
return $etpl->exec(IMPORTEXPORT_APP.'.uidefinitions.index',$content,array(),$readonlys,$preserv); return $etpl->exec( self::_appname.'.uidefinitions.index', $content, array(), $readonlys, $preserv );
} }
function edit() function edit()
@ -203,7 +200,7 @@ class uidefinitions
$this->wizzard_content_template = $this->$next_step($content,$sel_options,$readonlys,$preserv); $this->wizzard_content_template = $this->$next_step($content,$sel_options,$readonlys,$preserv);
} }
$html = $this->etpl->exec(IMPORTEXPORT_APP.'.uidefinitions.wizzard',$content,$sel_options,$readonlys,$preserv,1); $html = $this->etpl->exec(self::_appname.'.uidefinitions.wizzard',$content,$sel_options,$readonlys,$preserv,1);
} }
else else
{ {
@ -216,7 +213,7 @@ class uidefinitions
unset ($content['edit']); unset ($content['edit']);
$this->wizzard_content_template = $this->wizzard_step10($content, $sel_options, $readonlys, $preserv); $this->wizzard_content_template = $this->wizzard_step10($content, $sel_options, $readonlys, $preserv);
$html = $this->etpl->exec(IMPORTEXPORT_APP.'.uidefinitions.wizzard',$content,$sel_options,$readonlys,$preserv,1); $html = $this->etpl->exec(self::_appname.'.uidefinitions.wizzard',$content,$sel_options,$readonlys,$preserv,1);
} }
if(class_exists('xajaxResponse')) if(class_exists('xajaxResponse'))
@ -254,7 +251,7 @@ class uidefinitions
if ($GLOBALS['egw_info']['user']['apps']['manual']) if ($GLOBALS['egw_info']['user']['apps']['manual'])
{ {
$manual =& new etemplate('etemplate.popup.manual'); $manual =& new etemplate('etemplate.popup.manual');
echo $manual->exec(IMPORTEXPORT_APP.'.uidefinitions.wizzard',$content,$sel_options,$readonlys,$preserv,1); echo $manual->exec(self::_appname.'.uidefinitions.wizzard',$content,$sel_options,$readonlys,$preserv,1);
unset($manual); unset($manual);
} }
@ -448,14 +445,14 @@ class uidefinitions
$bodefinitions = new bodefinitions(); $bodefinitions = new bodefinitions();
if (is_array($content)) if (is_array($content))
{ {
$bodefinitions->import($content['import_file']); $bodefinitions->import($content['import_file']['tmp_name']);
// TODO make redirect here! // TODO make redirect here!
return $this->index(); return $this->index();
} }
else else
{ {
$etpl =& new etemplate(IMPORTEXPORT_APP.'.import_definition'); $etpl =& new etemplate(self::_appname.'.import_definition');
return $etpl->exec(IMPORTEXPORT_APP.'.uidefinitions.import_definition',$content,array(),$readonlys,$preserv); return $etpl->exec(self::_appname.'.uidefinitions.import_definition',$content,array(),$readonlys,$preserv);
} }
} }
} }

View File

@ -57,10 +57,11 @@ class uiexport {
if(empty($_content)) { if(empty($_content)) {
$et = new etemplate(self::_appname. '.export_dialog'); $et = new etemplate(self::_appname. '.export_dialog');
$_appname = $_GET['appname']; $_appname = $_GET['appname'];
$_definition =$_GET['definition']; $_definition =$_GET['definition'] = 'expert';
$_plugin = $_GET['plugin']; // NOTE: definition _must_ be 'expert' if for plugin to be used! $_plugin = $_GET['plugin']; // NOTE: definition _must_ be 'expert' if for plugin to be used!
$_selection = $_GET['selection']; $_selection = $_GET['selection'];
error_log(__FILE__.__FUNCTION__. '::$_GET[\'appname\']='. $_appname. ',$_GET[\'definition\']='. $_definition. ',$_GET[\'plugin\']='.$_plugin. ',$_GET[\'selection\']='.$_selection);
// if appname is given and valid, list available definitions (if no definition is given) // if appname is given and valid, list available definitions (if no definition is given)
if (!empty($_appname) && $GLOBALS['egw']->acl->check('run',1,$_appname)) { if (!empty($_appname) && $GLOBALS['egw']->acl->check('run',1,$_appname)) {
$content['appname'] = $_appname; $content['appname'] = $_appname;
@ -84,7 +85,7 @@ class uiexport {
unset($definitions); unset($definitions);
$sel_options['definition']['expert'] = lang('Expert options'); $sel_options['definition']['expert'] = lang('Expert options');
if(isset($_definition) && array_key_exists($_definition,$sel_options[$_definition])) { if(isset($_definition) && array_key_exists($_definition,$sel_options)) {
$content['definition'] = $_definition; $content['definition'] = $_definition;
} }
else { else {
@ -101,6 +102,7 @@ class uiexport {
if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) { if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) {
$content['plugin'] = $_plugin; $content['plugin'] = $_plugin;
$selected_plugin = $_plugin; $selected_plugin = $_plugin;
error_log('hallo');
} }
else { else {
$plugins_classnames = array_keys($plugins); $plugins_classnames = array_keys($plugins);
@ -181,23 +183,23 @@ class uiexport {
$definition = new definition($_content['definition']); $definition = new definition($_content['definition']);
} }
if (isset($definition->options['selection'])) { if (isset($definition->plugin_options['selection'])) {
//$definition->options = parse(...) //$definition->plugin_options = parse(...)
} }
else { else {
$definition->options = array_merge( $definition->plugin_options = array_merge(
$definition->options, $definition->plugin_options,
array('selection' => $_content['selection']) array('selection' => $_content['selection'])
); );
} }
$tmpfname = tempnam('/tmp','export'); $tmpfname = tempnam('/tmp','export');
$file = fopen($tmpfname, "w+"); $file = fopen($tmpfname, "w+");
if (! $charset = $definition->options['charset']) { if (! $charset = $definition->plugin_options['charset']) {
$charset = $GLOBALS['egw']->translation->charset(); $charset = $GLOBALS['egw']->translation->charset();
} }
$plugin_object = new $definition->plugin; $plugin_object = new $definition->plugin;
$plugin_object->export($file, $charset, $definition); $plugin_object->export( $file, $definition );
if($_content['export'] == 'pressed') { if($_content['export'] == 'pressed') {
fclose($file); fclose($file);
@ -222,9 +224,16 @@ class uiexport {
fclose($file); fclose($file);
unlink($tmpfname); unlink($tmpfname);
$preview = $GLOBALS['egw']->translation->convert($preview,'iso-8859-1','utf-8');
// NOTE: $definition->plugin_options['charset'] may not be set,
// but it's the best guess atm.
$preview = $GLOBALS['egw']->translation->convert( $preview,
$definition->plugin_options['charset'],
$GLOBALS['egw']->translation->charset()
);
$response->addAssign('exec[preview-box]','innerHTML',$preview); $response->addAssign('exec[preview-box]','innerHTML',$preview);
$response->addAssign('divPoweredBy','style.display','none'); //$response->addAssign('divPoweredBy','style.display','none');
$response->addAssign('exec[preview-box]','style.display','inline'); $response->addAssign('exec[preview-box]','style.display','inline');
$response->addAssign('exec[preview-box-buttons]','style.display','inline'); $response->addAssign('exec[preview-box-buttons]','style.display','inline');
@ -234,6 +243,7 @@ class uiexport {
//nothing else expected! //nothing else expected!
throw new Exception('Error: unexpected submit in export_dialog!'); throw new Exception('Error: unexpected submit in export_dialog!');
} }
//error_log(print_r($content,true));
return $et->exec(self::_appname. '.uiexport.export_dialog',$content,$sel_options,$readonlys,$preserv,2); return $et->exec(self::_appname. '.uiexport.export_dialog',$content,$sel_options,$readonlys,$preserv,2);
} }

View File

@ -0,0 +1,28 @@
/**
* eGroupWare
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package importexport
* @link http://www.egroupware.org
* @author Cornelius Weiss <nelius@cwtech.de>
* @copyright Cornelius Weiss <nelius@cwtech.de>
* @version $Id:$
*/
function export_dialog() {
this.change_definition = function(sel_obj) {
if(sel_obj.value == 'expert') {
// next two lines fix some strange layout bug
set_style_by_class('tr','select_definition','display','none');
set_style_by_class('tr','select_definition','display','inline');
set_style_by_class('tr','select_plugin','display','inline');
set_style_by_class('tr','save_definition','display','inline');
}
else {
set_style_by_class('tr','select_plugin','display','none');
set_style_by_class('tr','save_definition','display','none');
}
};
}
var export_dialog = new export_dialog();

View File

@ -9,45 +9,23 @@
* @version $Id$ * @version $Id$
*/ */
$definition_table = 'egw_importexport_definitions'; require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.bodefinitions.inc.php');
// Add two rooms to give user an idea of what resources is... // apps, whose definitions should be installed automatically
$plugin_options = serialize(array( $appnames = array (
'fieldsep' => ',', 'addressbook',
'charset' => 'ISO-8859-1', );
'addressbook' => 'n',
'owner' => 5,
'field_mapping' => array(
0 => '#kundennummer',
1 => 'n_given',
2 => 'n_family',
3 => 'adr_one_street',
4 => 'adr_one_countryname',
5 => 'adr_one_postalcode',
6 => 'adr_one_locality',
7 => 'tel_work',
8 => '',
9 => '',
10 => '',
11 => '',
),
'field_tanslation' => array(),
'has_header_line' => false,
'max' => false,
'conditions' => array(
0 => array(
'type' => 0, // exists
'string' => '#kundennummer',
'true' => array(
'action' => 1, // update
'last' => true,
),
'false' => array(
'action' => 2, // insert
'last' => true,
),
)), foreach ($appnames as $appname) {
)); $defdir = EGW_INCLUDE_ROOT. "/$appname/importexport/definitions";
$oProc->query("INSERT INTO {$definition_table } (name,application,plugin,type,allowed_users,plugin_options) VALUES ( 'oelheld','addressbook','addressbook_csv_import','import','5','$plugin_options')"); if(!is_dir($defdir)) continue;
$d = dir($defdir);
// step through each file in appdir
while (false !== ($entry = $d->read())) {
$file = $appdir. '/'. $entry;
list( $filename, $extension) = explode('.',$entry);
if ( $extension != 'xml' ) continue;
bodefinitions::import( $file );
}
}

View File

@ -2,7 +2,7 @@
/** /**
* eGroupWare - eTemplates for Application importexport * eGroupWare - eTemplates for Application importexport
* http://www.egroupware.org * http://www.egroupware.org
* generated by soetemplate::dump4setup() 2006-11-16 12:03 * generated by soetemplate::dump4setup() 2007-06-09 17:40
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package importexport * @package importexport
@ -12,9 +12,9 @@
$templ_version=1; $templ_version=1;
$templ_data[] = array('name' => 'importexport.definition_index','template' => '','lang' => '','group' => '0','version' => '0.0.1','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:1:{s:2:"h1";s:6:",!@msg";}i:1;a:1:{s:1:"A";a:4:{s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"type";s:5:"label";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:2:{s:2:"c1";s:2:"th";s:2:"c2";s:7:"row,top";}i:1;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"Type";s:4:"span";s:11:",lr_padding";}s:1:"B";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"Name";s:4:"span";s:11:",lr_padding";}s:1:"C";a:3:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";s:4:"span";s:11:",lr_padding";}s:1:"D";a:4:{s:5:"align";s:6:"center";s:4:"type";s:5:"label";s:5:"label";s:13:"Allowed users";s:4:"span";s:11:",lr_padding";}s:1:"E";a:5:{s:5:"label";s:3:"Add";s:5:"align";s:6:"center";s:4:"type";s:6:"button";s:4:"span";s:11:",lr_padding";s:7:"onclick";s:213:"window.open(egw::link(\'/index.php\',\'menuaction=importexport.uidefinitions.wizzard\'),\'\',\'dependent=yes,width=400,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false; return false;";}s:1:"F";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:6:{s:5:"label";s:6:"Delete";s:4:"name";s:15:"delete_selected";s:4:"type";s:6:"button";s:4:"help";s:31:"delete ALL selected definitions";s:4:"size";s:6:"delete";s:7:"onclick";s:65:"return confirm(\'Do you really want to DELETE this definitions?\');";}i:2;a:5:{s:5:"label";s:6:"Export";s:4:"name";s:15:"export_selected";s:4:"type";s:6:"button";s:4:"help";s:31:"export ALL selected definitions";s:4:"size";s:10:"fileexport";}}}i:2;a:6:{s:1:"A";a:4:{s:7:"no_lang";s:1:"1";s:4:"type";s:5:"image";s:4:"span";s:11:",lr_padding";s:4:"name";s:12:"${row}[type]";}s:1:"B";a:4:{s:7:"no_lang";s:1:"1";s:4:"name";s:12:"${row}[name]";s:4:"type";s:5:"label";s:4:"span";s:11:",lr_padding";}s:1:"C";a:4:{s:7:"no_lang";s:1:"1";s:4:"name";s:19:"${row}[application]";s:4:"type";s:5:"label";s:4:"span";s:11:",lr_padding";}s:1:"D";a:6:{s:7:"no_lang";s:1:"1";s:4:"type";s:14:"select-account";s:4:"span";s:11:",lr_padding";s:8:"readonly";s:1:"1";s:4:"name";s:21:"${row}[allowed_users]";s:4:"size";s:1:"5";}s:1:"E";a:5:{s:5:"align";s:6:"center";s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:5:"label";s:4:"Edit";s:4:"type";s:6:"button";s:4:"size";s:4:"edit";s:7:"onclick";s:237:"window.open(egw::link(\'/index.php\',\'menuaction=importexport.uidefinitions.edit&definition=$row_cont[name]\'),\'\',\'dependent=yes,width=400,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false; return false;";}i:2;a:6:{s:5:"label";s:6:"Delete";s:7:"onclick";s:41:"return confirm(\'Delete this definition\');";s:4:"name";s:32:"delete[$row_cont[definition_id]]";s:4:"type";s:6:"button";s:4:"size";s:6:"delete";s:4:"help";s:21:"Delete this eTemplate";}}s:1:"F";a:4:{s:5:"align";s:6:"center";s:4:"name";s:34:"selected[$row_cont[definition_id]]";s:4:"type";s:8:"checkbox";s:4:"help";s:34:"select this eTemplate to delete it";}}}s:4:"cols";i:6;s:4:"rows";i:2;}}}s:4:"cols";i:1;s:4:"rows";i:2;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '.redItalic { color:red; font-style:italic;} td.lr_padding { padding-left: 5px; padding-right: 5px; }','modified' => '1145972373',); $templ_data[] = array('name' => 'importexport.definition_index','template' => '','lang' => '','group' => '0','version' => '0.0.1','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:1:{s:2:"h1";s:6:",!@msg";}i:1;a:1:{s:1:"A";a:4:{s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"type";s:5:"label";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:2:{s:2:"c1";s:2:"th";s:2:"c2";s:7:"row,top";}i:1;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"Type";s:4:"span";s:11:",lr_padding";}s:1:"B";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"Name";s:4:"span";s:11:",lr_padding";}s:1:"C";a:3:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";s:4:"span";s:11:",lr_padding";}s:1:"D";a:4:{s:5:"align";s:6:"center";s:4:"type";s:5:"label";s:5:"label";s:13:"Allowed users";s:4:"span";s:11:",lr_padding";}s:1:"E";a:5:{s:5:"label";s:3:"Add";s:5:"align";s:6:"center";s:4:"type";s:6:"button";s:4:"span";s:11:",lr_padding";s:7:"onclick";s:213:"window.open(egw::link(\'/index.php\',\'menuaction=importexport.uidefinitions.wizzard\'),\'\',\'dependent=yes,width=400,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false; return false;";}s:1:"F";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:6:{s:5:"label";s:6:"Delete";s:4:"name";s:15:"delete_selected";s:4:"type";s:6:"button";s:4:"help";s:31:"delete ALL selected definitions";s:4:"size";s:6:"delete";s:7:"onclick";s:65:"return confirm(\'Do you really want to DELETE this definitions?\');";}i:2;a:5:{s:5:"label";s:6:"Export";s:4:"name";s:15:"export_selected";s:4:"type";s:6:"button";s:4:"help";s:31:"export ALL selected definitions";s:4:"size";s:10:"fileexport";}}}i:2;a:6:{s:1:"A";a:4:{s:7:"no_lang";s:1:"1";s:4:"type";s:5:"image";s:4:"span";s:11:",lr_padding";s:4:"name";s:12:"${row}[type]";}s:1:"B";a:4:{s:7:"no_lang";s:1:"1";s:4:"name";s:12:"${row}[name]";s:4:"type";s:5:"label";s:4:"span";s:11:",lr_padding";}s:1:"C";a:4:{s:7:"no_lang";s:1:"1";s:4:"name";s:19:"${row}[application]";s:4:"type";s:5:"label";s:4:"span";s:11:",lr_padding";}s:1:"D";a:6:{s:7:"no_lang";s:1:"1";s:4:"type";s:14:"select-account";s:4:"span";s:11:",lr_padding";s:8:"readonly";s:1:"1";s:4:"name";s:21:"${row}[allowed_users]";s:4:"size";s:6:"5,both";}s:1:"E";a:5:{s:5:"align";s:6:"center";s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:5:"label";s:4:"Edit";s:4:"type";s:6:"button";s:4:"size";s:4:"edit";s:7:"onclick";s:237:"window.open(egw::link(\'/index.php\',\'menuaction=importexport.uidefinitions.edit&definition=$row_cont[name]\'),\'\',\'dependent=yes,width=400,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false; return false;";}i:2;a:6:{s:5:"label";s:6:"Delete";s:7:"onclick";s:41:"return confirm(\'Delete this definition\');";s:4:"name";s:32:"delete[$row_cont[definition_id]]";s:4:"type";s:6:"button";s:4:"size";s:6:"delete";s:4:"help";s:21:"Delete this eTemplate";}}s:1:"F";a:4:{s:5:"align";s:6:"center";s:4:"name";s:34:"selected[$row_cont[definition_id]]";s:4:"type";s:8:"checkbox";s:4:"help";s:34:"select this eTemplate to delete it";}}}s:4:"cols";i:6;s:4:"rows";i:2;}}}s:4:"cols";i:1;s:4:"rows";i:2;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '.redItalic { color:red; font-style:italic;} td.lr_padding { padding-left: 5px; padding-right: 5px; }','modified' => '1145972373',);
$templ_data[] = array('name' => 'importexport.export_dialog','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:1:{s:2:"c3";s:15:"save_definition";}i:1;a:1:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"name";s:3:"msg";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:3:"tab";s:5:"label";s:25:"General|Selection|Options";s:4:"name";s:37:"general_tab|selection_tab|options_tab";}}i:3;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:18:"Save as definition";s:4:"name";s:18:"save_as_definition";}}i:4;a:1:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Export";s:4:"name";s:6:"export";s:7:"onclick";s:36:"xajax_eT_wrapper(this);return false;";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:7:"Preview";s:4:"name";s:7:"preview";s:7:"onclick";s:36:"xajax_eT_wrapper(this);return false;";}}i:2;a:5:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:5:"align";s:5:"right";s:4:"name";s:6:"cancel";s:7:"onclick";s:29:"window.close(); return false;";}}}i:5;a:1:{s:1:"A";a:6:{s:4:"type";s:3:"box";s:4:"size";s:1:"1";s:4:"name";s:11:"preview-box";s:6:"needed";s:1:"1";i:1;a:1:{s:4:"type";s:5:"label";}s:4:"span";s:12:",preview-box";}}i:6;a:1:{s:1:"A";a:7:{s:4:"type";s:3:"box";s:4:"size";s:1:"1";s:4:"span";s:20:",preview-box-buttons";s:4:"name";s:19:"preview-box-buttons";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:2:"OK";s:5:"align";s:6:"center";s:7:"onclick";s:230:"document.getElementById(\'divPoweredBy\').style.display=\'block\'; document.getElementById(form::name(\'preview-box\')).style.display=\'none\'; document.getElementById(form::name(\'preview-box-buttons\')).style.display=\'none\'; return false;";}s:6:"needed";s:1:"1";s:5:"align";s:6:"center";}}}s:4:"rows";i:6;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '.preview-box { $templ_data[] = array('name' => 'importexport.export_dialog','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:1:{s:2:"c3";s:15:"save_definition";}i:1;a:1:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"name";s:3:"msg";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:3:"tab";s:5:"label";s:25:"General|Selection|Options";s:4:"name";s:37:"general_tab|selection_tab|options_tab";}}i:3;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:18:"Save as definition";s:4:"name";s:18:"save_as_definition";}}i:4;a:1:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Export";s:4:"name";s:6:"export";s:7:"onclick";s:36:"xajax_eT_wrapper(this);return false;";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:7:"Preview";s:4:"name";s:7:"preview";s:7:"onclick";s:36:"xajax_eT_wrapper(this);return false;";}}i:2;a:5:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:5:"align";s:5:"right";s:4:"name";s:6:"cancel";s:7:"onclick";s:29:"window.close(); return false;";}}}i:5;a:1:{s:1:"A";a:6:{s:4:"type";s:3:"box";s:4:"size";s:1:"1";s:4:"name";s:11:"preview-box";s:6:"needed";s:1:"1";i:1;a:1:{s:4:"type";s:5:"label";}s:4:"span";s:12:",preview-box";}}i:6;a:1:{s:1:"A";a:7:{s:4:"type";s:3:"box";s:4:"size";s:1:"1";s:4:"span";s:20:",preview-box-buttons";s:4:"name";s:19:"preview-box-buttons";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:2:"OK";s:5:"align";s:6:"center";s:7:"onclick";s:167:"document.getElementById(form::name(\'preview-box\')).style.display=\'none\'; document.getElementById(form::name(\'preview-box-buttons\')).style.display=\'none\'; return false;";}s:6:"needed";s:1:"1";s:5:"align";s:6:"center";}}}s:4:"rows";i:6;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '.preview-box {
position: absolute; position: absolute;
top: 0px; top: 0px;
left: 0px; left: 0px;

View File

@ -1,7 +1,18 @@
allowed users importexport de Erlaubte Benutzer
choose a name for this definition importexport de Wählen sie einen Namen für diese Definition. choose a name for this definition importexport de Wählen sie einen Namen für diese Definition.
choose a plugin importexport de Wählen sie ein Plugin. choose a plugin importexport de Wählen sie ein Plugin.
choose an application importexport de Wählen sei eine Anwendung. choose an application importexport de Wählen sei eine Anwendung.
delete all selected definitions importexport de Alle ausgewählten Definitionen löschen
export importexport de Exportieren
export all selected definitions importexport de Alle ausgewählten Definitionen exportieren
finish importexport de Fertig finish importexport de Fertig
general importexport de Generell
import definitions (attension: existing definitions with equal names will be overwritten!!!) importexport de Definitionen importieren (Achtung: Alle gleichnamigen existierenden Definitionen werden überschrieben!)
next importexport de Weiter next importexport de Weiter
preview importexport de Vorschau
previous importexport de Zurück previous importexport de Zurück
save as definition importexport de Als Definition speichern
select definition importexport de Definition auswählen
select plugin importexport de Plugin auswählen
some nice text importexport de Ein schöner Text
which useres are allowed for this definition importexport de Welche Benutzer dürden diese Definition verwenden? which useres are allowed for this definition importexport de Welche Benutzer dürden diese Definition verwenden?

View File

@ -2,7 +2,17 @@ allowed users importexport en Allowed users
choose a name for this definition importexport en Choose a name for this definition choose a name for this definition importexport en Choose a name for this definition
choose a plugin importexport en Choose a plugin choose a plugin importexport en Choose a plugin
choose an application importexport en Choose an application choose an application importexport en Choose an application
delete all selected definitions importexport en delete ALL selected definitions
export importexport en Export
export all selected definitions importexport en export ALL selected definitions
finish importexport en finish finish importexport en finish
general importexport en General
import definitions (attension: existing definitions with equal names will be overwritten!!!) importexport en Import definitions (Attension: Existing definitions with equal names will be overwritten!!!)
next importexport en next next importexport en next
preview importexport en Preview
previous importexport en previous previous importexport en previous
save as definition importexport en Save as definition
select definition importexport en Select definition
select plugin importexport en Select plugin
some nice text importexport en some nice text
which useres are allowed for this definition importexport en Which useres are allowed for this definition which useres are allowed for this definition importexport en Which useres are allowed for this definition

View File

@ -0,0 +1,8 @@
allowed users importexport fi Sallittu käyttäjille
choose a name for this definition importexport fi Valitse nimi tälle selitteelle
choose a plugin importexport fi Valitse liitännäinen
choose an application importexport fi Valitse sovellus
finish importexport fi Valmis
next importexport fi Seuraava
previous importexport fi Edellinen
which useres are allowed for this definition importexport fi Ketkä käyttäjät saavat käyttää tätä selitettä

View File

@ -0,0 +1,8 @@
allowed users importexport fr Utilisateurs autorisés
choose a name for this definition importexport fr Choisissez un nom pour cette définition
choose a plugin importexport fr Choisissez un module enfichable
choose an application importexport fr Choisissez une application
finish importexport fr terminer
next importexport fr prochain
previous importexport fr précédent
which useres are allowed for this definition importexport fr Quels utilisateurs sont autorisés pour cette définition

View File

@ -0,0 +1,8 @@
allowed users importexport pl U¿ytkownicy z dostêpem
choose a name for this definition importexport pl Wybierz nazwê dla tej definicji
choose a plugin importexport pl Wybierz wtyczkê
choose an application importexport pl Wybierz aplikacjê
finish importexport pl zakoñcz
next importexport pl nastêpny
previous importexport pl poprzedni
which useres are allowed for this definition importexport pl Którzy u¿ytkownicy maj± dostêp do tej definicji?

View File

@ -0,0 +1,8 @@
allowed users importexport sk Oprávnení pou¾ívatelia
choose a name for this definition importexport sk Zvoµte názov pre túto definíciu
choose a plugin importexport sk Zvoµte zásuvný modul (plugin)
choose an application importexport sk Zvoµte aplikáciu
finish importexport sk Dokonèi»
next importexport sk Ïal¹ie
previous importexport sk Predchádzajúce
which useres are allowed for this definition importexport sk Ktorí pou¾ívatelia sú oprávnení pre túto definíciu

View File

@ -9,7 +9,7 @@
*/ */
$setup_info['importexport']['name'] = 'importexport'; $setup_info['importexport']['name'] = 'importexport';
$setup_info['importexport']['version'] = '0.003'; $setup_info['importexport']['version'] = '1.4';
$setup_info['importexport']['app_order'] = 2; $setup_info['importexport']['app_order'] = 2;
$setup_info['importexport']['enable'] = 2; $setup_info['importexport']['enable'] = 2;
$setup_info['importexport']['tables'] = array('egw_importexport_definitions'); $setup_info['importexport']['tables'] = array('egw_importexport_definitions');
@ -35,11 +35,11 @@
/* Dependencies for this app to work */ /* Dependencies for this app to work */
$setup_info['importexport']['depends'][] = array( $setup_info['importexport']['depends'][] = array(
'appname' => 'phpgwapi', 'appname' => 'phpgwapi',
'versions' => Array('1.2','1.3') 'versions' => Array('1.3','1.4','1.5')
); );
$setup_info['importexport']['depends'][] = array( $setup_info['importexport']['depends'][] = array(
'appname' => 'etemplate', 'appname' => 'etemplate',
'versions' => Array('1.2','1.3') 'versions' => Array('1.3','1.4','1.5')
); );

View File

@ -26,7 +26,6 @@
$test[] = '0.003'; $test[] = '0.003';
function importexport_upgrade0_003() function importexport_upgrade0_003()
{ {
return $GLOBALS['setup_info']['importexport']['currentver'] = '1.4';
return $GLOBALS['setup_info']['importexport']['currentver'] = '0.003';
} }
?> ?>