summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/template.php50
-rw-r--r--lang/de/lang.php1
-rw-r--r--lang/en/lang.php1
3 files changed, 52 insertions, 0 deletions
diff --git a/inc/template.php b/inc/template.php
index ea8b99b6c..7d3765ee0 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -194,6 +194,42 @@ function tpl_link($url,$name,$more=''){
}
/**
+ * 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
*
* Available Buttons are
@@ -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 145be6bcc..c4f65d814 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 d639276d9..49773b594 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';