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.
 
 
 
 
 

208 lines
5.6 KiB

  1. <?php
  2. /**
  3. * Provide navigation sidebar functionality to Dokuwiki Templates
  4. *
  5. * @author Christopher Smith <chris@jalakai.co.uk>
  6. * @author Esther Brunner <wikidesign@gmail.com>
  7. * @author Don Bowman <don@lynsoft.co.uk>
  8. */
  9. /**
  10. * Recursive function to establish best sidebar file to be used
  11. */
  12. function getSidebarFN($ns, $file) {//func
  13. /****** check for wiki page = $ns:$file (or $file where no namespace) ******/
  14. $nsFile = ($ns) ? "$ns:$file" : $file;
  15. if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($nsFile))
  16. return $nsFile;
  17. /****** no namespace left, exit with no file found ******/
  18. if (!$ns)
  19. return '';
  20. /****** remove deepest namespace level and call function recursively ******/
  21. $i = strrpos($ns, ":");
  22. $ns = ($i) ? substr($ns, 0, $i) : false;
  23. return getSidebarFN($ns, $file);
  24. }//function getSidebarFN($ns, $file)
  25. /**
  26. * Display the sidebar
  27. */
  28. function minima_sidebar() {//func
  29. /****** declare global variables ******/
  30. global $ID, $REV, $ACT, $conf;
  31. /****** save global variables ******/
  32. $saveID = $ID;
  33. $saveREV = $REV;
  34. // $saveACT = $ACT;
  35. /****** find file to be displayed in navigation sidebar ******/
  36. $sidebar = tpl_getConf('sidebar_page');
  37. $fileSidebar = getSidebarFN(getNS($ID), $sidebar);
  38. /****** show main sidebar if necessary ******/
  39. if (tpl_getConf('minima_main_sidebar') && $fileSidebar != $sidebar) {//do
  40. $ID = $sidebar;
  41. $REV = '';
  42. echo p_wiki_xhtml($ID, $REV, false);
  43. // $ACT = 'show';
  44. // tpl_content(false);
  45. echo "<hr>";
  46. }//if (tpl_getConf('minima_main_sidebar') && $fileSidebar != $sidebar)
  47. /****** show current sidebar ******/
  48. if ($fileSidebar) {//do
  49. $ID = $fileSidebar;
  50. $REV = '';
  51. echo p_wiki_xhtml($ID, $REV, false);
  52. // $ACT = 'show';
  53. // tpl_content(false);
  54. }//if ($fileSidebar)
  55. /****** show index ******/
  56. else {//if (!$fileSidebar)
  57. // $REV = '';
  58. // $ACT = 'index';
  59. global $IDX;
  60. html_index($IDX);
  61. // tpl_content(false);
  62. }//if (!$fileSidebar)
  63. /****** restore global variables ******/
  64. $ID = $saveID;
  65. $REV = $saveREV;
  66. // $ACT = $saveACT;
  67. }//function minima_sidebar()
  68. /**
  69. * Return the correct ID for <div class="dokuwiki">
  70. */
  71. function minima_classID() {//func
  72. echo 'minima__'.tpl_getConf('width').'_'.tpl_getConf('sidebar_position');
  73. }//function minima_classID()
  74. /**
  75. * Checks if the color scheme has changed
  76. */
  77. function minima_checkColor() {//func
  78. /****** set local variables ******/
  79. $color = tpl_getConf('color');
  80. $file = tpl_incdir().'style.ini';
  81. $file2 = tpl_incdir().'style_'.$color.'.ini';
  82. $ini = parse_ini_file($file);
  83. /****** change theme as requested ******/
  84. if ($ini['__theme__'] != '_'.$color) {//do
  85. if ((@file_exists($file2)) && (@unlink($file)) && (@copy($file2, $file))) {//do
  86. global $conf;
  87. if ($conf['fperm']) chmod($file, $conf['fperm']);
  88. }//if ((@file_exists($file2)) && (@unlink($file)) && (@copy($file2, $file)))
  89. else {//if not ((@file_exists($file2)) && (@unlink($file)) && (@copy($file2, $file)))
  90. msg('Could not set correct style.ini file for your chosen color scheme.', -1);
  91. }//else {//if not ...
  92. }//if ($ini['__theme__'] != '_'.$color)
  93. }//function minima_checkColor()
  94. /**
  95. * Display tabs for easy navigation
  96. */
  97. function minima_tabs() {//func
  98. /****** declare global variables ******/
  99. global $ID;
  100. /****** set local variables ******/
  101. $out = '';
  102. /****** get tabs file name ******/
  103. $ns = getNS($ID);
  104. $tabsFile = wikiFN(($ns).':'.tpl_getConf('tabs_page'));
  105. /****** show tabs ******/
  106. if ((@file_exists($tabsFile)) && (auth_quickaclcheck($tabs))) {//do
  107. $ins = p_cached_instructions($tabsFile);
  108. /****** process each tab ******/
  109. foreach ($ins as $in) {//do
  110. /****** collect internal links to pages in same namespace ******/
  111. if ($in[0] == 'internallink') {//do
  112. list($id, $hash) = explode('#', $in[1][0], 2);
  113. resolve_pageid(getNS($ID), $id, $exists);
  114. /****** ignore links to other namespaces ******/
  115. if (getNS($id) != $ns)
  116. continue;
  117. /****** ignore links to non-existent pages ******/
  118. if (!$exists)
  119. continue;
  120. /****** determine link title ******/
  121. $title = hsc($in[1][1]);
  122. if (!$title)
  123. $title = hsc(p_get_first_heading($id));
  124. if (!$title)
  125. $title = hsc(ucwords(noNS($id)));
  126. /****** now construct the output link ******/
  127. if ($id == $ID)
  128. $out .= '<span class="activetab">'.$title.'</span> ';
  129. else
  130. $out .= '<a href="'.wl($id).'" class="tab">'.$title.'</a> ';
  131. }//if ($in[0] == 'internallink')
  132. /****** first header of tabs.txt is heading for whole namespace ******/
  133. elseif (($in[0] == 'header') && (!$heading)) {//do
  134. $heading = $in[1][0];
  135. $level = $in[1][1];
  136. }//if (($in[0] == 'header') && (!$heading))
  137. }//foreach ($ins as $in)
  138. /****** add heading to list ******/
  139. if ($heading)
  140. $out = '<h'.$level.'>'.$heading.'</h'.$level.'>'.$out;
  141. /****** show list ******/
  142. if ($out <> "")
  143. echo '<div class="tabs">'.$out.'</div>';
  144. }//if ((@file_exists($tabsFile)) && (auth_quickaclcheck($tabs)))
  145. }//function minima_tabs()
  146. /**
  147. * Outputs the namespace title
  148. */
  149. function minima_nstitle() {//func
  150. /****** declare global variables ******/
  151. global $ID;
  152. /****** get namespace title ******/
  153. $title = p_get_metadata(getNS($ID).':'.tpl_getConf('tabs_page'), 'title');
  154. /****** show namespace title ******/
  155. if ($title)
  156. echo $title.': ';
  157. }//function minima_nstitle()