diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-08-17 22:38:41 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-08-17 22:38:41 +0200 |
commit | a00de5b59af578ac2c2a88d06027a06fc0d9ae1d (patch) | |
tree | 1e845c5664dce59afcd019da0dd026c7d9797b6a | |
parent | 7d3c8d4263d48bd16be068d3b134f70451afac94 (diff) | |
download | rpg-a00de5b59af578ac2c2a88d06027a06fc0d9ae1d.tar.gz rpg-a00de5b59af578ac2c2a88d06027a06fc0d9ae1d.tar.bz2 |
tpl_actiondropdown added
This new template function allows a dropdown menu to be used to access all
the DokuWiki do actions with minimal space requirement.
darcs-hash:20080817203841-7ad00-f267285a3e9f119c5aaaf73ca276e3a2f1f72a94.gz
-rw-r--r-- | inc/template.php | 100 | ||||
-rw-r--r-- | lib/scripts/script.js | 17 |
2 files changed, 117 insertions, 0 deletions
diff --git a/inc/template.php b/inc/template.php index c3cfe21f2..9a874530d 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1157,4 +1157,104 @@ function tpl_mediaTree(){ ptln('</div>'); } + +/** + * Print a dropdown menu with all DokuWiki actions + * + * Note: this will not use any pretty URLs + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tpl_actiondropdown($empty='',$button='>'){ + global $ID; + global $INFO; + global $REV; + global $ACT; + global $conf; + global $lang; + global $auth; + + + echo '<form method="post" accept-charset="utf-8">'; #FIXME action + 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=" — ">'; + // 'edit' - most complicated type, we need to decide on current action + if($ACT == 'show' || $ACT == 'search'){ + if($INFO['writable']){ + if(!empty($INFO['draft'])) { + echo '<option value="edit">'.$lang['btn_draft'].'</option>'; + } else { + if($INFO['exists']){ + echo '<option value="edit">'.$lang['btn_edit'].'</option>'; + }else{ + echo '<option value="edit">'.$lang['btn_create'].'</option>'; + } + } + }else if(actionOK('source')) { //pseudo action + echo '<option value="edit">'.$lang['btn_source'].'</option>'; + } + }else{ + echo '<option value="show">'.$lang['btn_show'].'</option>'; + } + + echo '<option value="revisions">'.$lang['btn_revs'].'</option>'; + echo '<option value="backlink">'.$lang['btn_backlink'].'</option>'; + echo '</optgroup>'; + + echo '<optgroup label=" — ">'; + echo '<option value="recent">'.$lang['btn_recent'].'</option>'; + echo '<option value="index">'.$lang['btn_index'].'</option>'; + echo '</optgroup>'; + + echo '<optgroup label=" — ">'; + if($conf['useacl'] && $auth){ + if($_SERVER['REMOTE_USER']){ + echo '<option value="logout">'.$lang['btn_logout'].'</option>'; + }else{ + echo '<option value="login">'.$lang['btn_login'].'</option>'; + } + } + + if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && + $auth->canDo('Profile') && ($ACT!='profile')){ + echo '<option value="profile">'.$lang['btn_profile'].'</option>'; + } + + if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ + if($_SERVER['REMOTE_USER']){ + if($INFO['subscribed']) { + echo '<option value="unsubscribe">'.$lang['btn_unsubscribe'].'</option>'; + } else { + echo '<option value="subscribe">'.$lang['btn_subscribe'].'</option>'; + } + } + } + + if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ + if($_SERVER['REMOTE_USER']){ + if($INFO['subscribedns']) { + echo '<option value="unsubscribens">'.$lang['btn_unsubscribens'].'</option>'; + } else { + echo '<option value="subscribens">'.$lang['btn_subscribens'].'</option>'; + } + } + } + + if($INFO['ismanager']){ + echo '<option value="admin">'.$lang['btn_admin'].'</option>'; + } + echo '</optgroup>'; + + echo '</select>'; + echo '<input type="submit" value="'.$button.'" id="action__selectorbtn" />'; + echo '</form>'; +} + //Setup VIM: ex: et ts=4 enc=utf-8 : + diff --git a/lib/scripts/script.js b/lib/scripts/script.js index fd2679f01..8a5770f16 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -501,3 +501,20 @@ function cleanMsgArea(){ } } } + +/** + * Add the event handler to the actiondropdown + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +addInitEvent(function(){ + var selector = $('action__selector'); + if(!selector) return; + + addEvent(selector,'change',function(e){ + this.form.submit(); + }); + + $('action__selectorbtn').style.display = 'none'; +}); + |