Example #1
0
/**
 * Print a dropdown menu with all DokuWiki actions
 *
 * Note: this will not use any pretty URLs
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function tpl_actiondropdown($empty = '', $button = '&gt;')
{
    global $ID;
    global $REV;
    global $lang;
    echo '<form action="' . DOKU_SCRIPT . '" method="post" accept-charset="utf-8">';
    echo '<div class="no">';
    echo '<input type="hidden" name="id" value="' . $ID . '" />';
    if ($REV) {
        echo '<input type="hidden" name="rev" value="' . $REV . '" />';
    }
    echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />';
    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>';
    echo '</select>';
    echo '<input type="submit" value="' . $button . '" />';
    echo '</div>';
    echo '</form>';
}
Example #2
0
/**
 * Print a dropdown menu with all DokuWiki actions
 *
 * Note: this will not use any pretty URLs
 *
 * @author Andreas Gohr <*****@*****.**>
 *
 * @param string $empty empty option label
 * @param string $button submit button label
 */
function tpl_actiondropdown($empty = '', $button = '&gt;')
{
    global $ID;
    global $REV;
    global $lang;
    /** @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 . '" />';
    if ($REV) {
        echo '<input type="hidden" name="rev" value="' . $REV . '" />';
    }
    if ($INPUT->server->str('REMOTE_USER')) {
        echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />';
    }
    echo '<select name="do" class="edit quickselect" title="' . $lang['tools'] . '">';
    echo '<option value="">' . $empty . '</option>';
    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>';
    echo '</div>';
    echo '</form>';
}
function _mixture_actionlink($type, $pre = '', $inner = '', $context = null, $return = true, $button = false)
{
    global $lang, $uhp;
    $data = tpl_get_action($type);
    if (!is_array($data)) {
        if ($type == 'home') {
            $target = explode("=", wl())[1];
            $label = tpl_getLang('wikihome');
        } elseif ($type == 'userpublic' and isset($uhp['public']['id'])) {
            // Without Userhomepage plugin, Public Page namespace is set by 'user' value in 'conf/interwiki.conf'
            $target = $uhp['public']['id'];
            if (isset($uhp['public']['string'])) {
                $label = $uhp['public']['string'];
            } else {
                $label = tpl_getLang('userpublic');
            }
            // Currently, Mixture only manages user's private namespace generated by Userhomepage plugin
        } elseif ($type == 'userprivate' and isset($uhp['private']['id'])) {
            $target = $uhp['private']['id'];
            $label = $uhp['private']['string'];
        } else {
            $target = null;
        }
        if ($target != null) {
            if ($button != false) {
                $classes = 'btn ' . $button;
                $modLabel = null;
            } else {
                $classes = 'action ' . $type . _mixture_menuitem_classes($type);
                $modLabel = _mixture_menuitem_string($label, $context);
            }
            $out = tpl_link(wl($target), _mixture_glyph($type, $context, $button) . $modLabel, 'class="' . $classes . '" title="' . $label . ' (' . $target . ')"', true);
        } else {
            return false;
        }
    } else {
        /**
         * $data array content:
         * @var string $accesskey
         * @var string $id
         * @var string $method
         * @var bool   $nofollow
         * @var array  $params
         * @var string $replacement
         */
        extract($data);
        if (strpos($id, '#') === 0) {
            $linktarget = $id;
        } else {
            $linktarget = wl($id, $params);
        }
        $caption = $lang['btn_' . $type];
        /*
        if(strpos($caption, '%s')){
            $caption = sprintf($caption, $replacement);
        }
        */
        $akey = $addTitle = '';
        if ($accesskey) {
            $akey = 'accesskey="' . $accesskey . '" ';
            $addTitle = ' [' . strtoupper($accesskey) . ']';
        }
        $rel = $nofollow ? 'rel="nofollow" ' : '';
        if ($button != false) {
            $classes = 'btn ' . $button;
            $modLabel = _mixture_glyph($type, $context, $button);
        } else {
            $classes = 'action ' . $type . _mixture_menuitem_classes($type);
            $modLabel = _mixture_menuitem_string($inner ? $inner : $caption, $context);
        }
        $out = tpl_link($linktarget, $pre . $modLabel . $suf, 'class="' . $classes . '" ' . $akey . $rel . 'title="' . hsc($caption) . $addTitle . '"', true);
    }
    if ($return) {
        return $out;
    }
    echo $out;
    return true;
}
Example #4
0
/**
 * Print a dropdown menu with all DokuWiki actions
 *
 * Note: this will not use any pretty URLs
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function tpl_actiondropdown($empty = '', $button = '&gt;')
{
    global $ID;
    global $INFO;
    global $REV;
    global $ACT;
    global $conf;
    global $lang;
    global $auth;
    echo '<form action="' . DOKU_SCRIPT . '" method="post" accept-charset="utf-8">';
    echo '<input type="hidden" name="id" value="' . $ID . '" />';
    if ($REV) {
        echo '<input type="hidden" name="rev" value="' . $REV . '" />';
    }
    echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />';
    echo '<select name="do" id="action__selector" class="edit">';
    echo '<option value="">' . $empty . '</option>';
    echo '<optgroup label=" &mdash; ">';
    $act = tpl_get_action('edit');
    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('revert');
    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>';
    }
    echo '</optgroup>';
    echo '<optgroup label=" &mdash; ">';
    $act = tpl_get_action('recent');
    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=" &mdash; ">';
    $act = tpl_get_action('login');
    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('subscribe');
    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>';
    echo '</select>';
    echo '<input type="submit" value="' . $button . '" id="action__selectorbtn" />';
    echo '</form>';
}
Example #5
0
/**
 * Like the action buttons but links
 *
 * @author Adrian Lang <*****@*****.**>
 * @see    tpl_get_action
 */
function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = false)
{
    global $lang;
    $data = tpl_get_action($type);
    if ($data === false) {
        return false;
    } elseif (!is_array($data)) {
        $out = sprintf($data, 'link');
    } else {
        extract($data);
        if (strpos($id, '#') === 0) {
            $linktarget = $id;
        } else {
            $linktarget = wl($id, $params);
        }
        $caption = $lang['btn_' . $type];
        $out = tpl_link($linktarget, $pre . ($inner ? $inner : $caption) . $suf, 'class="action ' . $type . '" ' . 'accesskey="' . $accesskey . '" rel="nofollow" ' . 'title="' . hsc($caption) . '"', 1);
    }
    if ($return) {
        return $out;
    }
    echo $out;
    return true;
}