You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.3 KiB

14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. <?php
  2. /**
  3. * Template Functions
  4. *
  5. * This file provides template specific custom functions that are
  6. * not provided by the DokuWiki core.
  7. * It is common practice to start each function with an underscore
  8. * to make sure it won't interfere with future core functions.
  9. */
  10. // must be run from within DokuWiki
  11. if (!defined('DOKU_INC')) die();
  12. /**
  13. * Create link/button to discussion page and back
  14. *
  15. * @author Anika Henke <anika@selfthinker.org>
  16. */
  17. function _tpl_discussion($discussNS='discussion',$link=0,$wrapper=0,$reverse=0) {
  18. global $ID;
  19. if ($reverse) {
  20. $discussPage = $ID.':'.$discussNS;
  21. $isDiscussPage = substr($ID,-strlen($discussNS),strlen($discussNS))==$discussNS;
  22. $backID = substr($ID,0,-strlen($discussNS));
  23. } else {
  24. $discussPage = $discussNS.':'.$ID;
  25. $isDiscussPage = substr($ID,0,strlen($discussNS))==$discussNS;
  26. $backID = strstr($ID,':');
  27. }
  28. if ($wrapper) echo "<$wrapper>";
  29. if($isDiscussPage) {
  30. if ($link)
  31. tpl_pagelink($backID,tpl_getLang('back_to_article'));
  32. else
  33. echo html_btn('back2article',$backID,'',array(),0,0,tpl_getLang('back_to_article'));
  34. } else {
  35. if ($link)
  36. tpl_pagelink($discussPage,tpl_getLang('discussion'));
  37. else
  38. echo html_btn('discussion',$discussPage,'',array(),0,0,tpl_getLang('discussion'));
  39. }
  40. if ($wrapper) echo "</$wrapper>";
  41. }
  42. /**
  43. * Create link/button to user page
  44. *
  45. * @author Anika Henke <anika@selfthinker.org>
  46. */
  47. function _tpl_userpage($userNS='user',$link=0,$wrapper=false) {
  48. if (!$_SERVER['REMOTE_USER']) return;
  49. global $conf;
  50. $userPage = $userNS.':'.$_SERVER['REMOTE_USER'].':'.$conf['start'];
  51. if ($wrapper) echo "<$wrapper>";
  52. if ($link)
  53. tpl_pagelink($userPage,tpl_getLang('userpage'));
  54. else
  55. echo html_btn('userpage',$userPage,'',array(),0,0,tpl_getLang('userpage'));
  56. if ($wrapper) echo "</$wrapper>";
  57. }
  58. /**
  59. * Use favicon.ico from data/media root directory if it exists, otherwise use
  60. * the one in the template's image directory.
  61. *
  62. * @author Anika Henke <anika@selfthinker.org>
  63. */
  64. function _tpl_getFavicon() {
  65. if (file_exists(mediaFN('favicon.ico')))
  66. return ml('favicon.ico');
  67. return DOKU_TPL.'images/favicon.ico';
  68. }