renamed etemplate to etemplate_old and etemplate_new to etemplate, thought new etemplate is still disabled in etemplate/inc/class.etemplate.inc.php line 38

This commit is contained in:
Ralf Becker 2012-03-27 15:45:31 +00:00
parent 8d08b9ca49
commit 4a08f033e7
18 changed files with 2989 additions and 2959 deletions

View File

@ -27,9 +27,9 @@ class ajax_captcha_widget
private $debug = false;
function ajax_captcha_widget($ui='')
function __construct($ui='')
{
$this->img = new securimage();
switch($ui)
{
@ -62,25 +62,25 @@ class ajax_captcha_widget
//sets main etemplate cell with data created in etemplate.captcha_widget
$cell['type'] = 'template';
$cell['size'] = $cell['name'];
$widget = new etemplate('etemplate.captcha_widget');
$widget = new etemplate_old('etemplate.captcha_widget');
$widget->no_onclick = True;
$cell['obj'] = &$widget;
$refresh_image_wig =& $widget->get_widget_by_name('etemplate/refresh.gif');
$refresh_image_wig['size'] = 'etemplate.captcha_widget.show_image';
$refresh_image_wig['onclick']='
document.getElementById(\'show_image\').src = \''.$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=etemplate.ajax_captcha_widget.show_image&sid=\' + Math.random(); return false;';
$value = array('captcha'=>'','captcha_code'=>'');
//set needed onload for refresh JS
egw_framework::set_onload('document.getElementById(\'show_image\').src = \''.$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=etemplate.ajax_captcha_widget.show_image&sid=\' + Math.random(); return false'
);
// sets audio icon link properties
$audio_image_wig =& $widget->get_widget_by_name('etemplate/audio_icon.gif');
$audio_image_wig['size'] = 'etemplate.ajax_captcha_widget.play_sound';
// sects code text field to be needed
$code_text_wig =& $widget->get_widget_by_name('captcha_code');
//$code_text_wig['name']=$name;
@ -112,7 +112,7 @@ class ajax_captcha_widget
if ($value_in[captcha_code]=='' || !isset($value_in[captcha_code]))
{
$loop=TRUE;
return false;
return false;
}
// sends uder back to form with err msg if wrong code
if ($this->img->getCode() != $value_in[captcha_code])
@ -120,12 +120,12 @@ class ajax_captcha_widget
$tmpl->set_validation_error('captcha',lang(" Your code is incorrect !!!"));
$loop=TRUE;
return false;
return false;
}
}//post process
/**
* Public function to return a new image and set the code in the sessions var from within the class
*
@ -135,19 +135,19 @@ class ajax_captcha_widget
return $this->img->show();
}
/**
* Return new wav file
* @return new wav file
*/
function play_sound() {
header('Content-type: audio/x-wav');
header('Content-Disposition: attachment; name="securimage.wav"');
echo $this->img->getAudibleCode();
}
}//widget
/**
@ -572,8 +572,8 @@ class Securimage {
$this->gd_font_file =EGW_SERVER_ROOT.'/etemplate/templates/default/gdfonts/automatic.gdf';
$this->audio_path=EGW_SERVER_ROOT.'/etemplate/templates/default/audio/';
$this->wordlist_file=EGW_SERVER_ROOT. '/etemplate/templates/default/words/words.txt';
if ( session_id() == '' ) { // no session has been started yet, which is needed for validation
session_start();
}
@ -1015,7 +1015,7 @@ class Securimage {
*/
function generateWAV($letters)
{
$fields = join('/',array( 'H8ChunkID', 'VChunkSize', 'H8Format',
'H8Subchunk1ID', 'VSubchunk1Size',
'vAudioFormat', 'vNumChannels', 'VSampleRate',
@ -1023,9 +1023,9 @@ class Securimage {
$data = '';
$count=0;
foreach($letters as $letter){
//print($count);
//if($count!=4){$count++;continue;}
//if($count!=4){$count++;continue;}
$fname=$this->audio_path . strtolower($letter) . '.wav';
$fp = fopen($fname,'rb');
$header = fread($fp,36);

View File

@ -183,7 +183,7 @@ class ajax_select_widget
$cell['size'] = $cell['name'];
$value = array('value' => $current_value, 'search' => $title);
$widget = new etemplate('etemplate.ajax_select_widget');
$widget = new etemplate_old('etemplate.ajax_select_widget');
$widget->no_onclick = True;
// Link if readonly & link is set
@ -278,7 +278,7 @@ class ajax_select_widget
$value = $results[0][$extension_data['options']['id_field']];
return true;
} elseif ($count > 1) {
etemplate::set_validation_error($name,lang("More than 1 match for '%1'",$value_in['search']));
etemplate_old::set_validation_error($name,lang("More than 1 match for '%1'",$value_in['search']));
$loop = true;
return false;
} else {
@ -299,7 +299,7 @@ class ajax_select_widget
if(!$return) {
$value = $extension_data['old_value'];
etemplate::set_validation_error($name,lang('Required'));
etemplate_old::set_validation_error($name,lang('Required'));
$loop = true;
}

View File

@ -109,7 +109,7 @@ class customfields_widget
* @param etemplate &$tmpl reference to the template we belong too
* @return boolean true if extra label is allowed, false otherwise
*/
function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,etemplate $tmpl)
function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,$tmpl)
{
list($app) = explode('.',$tmpl->name);
@ -215,11 +215,11 @@ class customfields_widget
{
continue; // not for our content type
}
$new_row = null; etemplate::add_child($cell,$new_row);
$new_row = null; boetemplate::add_child($cell,$new_row);
if ($type != 'customfields-list' && $type == 'customfields')
{
$row_class = 'row';
etemplate::add_child($cell,$label =& etemplate::empty_cell('label','',array(
boetemplate::add_child($cell,$label =& boetemplate::empty_cell('label','',array(
'label' => $field['label'],
'no_lang' => substr(lang($field['label']),-1) == '*' ? 2 : 0,
'span' => $field['type'] === 'label' ? '2' : '',
@ -234,7 +234,7 @@ class customfields_widget
case 'checkbox':
if ($value[$this->prefix.$lname]==0) break;
default:
etemplate::add_child($cell,$input =& etemplate::empty_cell('image','info.png',
boetemplate::add_child($cell,$input =& boetemplate::empty_cell('image','info.png',
array('label'=> $field['label'],'width'=>"16px")));
}
}
@ -255,7 +255,7 @@ class customfields_widget
$field['values'][$key] = $val;
}
}
$input =& etemplate::empty_cell('select',$this->prefix.$lname,array(
$input =& boetemplate::empty_cell('select',$this->prefix.$lname,array(
'sel_options' => $field['values'],
'size' => $field['rows'],
'no_lang' => True,
@ -263,10 +263,10 @@ class customfields_widget
if($this->advanced_search)
{
$select =& $input; unset($input);
$input =& etemplate::empty_cell('hbox');
etemplate::add_child($input, $select); unset($select);
$input =& boetemplate::empty_cell('hbox');
boetemplate::add_child($input, $select); unset($select);
/* the following seem to double the select fields in advanced search.
etemplate::add_child($input, etemplate::empty_cell('select',$this->prefix.$lname,array(
boetemplate::add_child($input, boetemplate::empty_cell('select',$this->prefix.$lname,array(
'sel_options' => $field['values'],
'size' => $field['rows'],
'no_lang' => True
@ -296,7 +296,7 @@ class customfields_widget
}
$options = array_merge($options, array_intersect_key($field['values'], array_flip(ajax_select_widget::$known_options)));
$input =& etemplate::empty_cell('ajax_select', $this->prefix.$lname, array(
$input =& boetemplate::empty_cell('ajax_select', $this->prefix.$lname, array(
'readonly' => $readonly,
'no_lang' => True,
'size' => $options
@ -315,26 +315,26 @@ class customfields_widget
if ($readonly)
{
$showthis = $value[$this->prefix.$lname];
$input =& etemplate::empty_cell('hbox');
$input =& boetemplate::empty_cell('hbox');
}
else
{
$input =& etemplate::empty_cell('groupbox');
$input =& boetemplate::empty_cell('groupbox');
}
$m = 0;
foreach ($field['values'] as $key => $val)
{
$radio = etemplate::empty_cell('radio',$this->prefix.$lname);
$radio = boetemplate::empty_cell('radio',$this->prefix.$lname);
$radio['label'] = $val;
$radio['size'] = $key;
if ($showthis == '#a#l#l#' || $showthis == $key) etemplate::add_child($input,$radio);
if ($showthis == '#a#l#l#' || $showthis == $key) boetemplate::add_child($input,$radio);
unset($radio);
}
break;
case 'float':
$known_options = array('min'=>null, 'max'=>null,'size' => $field['len'], 'precision' => null);
$options = array_merge($known_options, $field['values']);
$input =& etemplate::empty_cell($field['type'],$this->prefix.$lname,array(
$input =& boetemplate::empty_cell($field['type'],$this->prefix.$lname,array(
'size' => implode(',',$options)
));
break;
@ -359,7 +359,7 @@ class customfields_widget
if(!$this->advanced_search) $tmparray['readonly']='readonly';
}
}
$input =& etemplate::empty_cell('text',$this->prefix.$lname,$tmparray);
$input =& boetemplate::empty_cell('text',$this->prefix.$lname,$tmparray);
}
else
{//textarea
@ -371,30 +371,30 @@ class customfields_widget
{
if(!$this->advanced_search) $tmparray['readonly']='readonly';
}
$input =& etemplate::empty_cell('textarea',$this->prefix.$lname,$tmparray);
$input =& boetemplate::empty_cell('textarea',$this->prefix.$lname,$tmparray);
}
}
else
{
$input =& etemplate::empty_cell('label',$this->prefix.$lname,array('no_lang' => True));
$input =& boetemplate::empty_cell('label',$this->prefix.$lname,array('no_lang' => True));
}
break;
case 'date':
case 'date-time':
$input =& etemplate::empty_cell($field['type'],$this->prefix.$lname,array(
$input =& boetemplate::empty_cell($field['type'],$this->prefix.$lname,array(
'size' => $field['len'] ? $field['len'] : ($field['type'] == 'date' ? 'Y-m-d' : 'Y-m-d H:i:s'),
));
break;
case 'select-account':
list($opts) = explode('=',$field['values'][0]);
$input =& etemplate::empty_cell('select-account',$this->prefix.$lname,array(
$input =& boetemplate::empty_cell('select-account',$this->prefix.$lname,array(
'size' => ($field['rows']>1?$field['rows']:lang('None')).','.$opts,
));
break;
case 'button': // button(s) to execute javascript (label=onclick) or textinputs (empty label, readonly with neg. length)
// a button does not seem to be helpful in advanced search ???,
if($this->advanced_search) break;
$input =& etemplate::empty_cell('hbox');
$input =& boetemplate::empty_cell('hbox');
foreach($field['values'] as $label => $js)
{
if (!$label) // display an readonly input
@ -404,18 +404,18 @@ class customfields_widget
'readonly' => $field['len'] < 0,
'onchange' => $js,
);
$widget =& etemplate::empty_cell('text',$this->prefix.$lname.$label,$tmparray);
$widget =& boetemplate::empty_cell('text',$this->prefix.$lname.$label,$tmparray);
}
else
{
if ($readonly) continue; // dont display buttons if we're readonly
$widget =& etemplate::empty_cell('buttononly',$this->prefix.$lname.$label,array(
$widget =& boetemplate::empty_cell('buttononly',$this->prefix.$lname.$label,array(
'label' => $label ? $label : lang('Submit'),
'onclick' => $js,
'no_lang' => True
));
}
etemplate::add_child($input,$widget);
boetemplate::add_child($input,$widget);
unset($widget);
}
break;
@ -425,7 +425,7 @@ class customfields_widget
if (empty($shown)) $shown = 28;
if (empty($validation_type)) $validation_type = 1;
$field['len'] = implode(',',array($shown, $max, $validation_type, $default));
$input =& etemplate::empty_cell($field['type'],$this->prefix.$lname,array(
$input =& boetemplate::empty_cell($field['type'],$this->prefix.$lname,array(
'size' => $field['len']
));
break;
@ -435,27 +435,27 @@ class customfields_widget
if (empty($max)) $max =128;
if (empty($shown)) $shown = 28;
$field['len']=implode(',',array( $shown, $max, $validation_type));
$input =& etemplate::empty_cell($field['type'],$this->prefix.$lname,array(
$input =& boetemplate::empty_cell($field['type'],$this->prefix.$lname,array(
'size' => $field['len']
));
break;
case 'htmlarea': // defaults: len: width=100%,mode=simple,tooldbar=false; rows: 5
list($width,$mode,$toolbar) = explode(',',$field['len']);
$input =& etemplate::empty_cell($field['type'],$this->prefix.$lname,array(
$input =& boetemplate::empty_cell($field['type'],$this->prefix.$lname,array(
'size' => $mode.','.(($field['rows'] ? $field['rows'] : 5)*16).'px,'.$width.','.($toolbar=='true'?'true':'false'),
));
break;
// other etemplate types, which are used just as is
case 'checkbox' :
$input =& etemplate::empty_cell($field['type'],$this->prefix.$lname);
$input =& boetemplate::empty_cell($field['type'],$this->prefix.$lname);
break;
case 'link-entry':
default : // link-entry to given app
$input =& etemplate::empty_cell('link-entry',$this->prefix.$lname,array(
$input =& boetemplate::empty_cell('link-entry',$this->prefix.$lname,array(
'size' => $field['type'] == 'link-entry' ? '' : $field['type'],
));
// register post-processing of link widget to get eg. needed/required validation
etemplate::$request->set_to_process(etemplate::form_name($form_name,$this->prefix.$lname), 'ext-link');
etemplate_old::$request->set_to_process(etemplate_old::form_name($form_name,$this->prefix.$lname), 'ext-link');
}
$cell['data'][0]['c'.$n++] = $row_class.',top';
@ -478,7 +478,7 @@ class customfields_widget
$value = $value[$this->prefix.$lname];
return true;
}
etemplate::add_child($cell,$input);
boetemplate::add_child($cell,$input);
unset($input);
}
unset($label);

View File

@ -239,11 +239,11 @@ class date_widget
}
if ($cell['needed'])
{
etemplate::$request->set_to_process($name,'ext-'.$type,array(
etemplate_old::$request->set_to_process($name,'ext-'.$type,array(
'needed' => $cell['needed'],
));
}
$tpl = new etemplate;
$tpl = new etemplate_old;
$tpl->init('*** generated fields for date','','',0,'',0,0); // make an empty template
// keep the editor away from the generated tmpls
$tpl->no_onclick = true;
@ -427,7 +427,7 @@ class date_widget
'value' => $value,
'unit' => $unit,
);
$tpl = new etemplate;
$tpl = new etemplate_old;
$tpl->init('*** generated fields for duration','','',0,'',0,0); // make an empty template
// keep the editor away from the generated tmpls
$tpl->no_onclick = true;
@ -491,7 +491,7 @@ class date_widget
'i' => 60,
's' => 1,
);
$cell = etemplate::empty_cell('label','',array('label'=>$cell['label']));
$cell = boetemplate_old::empty_cell('label','',array('label'=>$cell['label']));
if ((string)$value['Y'] !== '')
{
@ -555,7 +555,7 @@ class date_widget
}
elseif (!preg_match('/^-?[0-9]*[,.]?[0-9]*'.($extension_data['percent_allowed'] ? '%?' : '').'$/',$value_in))
{
etemplate::set_validation_error($name,lang("'%1' is not a valid floatingpoint number !!!",$value_in));
etemplate_old::set_validation_error($name,lang("'%1' is not a valid floatingpoint number !!!",$value_in));
return false;
}
else
@ -629,7 +629,7 @@ class date_widget
// checking the date is a correct one
if (!checkdate($value['m'],$value['d'],$value['Y']))
{
etemplate::set_validation_error($name,lang("'%1' is not a valid date !!!",
etemplate_old::set_validation_error($name,lang("'%1' is not a valid date !!!",
common::dateformatorder($value['Y'],$value['m'],$value['d'],true)));
}
$data_format = $extension_data['data_format'];

View File

@ -238,7 +238,7 @@ class db_tools
{
echo 'editor.edit: content ='; _debug_array($content);
}
$tpl = new etemplate('etemplate.db-tools.edit');
$tpl = new etemplate_old('etemplate.db-tools.edit');
$tpl->exec('etemplate.db_tools.edit',$content,$sel_options,$no_button,
array('posted_table' => $this->table,'posted_app' => $this->app,'changes' => $this->changes));
}
@ -330,7 +330,7 @@ class db_tools
$new_version[$minor] = sprintf('%03d',1+$new_version[$minor]);
$content['new_version'] = implode('.',$new_version);
$tmpl = new etemplate('etemplate.db-tools.ask_save');
$tmpl = new etemplate_old('etemplate.db-tools.ask_save');
if (!file_exists(EGW_SERVER_ROOT."/$posted_app/setup/tables_current.inc.php"))
{

View File

@ -11,6 +11,13 @@
* @version $Id$
*/
// to be able to run with new etemplate enabled or not
require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate.inc.php';
if (!class_exists('etemplate_old'))
{
class etemplate_old extends etemplate {}
}
/**
* template editor of the eTemplate package
*/
@ -106,7 +113,7 @@ class editor
function __construct()
{
$this->etemplate = new etemplate();
$this->etemplate = new etemplate_old();
$this->extensions = $GLOBALS['egw']->session->appsession('extensions','etemplate');
}
@ -276,7 +283,7 @@ class editor
{
$content[$row] = $param;
}
$list_result = new etemplate('etemplate.editor.list_result');
$list_result = new etemplate_old('etemplate.editor.list_result');
$GLOBALS['egw_info']['flags']['app_header'] = lang('Editable Templates - Search');
$list_result->exec('etemplate.editor.list_result',$content,'','',array(
'result' => $result,
@ -326,7 +333,7 @@ class editor
{
if ($_GET['name'])
{
foreach(etemplate::$db_key_cols as $var)
foreach(boetemplate::$db_key_cols as $var)
{
$content[$var] = $_GET[$var];
}
@ -445,7 +452,7 @@ class editor
$additional = array();
if ($app == 'etemplate')
{
$additional = etemplate::$types + $this->extensions + $this->aligns + $this->valigns +
$additional = boetemplate::$types + $this->extensions + $this->aligns + $this->valigns +
$this->edit_menu + $this->box_menu + $this->row_menu + $this->column_menu + $this->onclick_types + $this->onchange_types;
}
else // try to call the writeLangFile function of the app's ui-layer
@ -480,7 +487,7 @@ class editor
'xml' => $xml ? '<pre>'.html::htmlspecialchars($xml)."</pre>\n" : '',
);
$editor = new etemplate('etemplate.editor.new');
$editor = new etemplate_old('etemplate.editor.new');
if (isset($content['values']) && !isset($content['vals']))
{
$r = 1;
@ -554,12 +561,12 @@ class editor
{
//echo "<p>editor::change_widget_type($widget[type]=$old[type])</p>\n";
$old_type = $old['type'];
$old_had_children = isset(etemplate::$widgets_with_children[$old_type]);
$old_had_children = isset(boetemplate::$widgets_with_children[$old_type]);
if (!isset(etemplate::$widgets_with_children[$widget['type']]) ||
if (!isset(boetemplate::$widgets_with_children[$widget['type']]) ||
($old_type == 'grid') == ($widget['type'] == 'grid'))
{
if (etemplate::$widgets_with_children[$widget['type']] == 'box') // box
if (boetemplate::$widgets_with_children[$widget['type']] == 'box') // box
{
if ((int) $widget['size'] < 1) // min. 1 child
{
@ -569,13 +576,13 @@ class editor
// 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 : etemplate::empty_cell();
if (!is_array($widget[$n])) $widget[$n] = $n == 1 ? $old : boetemplate::empty_cell();
}
unset($widget['onclick']); // not valid for a box
}
return; // no change necessary, eg. between different box-types
}
switch (etemplate::$widgets_with_children[$widget['type']])
switch (boetemplate::$widgets_with_children[$widget['type']])
{
case 'grid':
$widget['data'] = array(array());
@ -587,15 +594,15 @@ class editor
for ($n = 1; is_array($old[$n]) && $n <= $num; ++$n)
{
$new_line = null;
if ($old_type != 'hbox') etemplate::add_child($widget,$new_line);
etemplate::add_child($widget,$old[$n]);
if ($old_type != 'hbox') boetemplate::add_child($widget,$new_line);
boetemplate::add_child($widget,$old[$n]);
unset($widget[$n]);
}
$widget['size'] = '';
}
else // 1 row with 1 column/child
{
etemplate::add_child($widget,$cell=etemplate::empty_cell());
boetemplate::add_child($widget,$cell=boetemplate::empty_cell());
}
break;
@ -617,8 +624,8 @@ class editor
$row =& $old['data'][1];
for ($n = 0; $n < $old['cols']; ++$n)
{
$cell =& $row[etemplate::num2chrs($n)];
etemplate::add_child($widget,$cell);
$cell =& $row[boetemplate::num2chrs($n)];
boetemplate::add_child($widget,$cell);
list($span) = (int)explode(',',$cell['span']);
if ($span == 'all') break;
while ($span-- > 1) ++$n;
@ -628,13 +635,13 @@ class editor
{
for ($n = 1; $n <= $old['rows']; ++$n)
{
etemplate::add_child($widget,$old['data'][$n][etemplate::num2chrs(0)]);
boetemplate::add_child($widget,$old['data'][$n][boetemplate::num2chrs(0)]);
}
}
}
if (!$widget['size']) // minimum one child
{
etemplate::add_child($widget,etemplate::empty_cell());
boetemplate::add_child($widget,boetemplate::empty_cell());
}
break;
}
@ -678,11 +685,11 @@ class editor
{
list(,$r,$c) = $matches;
// find the column-number (base 0) for $c (A, B, C, ...)
for($col = 0; etemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
for($col = 0; boetemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
if ($col > 0) $left = $parent_path.'/'.$r.etemplate::num2chrs($col-1);
if ($col > 0) $left = $parent_path.'/'.$r.boetemplate::num2chrs($col-1);
if ($col < $parent['cols']-1) $right = $parent_path.'/'.$r.etemplate::num2chrs($col+1);
if ($col < $parent['cols']-1) $right = $parent_path.'/'.$r.boetemplate::num2chrs($col+1);
if ($r > 1) $up = $parent_path.'/'.($r-1).$c;
@ -704,7 +711,7 @@ class editor
{
$in = $parent_path.'/'.$child_id.'/1A';
}
elseif (isset(etemplate::$widgets_with_children[$widget['type']]) && $widget['type'] != 'template')
elseif (isset(boetemplate::$widgets_with_children[$widget['type']]) && $widget['type'] != 'template')
{
if ($widget['type']) // box
{
@ -769,7 +776,7 @@ class editor
list($num,$options) = explode(',',$parent['size'],2);
if ($num <= 1) // cant delete last child --> only empty it
{
$parent[$num=1] = etemplate::empty_cell();
$parent[$num=1] = boetemplate::empty_cell();
}
else
{
@ -785,7 +792,7 @@ class editor
{
if (count($this->etemplate->children) <= 1) // cant delete last child
{
$this->etemplate->children[0] = etemplate::empty_cell();
$this->etemplate->children[0] = boetemplate::empty_cell();
}
else
{
@ -797,7 +804,7 @@ class editor
}
else
{
$content['cell'] = etemplate::empty_cell();
$content['cell'] = boetemplate::empty_cell();
return lang('cant delete a single widget from a grid !!!');
}
break;
@ -835,7 +842,7 @@ class editor
{
$parent[1+$i] = $parent[$i];
}
$parent[$n] = $content['cell'] = etemplate::empty_cell();
$parent[$n] = $content['cell'] = boetemplate::empty_cell();
$child_id = $n;
if ($parent['type']) $parent['size'] = (1+$num) . ($options ? ','.$options : '');
break;
@ -931,8 +938,8 @@ class editor
}
for($i = 0; $i < $cols; ++$i)
{
echo (1+$r).":$i=".etemplate::num2chrs($i)."=empty_cell()<br>\n";
$data[1+$r][etemplate::num2chrs($i)] = etemplate::empty_cell();
echo (1+$r).":$i=".boetemplate::num2chrs($i)."=empty_cell()<br>\n";
$data[1+$r][boetemplate::num2chrs($i)] = boetemplate::empty_cell();
}
$opts['c'.(1+$r)] = $opts['h'.(1+$r)] = '';
++$rows;
@ -962,7 +969,7 @@ class editor
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; etemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
for($col = 0; boetemplate::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";
@ -972,9 +979,9 @@ class editor
if ($col >= $cols-1)
{
if ($col != $cols-1) return lang('no column to swap with !!!');
$c = etemplate::num2chrs(--$col); // in last column swap with the one before
$c = boetemplate::num2chrs(--$col); // in last column swap with the one before
}
$c_next = etemplate::num2chrs(1+$col);
$c_next = boetemplate::num2chrs(1+$col);
for($row = 1; $row <= $rows; ++$row)
{
$this->swap($data[$row][$c],$data[$row][$c_next]);
@ -992,15 +999,15 @@ class editor
{
for ($i = $cols; $i > $col; --$i)
{
$data[$row][etemplate::num2chrs($i)] = $data[$row][etemplate::num2chrs($i-1)];
$data[$row][boetemplate::num2chrs($i)] = $data[$row][boetemplate::num2chrs($i-1)];
}
$data[$row][etemplate::num2chrs($col)] = etemplate::empty_cell();
$data[$row][boetemplate::num2chrs($col)] = boetemplate::empty_cell();
}
for ($i = $cols; $i > $col; --$i)
{
$opts[etemplate::num2chrs($i)] = $opts[etemplate::num2chrs($i-1)];
$opts[boetemplate::num2chrs($i)] = $opts[boetemplate::num2chrs($i-1)];
}
unset($opts[etemplate::num2chrs($col)]);
unset($opts[boetemplate::num2chrs($col)]);
++$cols;
//_debug_array($grid); return '';
break;
@ -1015,15 +1022,15 @@ class editor
{
for ($i = $col; $i < $cols-1; ++$i)
{
$data[$row][etemplate::num2chrs($i)] = $data[$row][etemplate::num2chrs($i+1)];
$data[$row][boetemplate::num2chrs($i)] = $data[$row][boetemplate::num2chrs($i+1)];
}
unset($data[$row][etemplate::num2chrs($cols-1)]);
unset($data[$row][boetemplate::num2chrs($cols-1)]);
}
for ($i = $col; $i < $cols-1; ++$i)
{
$opts[etemplate::num2chrs($i)] = $opts[etemplate::num2chrs($i+1)];
$opts[boetemplate::num2chrs($i)] = $opts[boetemplate::num2chrs($i+1)];
}
unset($opts[etemplate::num2chrs(--$cols)]);
unset($opts[boetemplate::num2chrs(--$cols)]);
break;
}
$action = 'save-no-merge';
@ -1251,7 +1258,7 @@ class editor
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(etemplate::$widgets_with_children[$content['cell']['type']]))
if (isset(boetemplate::$widgets_with_children[$content['cell']['type']]))
{
$this->change_widget_type($content['cell'],$widget);
}
@ -1357,8 +1364,8 @@ class editor
$content['cell']['options'] = explode(',',$content['cell']['size']);
$editor = new etemplate('etemplate.editor.widget');
$type_tmpl = new etemplate;
$editor = new etemplate_old('etemplate.editor.widget');
$type_tmpl = new etemplate_old;
list($ext_type) = explode('-',$widget['type']);
// allow to read template of app-specific widgets from their app: eg. "infolog-value" --> "infolog.widget.infolog-value"
@ -1389,7 +1396,7 @@ class editor
$GLOBALS['egw_info']['flags']['java_script'] = "<script>window.focus();</script>\n";
$GLOBALS['egw_info']['flags']['app_header'] = lang('Editable Templates - Editor');
$editor->exec('etemplate.editor.widget',$content,array(
'type' => array_merge(etemplate::$types,$this->extensions),
'type' => array_merge(boetemplate::$types,$this->extensions),
'align' => &$this->aligns,
'valign' => &$this->valigns,
'part' => $allowed_parts,
@ -1445,7 +1452,7 @@ class editor
{
if (!is_array($content))
{
foreach(etemplate::$db_key_cols as $var)
foreach(boetemplate::$db_key_cols as $var)
{
if (isset($_GET[$var])) $content[$var] = $_GET[$var];
}
@ -1508,7 +1515,7 @@ class editor
'java_script' => $js ? '<script>'.$js.'</script>' : '',
'msg' => $msg
);
$tmpl = new etemplate('etemplate.editor.styles');
$tmpl = new etemplate_old('etemplate.editor.styles');
if ($content['from'])
{

File diff suppressed because it is too large Load Diff

View File

@ -1,436 +0,0 @@
<?php
/**
* EGroupware - eTemplate serverside
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-11 by RalfBecker@outdoor-training.de
* @version $Id$
*/
// allow to call direct for tests (see end of class)
if (!isset($GLOBALS['egw_info']))
{
$GLOBALS['egw_info'] = array(
'flags' => array(
'currentapp' => $_REQUEST['sessionid'] ? 'etemplate' : 'login',
'nonavbar' => true,
'debug' => 'etemplate_new',
)
);
include_once '../../header.inc.php';
}
/**
* New eTemplate serverside contains:
* - main server methods like read, exec
* -
*
* Not longer available methods:
* - set_(row|column)_attributes modifies template on run-time, was only used internally by etemplate itself
* - disable_(row|column) dto.
*
* @ToDo supported customized templates stored in DB, currently we only support xet files stored in filesystem
*/
class etemplate_new extends etemplate_widget_template
{
/**
* Are we running as sitemgr module or not
*
* @public boolean
*/
public $sitemgr=false;
/**
* constructor of etemplate class, reads an eTemplate if $name is given
*
* @param string $name of etemplate or array with name and other keys
* @param string|array $load_via with keys of other etemplate to load in order to get $name
*/
function __construct($name='',$load_via='')
{
$this->sitemgr = isset($GLOBALS['Common_BO']) && is_object($GLOBALS['Common_BO']);
if ($name) $this->read($name,$template='default',$lang='default',$group=0,$version='',$load_via);
}
/**
* Abstracts a html-location-header call
*
* In other UI's than html this needs to call the methode, defined by menuaction or
* open a browser-window for any other links.
*
* @param string|array $params url or array with get-params incl. menuaction
*/
static function location($params='')
{
egw::redirect_link(is_array($params) ? '/index.php' : $params,
is_array($params) ? $params : '');
}
/**
* Generates a Dialog from an eTemplate - abstract the UI-layer
*
* This is the only function an application should use, all other are INTERNAL and
* do NOT abstract the UI-layer, because they return HTML.
* Generates a webpage with a form from the template and puts process_exec in the
* form as submit-url to call process_show for the template before it
* ExecuteMethod's the given $method of the caller.
*
* @param string $method Methode (e.g. 'etemplate.editor.edit') to be called if form is submitted
* @param array $content with content to fill the input-fields of template, eg. the text-field
* 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
* field-names, eg. array('name' => array(1 => 'one',2 => 'two')) set the
* options for field 'name'. ($content['options-name'] is possible too !!!)
* @param array $readonlys with field-names as keys for fields with should be readonly
* (eg. to implement ACL grants on field-level or to remove buttons not applicable)
* @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 int $output_mode
* 0 = echo incl. navbar
* 1 = return html
* -1 = first time return html, after use 0 (echo html incl. navbar), eg. for home
* 2 = echo without navbar (eg. for popups)
* 3 = return eGW independent html site
* @param string $ignore_validation if not empty regular expression for validation-errors to ignore
* @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
*/
function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$output_mode=0,$ignore_validation='',$changes='')
{
// Include the etemplate2 javascript code
egw_framework::validate_file('.', 'etemplate2', 'etemplate');
if (!$this->rel_path) throw new egw_exception_assertion_failed('No (valid) template read!');
// generate new etemplate request object
self::$request = etemplate_request::read();
self::$request->output_mode = $output_mode; // let extensions "know" they are run eg. in a popup
self::$request->readonlys = $readonlys;
self::$request->content = $content;
self::$request->changes = $changes;
self::$request->sel_options = $sel_options;
self::$request->preserv = $preserv;
self::$request->method = $method;
self::$request->ignore_validation = $ignore_validation;
self::$request->app_header = $GLOBALS['egw_info']['flags']['app_header'];
if (self::$request->output_mode == -1) self::$request->output_mode = 0;
self::$request->template = $this->as_array();
// instanciate template to fill self::$request->sel_options for select-* widgets
// not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes
$template = etemplate_widget_template::instance($this->name, $this->template_set, $this->version, $this->laod_via);
$template->run('beforeSendToClient');
$data = array(
'etemplate_exec_id' => self::$request->id(),
'app_header' => self::$request->app_header,
'content' => self::$request->content,
'sel_options' => self::$request->sel_options,
'readonlys' => self::$request->readonlys,
'modifications' => self::$request->modifications,
'validation_errors' => self::$validation_errors,
);
if (self::$response) // call is within an ajax event / form submit
{
self::$response->generic('et2_load', array(
'name' => $this->name,
'url' => $GLOBALS['egw_info']['server']['webserver_url'].$this->rel_path,
'data' => $data,
));
}
else // first call
{
// missing dependency, thought egw:uses jquery.jquery.tools does NOT work, maybe we should rename it to jquery-tools
// egw_framework::validate_file('jquery','jquery.tools.min');
egw_framework::includeCSS('/etemplate/templates/default/etemplate2.css');
// Include the jQuery-UI CSS - many more complex widgets use it
$theme = 'smoothness';
egw_framework::includeCSS("/phpgwapi/js/jquery/jquery-ui/$theme/jquery-ui-1.8.16.custom.css");
common::egw_header();
if ($output_mode != 2)
{
parse_navbar();
}
// load translations
translation::add_app('etemplate');
$langRequire = array();
foreach(translation::$loaded_apps as $app => $lang)
{
$langRequire[] = array('app' => $app, 'lang' => $lang);
}
echo '
<div id="container"></div>
<script>
egw.langRequire(window, '.json_encode($langRequire).');
egw(window).ready(function() {
var et2 = new etemplate2(document.getElementById("container"), "etemplate_new::ajax_process_content");
et2.load("'.$this->name.'","'.$GLOBALS['egw_info']['server']['webserver_url'].$this->rel_path.'",'.json_encode($data).');
}, null, true);
</script>
';
common::egw_footer();
}
}
/**
* Process via Ajax submitted content
*/
static public function ajax_process_content($etemplate_exec_id, array $content)
{
error_log(__METHOD__."(".array2string($etemplate_exec_id).', '.array2string($content).")");
self::$request = etemplate_request::read($etemplate_exec_id);
error_log('request='.array2string(self::$request));
self::$response = egw_json_response::get();
if (!($template = self::instance(self::$request->template['name'], self::$request->template['template_set'],
self::$request->template['version'], self::$request->template['load_via'])))
{
throw new egw_exception_wrong_parameter('Can NOT read template '.array2string(self::$request->template));
}
$validated = array();
$template->run('validate', array('', $content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children
if (self::validation_errors(self::$request->ignore_validation))
{
error_log(__METHOD__."(,".array2string($content).') validation_errors='.array2string(self::$validation_errors));
self::$response->generic('et2_validation_error', self::$validation_errors);
exit;
}
error_log(__METHOD__."(,".array2string($content).') validated='.array2string($validated));
return ExecMethod(self::$request->method, self::complete_array_merge(self::$request->preserv, $validated));
}
/**
* Path of template relative to EGW_SERVER_ROOT
*
* @var string
*/
public $rel_path;
public $name;
public $template_set;
public $version;
public $laod_via;
/**
* Reads an eTemplate from filesystem or DB (not yet supported)
*
* @param string $name name of the eTemplate or array with the values for all keys
* @param string $template_set template-set, '' loads the prefered template of the user, 'default' loads the default one '' in the db
* @param string $lang language, '' loads the pref. lang of the user, 'default' loads the default one '' in the db
* @param int $group id of the (primary) group of the user or 0 for none, not used at the moment !!!
* @param string $version version of the eTemplate
* @param mixed $load_via name/array of keys of etemplate to load in order to get $name (only as second try!)
* @return boolean True if a fitting template is found, else False
*
* @ToDo supported customized templates stored in DB
*/
public function read($name,$template_set='default',$lang='default',$group=0,$version='',$load_via='')
{
$this->rel_path = self::relPath($this->name=$name, $this->template_set=$template_set,
$this->version=$version, $this->laod_via = $load_via);
//error_log(__METHOD__."('$name', '$template_set', '$lang', $group, '$version', '$load_via') rel_path=".array2string($this->rel_path));
return (boolean)$this->rel_path;
}
/**
* Get template data as array
*
* @return array
*/
public function as_array()
{
return array(
'name' => $this->name,
'template_set' => $this->template_set,
'version' => $this->version,
'load_via' => $this->load_via,
);
}
/**
* Returns reference to an attribute in a named cell
*
* Currently we always return a reference to an not set value, unless it was set before.
* We do not return a reference to the actual cell, as it get's contructed on client-side!
*
* @param string $name cell-name
* @param string $attr attribute-name
* @return mixed reference to attribute, usually NULL
* @deprecated use getElementAttribute($name, $attr)
*/
public function &get_cell_attribute($name,$attr)
{
return self::getElementAttribute($name, $attr);
}
/**
* set an attribute in a named cell if val is not NULL else return the attribute
*
* @param string $name cell-name
* @param string $attr attribute-name
* @param mixed $val if not NULL sets attribute else returns it
* @return reference to attribute
* @deprecated use setElementAttribute($name, $attr, $val)
*/
public function &set_cell_attribute($name,$attr,$val)
{
return self::setElementAttribute($name, $attr, $val);
}
/**
* disables all cells with name == $name
*
* @param sting $name cell-name
* @param boolean $disabled=true disable or enable a cell, default true=disable
* @return reference to attribute
* @deprecated use disableElement($name, $disabled=true)
*/
public function disable_cells($name,$disabled=True)
{
return self::disableElement($name, $disabled);
}
/**
* merges $old and $new, content of $new has precedence over $old
*
* THIS IS NOT THE SAME AS PHP's functions:
* - array_merge, as it calls itself recursive for values which are arrays.
* - array_merge_recursive accumulates values with the same index and $new does NOT overwrite $old
*
* @param array $old
* @param array $new
* @return array the merged array
*/
public static function complete_array_merge($old,$new)
{
if (is_array($new))
{
if (!is_array($old)) $old = (array) $old;
foreach($new as $k => $v)
{
if (!is_array($v) || !isset($old[$k]) || // no array or a new array
isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1])) // or no associative array, eg. selecting multiple accounts
{
$old[$k] = $v;
}
else
{
$old[$k] = self::complete_array_merge($old[$k],$v);
}
}
}
return $old;
}
/**
* Debug callback just outputting content
*
* @param array $content=null
*/
public function debug(array $content=null)
{
common::egw_header();
_debug_array($content);
common::egw_footer();
}
/**
* Message containing the max Upload size from the current php.ini settings
*
* We have to take the smaler one of upload_max_filesize AND post_max_size-2800 into account.
* memory_limit does NOT matter any more, because of the stream-interface of the vfs.
*
* @param int &$max_upload=null on return max. upload size in byte
* @return string
*/
static function max_upload_size_message(&$max_upload=null)
{
$upload_max_filesize = ini_get('upload_max_filesize');
$post_max_size = ini_get('post_max_size');
$max_upload = min(self::km2int($upload_max_filesize),self::km2int($post_max_size)-2800);
return lang('Maximum size for uploads').': '.egw_vfs::hsize($max_upload).
" (php.ini: upload_max_filesize=$upload_max_filesize, post_max_size=$post_max_size)";
}
/**
* Convert numbers like '32M' or '512k' to integers
*
* @param string $size
* @return int
*/
private static function km2int($size)
{
if (!is_numeric($size))
{
switch(strtolower(substr($size,-1)))
{
case 'm':
$size = 1024*1024*(int)$size;
break;
case 'k':
$size = 1024*(int)$size;
break;
}
}
return (int)$size;
}
/**
* creates HTML from an eTemplate
*
* Compatibility function for calendar, which uses etemplate::show to generate html --> use etemplate_old class
* @todo Once etemplate_new is renamed to etemplate and we have an explicit etemplate_old class, change it at caller (egw. calendar)
*
* This is done by calling show_cell for each cell in the form. show_cell itself
* calls show recursivly for each included eTemplate.
* You could use it in the UI-layer of an app, just make shure to call process_show !!!
* This is intended as internal function and should NOT be called by new app's direct,
* as it deals with HTML and is so UI-dependent, use exec instead.
*
* @param array $content with content for the cells, keys are the names given in the cells/form elements
* @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
* @return string the generated HTML
*/
function show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0)
{
$etemplate_old = new etemplate_old($this->name, $this->laod_via);
return $etemplate_old->show($content,$sel_options,$readonlys,$cname,$show_c,$show_row);
}
}
if ($GLOBALS['egw_info']['flags']['debug'] == 'etemplate_new')
{
$name = isset($_GET['name']) ? $_GET['name'] : 'timesheet.edit';
$template = new etemplate_new();
if (!$template->read($name))
{
header('HTTP-Status: 404 Not Found');
echo "<html><head><title>Not Found</title><body><h1>Not Found</h1><p>The requested eTemplate '$name' was not found!</p></body></html>\n";
exit;
}
$GLOBALS['egw_info']['flags']['app_header'] = $name;
$template->exec('etemplate.etemplate.debug', array(), array(), array(), array(), 2);
}

File diff suppressed because it is too large Load Diff

View File

@ -55,11 +55,11 @@ class historylog_widget
* @param array &$cell array with the widget, can be modified for ui-independent widgets
* @return boolean true if extra label is allowed, false otherwise
*/
private function pre_process_helper(&$value, &$cell, etemplate $tmpl)
private function pre_process_helper(&$value, &$cell, $tmpl)
{
if (empty($value) && (string)$value !== '0')
{
$cell = etemplate::empty_cell();
$cell = boetemplate::empty_cell();
return true;
}
//echo $value.'/'.$cell['size']; _debug_array(self::$status_widgets);
@ -76,7 +76,7 @@ class historylog_widget
$type6 = 2;
$options = implode(',',array($rows,$type1,$type2,$type3,$type4,$type5,$type6));
}
$cell = etemplate::empty_cell($type,$cell['name'],array('readonly' => true,'size' => $options));
$cell = boetemplate::empty_cell($type,$cell['name'],array('readonly' => true,'size' => $options));
// display unsupported iCal properties, which have multiple values or attributes, or multiple components
if ($type === 'label' && $value[1] === ':' && ($values = unserialize($value)))
{
@ -111,9 +111,9 @@ class historylog_widget
{
list($t,$opt) = explode(':',$t);
}
$child = etemplate::empty_cell($t,$cell['name']."[$n]",array('readonly' => true,'no_lang' => true,'size' => $opt));
$child = boetemplate::empty_cell($t,$cell['name']."[$n]",array('readonly' => true,'no_lang' => true,'size' => $opt));
$child['sel_options'] = $sel_options;
etemplate::add_child($cell,$child);
boetemplate::add_child($cell,$child);
unset($sel_options);
unset($child);
}
@ -145,7 +145,7 @@ class historylog_widget
* @param etemplate $tmpl reference to the template we belong too
* @return boolean true if extra label is allowed, false otherwise
*/
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,etemplate $tmpl)
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,$tmpl)
{
switch ($cell['type'])
{
@ -165,7 +165,7 @@ class historylog_widget
}
unset($historylog);
$tpl = new etemplate;
$tpl = new etemplate_old;
$tpl->init('*** generated fields for historylog','','',0,'',0,0); // make an empty template
// keep the editor away from the generated tmpls
$tpl->no_onclick = true;

View File

@ -171,7 +171,7 @@ class link_widget
}
}
if (!($popup = egw_link::is_popup($value['app'],'view')) &&
etemplate::$request->output_mode == 2) // we are in a popup
etemplate_old::$request->output_mode == 2) // we are in a popup
{
$target = '_blank';
}
@ -257,14 +257,14 @@ class link_widget
// modify add_app default to the action used as value
if (isset($value['add_app']) && $app == $value['add_app']) $value['add_app'] = $action;
}
$tpl = new etemplate('etemplate.link_widget.add');
$tpl = new etemplate_old('etemplate.link_widget.add');
break;
case 'link-to':
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
if ($value['search_label'] && $extension_data['search_label'] != $value['search_label']) $value['search_label'] = lang($value['search_label']);
$extension_data = $value;
$tpl = new etemplate('etemplate.link_widget.to');
$tpl = new etemplate_old('etemplate.link_widget.to');
if ($value['link_label']) $tpl->set_cell_attribute('create','label',$value['link_label']);
if ($value['search_label']) $tpl->set_cell_attribute('search','label',$value['search_label']);
@ -294,7 +294,7 @@ class link_widget
return True;
}
$value['link_list_format'] = $GLOBALS['egw_info']['user']['preferences']['common']['link_list_format'];
$tpl = new etemplate('etemplate.link_widget.list');
$tpl = new etemplate_old('etemplate.link_widget.list');
for($row=$tpl->rows-1; list(,$link) = each($links); ++$row)
{
$value[$row] = $link;
@ -303,7 +303,7 @@ class link_widget
{
$value[$row]['view'] = egw_link::view($link['app'],$link['id'],$link);
if (!($value[$row]['popup'] = egw_link::is_popup($link['app'],'view',$link)) &&
etemplate::$request->output_mode == 2) // we are in a popup
etemplate_old::$request->output_mode == 2) // we are in a popup
{
$value[$row]['target'] = '_blank'; // we create a new window as the linked page is no popup
}
@ -324,7 +324,7 @@ class link_widget
$value[$row]['icon'] = egw_link::get_registry($value[$row]['app'], 'icon');
$value[$row]['label'] = 'Unlink';
$value[$row]['help'] = lang('Remove this link (not the entry itself)');
if(!egw_link::is_popup($link['app'],'view') && etemplate::$request->output_mode == 2)
if(!egw_link::is_popup($link['app'],'view') && etemplate_old::$request->output_mode == 2)
{
// If link doesn't want a popup, make sure to open it in appropriate tab of main window
$value[$row]['view'] = "javascript:if(typeof opener.top.framework != 'undefined') {
@ -352,7 +352,7 @@ class link_widget
return true;
}
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
$tpl = new etemplate('etemplate.link_widget.entry');
$tpl = new etemplate_old('etemplate.link_widget.entry');
$options = $cell['size'] ? explode(',',$cell['size']) : array();
$app = $extension_data['app'] = $options[0];
$link_type = $extension_data['link_type'];
@ -495,7 +495,7 @@ class link_widget
list($w,$h) = explode('x',$popup);
$options = ' onclick="window.open(this,this.target,\'width='.(int)$w.',height='.(int)$h.',location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;"';
}
elseif (etemplate::$request->output_mode == 2 || // we are in a popup
elseif (etemplate_old::$request->output_mode == 2 || // we are in a popup
$link['app'] == egw_link::VFS_APPNAME || // or it's a link to an attachment
($target = egw_link::get_registry($link['app'],'view_target'))) // or explicit target set
{
@ -653,7 +653,7 @@ class link_widget
if (!($link_id = egw_link::link($value['to_app'],$value['to_id'],
egw_link::VFS_APPNAME,$value['file'],$value['remark'])))
{
etemplate::set_validation_error($name.'[file]',lang('Error copying uploaded file to vfs!'));
etemplate_old::set_validation_error($name.'[file]',lang('Error copying uploaded file to vfs!'));
}
else
{
@ -669,7 +669,7 @@ class link_widget
}
else
{
etemplate::set_validation_error($name.'[file]',lang('You need to select a file first!'));
etemplate_old::set_validation_error($name.'[file]',lang('You need to select a file first!'));
}
$extension_data = $value;
$loop = True;

View File

@ -181,7 +181,7 @@ class nextmatch_widget
* @param etemplate &$tmpl reference to the template we belong too
* @return boolean true if extra label is allowed, false otherwise
*/
public function pre_process($name,&$value,array &$cell,&$readonlys,&$extension_data,etemplate &$tmpl)
public function pre_process($name,&$value,array &$cell,&$readonlys,&$extension_data,$tmpl)
{
$nm_global =& self::get_nm_global($name,$cell['type']);
//echo "<p>nextmatch_widget.pre_process(name='$name',type='$cell[type]'): value = "; _debug_array($value);
@ -209,11 +209,11 @@ class nextmatch_widget
$sorting = $cell;
unset($sorting['align']);
unset($sorting['span']);
$cell = etemplate::empty_cell('hbox','',array(
$cell = boetemplate::empty_cell('hbox','',array(
'span' => $cell['span'],
'size' => '2,,0,0',
1 => $sorting,
2 => etemplate::empty_cell('image',$nm_global['sort'] != 'DESC' ? 'down' : 'up'),
2 => boetemplate::empty_cell('image',$nm_global['sort'] != 'DESC' ? 'down' : 'up'),
));
$class = 'activ_sortcolumn';
}
@ -314,8 +314,8 @@ class nextmatch_widget
if (!is_array($readonlys)) $readonlys = array();
if (($total = $extension_data['total'] = $value['total'] = self::call_get_rows($value,$rows,$readonlys['rows'])) === false)
{
//error_log(__METHOD__."() etemplate::set_validation_error('$name') '$value[get_rows]' is no valid method!!!");
etemplate::set_validation_error($name,__METHOD__."($cell[name]): '$value[get_rows]' is no valid method !!!");
//error_log(__METHOD__."() etemplate_old::set_validation_error('$name') '$value[get_rows]' is no valid method!!!");
etemplate_old::set_validation_error($name,__METHOD__."($cell[name]): '$value[get_rows]' is no valid method !!!");
}
// allow the get_rows function to override / set sel_options
if (isset($rows['sel_options']) && is_array($rows['sel_options']))
@ -333,7 +333,7 @@ class nextmatch_widget
}
if (!is_object($value['template']))
{
$value['template'] = new etemplate($value['template'],$tmpl->as_array());
$value['template'] = new etemplate_old($value['template'],$tmpl->as_array());
}
if (is_array($value['rows'][0])) // pad 0 based arrays with rows-1 false values
{
@ -356,7 +356,7 @@ class nextmatch_widget
{ // disable whole nextmatch line if no scrolling necessary
if ($value['header_left'] || $value['header_right'])
{
$nextmatch = new etemplate('etemplate.nextmatch_widget.header_only');
$nextmatch = new etemplate_old('etemplate.nextmatch_widget.header_only');
$cell['size'] = $cell['name'];
$cell['obj'] = &$nextmatch;
$cell['name'] = $nextmatch->name;
@ -371,8 +371,7 @@ class nextmatch_widget
}
else
{
$nextmatch = new etemplate('etemplate.nextmatch_widget');
$nextmatch->read('etemplate.nextmatch_widget');
$nextmatch = new etemplate_old('etemplate.nextmatch_widget');
// keep the editor away from the generated tmpls
$nextmatch->no_onclick = true;
@ -392,22 +391,22 @@ class nextmatch_widget
{
// make each letter internally behave like a button
$form_name = $name.'[searchletter]['.($key === 'all' ? $key : $letter).']';
etemplate::$request->set_to_process($form_name,'button');
etemplate_old::$request->set_to_process($form_name,'button');
if (!$key) $letterbox =& $lettersearch[1]; // to re-use the first child
$letterbox = etemplate::empty_cell('label',$letter,array(
$letterbox = boetemplate::empty_cell('label',$letter,array(
'label' => $letter,
'span' => ',lettersearch'.($letter == (string) $value['searchletter'] ||
$key === 'all' && !$value['searchletter'] ? '_active' : ''),
'no_lang' => 2,
'align' => $key == 'all' ? 'right' : '',
'onclick' => 'return submitit('.etemplate::$name_form.",'$form_name');",
'onclick' => 'return submitit('.etemplate_old::$name_form.",'$form_name');",
));
// if not the first (re-used) child, add it to the parent
if ($key) etemplate::add_child($lettersearch,$letterbox);
if ($key) boetemplate::add_child($lettersearch,$letterbox);
unset($letterbox);
}
//_debug_array(etemplate::$request->to_process);
//_debug_array(etemplate_old::$request->to_process);
}
if(isset($value['no_search'])) $value['no_start_search'] = $value['no_search'];
foreach(array('no_cat'=>'cat_id','no_filter'=>'filter','no_filter2'=>'filter2', 'no_search' => 'search', 'no_start_search' => 'start_search' ) as $val_name => $cell_name)
@ -521,7 +520,7 @@ class nextmatch_widget
}
$value['bottom'] = $value; // copy the values for the bottom-bar
// pass actions and row_id to etemplate::show_grid()
// pass actions and row_id to etemplate_old::show_grid()
$value['rows']['_actions'] =& $value['actions'];
$value['rows']['_action_links'] =& $value['action_links'];
$value['rows']['_row_id'] =& $value['row_id'];
@ -864,7 +863,7 @@ class nextmatch_widget
/**
* Return HTML to initialise actions, if called without arguments only CSS and JS get loaded
*
* Gets called from etemplate::show_grid() and addressbook_ui::view (without arguments).
* Gets called from etemplate_old::show_grid() and addressbook_ui::view (without arguments).
*
* @param array $actions=null
* @param array $action_links=null
@ -908,8 +907,8 @@ class nextmatch_widget
actionCntr.updateActions('.json_encode($enc_actions).');
actionCntr.setDefaultExecute("javaScript:nm_action");
actionCntr.etemplate_var_prefix="'.etemplate::$name_vars.'";
actionCntr.etemplate_form=document.forms.'.etemplate::$name_form.';
actionCntr.etemplate_var_prefix="'.etemplate_old::$name_vars.'";
actionCntr.etemplate_form=document.forms.'.etemplate_old::$name_form.';
var actionLinks = ["'.implode('","', $action_links).'"];
@ -1012,7 +1011,7 @@ class nextmatch_widget
*
* @param array &$cell
*/
private function pre_process_cf_header(array &$cell,etemplate $tmpl, &$value, $nm_global)
private function pre_process_cf_header(array &$cell,$tmpl, &$value, $nm_global)
{
//echo __CLASS__.'::'.__METHOD__."() selectcols=$this->selectcols\n";
if (is_null($this->cfs))
@ -1042,7 +1041,7 @@ class nextmatch_widget
{
if($field['type'] == 'select')
{
$header =& etemplate::empty_cell('nextmatch-filterheader',self::CF_PREFIX.$name,array(
$header =& boetemplate::empty_cell('nextmatch-filterheader',self::CF_PREFIX.$name,array(
'sel_options' => $field['values'],
'size' => $field['label'],
'no_lang' => True,
@ -1051,26 +1050,26 @@ class nextmatch_widget
}
elseif($GLOBALS['egw_info']['apps'][$field['type']])
{
$header =& etemplate::empty_cell('link-entry', $cell_name . '['.self::CF_PREFIX.$name .']', array(
$header =& boetemplate::empty_cell('link-entry', $cell_name . '['.self::CF_PREFIX.$name .']', array(
'label' => $field['label'],
'size' => $field['type'],
'readonly' => $cell['readonly'],
'onchange' => 1
));
etemplate::add_child($cell,$header);
boetemplate::add_child($cell,$header);
unset($header);
$header =& etemplate::empty_cell('label', '');
$header =& boetemplate::empty_cell('label', '');
$value[self::CF_PREFIX.$name] = $field['type'] . ':' . $nm_global['col_filter'][self::CF_PREFIX.$name];
}
else
{
$header =& etemplate::empty_cell('nextmatch-sortheader',self::CF_PREFIX.$name,array(
$header =& boetemplate::empty_cell('nextmatch-sortheader',self::CF_PREFIX.$name,array(
'label' => $field['label'],
'readonly' => $cell['readonly'],
));
}
etemplate::add_child($cell,$header);
boetemplate::add_child($cell,$header);
unset($header);
}
}
@ -1079,11 +1078,11 @@ class nextmatch_widget
if ($num > 5)
{
$vbox = $cell;
$cell = etemplate::empty_cell('box','',array(
$cell = boetemplate::empty_cell('box','',array(
'size' => '0,,0,0',
'span' => ',cf_header_height_limit',
));
etemplate::add_child($cell,$vbox);
boetemplate::add_child($cell,$vbox);
}
return false; // no extra label
}
@ -1098,7 +1097,7 @@ class nextmatch_widget
* @param array $selectcols selected colums
* @return int columns found, count($cols)
*/
private function cols_from_tpl(etemplate $tmpl,&$cols,&$name2col,&$content,$selectcols)
private function cols_from_tpl($tmpl,&$cols,&$name2col,&$content,$selectcols)
{
//_debug_array($cols);
// fetching column-names & -labels from the template
@ -1150,7 +1149,7 @@ class nextmatch_widget
}
/**
* Extract the column names and labels from the template (callback for etemplate::widget_tree_walk())
* Extract the column names and labels from the template (callback for etemplate_old::widget_tree_walk())
*
* @param array &$widget
* @param array &$cols here we add the column-name/-label
@ -1185,7 +1184,7 @@ class nextmatch_widget
$col = substr($col,$row > 9 ? 2 : 1);
if (($label[0] == '@' || strchr($lable,'$') !== false) && is_array($cols['__content__']))
{
$label = etemplate::expand_name($label,$col,$row,'','',$cols['__content__']);
$label = boetemplate::expand_name($label,$col,$row,'','',$cols['__content__']);
}
if (!isset($cols[$widget['name']]) && $label)
{
@ -1218,7 +1217,7 @@ class nextmatch_widget
* @param mixed &value_in the posted values (already striped of magic-quotes)
* @return boolean true if $value has valid content, on false no content will be returned!
*/
public function post_process($name,&$value,&$extension_data,&$loop,etemplate &$tmpl,$value_in)
public function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
{
$nm_global =& self::get_nm_global($name,$extension_data['type']);
@ -1483,7 +1482,7 @@ class nextmatch_widget
}
if (!$exportLimitExempted && (!bo_merge::hasExportLimit($export_limit,'ISALLOWED') || (bo_merge::hasExportLimit($export_limit) && (int)$export_limit < $total)))
{
etemplate::set_validation_error($name,lang('You are not allowed to export more than %1 entries!',(int)$export_limit));
etemplate_old::set_validation_error($name,lang('You are not allowed to export more than %1 entries!',(int)$export_limit));
return false;
}
if (!isset($value['no_csv_support'])) $value['no_csv_support'] = !is_array($value['csv_fields']);
@ -1571,7 +1570,7 @@ class nextmatch_widget
*/
private static function csv_encode($data,$fields,$use_type=true,$extra_sel_options=null,$charset_out=null,$charset=null,$separator=';')
{
$sel_options =& boetemplate::$request->sel_options;
$sel_options =& etemplate_old::$request->sel_options;
$out = array();
foreach($fields as $field => $label)

View File

@ -279,8 +279,8 @@ class select_widget
}
$cell['type'] = 'html';
$cell['size'] = ''; // is interpreted as link otherwise
etemplate::$request->set_to_process($name,'select');
if ($cell['needed']) etemplate::$request->set_to_process_attribute($name,'needed',$cell['needed']);
etemplate_old::$request->set_to_process($name,'select');
if ($cell['needed']) etemplate_old::$request->set_to_process_attribute($name,'needed',$cell['needed']);
break;
}
$cell['no_lang'] = True;
@ -384,7 +384,7 @@ class select_widget
}
if (!$readonly)
{
etemplate::$request->set_to_process($name,'ext-select-dow');
etemplate_old::$request->set_to_process($name,'ext-select-dow');
}
$cell['size'] = $rows.($type2 ? ','.$type2 : '');
break;

View File

@ -85,7 +85,7 @@
$labels = array_values($labels);
}
}
$tab_widget = new etemplate('etemplate.tab_widget');
$tab_widget = new etemplate_old('etemplate.tab_widget');
$tab_widget->no_onclick = true;
if ($value && strpos($value,'.') === false)
@ -117,7 +117,7 @@
{
$name = $names[$k] = $tmpl->name . '.' . $name;
}
$tcell =& $tab_widget->empty_cell();
$tcell = boetemplate::empty_cell();
if ($value == $name)
{
$tcell['span'] = ',etemplate_tab_active';
@ -150,8 +150,8 @@
{
foreach($names as $n => $name)
{
$bcell = $tab_widget->empty_cell('template',$name);
$bcell['obj'] = new etemplate($name,$tmpl->as_array());
$bcell = boetemplate::empty_cell('template',$name);
$bcell['obj'] = new etemplate_old($name,$tmpl->as_array());
$tab_widget->set_cell_attribute('body',$n+1,$bcell);
}
$tab_widget->set_cell_attribute('body','type','deck');
@ -161,7 +161,7 @@
}
else
{
$stab = new etemplate($selected_tab,$tmpl->as_array());
$stab = new etemplate_old($selected_tab,$tmpl->as_array());
$tab_widget->set_cell_attribute('body','type','template');
$tab_widget->set_cell_attribute('body','size',''); // the deck has a '1' there
$tab_widget->set_cell_attribute('body','obj',$stab);

View File

@ -157,7 +157,7 @@ class tree_widget
list(,$class) = explode(',',$cell['span']);
$value = $script.html::tree($tmpl->_sel_options($cell,$name),$value,false,$onNodeSelect,$tree_id,$class,'',$onCheck);
$cell = etemplate::empty_cell('html',$cell['name']);
$cell = boetemplate::empty_cell('html',$cell['name']);
return True; // extra Label Ok
}

View File

@ -86,7 +86,7 @@ class vfs_widget
if (!$value || !($stat = egw_vfs::stat($value)))
{
if ($value) $value = lang("File '%1' not found!",egw_vfs::decodePath($value));
$cell = etemplate::empty_cell();
$cell = boetemplate::empty_cell();
return true; // allow extra value;
}
}
@ -144,7 +144,7 @@ class vfs_widget
{
//echo $path; _debug_array($files);
$upload = $cell;
$cell = etemplate::empty_cell('vbox','',array('size' => ',,0,0'));
$cell = boetemplate::empty_cell('vbox','',array('size' => ',,0,0'));
$extension_data['files'] = $files;
$value = array();
foreach($files as $file)
@ -153,9 +153,9 @@ class vfs_widget
$basename = basename($file);
unset($widget);
$widget = $this->file_widget($value[$basename],$file,$upload['name']."[$basename]");
etemplate::add_child($cell,$widget);
boetemplate::add_child($cell,$widget);
}
etemplate::add_child($cell,$upload);
boetemplate::add_child($cell,$upload);
}
break;
@ -245,7 +245,7 @@ class vfs_widget
if ($cell['onclick'])
{
$comp = etemplate::empty_cell('button',$cell_name.'[c'.$n.']',array(
$comp = boetemplate::empty_cell('button',$cell_name.'[c'.$n.']',array(
'size' => '1',
'no_lang' => true,
'span' => ',vfsFilename',
@ -255,13 +255,13 @@ class vfs_widget
}
else
{
$comp = etemplate::empty_cell('label',$cell_name.'[c'.$n.']',array(
$comp = boetemplate::empty_cell('label',$cell_name.'[c'.$n.']',array(
'size' => ',@'.$cell_name.'[l'.$n.'],,,'.$target.','.$popup,
'no_lang' => true,
'span' => ',vfsFilename',
));
}
etemplate::add_child($cell,$comp);
boetemplate::add_child($cell,$comp);
unset($comp);
}
unset($cell['onclick']); // otherwise it's handled by the grid too
@ -287,7 +287,7 @@ class vfs_widget
if (!$value)
{
$cell = etemplate::empty_cell();
$cell = boetemplate::empty_cell();
return true;
}
if (!is_array($value))
@ -375,21 +375,21 @@ class vfs_widget
{
$value = empty($label) ? egw_vfs::decodePath(egw_vfs::basename($path)) : lang($label); // display (translated) Label or filename (if label empty)
$vfs_link = etemplate::empty_cell('label',$name,array(
$vfs_link = boetemplate::empty_cell('label',$name,array(
'size' => ','.egw_vfs::download_url($path).',,,_blank,,'.$path,
));
// if dir is writable, add delete link
if (egw_vfs::is_writable(egw_vfs::dirname($path)))
{
$cell = etemplate::empty_cell('hbox','',array('size' => ',,0,0'));
etemplate::add_child($cell,$vfs_link);
$delete_icon = etemplate::empty_cell('button',$path,array(
$cell = boetemplate::empty_cell('hbox','',array('size' => ',,0,0'));
boetemplate::add_child($cell,$vfs_link);
$delete_icon = boetemplate::empty_cell('button',$path,array(
'label' => 'delete',
'size' => 'delete', // icon
'onclick' => "return confirm('Delete this file');",
'span' => ',leftPad5',
));
etemplate::add_child($cell,$delete_icon);
boetemplate::add_child($cell,$delete_icon);
}
else
{
@ -480,7 +480,7 @@ class vfs_widget
{
if (!egw_vfs::unlink($extension_data['path'].$file))
{
etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'].$file)));
etemplate_old::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'].$file)));
}
break;
}
@ -488,7 +488,7 @@ class vfs_widget
}
elseif (!egw_vfs::unlink($extension_data['path']))
{
etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'])));
etemplate_old::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'])));
}
$loop = true;
return false;
@ -497,16 +497,16 @@ class vfs_widget
// handle file upload
$name = preg_replace('/^exec\[([^]]+)\](.*)$/','\\1\\2',$name); // remove exec prefix
if (!is_array($_FILES['exec']) || !($filename = etemplate::get_array($_FILES['exec']['name'],$name)))
if (!is_array($_FILES['exec']) || !($filename = boetemplate::get_array($_FILES['exec']['name'],$name)))
{
return false; // no file attached
}
$tmp_name = etemplate::get_array($_FILES['exec']['tmp_name'],$name);
$error = etemplate::get_array($_FILES['exec']['error'],$name);
$tmp_name = boetemplate::get_array($_FILES['exec']['tmp_name'],$name);
$error = boetemplate::get_array($_FILES['exec']['error'],$name);
if ($error)
{
etemplate::set_validation_error($name,lang('Error uploading file!')."\n".
etemplate::max_upload_size_message());
etemplate_old::set_validation_error($name,lang('Error uploading file!')."\n".
etemplate_old::max_upload_size_message());
$loop = true;
return false;
}
@ -517,11 +517,11 @@ class vfs_widget
// check if type matches required mime-type, if specified
if (!empty($extension_data['mimetype']))
{
$type = etemplate::get_array($_FILES['exec']['type'],$name);
$type = boetemplate::get_array($_FILES['exec']['type'],$name);
$is_preg = $extension_data['mimetype'][0] == '/';
if (!$is_preg && strcasecmp($extension_data['mimetype'],$type) || $is_preg && !preg_match($extension_data['mimetype'],$type))
{
etemplate::set_validation_error($name,lang('File is of wrong type (%1 != %2)!',$type,$extension_data['mimetype']));
etemplate_old::set_validation_error($name,lang('File is of wrong type (%1 != %2)!',$type,$extension_data['mimetype']));
return false;
}
}
@ -541,12 +541,12 @@ class vfs_widget
}
if (!egw_vfs::file_exists($dir = egw_vfs::dirname($path)) && !egw_vfs::mkdir($dir,null,STREAM_MKDIR_RECURSIVE))
{
etemplate::set_validation_error($name,lang('Error create parent directory %1!',egw_vfs::decodePath($dir)));
etemplate_old::set_validation_error($name,lang('Error create parent directory %1!',egw_vfs::decodePath($dir)));
return false;
}
if (!copy($tmp_name,egw_vfs::PREFIX.$path))
{
etemplate::set_validation_error($name,lang('Error copying uploaded file to vfs!'));
etemplate_old::set_validation_error($name,lang('Error copying uploaded file to vfs!'));
return false;
}
$value = $path; // return path of file, important if only a temporary location is used

View File

@ -205,7 +205,7 @@ class xul_io
{
case 'nextmatch':
list($tpl) = explode(',',$cell['size']);
$embeded = new etemplate($tpl,$this->load_via);
$embeded = new boetemplate($tpl,$this->load_via);
if ($embeded_too)
{
$this->add_etempl($embeded,$embeded_too);
@ -229,7 +229,7 @@ class xul_io
if ($helps[$n]) $tab->set_attribute('statustext',$helps[$n]);
$child->add_node($tab);
$embeded = new etemplate($names[$n],$this->load_via);
$embeded = new boetemplate($names[$n],$this->load_via);
if ($embeded_too)
{
$this->add_etempl($embeded,$embeded_too);
@ -282,7 +282,7 @@ class xul_io
case 'template':
if ($cell['name'][0] != '@' && $embeded_too)
{
$templ = new etemplate();
$templ = new boetemplate();
if ($templ->read(boetemplate::expand_name($cell['name'],0,0),'default','default',0,'',$this->load_via))
{
$this->add_etempl($templ,$embeded_too);
@ -374,10 +374,10 @@ class xul_io
/**
* add / embed an eTemplate into the global $xul_overlay object (used by export)
*
* @param etemplate &$etempl eTemplate to embed
* @param boetemplate &$etempl eTemplate to embed
* @param array &embeded_too array with already embeded templates
*/
function add_etempl(etemplate $etempl,&$embeded_too)
function add_etempl(boetemplate $etempl,&$embeded_too)
{
if (is_array($embeded_too))
{

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package etemplate
* @copyright (c) 2002-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2002-12 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -21,4 +21,4 @@ $GLOBALS['egw_info'] = array(
);
include('../header.inc.php');
ExecMethod('etemplate.etemplate.process_exec');
ExecMethod('etemplate.etemplate_old.process_exec');