mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-14 01:48:35 +01:00
Allow to set an explicit name for a tab_widget: "tabs=one|two|three"
In the example the tab itself is named "tabs", with tabs "one", "two" and "three". Therefore the name of the tab-widget (where the select tab gets reported and used to disable a single tab) does no longer depend on the available tabs. This allows for a deeper customization. Examples on how to use it are in the next two commits: tracker and pm
This commit is contained in:
parent
c2ca3760b7
commit
3b962e7064
@ -957,7 +957,12 @@ class etemplate extends boetemplate
|
|||||||
$show_c,$show_row,$content['.c'],$content['.row'],$content));
|
$show_c,$show_row,$content['.c'],$content['.row'],$content));
|
||||||
}
|
}
|
||||||
$name = $this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
$name = $this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
|
||||||
|
// allow names like "tabs=one|two|three", which will be equal to just "tabs"
|
||||||
|
// eg. for tabs to use a name independent of the tabs contained
|
||||||
|
if (is_string($name) && strpos($name,'=') !== false)
|
||||||
|
{
|
||||||
|
list($name) = explode('=',$name);
|
||||||
|
}
|
||||||
$form_name = $this->form_name($cname,$name);
|
$form_name = $this->form_name($cname,$name);
|
||||||
|
|
||||||
$value = $this->get_array($content,$name);
|
$value = $this->get_array($content,$name);
|
||||||
|
@ -4,22 +4,18 @@
|
|||||||
*
|
*
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
* @package etemplate
|
* @package etemplate
|
||||||
|
* @subpackage extensions
|
||||||
* @link http://www.egroupware.org
|
* @link http://www.egroupware.org
|
||||||
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eTemplate Extension: widget that shows one row of tabs and an other row with the eTemplate of the selected tab
|
* eTemplate Extension: widget that shows one row of tabs and an other row with the eTemplate of the selected tab
|
||||||
*
|
*
|
||||||
* See the example in 'etemplate.tab_widget.test'
|
* See the example in 'etemplate.tab_widget.test'
|
||||||
*
|
*
|
||||||
* This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
|
* This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
|
||||||
*
|
|
||||||
* @package etemplate
|
|
||||||
* @subpackage extensions
|
|
||||||
* @author RalfBecker-AT-outdoor-training.de
|
|
||||||
* @license GPL
|
|
||||||
*/
|
*/
|
||||||
class tab_widget
|
class tab_widget
|
||||||
{
|
{
|
||||||
@ -36,7 +32,7 @@
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $human_name = 'Tabs'; // this is the name for the editor
|
var $human_name = 'Tabs'; // this is the name for the editor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of the extension
|
* Constructor of the extension
|
||||||
*
|
*
|
||||||
@ -45,7 +41,7 @@
|
|||||||
function tab_widget($ui)
|
function tab_widget($ui)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pre-processing of the extension
|
* pre-processing of the extension
|
||||||
*
|
*
|
||||||
@ -62,15 +58,19 @@
|
|||||||
function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
||||||
{
|
{
|
||||||
//echo "<p>tab_widget::pre_process('$form_name',$value,,$extension_data)</p>\n";
|
//echo "<p>tab_widget::pre_process('$form_name',$value,,$extension_data)</p>\n";
|
||||||
|
|
||||||
if (!$cell['onchange']) // onchange allows to use the old behavior (submit for each new tab)
|
if (!$cell['onchange']) // onchange allows to use the old behavior (submit for each new tab)
|
||||||
{
|
{
|
||||||
$dom_enabled = isset($GLOBALS['egw_info']['etemplate']['dom_enabled']) ? $GLOBALS['egw_info']['etemplate']['dom_enabled'] : true;
|
$dom_enabled = isset($GLOBALS['egw_info']['etemplate']['dom_enabled']) ? $GLOBALS['egw_info']['etemplate']['dom_enabled'] : true;
|
||||||
}
|
}
|
||||||
$labels = explode('|',$cell['label']);
|
$labels = explode('|',$cell['label']);
|
||||||
$helps = explode('|',$cell['help']);
|
$helps = explode('|',$cell['help']);
|
||||||
$names = explode('|',$cell['name']);
|
if (strpos($cell_name=$tab_names=$cell['name'],'=') !== false)
|
||||||
|
{
|
||||||
|
list($cell_name,$tab_names) = explode('=',$cell['name']);
|
||||||
|
$cell['name'] = $cell_name;
|
||||||
|
}
|
||||||
|
$names = explode('|',$tab_names);
|
||||||
// disable tab mentioned in readonlys
|
// disable tab mentioned in readonlys
|
||||||
foreach(is_array($readonlys) ? $readonlys : array($readonlys => true) as $name => $disable)
|
foreach(is_array($readonlys) ? $readonlys : array($readonlys => true) as $name => $disable)
|
||||||
{
|
{
|
||||||
@ -85,7 +85,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$all_names = implode('|',$names);
|
$all_names = implode('|',$names);
|
||||||
|
|
||||||
$tab_widget =& new etemplate('etemplate.tab_widget');
|
$tab_widget =& new etemplate('etemplate.tab_widget');
|
||||||
$tab_widget->no_onclick = true;
|
$tab_widget->no_onclick = true;
|
||||||
|
|
||||||
@ -109,7 +109,7 @@
|
|||||||
$value = $selected_tab = $names[0];
|
$value = $selected_tab = $names[0];
|
||||||
}
|
}
|
||||||
$extension_data = $value; // remember the active tab in the extension_data
|
$extension_data = $value; // remember the active tab in the extension_data
|
||||||
|
|
||||||
foreach($names as $k => $name)
|
foreach($names as $k => $name)
|
||||||
{
|
{
|
||||||
if (strpos($name,'.') === false)
|
if (strpos($name,'.') === false)
|
||||||
@ -134,17 +134,17 @@
|
|||||||
{
|
{
|
||||||
$tcell['type'] = 'button';
|
$tcell['type'] = 'button';
|
||||||
$tcell['onchange'] = '1';
|
$tcell['onchange'] = '1';
|
||||||
$tcell['name'] = $cell['name'].'['.$name.']';
|
$tcell['name'] = $cell_name.'['.$name.']';
|
||||||
}
|
}
|
||||||
$tcell['label'] = $labels[$k];
|
$tcell['label'] = $labels[$k];
|
||||||
$tcell['help'] = $helps[$k];
|
$tcell['help'] = $helps[$k];
|
||||||
|
|
||||||
$tab_widget->set_cell_attribute('tabs',1+$k,$tcell);
|
$tab_widget->set_cell_attribute('tabs',1+$k,$tcell);
|
||||||
}
|
}
|
||||||
$tab_widget->set_cell_attribute('tabs','type','hbox');
|
$tab_widget->set_cell_attribute('tabs','type','hbox');
|
||||||
$tab_widget->set_cell_attribute('tabs','size',count($names));
|
$tab_widget->set_cell_attribute('tabs','size',count($names));
|
||||||
$tab_widget->set_cell_attribute('tabs','name','');
|
$tab_widget->set_cell_attribute('tabs','name','');
|
||||||
|
|
||||||
if ($dom_enabled)
|
if ($dom_enabled)
|
||||||
{
|
{
|
||||||
foreach($names as $n => $name)
|
foreach($names as $n => $name)
|
||||||
@ -156,7 +156,7 @@
|
|||||||
$tab_widget->set_cell_attribute('body','type','deck');
|
$tab_widget->set_cell_attribute('body','type','deck');
|
||||||
$tab_widget->set_cell_attribute('body','size',count($names));
|
$tab_widget->set_cell_attribute('body','size',count($names));
|
||||||
$tab_widget->set_cell_attribute('body','span',',tab_body');
|
$tab_widget->set_cell_attribute('body','span',',tab_body');
|
||||||
$tab_widget->set_cell_attribute('body','name',$cell['name']);
|
$tab_widget->set_cell_attribute('body','name',$cell_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -166,14 +166,14 @@
|
|||||||
$tab_widget->set_cell_attribute('body','obj',$stab);
|
$tab_widget->set_cell_attribute('body','obj',$stab);
|
||||||
}
|
}
|
||||||
$tab_widget->set_cell_attribute('body','name',$selected_tab);
|
$tab_widget->set_cell_attribute('body','name',$selected_tab);
|
||||||
|
|
||||||
$cell['type'] = 'template';
|
$cell['type'] = 'template';
|
||||||
$cell['obj'] = &$tab_widget;
|
$cell['obj'] = &$tab_widget;
|
||||||
$cell['label'] = $cell['help'] = '';
|
$cell['label'] = $cell['help'] = '';
|
||||||
|
|
||||||
return False; // NO extra Label
|
return False; // NO extra Label
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* postprocessing method, called after the submission of the form
|
* postprocessing method, called after the submission of the form
|
||||||
*
|
*
|
||||||
@ -194,7 +194,7 @@
|
|||||||
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
|
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
|
||||||
{
|
{
|
||||||
//echo "<p>tab_widget::post_process($name): value_in = "; _debug_array($value_in);
|
//echo "<p>tab_widget::post_process($name): value_in = "; _debug_array($value_in);
|
||||||
|
|
||||||
if (is_array($value_in))
|
if (is_array($value_in))
|
||||||
{
|
{
|
||||||
foreach ($value_in as $tab => $button_pressed)
|
foreach ($value_in as $tab => $button_pressed)
|
||||||
|
@ -200,7 +200,11 @@
|
|||||||
case 'tabbox':
|
case 'tabbox':
|
||||||
$labels = explode('|',$cell['label']); unset($cell['label']);
|
$labels = explode('|',$cell['label']); unset($cell['label']);
|
||||||
$helps = explode('|',$cell['help']); unset($cell['help']);
|
$helps = explode('|',$cell['help']); unset($cell['help']);
|
||||||
$names = explode('|',$cell['name']); unset($cell['name']);
|
if (strpos($tab_names=$cell['name'],'=') !== false)
|
||||||
|
{
|
||||||
|
list($cell['name'],$tab_names) = explode('=',$cell['name']);
|
||||||
|
}
|
||||||
|
$names = explode('|',$tab_names);
|
||||||
for ($n = 0; $n < count($labels); ++$n)
|
for ($n = 0; $n < count($labels); ++$n)
|
||||||
{
|
{
|
||||||
$tab =& new xmlnode('tab');
|
$tab =& new xmlnode('tab');
|
||||||
|
Loading…
Reference in New Issue
Block a user