Skip to content
Snippets Groups Projects
Commit 768d1852 authored by Anika Henke's avatar Anika Henke
Browse files

refactored tpl_actiondropdown() to avoid duplication

parent ae614416
No related branches found
No related tags found
No related merge requests found
......@@ -1613,6 +1613,12 @@ function tpl_actiondropdown($empty = '', $button = '>') {
/** @var Input $INPUT */
global $INPUT;
$action_structure = array(
'page_tools' => array('edit', 'revert', 'revisions', 'backlink', 'subscribe'),
'site_tools' => array('recent', 'media', 'index'),
'user_tools' => array('login', 'register', 'profile', 'admin'),
);
echo '<form action="'.script().'" method="get" accept-charset="utf-8">';
echo '<div class="no">';
echo '<input type="hidden" name="id" value="'.$ID.'" />';
......@@ -1624,47 +1630,14 @@ function tpl_actiondropdown($empty = '', $button = '&gt;') {
echo '<select name="do" class="edit quickselect" title="'.$lang['tools'].'">';
echo '<option value="">'.$empty.'</option>';
echo '<optgroup label="'.$lang['page_tools'].'">';
$act = tpl_get_action('edit');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('revert');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('revisions');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('backlink');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('subscribe');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
echo '</optgroup>';
echo '<optgroup label="'.$lang['site_tools'].'">';
$act = tpl_get_action('recent');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('media');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('index');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
echo '</optgroup>';
echo '<optgroup label="'.$lang['user_tools'].'">';
$act = tpl_get_action('login');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('register');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('profile');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
$act = tpl_get_action('admin');
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
echo '</optgroup>';
foreach($action_structure as $tools => $actions) {
echo '<optgroup label="'.$lang[$tools].'">';
foreach($actions as $action) {
$act = tpl_get_action($action);
if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>';
}
echo '</optgroup>';
}
echo '</select>';
echo '<button type="submit">'.$button.'</button>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment