we have investigated a bit to find how to make the tabsheet simplier for plugins (ie: plugins adding tabs on the same tabsheet)
so here is my idea:
1) modify tabsheet to add a id parameter, and a trigger
Index: tabsheet.class.php
===================================================================
--- tabsheet.class.php (revision 16527)
+++ tabsheet.class.php (working copy)
@@ -24,6 +24,7 @@
class tabsheet
{
var $sheets;
+ var $id;
var $name;
var $titlename;
var $selected;
@@ -32,9 +33,10 @@
$name is the tabsheet's name inside the template .tpl file
$titlename in the template is affected by $titlename value
*/
- function tabsheet($name = 'TABSHEET', $titlename = 'TABSHEET_TITLE')
+ function tabsheet($id=null, $name = 'TABSHEET', $titlename = 'TABSHEET_TITLE')
{
$this->sheets = array();
+ $this->id = $id;
$this->name = $name;
$this->titlename = $titlename;
$this->selected = "";
@@ -81,6 +83,7 @@
*/
function select($name)
{
+ $this->sheets = trigger_event('tabsheet_before_select', $this->sheets, $this->id);
$this->selected = $name;
}
2) define this id in all core tabsheets, example for album.php
$tabsheet = new tabsheet('album');
$tabsheet->assign();
3) add in admin.php (or included new file) the declaration of all core tabs, like
add_event_handler('tabsheet_before_select', 'add_core_tabs', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
function add_core_tabs($sheets, $id)
{
switch ($id)
{
case 'album':
global $admin_album_base_url;
$sheets['properties'] = array('caption'=>l10n('Properties'), 'url'=>$admin_album_base_url.'-properties');
$sheets['sort_order'] = array('caption'=>l10n('Manage photo ranks'), 'url'=>$admin_album_base_url.'-sort_order');
.............................
return $sheets;
}
this way plugins can add tabs using the same handler used in the core AND they can easily reproduce core tabsheets in their page with
$tabsheet = new tabsheet('album');
$tabsheet->assign();
(allowing to display others plugins tabs with extra tests)
this method is comptaible with "old shcool" tabs, execpt for those who used "$name" and "$titlename" parameters of tabsheet constructor (I think about grum in AMM)