summaryrefslogtreecommitdiff
path: root/tpl_functions.php
diff options
context:
space:
mode:
authorAnika Henke <anika@selfthinker.org>2010-12-05 13:01:15 +0000
committerAnika Henke <anika@selfthinker.org>2010-12-05 13:01:15 +0000
commitafe47fae3b5d4dbb4c209df698b72d4f2e716ad7 (patch)
tree2d10ce2685f345ab21c894d6a25d756dcceeb6f1 /tpl_functions.php
parentc21fe1fab827d3d35d3cf59b0f6403f005e86df2 (diff)
downloadrpg-afe47fae3b5d4dbb4c209df698b72d4f2e716ad7.tar.gz
rpg-afe47fae3b5d4dbb4c209df698b72d4f2e716ad7.tar.bz2
made template functions more flexible
* attention: incompatible to previous version! * introduced _tpl_action() (wrapper similar to tpl_action()) * improved discussion and user page functions * made them work independent from config * added full control to how the page links are built (with placeholders @ID@ and @USER@) * config option changes: removed 'discussNSreverse', renamed 'discussionNS' and 'userNS' to 'discussionPage' and 'userPage'
Diffstat (limited to 'tpl_functions.php')
-rw-r--r--tpl_functions.php53
1 files changed, 34 insertions, 19 deletions
diff --git a/tpl_functions.php b/tpl_functions.php
index d258ed38b..fcd50585a 100644
--- a/tpl_functions.php
+++ b/tpl_functions.php
@@ -16,31 +16,26 @@ if (!defined('DOKU_INC')) die();
*
* @author Anika Henke <anika@selfthinker.org>
*/
-function _tpl_discussion($discussNS='discussion',$link=0,$wrapper=0,$reverse=0) {
+function _tpl_discussion($discussionPage,$title,$backTitle,$link=0,$wrapper=0) {
global $ID;
- if ($reverse) {
- $discussPage = $ID.':'.$discussNS;
- $isDiscussPage = substr($ID,-strlen($discussNS),strlen($discussNS))==$discussNS;
- $backID = substr($ID,0,-strlen($discussNS));
- } else {
- $discussPage = $discussNS.':'.$ID;
- $isDiscussPage = substr($ID,0,strlen($discussNS))==$discussNS;
- $backID = strstr($ID,':');
- }
+ $discussPage = str_replace('@ID@',$ID,$discussionPage);
+ $discussPageRaw = str_replace('@ID@','',$discussionPage);
+ $isDiscussPage = strpos($ID,$discussPageRaw)!==false;
+ $backID = str_replace($discussPageRaw,'',$ID);
if ($wrapper) echo "<$wrapper>";
- if($isDiscussPage) {
+ if ($isDiscussPage) {
if ($link)
- tpl_pagelink($backID,tpl_getLang('back_to_article'));
+ tpl_pagelink($backID,$backTitle);
else
- echo html_btn('back2article',$backID,'',array(),0,0,tpl_getLang('back_to_article'));
+ echo html_btn('back2article',$backID,'',array(),0,0,$backTitle);
} else {
if ($link)
- tpl_pagelink($discussPage,tpl_getLang('discussion'));
+ tpl_pagelink($discussPage,$title);
else
- echo html_btn('discussion',$discussPage,'',array(),0,0,tpl_getLang('discussion'));
+ echo html_btn('discussion',$discussPage,'',array(),0,0,$title);
}
if ($wrapper) echo "</$wrapper>";
@@ -51,23 +46,43 @@ function _tpl_discussion($discussNS='discussion',$link=0,$wrapper=0,$reverse=0)
*
* @author Anika Henke <anika@selfthinker.org>
*/
-function _tpl_userpage($userNS='user',$link=0,$wrapper=false) {
+function _tpl_userpage($userPage,$title,$link=0,$wrapper=0) {
if (!$_SERVER['REMOTE_USER']) return;
global $conf;
- $userPage = $userNS.':'.$_SERVER['REMOTE_USER'].':'.$conf['start'];
+ $userPage = str_replace('@USER@',$_SERVER['REMOTE_USER'],$userPage);
if ($wrapper) echo "<$wrapper>";
if ($link)
- tpl_pagelink($userPage,tpl_getLang('userpage'));
+ tpl_pagelink($userPage,$title);
else
- echo html_btn('userpage',$userPage,'',array(),0,0,tpl_getLang('userpage'));
+ echo html_btn('userpage',$userPage,'',array(),0,0,$title);
if ($wrapper) echo "</$wrapper>";
}
/**
+ * Wrapper around custom template actions
+ *
+ * @author Anika Henke <anika@selfthinker.org>
+ */
+function _tpl_action($type,$link=0,$wrapper=0) {
+ switch ($type) {
+ case 'discussion':
+ if (tpl_getConf('discussionPage')) {
+ _tpl_discussion(tpl_getConf('discussionPage'),tpl_getLang('discussion'),tpl_getLang('back_to_article'),$link,$wrapper);
+ }
+ break;
+ case 'userpage':
+ if (tpl_getConf('userPage')) {
+ _tpl_userpage(tpl_getConf('userPage'),tpl_getLang('userpage'),$link,$wrapper);
+ }
+ break;
+ }
+}
+
+/**
* Use favicon.ico from data/media root directory if it exists, otherwise use
* the one in the template's image directory.
*