mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 17:18:54 +01:00
117 lines
3.8 KiB
PHP
117 lines
3.8 KiB
PHP
<?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
|
|
@author ralfbecker
|
|
@abstract widget that shows one row of tabs and an other row with the eTemplate of the selected tab
|
|
@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
|
|
*/
|
|
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($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
|
{
|
|
$labels = explode('|',$cell['label']);
|
|
$helps = explode('|',$cell['help']);
|
|
$names = explode('|',$cell['name']);
|
|
|
|
$tabs = new etemplate();
|
|
$tab = new etemplate('etemplate.tab_widget.tab');
|
|
$tab_active = new etemplate('etemplate.tab_widget.tab_active');
|
|
|
|
$tabs->init('*** generated tabs','','',0,'',0,0); // make an empty template
|
|
|
|
$tab_row = array(); // generate the tab row
|
|
while (list($k,$name) = each($names))
|
|
{
|
|
$tcell = $tabs->empty_cell();
|
|
if ($extension_data == $name)
|
|
{
|
|
// save selected tab in persistent extension_data to use it in post_process
|
|
$selected_tab = $name;
|
|
$tcell['obj'] = &$tab_active;
|
|
$tcell['name'] = $tab_active->name;
|
|
}
|
|
else
|
|
{
|
|
$tcell['obj'] = &$tab;
|
|
$tcell['name'] = $tab->name;
|
|
}
|
|
$tcell['type'] = 'template';
|
|
$tcell['size'] = $cell['name']/*form_name*/.'['.$name.']';
|
|
$value[$name] = array(
|
|
'name' => $name,
|
|
'label' => $labels[$k],
|
|
'help' => $helps[$k]
|
|
);
|
|
$tab_row[$tabs->num2chrs($k)] = $tcell;
|
|
}
|
|
// add one empty cell to take all the space of the row
|
|
$tab_row[$k = $tabs->num2chrs(sizeof($tab_row))] = $tabs->empty_cell();
|
|
$tabs->data[0][$k] = '99%'; // width
|
|
$tabs->data[0]['c1'] = ',bottom';
|
|
|
|
if (!isset($selected_tab))
|
|
{
|
|
$tab_row['A']['obj'] = &$tab_active;
|
|
$tcell['name'] = $tab_active->name;
|
|
$extension_data = $selected_tab = $names[0];
|
|
}
|
|
$tabs->data[1] = $tab_row;
|
|
$tabs->rows = 1;
|
|
$tabs->cols = sizeof($tab_row);
|
|
$tabs->size = ',,,,0';
|
|
|
|
$tab_widget = new etemplate('etemplate.tab_widget');
|
|
$tab_widget->set_cell_attribute('@tabs','obj',$tabs);
|
|
if ($tmpl->tpls_in_file > 1)
|
|
$tab_widget->set_cell_attribute('@body','obj',new etemplate($selected_tab,$tmpl->as_array()));
|
|
else
|
|
$tab_widget->set_cell_attribute('@body','name',$selected_tab);
|
|
|
|
$cell['type'] = 'template';
|
|
$cell['obj'] = &$tab_widget;
|
|
$cell['label'] = $cell['help'] = '';
|
|
|
|
return False; // NO extra Label
|
|
}
|
|
|
|
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl)
|
|
{
|
|
//echo "<p>tab_widget::post_process($name): value = "; _debug_array($value);
|
|
if (is_array($value))
|
|
{
|
|
reset($value);
|
|
list($tab,$button) = each($value);
|
|
list(,$button) = each($button);
|
|
if ($button)
|
|
{
|
|
$extension_data = $tab;
|
|
$loop = True;
|
|
}
|
|
}
|
|
return True;
|
|
}
|
|
} |