2002-06-09 23:36:37 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - eTemplate Extension - Tab Widget *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@class tab_widget
|
2002-09-02 13:14:30 +02:00
|
|
|
@author ralfbecker
|
2002-06-09 23:36:37 +02:00
|
|
|
@abstract widget that shows one row of tabs and an other row with the eTemplate of the selected tab
|
2002-09-02 13:14:30 +02:00
|
|
|
@discussion see the example in 'etemplate.tab_widget.test' (use show to view it)
|
|
|
|
@discussion This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
|
2002-06-09 23:36:37 +02:00
|
|
|
*/
|
|
|
|
class tab_widget
|
|
|
|
{
|
|
|
|
var $public_functions = array(
|
|
|
|
'pre_process' => True,
|
|
|
|
'post_process' => True
|
|
|
|
);
|
|
|
|
var $human_name = 'Tabs'; // this is the name for the editor
|
|
|
|
|
|
|
|
function tab_widget($ui)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-06-15 14:54:38 +02:00
|
|
|
function pre_process(&$cell,&$value,&$templ)
|
2002-06-09 23:36:37 +02:00
|
|
|
{
|
|
|
|
$labels = explode('|',$cell['label']);
|
|
|
|
$helps = explode('|',$cell['help']);
|
|
|
|
$names = explode('|',$cell['name']);
|
|
|
|
|
2002-06-15 14:54:38 +02:00
|
|
|
$tabs = new etemplate();
|
2002-06-10 23:36:22 +02:00
|
|
|
$tab = new etemplate('etemplate.tab_widget.tab');
|
|
|
|
$tab_active = new etemplate('etemplate.tab_widget.tab_active');
|
2002-06-09 23:36:37 +02:00
|
|
|
|
2002-06-15 14:54:38 +02:00
|
|
|
$tabs->init('*** generated tabs','','',0,'',0,0); // make an empty template
|
2002-06-09 23:36:37 +02:00
|
|
|
|
2002-06-15 14:54:38 +02:00
|
|
|
$tab_row = array(); // generate the tab row
|
2002-06-09 23:36:37 +02:00
|
|
|
while (list($k,$name) = each($names))
|
|
|
|
{
|
2002-06-15 14:54:38 +02:00
|
|
|
$tcell = $tabs->empty_cell();
|
2002-06-15 21:59:07 +02:00
|
|
|
if (is_array($value['_tab_widget']) && $value['_tab_widget'][$name][0])
|
2002-06-09 23:36:37 +02:00
|
|
|
{
|
2002-06-15 14:54:38 +02:00
|
|
|
// save selected tab in persistent extension_data to use it in post_process
|
2002-06-09 23:36:37 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']] = $selected_tab = $name;
|
2002-06-10 23:36:22 +02:00
|
|
|
$tcell['name'] = $tab_active;
|
2002-06-09 23:36:37 +02:00
|
|
|
}
|
2002-06-10 23:36:22 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$tcell['name'] = $tab;
|
|
|
|
}
|
|
|
|
$tcell['type'] = 'template';
|
|
|
|
$tcell['size'] = "_tab_widget[$name]";
|
|
|
|
$value['_tab_widget'][$name] = array(
|
2002-06-15 14:54:38 +02:00
|
|
|
'name' => $name,
|
2002-06-10 23:36:22 +02:00
|
|
|
'label' => $labels[$k],
|
|
|
|
'help' => $helps[$k]
|
|
|
|
);
|
2002-06-15 14:54:38 +02:00
|
|
|
$tab_row[$tabs->num2chrs($k)] = $tcell;
|
2002-06-09 23:36:37 +02:00
|
|
|
}
|
|
|
|
// add one empty cell to take all the space of the row
|
2002-06-15 14:54:38 +02:00
|
|
|
$tab_row[$k = $tabs->num2chrs(sizeof($tab_row))] = $tabs->empty_cell();
|
|
|
|
$tabs->data[0][$k] = '99%'; // width
|
|
|
|
$tabs->data[0]['c1'] = ',bottom';
|
2002-06-09 23:36:37 +02:00
|
|
|
|
|
|
|
if (!isset($selected_tab))
|
|
|
|
{
|
2002-06-15 14:54:38 +02:00
|
|
|
$tab_row['A']['name'] = $tab_active;
|
2002-06-09 23:36:37 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']] = $selected_tab = $names[0];
|
|
|
|
}
|
2002-06-15 14:54:38 +02:00
|
|
|
$tabs->data[1] = $tab_row;
|
|
|
|
$tabs->rows = 1;
|
|
|
|
$tabs->cols = sizeof($tab_row);
|
|
|
|
$tabs->size = ',,,,0';
|
2002-06-09 23:36:37 +02:00
|
|
|
|
2002-06-15 14:54:38 +02:00
|
|
|
$tab_widget = new etemplate('etemplate.tab_widget');
|
|
|
|
$tab_widget->set_cell_attribute('@tabs','name',$tabs);
|
|
|
|
$tab_widget->set_cell_attribute('@body','name',$selected_tab);
|
2002-06-10 23:36:22 +02:00
|
|
|
|
2002-06-09 23:36:37 +02:00
|
|
|
$cell['type'] = 'template';
|
2002-06-15 14:54:38 +02:00
|
|
|
$cell['name'] = $tab_widget;
|
2002-06-09 23:36:37 +02:00
|
|
|
$cell['label'] = $cell['help'] = '';
|
|
|
|
|
2002-06-15 14:54:38 +02:00
|
|
|
return False; // NO extra Label
|
2002-06-09 23:36:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function post_process(&$cell,&$value,&$templ)
|
|
|
|
{
|
|
|
|
$old_value = array(
|
|
|
|
'_tab_widget' => array(
|
2002-06-15 21:59:07 +02:00
|
|
|
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']] => array(True)
|
2002-06-09 23:36:37 +02:00
|
|
|
));
|
|
|
|
$this->pre_process($cell,$old_value,$templ);
|
|
|
|
|
2002-06-15 21:59:07 +02:00
|
|
|
if (is_array($value['_tab_widget']))
|
|
|
|
{
|
|
|
|
while (list($key,$val) = each($value['_tab_widget']))
|
|
|
|
{
|
|
|
|
if (is_array($val) && $val[0])
|
|
|
|
{
|
|
|
|
$templ->loop = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//$templ->loop = is_array($value['_tab_widget']);
|
2002-06-09 23:36:37 +02:00
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|