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
|
|
|
|
@abstract widget that shows one row of tabs and an other row with the eTemplate of the selected tab
|
|
|
|
@note This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
function pre_process(&$cell,&$value,&$parent)
|
|
|
|
{
|
|
|
|
$labels = explode('|',$cell['label']);
|
|
|
|
$helps = explode('|',$cell['help']);
|
|
|
|
$names = explode('|',$cell['name']);
|
|
|
|
|
|
|
|
$cell['type'] = 'template';
|
|
|
|
$templ = 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
|
|
|
|
|
|
|
$templ->init('*** generated tab_widget','','',0,'',0,0); // make an empty template
|
|
|
|
|
|
|
|
$tabs = array(); // generate the tabs row
|
|
|
|
while (list($k,$name) = each($names))
|
|
|
|
{
|
|
|
|
$tcell = $templ->empty_cell();
|
2002-06-10 23:36:22 +02:00
|
|
|
/* $tcell['name'] = "_tab_widget[$name]";
|
2002-06-09 23:36:37 +02:00
|
|
|
$tcell['type'] = 'button';
|
|
|
|
$tcell['label'] = $labels[$k];
|
|
|
|
$tcell['help'] = $helps[$k];
|
2002-06-10 23:36:22 +02:00
|
|
|
*/ if (is_array($value['_tab_widget']) && isset($value['_tab_widget'][$name]))
|
2002-06-09 23:36:37 +02:00
|
|
|
{
|
2002-06-10 23:36:22 +02:00
|
|
|
// $tcell['span'] = ',nmh'; // set tab as selected
|
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(
|
|
|
|
'name' => "_tab_widget[$name]",
|
|
|
|
'label' => $labels[$k],
|
|
|
|
'help' => $helps[$k]
|
|
|
|
);
|
2002-06-09 23:36:37 +02:00
|
|
|
$tabs[$templ->num2chrs($k)] = $tcell;
|
|
|
|
}
|
|
|
|
// add one empty cell to take all the space of the row
|
|
|
|
$tabs[$k = $templ->num2chrs(sizeof($tabs))] = $templ->empty_cell();
|
|
|
|
$templ->data[0][$k] = '99%'; // width
|
|
|
|
|
|
|
|
if (!isset($selected_tab))
|
|
|
|
{
|
2002-06-10 23:36:22 +02:00
|
|
|
//$tabs['A']['span'] = ',nmh';
|
|
|
|
$tabs['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];
|
|
|
|
}
|
|
|
|
$templ->data[1] = $tabs;
|
|
|
|
|
2002-06-10 23:36:22 +02:00
|
|
|
$tcell = $templ->empty_cell(); // make the tabwidget-header
|
|
|
|
$tcell['label'] = ' ';
|
|
|
|
$tcell['span'] = 'all';
|
|
|
|
$templ->data[2]['A'] = $tcell;
|
|
|
|
$templ->data[0]['c2'] = 'nmh';
|
|
|
|
|
2002-06-09 23:36:37 +02:00
|
|
|
$tcell = $templ->empty_cell(); // make the tabwidget-body
|
|
|
|
$tcell['type'] = 'template';
|
|
|
|
$tcell['name'] = $selected_tab;
|
|
|
|
$tcell['span'] = 'all';
|
2002-06-10 23:36:22 +02:00
|
|
|
$templ->data[3]['A'] = $tcell;
|
2002-06-09 23:36:37 +02:00
|
|
|
|
2002-06-10 23:36:22 +02:00
|
|
|
$templ->rows = 3;
|
2002-06-09 23:36:37 +02:00
|
|
|
$templ->cols = sizeof($tabs);
|
|
|
|
|
2002-06-10 23:36:22 +02:00
|
|
|
$templ->size = ',,,,0';
|
|
|
|
|
2002-06-09 23:36:37 +02:00
|
|
|
$cell['type'] = 'template';
|
|
|
|
$cell['name'] = $templ;
|
|
|
|
$cell['label'] = $cell['help'] = '';
|
|
|
|
|
|
|
|
return False; // extra Label NOT ok
|
|
|
|
}
|
|
|
|
|
|
|
|
function post_process(&$cell,&$value,&$templ)
|
|
|
|
{
|
|
|
|
$old_value = array(
|
|
|
|
'_tab_widget' => array(
|
|
|
|
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']] => True
|
|
|
|
));
|
|
|
|
$this->pre_process($cell,$old_value,$templ);
|
|
|
|
|
|
|
|
$templ->loop = is_array($value['_tab_widget']);
|
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|