diff --git a/inc/template.php b/inc/template.php index ea8b99b6c6d0a990b62790b0d3895bfa1e48713b..7d3765ee0b610f2a7e1b89f54657fab84d479400 100644 --- a/inc/template.php +++ b/inc/template.php @@ -193,6 +193,42 @@ function tpl_link($url,$name,$more=''){ print ">$name</a>"; } +/** + * get the parent page + * + * Tries to find out which page is parent. + * returns false if none is available + * + * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> + */ +function tpl_getparent($ID){ + global $conf; + + if ($ID != $conf['start']) { + $idparts = explode(':', $ID); + $pn = array_pop($idparts); // get the page name + + for ($n=0; $n < 2; $n++) { + if (count($idparts) == 0) { + $ID = $conf['start']; // go to topmost page + break; + }else{ + $ns = array_pop($idparts); // get the last part of namespace + if ($pn != $ns) { // are we already home? + array_push($idparts, $ns, $ns); // no, then add a page with same name + $ID = implode (':', $idparts); // as the namespace and recombine $ID + break; + } + } + } + + if (@file_exists(wikiFN($ID))) { + return $ID; + } + } + return false; +} + /** * Print one of the buttons * @@ -205,8 +241,10 @@ function tpl_link($url,$name,$more=''){ * index - The index * admin - admin page - if enough rights * top - a back to top button + * back - a back to parent button - if available * * @author Andreas Gohr <andi@splitbrain.org> + * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> */ function tpl_button($type){ global $ID; @@ -226,6 +264,11 @@ function tpl_button($type){ case 'index': print html_btn(index,$ID,'x',array('do' => 'index')); break; + case 'back': + if ($ID = tpl_getparent($ID)) { + print html_btn(back,$ID,'b',array('do' => 'show')); + } + break; case 'top': print html_topbtn(); break; @@ -259,8 +302,10 @@ function tpl_button($type){ * index - The index * admin - admin page - if enough rights * top - a back to top button + * back - a back to parent button - if available * * @author Andreas Gohr <andi@splitbrain.org> + * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> * @see tpl_button */ function tpl_actionlink($type,$pre='',$suf=''){ @@ -308,6 +353,11 @@ function tpl_actionlink($type,$pre='',$suf=''){ case 'top': print '<a href="#top" class="action" accesskey="x">'.$pre.$lang['btn_top'].$suf.'</a>'; break; + case 'back': + if ($ID = tpl_getparent($ID)) { + tpl_link(wl($ID,'do=show'),$pre.$lang['btn_back'].$suf,'class="action" accesskey="b"'); + } + break; case 'login': if($conf['useacl']){ if($_SERVER['REMOTE_USER']){ diff --git a/lang/de/lang.php b/lang/de/lang.php index 145be6bccdd7651e2ce8a4a1beb08f7815cc5752..c4f65d8147b03be1051b891b7831b6e6c922279f 100644 --- a/lang/de/lang.php +++ b/lang/de/lang.php @@ -31,6 +31,7 @@ $lang['btn_logout'] = 'Abmelden'; $lang['btn_admin'] = 'Admin'; $lang['btn_update'] = 'Updaten'; $lang['btn_delete'] = 'Löschen'; +$lang['btn_back'] = 'Zurück'; $lang['loggedinas'] = 'Angemeldet als'; $lang['user'] = 'Benutzername'; diff --git a/lang/en/lang.php b/lang/en/lang.php index d639276d960ef8a1fa403c8cb71ce1303ea4c728..49773b594681158c93cb80d90838f03a8a61f4e6 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -30,6 +30,7 @@ $lang['btn_logout'] = 'Logout'; $lang['btn_admin'] = 'Admin'; $lang['btn_update'] = 'Update'; $lang['btn_delete'] = 'Delete'; +$lang['btn_back'] = 'Back'; $lang['loggedinas'] = 'Logged in as'; $lang['user'] = 'Username';