forked from extern/egroupware
fixed inline documentation, works very nice now
This commit is contained in:
parent
f2e0fda75d
commit
bc13c208fe
@ -12,6 +12,13 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* db-tools: creats and modifys eGroupWare schem-files (to be installed via setup)
|
||||||
|
*
|
||||||
|
* @package etemplate
|
||||||
|
* @author RalfBecker-AT-outdoor-training.de
|
||||||
|
* @license GPL
|
||||||
|
*/
|
||||||
class db_tools
|
class db_tools
|
||||||
{
|
{
|
||||||
var $public_functions = array
|
var $public_functions = array
|
||||||
@ -56,11 +63,8 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
';
|
';
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function db_tools
|
* constructor of class
|
||||||
@syntax db_tools( )
|
|
||||||
@author ralfbecker
|
|
||||||
@abstract constructor of class
|
|
||||||
*/
|
*/
|
||||||
function db_tools()
|
function db_tools()
|
||||||
{
|
{
|
||||||
@ -75,11 +79,8 @@
|
|||||||
$GLOBALS['phpgw_info']['apps']['etemplate']['title'].' - '.lang('DB-Tools');
|
$GLOBALS['phpgw_info']['apps']['etemplate']['title'].' - '.lang('DB-Tools');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function edit
|
* table editor (and the callback/submit-method too)
|
||||||
@syntax edit( $content='',$msg='' )
|
|
||||||
@author ralfbecker
|
|
||||||
@abstract this is the table editor (and the callback/submit-method too)
|
|
||||||
*/
|
*/
|
||||||
function edit($content='',$msg = '')
|
function edit($content='',$msg = '')
|
||||||
{
|
{
|
||||||
@ -234,16 +235,14 @@
|
|||||||
array('posted_table' => $this->table,'posted_app' => $this->app,'changes' => $this->changes));
|
array('posted_table' => $this->table,'posted_app' => $this->app,'changes' => $this->changes));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function needs_save
|
* checks if table was changed and if so offers user to save changes
|
||||||
@syntax needs_save( $cont='',$posted_app='',$posted_table='',$edited_table='' )
|
*
|
||||||
@author ralfbecker
|
* @param array $cont the content of the form (if called by process_exec)
|
||||||
@abstract checks if table was changed and if so offers user to save changes
|
* @param string $posted_app the app the table is from
|
||||||
@param $cont the content of the form (if called by process_exec)
|
* @param string $posted_table the table-name
|
||||||
@param $posted_app the app the table is from
|
* @param string $edited_table the edited table-definitions
|
||||||
@param $posted_table the table-name
|
* @return only if no changes
|
||||||
@param $edited_table the edited table-definitions
|
|
||||||
@result only if no changes
|
|
||||||
*/
|
*/
|
||||||
function needs_save($cont='',$posted_app='',$posted_table='',$edited_table='')
|
function needs_save($cont='',$posted_app='',$posted_table='',$edited_table='')
|
||||||
{
|
{
|
||||||
@ -326,14 +325,13 @@
|
|||||||
return True; // dont continue in edit
|
return True; // dont continue in edit
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function has_single_index
|
* checks if there is an index (only) on $col (not a multiple index incl. $col)
|
||||||
@syntax has_single_index( $col,$index )
|
*
|
||||||
@author ralfbecker
|
* @param string $col column name
|
||||||
@abstract checks if there is an index (only) on $col (not a multiple index incl. $col)
|
* @param array $index ix or uc array of table-defintion
|
||||||
@param $col column name
|
* @param string &$options db specific options
|
||||||
@param $index ix or uc array of table-defintion
|
* @return True if $col has a single index
|
||||||
@result True if $col has a single index
|
|
||||||
*/
|
*/
|
||||||
function has_single_index($col,$index,&$options)
|
function has_single_index($col,$index,&$options)
|
||||||
{
|
{
|
||||||
@ -355,13 +353,13 @@
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function table2content
|
* creates content-array from a table
|
||||||
@syntax table2content( $table )
|
*
|
||||||
@author ralfbecker
|
* @param array $table table-definition, eg. $phpgw_baseline[$table_name]
|
||||||
@abstract creates content-array from a $table
|
* @param array &$columns returns array with column-names
|
||||||
@param $table table-definition, eg. $phpgw_baseline[$table_name]
|
* @param bool $extra_index add an additional index-row
|
||||||
@result content-array
|
* @return array content-array to call exec with
|
||||||
*/
|
*/
|
||||||
function table2content($table,&$columns,$extra_index=False)
|
function table2content($table,&$columns,$extra_index=False)
|
||||||
{
|
{
|
||||||
@ -414,14 +412,13 @@
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function content2table
|
* creates table-definition from posted content
|
||||||
@syntax content2table( $content )
|
*
|
||||||
@author ralfbecker
|
* It sets some reasonalbe defaults for not set precisions (else setup will not install)
|
||||||
@abstract creates table-definition from posted content
|
*
|
||||||
@param $content posted content-array
|
* @param array $content posted content-array
|
||||||
@note It sets some reasonalbe defaults for not set precisions (else setup will not install)
|
* @return table-definition
|
||||||
@result table-definition
|
|
||||||
*/
|
*/
|
||||||
function content2table($content)
|
function content2table($content)
|
||||||
{
|
{
|
||||||
@ -547,14 +544,11 @@
|
|||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function read
|
* includes $app/setup/tables_current.inc.php
|
||||||
@syntax read( $app,&$phpgw_baseline )
|
* @param string $app application name
|
||||||
@author ralfbecker
|
* @param array &$phpgw_baseline where to return the data
|
||||||
@abstract includes $app/setup/tables_current.inc.php
|
* @return boolean True if file found, False else
|
||||||
@param $app application name
|
|
||||||
@param $phpgw_baseline where to put the data
|
|
||||||
@result True if file found, False else
|
|
||||||
*/
|
*/
|
||||||
function read($app,&$phpgw_baseline)
|
function read($app,&$phpgw_baseline)
|
||||||
{
|
{
|
||||||
@ -578,6 +572,14 @@
|
|||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns an array as string in php-notation
|
||||||
|
*
|
||||||
|
* @param array $arr
|
||||||
|
* @param int $depth for idention
|
||||||
|
* @param string $parent
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function write_array($arr,$depth,$parent='')
|
function write_array($arr,$depth,$parent='')
|
||||||
{
|
{
|
||||||
if (in_array($parent,array('pk','fk','ix','uc')))
|
if (in_array($parent,array('pk','fk','ix','uc')))
|
||||||
@ -628,14 +630,12 @@
|
|||||||
return $def;
|
return $def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function write
|
* writes tabledefinitions $phpgw_baseline to file /$app/setup/tables_current.inc.php
|
||||||
@syntax write( $app,$phpgw_baseline )
|
*
|
||||||
@author ralfbecker
|
* @param string $app app-name
|
||||||
@abstract writes tabledefinitions $phpgw_baseline to file /$app/setup/tables_current.inc.php
|
* @param array $phpgw_baseline tabledefinitions
|
||||||
@param $app app-name
|
* @return boolean True if file writen else False
|
||||||
@param $phpgw_baseline tabledefinitions
|
|
||||||
@return True if file writen else False
|
|
||||||
*/
|
*/
|
||||||
function write($app,$phpgw_baseline)
|
function write($app,$phpgw_baseline)
|
||||||
{
|
{
|
||||||
@ -683,15 +683,12 @@
|
|||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function setup_version
|
* reads and updates the version and tables info in file $app/setup/setup.inc.php
|
||||||
@syntax setup_version( $app,$new = '',$tables='' )
|
* @param string $app the app
|
||||||
@author ralfbecker
|
* @param string $new new version number to set, if $new != ''
|
||||||
@abstract reads and updates the version and tables info in file $app/setup/setup.inc.php
|
* @param string $tables new tables to include (comma delimited), if != ''
|
||||||
@param $app the app
|
* @return the version or False if the file could not be read or written
|
||||||
@param $new new version number to set, if $new != ''
|
|
||||||
@param $tables new tables to include, if $tables != ''
|
|
||||||
@return the version or False if the file could not be read or written
|
|
||||||
*/
|
*/
|
||||||
function setup_version($app,$new = '',$tables='')
|
function setup_version($app,$new = '',$tables='')
|
||||||
{
|
{
|
||||||
@ -792,15 +789,13 @@
|
|||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function update
|
* updates file /$app/setup/tables_update.inc.php to reflect changes in $current
|
||||||
@syntax update( $app,$current,$version )
|
*
|
||||||
@author ralfbecker
|
* @param string $app app-name
|
||||||
@abstract updates file /$app/setup/tables_update.inc.php to reflect changes in $current
|
* @param array $current new tabledefinitions
|
||||||
@param $app app-name
|
* @param string $version new version
|
||||||
@param $current new tabledefinitions
|
* @return boolean True if file writen else False
|
||||||
@param $version new version
|
|
||||||
@return True if file writen else False
|
|
||||||
*/
|
*/
|
||||||
function update($app,$current,$version)
|
function update($app,$current,$version)
|
||||||
{
|
{
|
||||||
@ -864,6 +859,12 @@
|
|||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unsets all keys in an array which have a given value
|
||||||
|
*
|
||||||
|
* @param array &$arr
|
||||||
|
* @param mixed $val value to check against
|
||||||
|
*/
|
||||||
function remove_from_array(&$arr,$value)
|
function remove_from_array(&$arr,$value)
|
||||||
{
|
{
|
||||||
foreach($arr as $key => $val)
|
foreach($arr as $key => $val)
|
||||||
@ -875,6 +876,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates an update-script
|
||||||
|
*
|
||||||
|
* @param string $app app-name
|
||||||
|
* @param array $current new table-defintion
|
||||||
|
* @param string &$tables returns comma delimited list of new table-names
|
||||||
|
* @return string the update-script
|
||||||
|
*/
|
||||||
function update_schema($app,$current,&$tables)
|
function update_schema($app,$current,&$tables)
|
||||||
{
|
{
|
||||||
$this->read($app,$old);
|
$this->read($app,$old);
|
||||||
@ -968,14 +977,12 @@
|
|||||||
return $update;
|
return $update;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function normalize_index
|
* orders the single-colum-indices after the columns and the multicolunm ones behind
|
||||||
@abstract orders the single-colum-indices after the columns and the multicolunm ones bedind
|
*
|
||||||
@syntax normalize_index( $index,$cols )
|
* @param array $index array with indices
|
||||||
@param index array with indices
|
* @param array $cols array with column-defs (col-name is the key)
|
||||||
@param cols array with column-defs (col-name in key)
|
* @return array the new array of indices
|
||||||
@author ralfbecker
|
|
||||||
@result the new array
|
|
||||||
*/
|
*/
|
||||||
function normalize_index($index,$cols)
|
function normalize_index($index,$cols)
|
||||||
{
|
{
|
||||||
@ -999,12 +1006,13 @@
|
|||||||
return $normalized;
|
return $normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function normalize
|
* normalices all properties in a table-definiton, eg. all nullable properties to True or False
|
||||||
@syntax normalize( $table )
|
*
|
||||||
@author ralfbecker
|
* this is necessary to compare two table-defitions
|
||||||
@abstract sets all nullable properties to True or False
|
*
|
||||||
@result the new array
|
* @param array $table table-definition
|
||||||
|
* @return array the normaliced defintion
|
||||||
*/
|
*/
|
||||||
function normalize($table)
|
function normalize($table)
|
||||||
{
|
{
|
||||||
@ -1029,12 +1037,13 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function tables_identical
|
* compares two table-definitions, by comparing normaliced string-representations (serialize)
|
||||||
@syntax tables_identical( $old,$new )
|
*
|
||||||
@author ralfbecker
|
* @param array $a
|
||||||
@abstract compares two table-definitions
|
* @param array $b
|
||||||
@result True if they are identical or False else
|
* @return boolean true if they are identical (would create an identical schema), false otherwise
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
function tables_identical($a,$b)
|
function tables_identical($a,$b)
|
||||||
{
|
{
|
||||||
@ -1047,6 +1056,3 @@
|
|||||||
return $a == $b;
|
return $a == $b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,13 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* template editor of the eTemplate package
|
||||||
|
*
|
||||||
|
* @package etemplate
|
||||||
|
* @author RalfBecker-AT-outdoor-training.de
|
||||||
|
* @license GPL
|
||||||
|
*/
|
||||||
class editor
|
class editor
|
||||||
{
|
{
|
||||||
var $debug;
|
var $debug;
|
||||||
@ -94,9 +101,7 @@
|
|||||||
'xml_label' => $xml_label,
|
'xml_label' => $xml_label,
|
||||||
'xml' => $xml ? '<pre>'.$this->etemplate->html->htmlspecialchars($xml)."</pre>\n" : '',
|
'xml' => $xml ? '<pre>'.$this->etemplate->html->htmlspecialchars($xml)."</pre>\n" : '',
|
||||||
);
|
);
|
||||||
$options = explode(',',$this->etemplate->size);
|
foreach(explode(',',$this->etemplate->size) as $n => $opt)
|
||||||
reset($this->options);
|
|
||||||
while (list($n,$opt) = each($this->options))
|
|
||||||
{
|
{
|
||||||
$content['options'][$opt] = $options[$n];
|
$content['options'][$opt] = $options[$n];
|
||||||
}
|
}
|
||||||
@ -783,6 +788,8 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// set onclick handler
|
||||||
|
$this->etemplate->onclick_handler = "alert('%p');";
|
||||||
$show->data[$show->rows]['A']['obj'] = &$this->etemplate;
|
$show->data[$show->rows]['A']['obj'] = &$this->etemplate;
|
||||||
$vals = $post_vars['vals'];
|
$vals = $post_vars['vals'];
|
||||||
$olds = $post_vars['olds'];
|
$olds = $post_vars['olds'];
|
||||||
@ -800,13 +807,12 @@
|
|||||||
),'');
|
),'');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function scan_for_extensions
|
* search the inc-dirs of etemplate and the app whichs template is edited for extensions / custom widgets
|
||||||
@syntax scan_for_extensions( $app )
|
*
|
||||||
@author ralfbecker
|
* extensions are class-files in $app/inc/class.${name}_widget.inc.php
|
||||||
@abstract search the inc-dirs of etemplate and the app whichs template is edited for extensions / custom widgets
|
*
|
||||||
@discussion extensions are class-files in $app/inc/class.${name}_widget.inc.php
|
* @return array with name => human_name of the extensions found
|
||||||
@result array with name => human_name of the extensions found
|
|
||||||
*/
|
*/
|
||||||
function scan_for_extensions($app='etemplate')
|
function scan_for_extensions($app='etemplate')
|
||||||
{
|
{
|
||||||
|
@ -12,25 +12,49 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@class so_sql
|
* generalized SQL Storage Object
|
||||||
@author ralfbecker
|
*
|
||||||
@abstract generalized SQL Storage Object
|
* the class can be used in following ways:
|
||||||
@discussion the class can be used in following ways:
|
* 1) by calling the constructor with an app and table-name or
|
||||||
@discussion 1) by calling the constructor with an app and table-name or
|
* 2) by setting the following documented class-vars in a class derifed from this one
|
||||||
@discussion 2) by setting the following class-vars in a class derifed from this one
|
* Of cause can you derife the class and call the constructor with params.
|
||||||
@discussion Of cause can you derife the class and call the constructor with params.
|
*
|
||||||
@param $table_name need to be set in the derived class to the db-table-name
|
* @package etemplate
|
||||||
@param $autoinc_id db-col-name of autoincrement id or ''
|
* @author RalfBecker-AT-outdoor-training.de
|
||||||
@param $db_key_cols array of all primary-key-columns in form dbName => internalName
|
* @license GPL
|
||||||
@discussion the save function does NOT touch any other cols in the table!!!
|
*/
|
||||||
@param $db_data_cols array of all data-cols
|
|
||||||
@param $debug turns on debug-messages
|
|
||||||
@param $empty_on_write string to be written to db if a col-value is '', eg. "''" or 'NULL' (default)
|
|
||||||
@param $non_db_cols all cols in data which are not (direct)in the db, for data_merge
|
|
||||||
*/
|
|
||||||
class so_sql
|
class so_sql
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string $table_name need to be set in the derived class to the db-table-name
|
||||||
|
*/
|
||||||
|
var $table_name;
|
||||||
|
/**
|
||||||
|
* @var string $autoinc_id db-col-name of autoincrement id or ''
|
||||||
|
*/
|
||||||
|
var $autoinc_id = '';
|
||||||
|
/**
|
||||||
|
* @var array $db_key_cols array of all primary-key-columns in form dbName => internalName
|
||||||
|
* the save function does NOT touch any other cols in the table!!!
|
||||||
|
*/
|
||||||
|
var $db_key_cols = array();
|
||||||
|
/**
|
||||||
|
* @var array $db_data_cols array of all data-cols
|
||||||
|
*/
|
||||||
|
var $db_data_cols = array();
|
||||||
|
/**
|
||||||
|
* @var array $non_db_cols all cols in data which are not (direct)in the db, for data_merge
|
||||||
|
*/
|
||||||
|
var $non_db_cols = array();
|
||||||
|
/**
|
||||||
|
* @var int $debug turns on debug-messages
|
||||||
|
*/
|
||||||
|
var $debug = 0;
|
||||||
|
/**
|
||||||
|
* @var string $empty_on_write string to be written to db if a col-value is '', eg. "''" or 'NULL' (default)
|
||||||
|
*/
|
||||||
|
var $empty_on_write = 'NULL';
|
||||||
var $public_functions = array(
|
var $public_functions = array(
|
||||||
'init' => True,
|
'init' => True,
|
||||||
'data_merge' => True,
|
'data_merge' => True,
|
||||||
@ -39,23 +63,18 @@ class so_sql
|
|||||||
'delete' => True,
|
'delete' => True,
|
||||||
'search' => True,
|
'search' => True,
|
||||||
);
|
);
|
||||||
var $db,$table_name;
|
var $db;
|
||||||
var $autoinc_id = '';
|
|
||||||
var $db_key_cols = array(),$db_data_cols = array(); // key_cols mean primary keys
|
|
||||||
var $db_uni_cols = array();
|
var $db_uni_cols = array();
|
||||||
var $db_cols; // = $db_key_cols + $db_data_cols
|
var $db_cols; // = $db_key_cols + $db_data_cols
|
||||||
var $non_db_cols = array();
|
|
||||||
var $data; // holds the content of all db_cols
|
var $data; // holds the content of all db_cols
|
||||||
var $debug = 0;
|
|
||||||
var $empty_on_write = 'NULL';
|
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function so_sql
|
* constructor of the class
|
||||||
@syntax so_sql( $app='',$table='' )
|
*
|
||||||
@author ralfbecker
|
* NEED to be called from the constructor of the derived class !!!
|
||||||
@abstract constructor of the class
|
*
|
||||||
@discussion NEED to be called from the constructor of the derived class
|
* @param string $app should be set if table-defs to be read from <app>/setup/tables_current.inc.php
|
||||||
@param $app, $table should be set if table-defs to be read from <app>/setup/tables_current.inc.php
|
* @param string $table should be set if table-defs to be read from <app>/setup/tables_current.inc.php
|
||||||
*/
|
*/
|
||||||
function so_sql($app='',$table='')
|
function so_sql($app='',$table='')
|
||||||
{
|
{
|
||||||
@ -75,13 +94,11 @@ class so_sql
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function setup_table
|
* reads table-definition from <app>/setup/tables_current.inc.php
|
||||||
@syntax setup_table( $app,$table )
|
*
|
||||||
@author ralfbecker
|
* Does NOT set a different internal-data-name. If you want this, you have to do so
|
||||||
@abstract reads table-definition from <app>/setup/tables_current.inc.php
|
* in a derifed class !!!
|
||||||
@discussion Does NOT set a different internal-data-name. If you want this, you have to do so
|
|
||||||
@discussion in a derifed class !!!
|
|
||||||
*/
|
*/
|
||||||
function setup_table($app,$table)
|
function setup_table($app,$table)
|
||||||
{
|
{
|
||||||
@ -120,12 +137,10 @@ class so_sql
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function so_data_merge
|
* merges in new values from the given new data-array
|
||||||
@syntax so_data_merge( $new )
|
*
|
||||||
@author ralfbecker
|
* @param $new array in form col => new_value with values to set
|
||||||
@abstract merges in new values from the given new data-array
|
|
||||||
@param $new array in form col => new_value with values to set
|
|
||||||
*/
|
*/
|
||||||
function data_merge($new)
|
function data_merge($new)
|
||||||
{
|
{
|
||||||
@ -149,55 +164,48 @@ class so_sql
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function db2data
|
* changes the data from the db-format to your work-format
|
||||||
@abstract changes the data from the db-format to your work-format
|
*
|
||||||
@discussion it gets called everytime when data is read from the db
|
* it gets called everytime when data is read from the db
|
||||||
@discussion This function needs to be reimplemented in the derived class
|
* This function needs to be reimplemented in the derived class
|
||||||
@param $data if given works on that array and returns result, else works on internal data-array
|
*
|
||||||
|
* @param array $data if given works on that array and returns result, else works on internal data-array
|
||||||
*/
|
*/
|
||||||
function db2data($data=0)
|
function db2data($data=null)
|
||||||
{
|
{
|
||||||
if ($intern = !is_array($data))
|
if (!is_array($data))
|
||||||
{
|
{
|
||||||
$data = $this->data;
|
$data = &$this->data;
|
||||||
}
|
}
|
||||||
// do the necessare changes here
|
// do the necessare changes here
|
||||||
|
|
||||||
if ($intern)
|
|
||||||
{
|
|
||||||
$this->data = $data;
|
|
||||||
}
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function data2db
|
* changes the data from your work-format to the db-format
|
||||||
@abstract changes the data from your work-format to the db-format
|
*
|
||||||
@discussion It gets called everytime when data gets writen into db or on keys for db-searches
|
* It gets called everytime when data gets writen into db or on keys for db-searches
|
||||||
@discussion this needs to be reimplemented in the derived class
|
* this needs to be reimplemented in the derived class
|
||||||
@param $data if given works on that array and returns result, else works on internal data-array
|
*
|
||||||
|
* @param array $data if given works on that array and returns result, else works on internal data-array
|
||||||
*/
|
*/
|
||||||
function data2db($data=0)
|
function data2db($data=null)
|
||||||
{
|
{
|
||||||
if ($intern = !is_array($data))
|
if ($intern = !is_array($data))
|
||||||
{
|
{
|
||||||
$data = $this->data;
|
$data = &$this->data;
|
||||||
}
|
}
|
||||||
// do the necessary changes here
|
// do the necessary changes here
|
||||||
|
|
||||||
if ($intern)
|
|
||||||
{
|
|
||||||
$this->data = $data;
|
|
||||||
}
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function init
|
* initializes data with the content of key
|
||||||
@abstract initializes data with the content of key
|
*
|
||||||
@param $keys array with keys in form internalName => value
|
* @param array $keys array with keys in form internalName => value
|
||||||
@result void
|
|
||||||
*/
|
*/
|
||||||
function init($keys=array())
|
function init($keys=array())
|
||||||
{
|
{
|
||||||
@ -208,11 +216,11 @@ class so_sql
|
|||||||
$this->data_merge($keys);
|
$this->data_merge($keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function read
|
* reads row matched by key and puts all cols in the data array
|
||||||
@abstract reads row matched by key and puts all cols in the data array
|
*
|
||||||
@param $keys array with keys in form internalName => value, may be a scalar value if only one key
|
* @param array $keys array with keys in form internalName => value, may be a scalar value if only one key
|
||||||
@result data array if row could be retrived else False and data = array()
|
* @return array/boolean data if row could be retrived else False
|
||||||
*/
|
*/
|
||||||
function read($keys)
|
function read($keys)
|
||||||
{
|
{
|
||||||
@ -279,15 +287,15 @@ class so_sql
|
|||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function save
|
* saves the content of data to the db
|
||||||
@abstracts saves the content of data to the db
|
*
|
||||||
@param $keys if given $keys are copied to data before saveing => allows a save as
|
* @param array $keys if given $keys are copied to data before saveing => allows a save as
|
||||||
@result 0 on success and errno != 0 else
|
* @return int 0 on success and errno != 0 else
|
||||||
*/
|
*/
|
||||||
function save($keys='')
|
function save($keys=null)
|
||||||
{
|
{
|
||||||
$this->data_merge($keys);
|
if (is_array($keys) && count($keys)) $this->data_merge($keys);
|
||||||
|
|
||||||
if (!$this->autoinc_id) // no autoincrement id, so we need to find out with read if key already in db
|
if (!$this->autoinc_id) // no autoincrement id, so we need to find out with read if key already in db
|
||||||
{
|
{
|
||||||
@ -342,13 +350,13 @@ class so_sql
|
|||||||
return $this->db->errno;
|
return $this->db->errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function delete
|
* deletes row representing keys in internal data or the supplied $keys if != null
|
||||||
@abstract deletes row representing keys in internal data or the supplied $keys if != ''
|
*
|
||||||
@param $keys if not '', array with col => value pairs to characterise the rows to delete
|
* @param array $keys if given array with col => value pairs to characterise the rows to delete
|
||||||
@result affected rows, should be 1 if ok, 0 if an error
|
* @return affected rows, should be 1 if ok, 0 if an error
|
||||||
*/
|
*/
|
||||||
function delete($keys='')
|
function delete($keys=null)
|
||||||
{
|
{
|
||||||
if (!is_array($keys) || !count($keys)) // use internal data
|
if (!is_array($keys) || !count($keys)) // use internal data
|
||||||
{
|
{
|
||||||
@ -381,18 +389,19 @@ class so_sql
|
|||||||
return $this->db->affected_rows();
|
return $this->db->affected_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function search
|
* searches db for rows matching searchcriteria
|
||||||
@abstract searches db for rows matching searchcriteria
|
*
|
||||||
@discussion '*' and '?' are replaced with sql-wildcards '%' and '_'
|
* '*' and '?' are replaced with sql-wildcards '%' and '_'
|
||||||
@param $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
|
*
|
||||||
@param $only_keys True returns only keys, False returns all cols
|
* @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
|
||||||
@param $order_by fieldnames + {ASC|DESC} separated by colons ','
|
* @param boolean $only_keys True returns only keys, False returns all cols
|
||||||
@param $extra_cols string to be added to the SELECT, eg. (count(*) as num)
|
* @param string $order_by fieldnames + {ASC|DESC} separated by colons ','
|
||||||
@param $wildcard string appended befor and after each criteria
|
* @param string $extra_cols string to be added to the SELECT, eg. (count(*) as num)
|
||||||
@param $empty False=empty criteria are ignored in query, True=empty have to be empty in row
|
* @param string $wildcard appended befor and after each criteria
|
||||||
@param $op defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
|
* @param boolean $empty False=empty criteria are ignored in query, True=empty have to be empty in row
|
||||||
@result array of matching rows (the row is an array of the cols) or False
|
* @param string $op defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
|
||||||
|
* @return array of matching rows (the row is an array of the cols) or False
|
||||||
*/
|
*/
|
||||||
function search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND')
|
function search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND')
|
||||||
{
|
{
|
||||||
@ -444,15 +453,13 @@ class so_sql
|
|||||||
return $n ? $arr : False;
|
return $n ? $arr : False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@function not_unique
|
* Check if values for unique keys are unique
|
||||||
@syntax not_unique( $data='' )
|
*
|
||||||
@author ralfbecker
|
* @param array $data data-set to check, defaults to $this->data
|
||||||
@abstract Check if values for unique keys are unique
|
* @return int 0: all keys are unique, 1: first key not unique, 2: ...
|
||||||
@param $data data-set to check, defaults to $this->data
|
|
||||||
@result 0: all keys are unique, 1: first key not unique, 2: ...
|
|
||||||
*/
|
*/
|
||||||
function not_unique($data='')
|
function not_unique($data=null)
|
||||||
{
|
{
|
||||||
if (!is_array($data))
|
if (!is_array($data))
|
||||||
{
|
{
|
||||||
@ -479,4 +486,4 @@ class so_sql
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
/**
|
/**
|
||||||
* constructor of etemplate class, reads an eTemplate if $name is given
|
* constructor of etemplate class, reads an eTemplate if $name is given
|
||||||
*
|
*
|
||||||
* @param $name name of etemplate or array with name and other keys
|
* @param string $name of etemplate or array with name and other keys
|
||||||
* @param $load_via name/array with keys of other etemplate to load in order to get $name
|
* @param string/array $load_via with keys of other etemplate to load in order to get $name
|
||||||
*/
|
*/
|
||||||
function etemplate($name='',$load_via='')
|
function etemplate($name='',$load_via='')
|
||||||
{
|
{
|
||||||
@ -84,17 +84,17 @@
|
|||||||
* form as submit-url to call process_show for the template before it
|
* form as submit-url to call process_show for the template before it
|
||||||
* ExecuteMethod's the given $method of the caller.
|
* ExecuteMethod's the given $method of the caller.
|
||||||
*
|
*
|
||||||
* @param $method Methode (e.g. 'etemplate.editor.edit') to be called if form is submitted
|
* @param string $method Methode (e.g. 'etemplate.editor.edit') to be called if form is submitted
|
||||||
* @param $content array with content to fill the input-fields of template, eg. the text-field
|
* @param array $content with content to fill the input-fields of template, eg. the text-field
|
||||||
* @param with name 'name' gets its content from $content['name']
|
* with name 'name' gets its content from $content['name']
|
||||||
* @param $sel_options array or arrays with the options for each select-field, keys are the
|
* @param $sel_options array or arrays with the options for each select-field, keys are the
|
||||||
* @param field-names, eg. array('name' => array(1 => 'one',2 => 'two')) set the
|
* field-names, eg. array('name' => array(1 => 'one',2 => 'two')) set the
|
||||||
* @param options for field 'name'. ($content['options-name'] is possible too !!!)
|
* options for field 'name'. ($content['options-name'] is possible too !!!)
|
||||||
* @param $readonlys array with field-names as keys for fields with should be readonly
|
* @param array $readonlys with field-names as keys for fields with should be readonly
|
||||||
* @param (eg. to implement ACL grants on field-level or to remove buttons not applicable)
|
* (eg. to implement ACL grants on field-level or to remove buttons not applicable)
|
||||||
* @param $preserv array with vars which should be transported to the $method-call (eg. an id) array('id' => $id) sets $_POST['id'] for the $method-call
|
* @param array $preserv with vars which should be transported to the $method-call (eg. an id) array('id' => $id) sets $_POST['id'] for the $method-call
|
||||||
* @param $output_mode int 0 = echo incl. navbar, 1 = return html, 2 = echo without navbar (eg. for popups)
|
* @param int $output_mode 0 = echo incl. navbar, 1 = return html, 2 = echo without navbar (eg. for popups)
|
||||||
* @param $changes array change made in the last call if looping, only used internaly by process_exec
|
* @param array $changes change made in the last call if looping, only used internaly by process_exec
|
||||||
* @return string html for $output_mode == 1, else nothing
|
* @return string html for $output_mode == 1, else nothing
|
||||||
*/
|
*/
|
||||||
function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$output_mode=0,$changes='')
|
function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$output_mode=0,$changes='')
|
||||||
@ -294,14 +294,14 @@
|
|||||||
* as it deals with HTML and is so UI-dependent, use exec instead.
|
* as it deals with HTML and is so UI-dependent, use exec instead.
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
* @param $content array with content for the cells, keys are the names given in the cells/form elements
|
* @param array $content with content for the cells, keys are the names given in the cells/form elements
|
||||||
* @param $sel_options array with options for the selectboxes, keys are the name of the selectbox
|
* @param array $sel_options with options for the selectboxes, keys are the name of the selectbox
|
||||||
* @param $readonlys array with names of cells/form-elements to be not allowed to change
|
* @param array $readonlys with names of cells/form-elements to be not allowed to change
|
||||||
* @param This is to facilitate complex ACL's which denies access on field-level !!!
|
* This is to facilitate complex ACL's which denies access on field-level !!!
|
||||||
* @param $cname string basename of names for form-elements, means index in $_POST
|
* @param string $cname basename of names for form-elements, means index in $_POST
|
||||||
* eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
|
* eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
|
||||||
* @param $show_c string name/index for name expansion
|
* @param string $show_c name/index for name expansion
|
||||||
* @param $show_row string name/index for name expansion
|
* @param string $show_row name/index for name expansion
|
||||||
* @return string the generated HTML
|
* @return string the generated HTML
|
||||||
*/
|
*/
|
||||||
function show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0/*TEST-RB,$no_table_tr=False,$tr_class=''*/)
|
function show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0/*TEST-RB,$no_table_tr=False,$tr_class=''*/)
|
||||||
@ -345,15 +345,15 @@
|
|||||||
* as it deals with HTML and is so UI-dependent, use exec instead.
|
* as it deals with HTML and is so UI-dependent, use exec instead.
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
* @param $grid array representing a grid
|
* @param array $grid representing a grid
|
||||||
* @param $content array with content for the cells, keys are the names given in the cells/form elements
|
* @param array $content with content for the cells, keys are the names given in the cells/form elements
|
||||||
* @param $sel_options array with options for the selectboxes, keys are the name of the selectbox
|
* @param array $sel_options with options for the selectboxes, keys are the name of the selectbox
|
||||||
* @param $readonlys array with names of cells/form-elements to be not allowed to change
|
* @param array $readonlys with names of cells/form-elements to be not allowed to change
|
||||||
* @param This is to facilitate complex ACL's which denies access on field-level !!!
|
* This is to facilitate complex ACL's which denies access on field-level !!!
|
||||||
* @param $cname string basename of names for form-elements, means index in $_POST
|
* @param string $cname basename of names for form-elements, means index in $_POST
|
||||||
* eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
|
* eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
|
||||||
* @param $show_c string name/index for name expansion
|
* @param string $show_c name/index for name expansion
|
||||||
* @param $show_row string name/index for name expansion
|
* @param string $show_row name/index for name expansion
|
||||||
* @return string the generated HTML
|
* @return string the generated HTML
|
||||||
*/
|
*/
|
||||||
function show_grid(&$grid,$content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0/*TEST-RB,$no_table_tr=False,$tr_class=''*/)
|
function show_grid(&$grid,$content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0/*TEST-RB,$no_table_tr=False,$tr_class=''*/)
|
||||||
@ -522,9 +522,18 @@
|
|||||||
* calls show to generate included eTemplates. Again only an INTERMAL function.
|
* calls show to generate included eTemplates. Again only an INTERMAL function.
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
* @param $cell array with data of the cell: name, type, ...
|
* @param array $cell with data of the cell: name, type, ...
|
||||||
* @param for rest see show
|
* @param array $content with content for the cells, keys are the names given in the cells/form elements
|
||||||
* @return the generated HTML
|
* @param array $sel_options with options for the selectboxes, keys are the name of the selectbox
|
||||||
|
* @param array $readonlys with names of cells/form-elements to be not allowed to change
|
||||||
|
* This is to facilitate complex ACL's which denies access on field-level !!!
|
||||||
|
* @param string $cname basename of names for form-elements, means index in $_POST
|
||||||
|
* eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
|
||||||
|
* @param string $show_c name/index for name expansion
|
||||||
|
* @param string $show_row name/index for name expansion
|
||||||
|
* @param string &$span on return number of cells to span or 'all' for the rest (only used for grids)
|
||||||
|
* @param string &$class on return the css class of the cell, to be set in the <td> tag
|
||||||
|
* @return string the generated HTML
|
||||||
*/
|
*/
|
||||||
function show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span,&$class)
|
function show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span,&$class)
|
||||||
{
|
{
|
||||||
@ -1331,7 +1340,8 @@
|
|||||||
/**
|
/**
|
||||||
* returns the javascript to be included by exec
|
* returns the javascript to be included by exec
|
||||||
*
|
*
|
||||||
* @param $what &1 = returns the test, note: has to be included in the body, not the header, &2 = returns the common functions, best to be included in the header
|
* @param int $what &1 = returns the test, note: has to be included in the body, not the header,
|
||||||
|
* &2 = returns the common functions, best to be included in the header
|
||||||
* @return string javascript
|
* @return string javascript
|
||||||
*/
|
*/
|
||||||
function include_java_script($what = 3)
|
function include_java_script($what = 3)
|
||||||
|
@ -41,7 +41,10 @@
|
|||||||
|
|
||||||
function xul_io()
|
function xul_io()
|
||||||
{
|
{
|
||||||
$this->attr2xul = array( // how to translate attr, common to all widgets
|
/**
|
||||||
|
* @var array $attr2xul how to translate attr, common to all widgets
|
||||||
|
*/
|
||||||
|
$this->attr2xul = array(
|
||||||
'name' => 'id',
|
'name' => 'id',
|
||||||
'help' => 'statustext',
|
'help' => 'statustext',
|
||||||
'span' => 'span,class',
|
'span' => 'span,class',
|
||||||
@ -50,7 +53,10 @@
|
|||||||
'readonly' => 'readonly=true',
|
'readonly' => 'readonly=true',
|
||||||
'size' => 'options'
|
'size' => 'options'
|
||||||
);
|
);
|
||||||
$this->widget2xul = array( // how to translate widget-names and widget-spec. attr.
|
/**
|
||||||
|
* @var array $widget2xul how to widget-names and widget-spec. attr., not set ones are identical
|
||||||
|
*/
|
||||||
|
$this->widget2xul = array(
|
||||||
'label' => array(
|
'label' => array(
|
||||||
'.name' => 'description',
|
'.name' => 'description',
|
||||||
'label' => 'value'
|
'label' => 'value'
|
||||||
@ -100,6 +106,9 @@
|
|||||||
'size' => 'style,plugins',
|
'size' => 'style,plugins',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
/**
|
||||||
|
* @var array $xul2widget how to xul-widget names to our internal ones, not set ones are identical
|
||||||
|
*/
|
||||||
$this->xul2widget = array(
|
$this->xul2widget = array(
|
||||||
'menulist' => 'select',
|
'menulist' => 'select',
|
||||||
'listbox' => 'select',
|
'listbox' => 'select',
|
||||||
@ -107,6 +116,13 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets an attribute in the xml object representing a widget
|
||||||
|
*
|
||||||
|
* @param object &$widget widget to set the attribute in
|
||||||
|
* @param string $attr comma delimited attr = default-value pairs, eg. "type=int,min=0"
|
||||||
|
* @param array $val array with values to set
|
||||||
|
*/
|
||||||
function set_attributes(&$widget,$attr,$val)
|
function set_attributes(&$widget,$attr,$val)
|
||||||
{
|
{
|
||||||
if ($attr != '')
|
if ($attr != '')
|
||||||
@ -128,6 +144,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add a widget to a parent
|
||||||
|
*
|
||||||
|
* @param object &$parent parten to add the widget
|
||||||
|
* @param array $cell widget to add
|
||||||
|
* @param array &$embeded_too already embeded eTemplates
|
||||||
|
* @return object reference (!) the the xml object representing the widget, so other children can be added
|
||||||
|
*/
|
||||||
function &add_widget(&$parent,$cell,&$embeded_too)
|
function &add_widget(&$parent,$cell,&$embeded_too)
|
||||||
{
|
{
|
||||||
$type = $cell['type'];
|
$type = $cell['type'];
|
||||||
@ -276,6 +300,13 @@
|
|||||||
$parent->add_node($widget);
|
$parent->add_node($widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add a grid to $parent (xml object)
|
||||||
|
*
|
||||||
|
* @param object &$parent where to add the grid
|
||||||
|
* @param array $grid grid to add
|
||||||
|
* @param array &embeded_too array with already embeded eTemplates
|
||||||
|
*/
|
||||||
function add_grid(&$parent,$grid,&$embeded_too)
|
function add_grid(&$parent,$grid,&$embeded_too)
|
||||||
{
|
{
|
||||||
$xul_grid = new xmlnode('grid');
|
$xul_grid = new xmlnode('grid');
|
||||||
@ -317,6 +348,12 @@
|
|||||||
$parent->add_node($xul_grid);
|
$parent->add_node($xul_grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add / embed an eTemplate into the global $xul_overlay object (used by export)
|
||||||
|
*
|
||||||
|
* @param object &$etempl eTemplate to embed
|
||||||
|
* @param array &embeded_too array with already embeded templates
|
||||||
|
*/
|
||||||
function add_etempl(&$etempl,&$embeded_too)
|
function add_etempl(&$etempl,&$embeded_too)
|
||||||
{
|
{
|
||||||
if (is_array($embeded_too))
|
if (is_array($embeded_too))
|
||||||
@ -352,6 +389,12 @@
|
|||||||
$this->xul_overlay->add_node($template);
|
$this->xul_overlay->add_node($template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create an XML representation of an eTemplate
|
||||||
|
*
|
||||||
|
* @param object $etempl eTemplate object to export
|
||||||
|
* @return string the XML
|
||||||
|
*/
|
||||||
function export($etempl)
|
function export($etempl)
|
||||||
{
|
{
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
@ -377,6 +420,13 @@
|
|||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create an eTemplate from it's XML representation
|
||||||
|
*
|
||||||
|
* @param object &$etempl eTemplate object to set
|
||||||
|
* @param string $data the XML
|
||||||
|
* @param array/string array with names of imported templates or error-message
|
||||||
|
*/
|
||||||
function import(&$etempl,$data)
|
function import(&$etempl,$data)
|
||||||
{
|
{
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
|
Loading…
Reference in New Issue
Block a user