From c39273ac51ba5cfeeb1da3427051d2a3b10a5954 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 20 Aug 2013 16:41:31 +0000 Subject: [PATCH] allow to (optionally) add tabs to existing tabs in template instead of replacing them --- etemplate/js/et2_widget_tabs.js | 42 ++++++++++++-------- filemanager/inc/class.filemanager_ui.inc.php | 9 ++++- filemanager/templates/default/file.xet | 2 +- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/etemplate/js/et2_widget_tabs.js b/etemplate/js/et2_widget_tabs.js index 8f543a6ebe..9712d093db 100644 --- a/etemplate/js/et2_widget_tabs.js +++ b/etemplate/js/et2_widget_tabs.js @@ -30,6 +30,11 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput], 'name': 'Tabs', 'default': et2_no_init, 'description': "Array of [extra] tabs. Each tab needs {label:..., template:...}. Additional optional keys are hidden and id, for access into content array" + }, + 'add_tabs': { + 'name': 'Add tabs', + 'default': false, + 'description': 'Set to true if tabs should be added to tabs from read from template, default false if not' } }, @@ -155,8 +160,26 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput], this.tabContainer.css("height", height); } - // either use tabs defined via modification or xml (not both) - if(this.options.tabs) + // if no tabs set or they should be added to tabs from xml + if (!this.options.tabs || this.options.add_tabs) + { + if (tabsElems.length == 1 && tabpanelsElems.length == 1) + { + var tabs = tabsElems[0]; + var tabpanels = tabpanelsElems[0]; + + // Parse the "tabs" tag + this._readTabs(tabData, tabs); + + // Read and create the widgets defined in the "tabpanels" + this._readTabPanels(tabData, tabpanels); + } + else + { + this.egw().debug("error","Error while parsing tabbox, none or multiple tabs or tabpanels tags!",this); + } + } + if (this.options.tabs) { var readonly = this.getArrayMgr("readonlys").getEntry(this.id) || {}; for(var i = 0; i < this.options.tabs.length; i++) @@ -178,21 +201,6 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput], }); } } - else if (tabsElems.length == 1 && tabpanelsElems.length == 1) - { - var tabs = tabsElems[0]; - var tabpanels = tabpanelsElems[0]; - - // Parse the "tabs" tag - this._readTabs(tabData, tabs); - - // Read and create the widgets defined in the "tabpanels" - this._readTabPanels(tabData, tabpanels); - } - else - { - this.egw().debug("error","Error while parsing tabbox, none or multiple tabs or tabpanels tags!",this); - } // Create the tab DOM-Nodes this.createTabs(tabData); diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index 0410b9d518..ecc95f6b35 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -1173,9 +1173,14 @@ class filemanager_ui if(method_exists($tpl,'get_widget_by_name')) { $tabs =& $tpl->get_widget_by_name('tabs=general|perms|eacl|preview|custom'); - } else { - // et2 + } + else // et2 + { + // add to existing tabs in template + $tpl->setElementAttribute('tabs', 'add_tabs', true); + $tabs =& $tpl->getElementAttribute('tabs','tabs'); + $tabs = array(); } foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) diff --git a/filemanager/templates/default/file.xet b/filemanager/templates/default/file.xet index 7cadf28185..d21526530a 100644 --- a/filemanager/templates/default/file.xet +++ b/filemanager/templates/default/file.xet @@ -252,7 +252,7 @@ - +