fixed a few errors in the etemplate editor

This commit is contained in:
Ralf Becker 2008-03-20 18:43:11 +00:00
parent 186d0ad967
commit add5646e48
5 changed files with 2406 additions and 2408 deletions

View File

@ -2,20 +2,17 @@
/**
* eGroupWare eTemplates - DB-Tools
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-8 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage tools
* @version $Id$
*/
/**
* db-tools: creats and modifys eGroupWare schem-files (to be installed via setup)
*
* @package etemplate
* @subpackage tools
* @author RalfBecker-AT-outdoor-training.de
* @license GPL
*/
class db_tools
{
@ -51,7 +48,7 @@
*/
function db_tools()
{
$this->editor =& CreateObject('etemplate.etemplate','etemplate.db-tools.edit');
$this->editor = new etemplate.etemplate('etemplate.db-tools.edit');
$this->data = array();
if (!is_array($GLOBALS['egw_info']['apps']) || !count($GLOBALS['egw_info']['apps']))
@ -1072,7 +1069,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package '. $app. '
* @subpackage setup
* @version $Id$
* @version $Id'.'$
*/
';
}

View File

@ -2,20 +2,17 @@
/**
* eGroupWare eTemplates - Editor
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-8 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage tools
* @version $Id$
*/
/**
* template editor of the eTemplate package
*
* @package etemplate
* @subpackage tools
* @author RalfBecker-AT-outdoor-training.de
* @license GPL
*/
class editor
{
@ -324,7 +321,7 @@
{
if ($_GET['name'])
{
foreach($this->etemplate->db_key_cols as $var)
foreach(etemplate::$db_key_cols as $var)
{
$content[$var] = $_GET[$var];
}
@ -525,12 +522,12 @@
{
//echo "<p>editor::change_widget_type($widget[type]=$old[type])</p>\n";
$old_type = $old['type'];
$old_had_children = isset($this->etemplate->widgets_with_children[$old_type]);
$old_had_children = isset(etemplate::$widgets_with_children[$old_type]);
if (!isset($this->etemplate->widgets_with_children[$widget['type']]) ||
if (!isset(etemplate::$widgets_with_children[$widget['type']]) ||
($old_type == 'grid') == ($widget['type'] == 'grid'))
{
if ($this->etemplate->widgets_with_children[$widget['type']] == 'box') // box
if (etemplate::$widgets_with_children[$widget['type']] == 'box') // box
{
if ((int) $widget['size'] < 1) // min. 1 child
{
@ -540,13 +537,13 @@
// create the needed cells, if they dont exist
for ($n = 1; $n <= (int) $widget['size']; ++$n)
{
if (!is_array($widget[$n])) $widget[$n] = $n == 1 ? $old : soetemplate::empty_cell();
if (!is_array($widget[$n])) $widget[$n] = $n == 1 ? $old : etemplate::empty_cell();
}
unset($widget['onclick']); // not valid for a box
}
return; // no change necessary, eg. between different box-types
}
switch ($this->etemplate->widgets_with_children[$widget['type']])
switch (etemplate::$widgets_with_children[$widget['type']])
{
case 'grid':
$widget['data'] = array(array());
@ -558,15 +555,15 @@
for ($n = 1; is_array($old[$n]) && $n <= $num; ++$n)
{
$new_line = null;
if ($old_type != 'hbox') soetemplate::add_child($widget,$new_line);
soetemplate::add_child($widget,$old[$n]);
if ($old_type != 'hbox') etemplate::add_child($widget,$new_line);
etemplate::add_child($widget,$old[$n]);
unset($widget[$n]);
}
$widget['size'] = '';
}
else // 1 row with 1 column/child
{
soetemplate::add_child($widget,$cell=soetemplate::empty_cell());
etemplate::add_child($widget,$cell=etemplate::empty_cell());
}
break;
@ -588,8 +585,8 @@
$row =& $old['data'][1];
for ($n = 0; $n < $old['cols']; ++$n)
{
$cell =& $row[soetemplate::num2chrs($n)];
soetemplate::add_child($widget,$cell);
$cell =& $row[etemplate::num2chrs($n)];
etemplate::add_child($widget,$cell);
list($span) = (int)explode(',',$cell['span']);
if ($span == 'all') break;
while ($span-- > 1) ++$n;
@ -599,13 +596,13 @@
{
for ($n = 1; $n <= $old['rows']; ++$n)
{
soetemplate::add_child($widget,$old['data'][$n][soetemplate::num2chrs(0)]);
etemplate::add_child($widget,$old['data'][$n][etemplate::num2chrs(0)]);
}
}
}
if (!$widget['size']) // minimum one child
{
soetemplate::add_child($widget,soetemplate::empty_cell());
etemplate::add_child($widget,etemplate::empty_cell());
}
break;
}
@ -649,11 +646,11 @@
{
list(,$r,$c) = $matches;
// find the column-number (base 0) for $c (A, B, C, ...)
for($col = 0; soetemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
for($col = 0; etemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
if ($col > 0) $left = $parent_path.'/'.$r.soetemplate::num2chrs($col-1);
if ($col > 0) $left = $parent_path.'/'.$r.etemplate::num2chrs($col-1);
if ($col < $parent['cols']-1) $right = $parent_path.'/'.$r.soetemplate::num2chrs($col+1);
if ($col < $parent['cols']-1) $right = $parent_path.'/'.$r.etemplate::num2chrs($col+1);
if ($r > 1) $up = $parent_path.'/'.($r-1).$c;
@ -675,7 +672,7 @@
{
$in = $parent_path.'/'.$child_id.'/1A';
}
elseif (isset($this->etemplate->widgets_with_children[$widget['type']]) && $widget['type'] != 'template')
elseif (isset(etemplate::$widgets_with_children[$widget['type']]) && $widget['type'] != 'template')
{
if ($widget['type']) // box
{
@ -740,7 +737,7 @@
list($num,$options) = explode(',',$parent['size'],2);
if ($num <= 1) // cant delete last child --> only empty it
{
$parent[$num=1] = soetemplate::empty_cell();
$parent[$num=1] = etemplate::empty_cell();
}
else
{
@ -756,7 +753,7 @@
{
if (count($this->etemplate->children) <= 1) // cant delete last child
{
$this->etemplate->children[0] = soetemplate::empty_cell();
$this->etemplate->children[0] = etemplate::empty_cell();
}
else
{
@ -768,7 +765,7 @@
}
else
{
$content['cell'] = soetemplate::empty_cell();
$content['cell'] = etemplate::empty_cell();
return lang('cant delete a single widget from a grid !!!');
}
break;
@ -806,7 +803,7 @@
{
$parent[1+$i] = $parent[$i];
}
$parent[$n] = $content['cell'] = soetemplate::empty_cell();
$parent[$n] = $content['cell'] = etemplate::empty_cell();
$child_id = $n;
if ($parent['type']) $parent['size'] = (1+$num) . ($options ? ','.$options : '');
break;
@ -902,8 +899,8 @@
}
for($i = 0; $i < $cols; ++$i)
{
echo (1+$r).":$i=".soetemplate::num2chrs($i)."=empty_cell()<br>\n";
$data[1+$r][soetemplate::num2chrs($i)] = soetemplate::empty_cell();
echo (1+$r).":$i=".etemplate::num2chrs($i)."=empty_cell()<br>\n";
$data[1+$r][etemplate::num2chrs($i)] = etemplate::empty_cell();
}
$opts['c'.(1+$r)] = $opts['h'.(1+$r)] = '';
++$rows;
@ -933,7 +930,7 @@
if (preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches)) list(,$r,$c) = $matches;
// find the column-number (base 0) for $c (A, B, C, ...)
for($col = 0; soetemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
for($col = 0; etemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
if (!$c || !$r || $r > $rows || $col >= $cols) return "wrong child_id='$child_id' => r='$r', c='$c', col=$col";
@ -943,9 +940,9 @@
if ($col >= $cols-1)
{
if ($col != $cols-1) return lang('no column to swap with !!!');
$c = soetemplate::num2chrs(--$col); // in last column swap with the one before
$c = etemplate::num2chrs(--$col); // in last column swap with the one before
}
$c_next = soetemplate::num2chrs(1+$col);
$c_next = etemplate::num2chrs(1+$col);
for($row = 1; $row <= $rows; ++$row)
{
$this->swap($data[$row][$c],$data[$row][$c_next]);
@ -963,15 +960,15 @@
{
for ($i = $cols; $i > $col; --$i)
{
$data[$row][soetemplate::num2chrs($i)] = $data[$row][soetemplate::num2chrs($i-1)];
$data[$row][etemplate::num2chrs($i)] = $data[$row][etemplate::num2chrs($i-1)];
}
$data[$row][soetemplate::num2chrs($col)] = soetemplate::empty_cell();
$data[$row][etemplate::num2chrs($col)] = etemplate::empty_cell();
}
for ($i = $cols; $i > $col; --$i)
{
$opts[soetemplate::num2chrs($i)] = $opts[soetemplate::num2chrs($i-1)];
$opts[etemplate::num2chrs($i)] = $opts[etemplate::num2chrs($i-1)];
}
unset($opts[soetemplate::num2chrs($col)]);
unset($opts[etemplate::num2chrs($col)]);
++$cols;
//_debug_array($grid); return '';
break;
@ -986,15 +983,15 @@
{
for ($i = $col; $i < $cols-1; ++$i)
{
$data[$row][soetemplate::num2chrs($i)] = $data[$row][soetemplate::num2chrs($i+1)];
$data[$row][etemplate::num2chrs($i)] = $data[$row][etemplate::num2chrs($i+1)];
}
unset($data[$row][soetemplate::num2chrs($cols-1)]);
unset($data[$row][etemplate::num2chrs($cols-1)]);
}
for ($i = $col; $i < $cols-1; ++$i)
{
$opts[soetemplate::num2chrs($i)] = $opts[soetemplate::num2chrs($i+1)];
$opts[etemplate::num2chrs($i)] = $opts[etemplate::num2chrs($i+1)];
}
unset($opts[soetemplate::num2chrs(--$cols)]);
unset($opts[etemplate::num2chrs(--$cols)]);
break;
}
$action = 'save-no-merge';
@ -1222,7 +1219,7 @@
case 'save': case 'apply':
// initialise the children arrays if type is changed to a widget with children
//echo "<p>$content[path]: $widget[type] --> ".$content['cell']['type']."</p>\n";
if (isset($this->etemplate->widgets_with_children[$content['cell']['type']]))
if (isset(etemplate::$widgets_with_children[$content['cell']['type']]))
{
$this->change_widget_type($content['cell'],$widget);
}
@ -1288,7 +1285,7 @@
$this->fix_set_onclick($widget,$content['cell'],true);
$this->fix_set_onchange($widget,$content['cell'],true);
foreach($this->etemplate->db_key_cols as $var)
foreach(etemplate::$db_key_cols as $var)
{
if (isset($_GET[$var]))
{
@ -1375,7 +1372,7 @@
{
if (!is_array($content))
{
foreach($this->etemplate->db_key_cols as $var)
foreach(etemplate::$db_key_cols as $var)
{
if (isset($_GET[$var])) $content[$var] = $_GET[$var];
}

View File

@ -2,10 +2,12 @@
/**
* eGroupWare EditableTemplates - Storage Objects
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-8 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @version $Id$
*/
@ -25,11 +27,6 @@
* 2) preferd languages of the user (templates for all langs have $lang='')
* 3) selected template: verdilak, ... (the default is called '' in the db, not default)
* 4) a version-number of the form, eg: '0.9.13.001' (filled up with 0 same size)
*
* @package etemplate
* @subpackage api
* @author RalfBecker-AT-outdoor-training.de
* @license GPL
*/
class soetemplate
{

View File

@ -81,6 +81,13 @@ class etemplate extends boetemplate
* @var boolean
*/
var $sitemgr=false;
/**
* Javascript to be called, when a widget get's double-clicked (used only by the editor)
* A '%p' gets replace with the colon ':' separated template-name, -version and path of the clicked widget.
*
* @var string
*/
var $onclick_handler;
/**
* constructor of etemplate class, reads an eTemplate if $name is given
@ -955,7 +962,7 @@ class etemplate extends boetemplate
{
if ($this->debug && (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type']))
{
echo "<p>etemplate.show_cell($this->name,name='${cell['name']}',type='${cell['type']}',cname='$cname')</p>\n";
echo "<p>etemplate.show_cell($this->name,name='${cell['name']}',type='${cell['type']}',cname='$cname',...,'$path')</p>\n";
}
list($span) = explode(',',$cell['span']); // evtl. overriten later for type template
@ -1742,7 +1749,7 @@ class etemplate extends boetemplate
}
// generate an extra div, if we have an onclick handler and NO children or it's an extension
//echo "<p>$this->name($this->onclick_handler:$this->no_onclick:$this->onclick_proxy): $cell[type]/$cell[name]</p>\n";
if ($this->onclick_handler && !isset($this->widgets_with_children[$cell['type']]))
if ($this->onclick_handler && !isset(self::$widgets_with_children[$cell['type']]))
{
$handler = str_replace('%p',$this->no_onclick ? $this->onclick_proxy : $this->name.':'.$this->version.':'.$path,
$this->onclick_handler);