Merged revision(s) 16928 from trunk:

feature 2703: make it easy for plugins to add tabs in admin screens
centralize all core tabs in one file


git-svn-id: http://piwigo.org/svn/branches/2.4@16929 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
mistic100 2012-07-23 11:52:18 +00:00
parent 798de81516
commit 18bf888d16
20 changed files with 170 additions and 180 deletions

View file

@ -31,6 +31,7 @@ define('IN_ADMIN', true);
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
include_once(PHPWG_ROOT_PATH.'admin/include/functions_plugins.inc.php');
include_once(PHPWG_ROOT_PATH.'admin/include/add_core_tabs.inc.php');
trigger_action('loc_begin_admin');

View file

@ -63,10 +63,6 @@ if (isset($_GET['tab']))
$tabsheet = new tabsheet();
$tabsheet->set_id('album');
$tabsheet->add('properties', l10n('Properties'), $admin_album_base_url.'-properties');
$tabsheet->add('sort_order', l10n('Manage photo ranks'), $admin_album_base_url.'-sort_order');
$tabsheet->add('permissions', l10n('Permissions'), $admin_album_base_url.'-permissions');
$tabsheet->add('notification', l10n('Notification'), $admin_album_base_url.'-notification');
$tabsheet->select($page['tab']);
$tabsheet->assign();

View file

@ -350,22 +350,7 @@ else
// +-----------------------------------------------------------------------+
// | Tabs |
// +-----------------------------------------------------------------------+
$tabs = array(
array(
'code' => 'global',
'label' => l10n('global mode'),
),
array(
'code' => 'unit',
'label' => l10n('unit mode'),
),
);
$tab_codes = array_map(
create_function('$a', 'return $a["code"];'),
$tabs
);
$manager_link = get_root_url().'admin.php?page=batch_manager&mode=';
if (isset($_GET['mode']))
{
@ -373,23 +358,13 @@ if (isset($_GET['mode']))
}
else
{
$page['tab'] = $tabs[0]['code'];
$page['tab'] = 'global';
}
if (in_array($page['tab'], $tab_codes))
{
$tabsheet = new tabsheet();
$tabsheet->set_id('batch_manager');
foreach ($tabs as $tab)
{
$tabsheet->add(
$tab['code'],
$tab['label'],
get_root_url().'admin.php?page='.$_GET['page'].'&mode='.$tab['code']
);
}
$tabsheet->select($page['tab']);
$tabsheet->assign();
$tabsheet = new tabsheet();
$tabsheet->set_id('batch_manager');
$tabsheet->select($page['tab']);
$tabsheet->assign();
// +-----------------------------------------------------------------------+
// | tags |
@ -405,6 +380,5 @@ $template->assign('tags', get_taglist($query, false));
// | open specific mode |
// +-----------------------------------------------------------------------+
include(PHPWG_ROOT_PATH.'admin/batch_manager_'.$page['tab'].'.php');
}
include(PHPWG_ROOT_PATH.'admin/batch_manager_'.$page['tab'].'.php');
?>

View file

@ -139,21 +139,7 @@ $template->assign(
// TabSheet
$tabsheet = new tabsheet();
$tabsheet->set_id('cat_options');
// TabSheet initialization
$opt_link = $link_start.'cat_options&section=';
$tabsheet->add('status', l10n('Public / Private'), $opt_link.'status');
$tabsheet->add('visible', l10n('Lock'), $opt_link.'visible');
if ($conf['activate_comments'])
{
$tabsheet->add('comments', l10n('Comments'), $opt_link.'comments');
}
if ($conf['allow_random_representative'])
{
$tabsheet->add('representative', l10n('Representative'), $opt_link.'representative');
}
// TabSheet selection
$tabsheet->select($page['section']);
// Assign tabsheet to template
$tabsheet->assign();
// +-----------------------------------------------------------------------+

View file

@ -99,7 +99,6 @@ include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
$tabsheet = new tabsheet();
$tabsheet->set_id('comments');
$tabsheet->add('', l10n('User comments validation'), '');
$tabsheet->select('');
$tabsheet->assign();

View file

@ -287,16 +287,7 @@ $template->set_filename('config', 'configuration.tpl');
// TabSheet
$tabsheet = new tabsheet();
$tabsheet->set_id('configuration');
// TabSheet initialization
$tabsheet->add('main', l10n('Main'), $conf_link.'main');
$tabsheet->add('sizes', l10n('Photo sizes'), $conf_link.'sizes');
$tabsheet->add('watermark', l10n('Watermark'), $conf_link.'watermark');
$tabsheet->add('display', l10n('Display'), $conf_link.'display');
$tabsheet->add('comments', l10n('Comments'), $conf_link.'comments');
$tabsheet->add('default', l10n('Guest Settings'), $conf_link.'default');
// TabSheet selection
$tabsheet->select($page['section']);
// Assign tabsheet to template
$tabsheet->assign();
$action = get_root_url().'admin.php?page=configuration';

View file

@ -29,54 +29,20 @@ include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
// +-----------------------------------------------------------------------+
check_status(ACCESS_ADMINISTRATOR);
$link = get_root_url().'admin.php?page=help&section=';
$help_link = get_root_url().'admin.php?page=help&section=';
$selected = null;
$help_section_title = null;
$tabs = array();
$tabs[] = array(
'code' => 'add_photos',
'label' => l10n('Add Photos'),
);
$tabs[] = array(
'code' => 'permissions',
'label' => l10n('Permissions'),
);
$tabs[] = array(
'code' => 'groups',
'label' => l10n('Groups'),
);
$tabs[] = array(
'code' => 'virtual_links',
'label' => l10n('Virtual Links'),
);
$tabs[] = array(
'code' => 'misc',
'label' => l10n('Miscellaneous'),
);
if (!isset($_GET['section']))
{
$section = $tabs[0]['code'];
$selected = 'add_photos';
}
else
{
$section = $_GET['section'];
$selected = $_GET['section'];
}
$tabsheet = new tabsheet();
$tabsheet->set_id('help');
foreach ($tabs as $tab)
{
if ($tab['code'] == $section)
{
$selected_tab = $tab['code'];
$help_section_title = $tab['label'];
}
$tabsheet->add($tab['code'], $tab['label'], $link.$tab['code']);
}
$tabsheet->select($selected_tab);
$tabsheet->assign();
$template->set_filenames(array('help' => 'help.tpl'));
@ -84,11 +50,11 @@ $template->set_filenames(array('help' => 'help.tpl'));
$template->assign(
array(
'HELP_CONTENT' => load_language(
'help/help_'.$selected_tab.'.html',
'help/help_'.$tabsheet->selected.'.html',
'',
array('return'=>true)
),
'HELP_SECTION_TITLE' => $help_section_title,
'HELP_SECTION_TITLE' => $tabsheet->sheets[ $tabsheet->selected ]['caption'],
)
);

View file

@ -0,0 +1,147 @@
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | 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 |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
add_event_handler('tabsheet_before_select', 'add_core_tabs', 0, 2);
function add_core_tabs($sheets, $tab_id)
{
switch($tab_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');
$sheets['permissions'] = array('caption' => l10n('Permissions'), 'url' => $admin_album_base_url.'-permissions');
$sheets['notification'] = array('caption' => l10n('Notification'), 'url' => $admin_album_base_url.'-notification');
break;
case 'albums':
global $my_base_url;
$sheets['list'] = array('caption' => l10n('List'), 'url' => $my_base_url.'cat_list');
$sheets['move'] = array('caption' => l10n('Move'), 'url' => $my_base_url.'cat_move');
$sheets['permalinks'] = array('caption' => l10n('Permalinks'), 'url' => $my_base_url.'permalinks');
break;
case 'batch_manager':
global $manager_link;
$sheets['global'] = array('caption' => l10n('global mode'), 'url' => $manager_link.'global');
$sheets['unit'] = array('caption' => l10n('unit mode'), 'url' => $manager_link.'unit');
break;
case 'cat_options':
global $link_start, $conf;
$sheets['status'] = array('caption' => l10n('Public / Private'), 'url' => $link_start.'cat_options&amp;section=status');
$sheets['visible'] = array('caption' => l10n('Lock'), 'url' => $link_start.'cat_options&amp;section=visible');
if ($conf['activate_comments'])
$sheets['comments'] = array('caption' => l10n('Comments'), 'url' => $link_start.'cat_options&amp;section=comments');
if ($conf['allow_random_representative'])
$sheets['representative'] = array('caption' => l10n('Representative'), 'url' => $link_start.'cat_options&amp;section=representative');
break;
case 'comments':
$sheets[''] = array('caption' => l10n('User comments validation'), 'url' => '');
break;
case 'configuration':
global $conf_link;
$sheets['main'] = array('caption' => l10n('Main'), 'url' => $conf_link.'main');
$sheets['sizes'] = array('caption' => l10n('Photo sizes'), 'url' => $conf_link.'sizes');
$sheets['watermark'] = array('caption' => l10n('Watermark'), 'url' => $conf_link.'watermark');
$sheets['display'] = array('caption' => l10n('Display'), 'url' => $conf_link.'display');
$sheets['comments'] = array('caption' => l10n('Comments'), 'url' => $conf_link.'comments');
$sheets['default'] = array('caption' => l10n('Guest Settings'), 'url' => $conf_link.'default');
break;
case 'help':
global $help_link;
$sheets['add_photos'] = array('caption' => l10n('Add Photos'), 'url' => $help_link.'add_photos');
$sheets['permissions'] = array('caption' => l10n('Permissions'), 'url' => $help_link.'permissions');
$sheets['groups'] = array('caption' => l10n('Groups'), 'url' => $help_link.'groups');
$sheets['virtual_links'] = array('caption' => l10n('Virtual Links'), 'url' => $help_link.'virtual_links');
$sheets['misc'] = array('caption' => l10n('Miscellaneous'), 'url' => $help_link.'misc');
break;
case 'history':
global $link_start;
$sheets['stats'] = array('caption' => l10n('Statistics'), 'url' => $link_start.'stats');
$sheets['history'] = array('caption' => l10n('Search'), 'url' => $link_start.'history');
break;
case 'languages':
global $my_base_url;
$sheets['installed'] = array('caption' => l10n('Installed Languages'), 'url' => $my_base_url.'&amp;tab=installed');
$sheets['update'] = array('caption' => l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
$sheets['new'] = array('caption' => l10n('Add New Language'), 'url' => $my_base_url.'&amp;tab=new');
break;
case 'nbm':
global $base_url;
$sheets['param'] = array('caption' => l10n('Parameter'), 'url' => $base_url.'?page=notification_by_mail&amp;mode=param');
$sheets['subscribe'] = array('caption' => l10n('Subscribe'), 'url' => $base_url.'?page=notification_by_mail&amp;mode=subscribe');
$sheets['send'] = array('caption' => l10n('Send'), 'url' => $base_url.'?page=notification_by_mail&amp;mode=send');
break;
case 'photo':
global $admin_photo_base_url;
$sheets['properties'] = array('caption' => l10n('Properties'), 'url' => $admin_photo_base_url.'-properties');
$sheets['coi'] = array('caption' => l10n('Center of interest'), 'url' => $admin_photo_base_url.'-coi');
break;
case 'photos_add':
global $conf;
$sheets['direct'] = array('caption' => l10n('Web Form'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=direct');
$sheets['applications'] = array('caption' => l10n('Applications'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=applications');
if ($conf['enable_synchronization'])
$sheets['ftp'] = array('caption' => l10n('FTP + Synchronization'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=ftp');
break;
case 'plugins':
global $my_base_url;
$sheets['installed'] = array('caption' => l10n('Plugin list'), 'url' => $my_base_url.'&amp;tab=installed');
$sheets['update'] = array('caption' => l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
$sheets['new'] = array('caption' => l10n('Other plugins'), 'url' => $my_base_url.'&amp;tab=new');
break;
case 'rating':
$sheets['rating'] = array('caption' => l10n('Photos'), 'url' => get_root_url().'admin.php?page=rating');
$sheets['rating_user'] = array('caption' => l10n('Users'), 'url' => get_root_url().'admin.php?page=rating_user');
break;
case 'themes':
global $my_base_url;
$sheets['installed'] = array('caption' => l10n('Installed Themes'), 'url' => $my_base_url.'&amp;tab=installed');
$sheets['update'] = array('caption' => l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
$sheets['new'] = array('caption' => l10n('Add New Theme'), 'url' => $my_base_url.'&amp;tab=new');
break;
case 'updates':
global $my_base_url;
$sheets['pwg'] = array('caption' => l10n('Piwigo Update'), 'url' => $my_base_url);
$sheets['ext'] = array('caption' => l10n('Extensions Update'), 'url' => $my_base_url.'&amp;tab=ext');
break;
}
return $sheets;
}
?>

View file

@ -26,10 +26,7 @@ include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
$my_base_url = get_root_url().'admin.php?page=';
$tabsheet = new tabsheet();
$tabsheet->set_id('cat_list');
$tabsheet->add('list', l10n('List'), $my_base_url.'cat_list');
$tabsheet->add('move', l10n('Move'), $my_base_url.'cat_move');
$tabsheet->add('permalinks', l10n('Permalinks'), $my_base_url.'permalinks');
$tabsheet->set_id('albums');
$tabsheet->select($page['tab']);
$tabsheet->assign();

View file

@ -30,12 +30,7 @@ function history_tabsheet()
// TabSheet
$tabsheet = new tabsheet();
$tabsheet->set_id('history');
// TabSheet initialization
$tabsheet->add('stats', l10n('Statistics'), $link_start.'stats');
$tabsheet->add('history', l10n('Search'), $link_start.'history');
// TabSheet selection
$tabsheet->select($page['page']);
// Assign tabsheet to template
$tabsheet->assign();
}

View file

@ -89,6 +89,11 @@ class tabsheet
function select($name)
{
$this->sheets = trigger_event('tabsheet_before_select', $this->sheets, $this->uniqid);
if (!array_key_exists($name, $this->sheets))
{
$keys = array_keys($this->sheets);
$name = $keys[0];
}
$this->selected = $name;
}

View file

@ -35,11 +35,7 @@ if (isset($_GET['tab']))
else
$page['tab'] = 'installed';
$tabsheet = new tabsheet();
$tabsheet->set_id('languages');
$tabsheet->add('installed', l10n('Installed Languages'), $my_base_url.'&amp;tab=installed');
$tabsheet->add('update', l10n('Check for updates'), $my_base_url.'&amp;tab=update');
$tabsheet->add('new', l10n('Add New Language'), $my_base_url.'&amp;tab=new');
$tabsheet = new tabsheet('languages');
$tabsheet->select($page['tab']);
$tabsheet->assign();

View file

@ -589,19 +589,7 @@ if (is_autorize_status(ACCESS_WEBMASTER))
// TabSheet
$tabsheet = new tabsheet();
$tabsheet->set_id('nbm');
// TabSheet initialization
$tabsheet->add('param', l10n('Parameter'),
add_url_params($base_url.get_query_string_diff(array('mode', 'select')),
array('mode' => 'param')));
$tabsheet->add('subscribe', l10n('Subscribe'),
add_url_params($base_url.get_query_string_diff(array('mode', 'select')),
array('mode' => 'subscribe')));
$tabsheet->add('send', l10n('Send'),
add_url_params($base_url.get_query_string_diff(array('mode', 'select')),
array('mode' => 'send')));
// TabSheet selection
$tabsheet->select($page['mode']);
// Assign tabsheet to template
$tabsheet->assign();
}

View file

@ -62,9 +62,6 @@ if (isset($_GET['tab']))
$tabsheet = new tabsheet();
$tabsheet->set_id('photo');
$tabsheet->add('properties', l10n('Properties'), $admin_photo_base_url.'-properties');
$tabsheet->add('coi', l10n('Center of interest'), $admin_photo_base_url.'-coi');
$tabsheet->select($page['tab']);
$tabsheet->assign();

View file

@ -49,53 +49,17 @@ $upload_form_config = get_upload_form_config();
// +-----------------------------------------------------------------------+
// | Tabs |
// +-----------------------------------------------------------------------+
$tabs = array(
array(
'code' => 'direct',
'label' => l10n('Web Form'),
),
array(
'code' => 'applications',
'label' => l10n('Applications'),
),
);
if ($conf['enable_synchronization'])
{
array_push(
$tabs,
array(
'code' => 'ftp',
'label' => l10n('FTP + Synchronization'),
)
);
}
$tab_codes = array_map(
create_function('$a', 'return $a["code"];'),
$tabs
);
if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes))
if (isset($_GET['section']))
{
$page['tab'] = $_GET['section'];
}
else
{
$page['tab'] = $tabs[0]['code'];
$page['tab'] = 'direct';
}
$tabsheet = new tabsheet();
$tabsheet->set_id('photos_add');
foreach ($tabs as $tab)
{
$tabsheet->add(
$tab['code'],
$tab['label'],
PHOTOS_ADD_BASE_URL.'&amp;section='.$tab['code']
);
}
$tabsheet->select($page['tab']);
$tabsheet->assign();

View file

@ -37,9 +37,6 @@ else
$tabsheet = new tabsheet();
$tabsheet->set_id('plugins');
$tabsheet->add('installed', l10n('Plugin list'), $my_base_url.'&amp;tab=installed');
$tabsheet->add('update', l10n('Check for updates'), $my_base_url.'&amp;tab=update');
$tabsheet->add('new', l10n('Other plugins'), $my_base_url.'&amp;tab=new');
$tabsheet->select($page['tab']);
$tabsheet->assign();

View file

@ -37,8 +37,6 @@ check_status(ACCESS_ADMINISTRATOR);
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
$tabsheet = new tabsheet();
$tabsheet->set_id('rating');
$tabsheet->add('rating', l10n('Photos'), get_root_url().'admin.php?page=rating');
$tabsheet->add('rating_user', l10n('Users'), get_root_url().'admin.php?page=rating_user');
$tabsheet->select('rating');
$tabsheet->assign();

View file

@ -26,8 +26,6 @@ defined('PHPWG_ROOT_PATH') or die ("Hacking attempt!");
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
$tabsheet = new tabsheet();
$tabsheet->set_id('rating');
$tabsheet->add('rating', l10n('Photos'), get_root_url().'admin.php?page=rating');
$tabsheet->add('rating_user', l10n('Users'), get_root_url().'admin.php?page=rating_user');
$tabsheet->select('rating_user');
$tabsheet->assign();

View file

@ -37,9 +37,6 @@ else
$tabsheet = new tabsheet();
$tabsheet->set_id('themes');
$tabsheet->add('installed', l10n('Installed Themes'), $my_base_url.'&amp;tab=installed');
$tabsheet->add('update', l10n('Check for updates'), $my_base_url.'&amp;tab=update');
$tabsheet->add('new', l10n('Add New Theme'), $my_base_url.'&amp;tab=new');
$tabsheet->select($page['tab']);
$tabsheet->assign();

View file

@ -33,10 +33,8 @@ if (isset($_GET['tab']))
else
$page['tab'] = 'pwg';
$tabsheet = new tabsheet();
$tabsheet = new tabsheet();
$tabsheet->set_id('updates');
$tabsheet->add('pwg', l10n('Piwigo Update'), $my_base_url);
$tabsheet->add('ext', l10n('Extensions Update'), $my_base_url.'&amp;tab=ext');
$tabsheet->select($page['tab']);
$tabsheet->assign();