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.
 
 
 
 
 

185 lines
5.6 KiB

  1. <?php
  2. /**
  3. * DokuWiki Bootstrap3 Template: Compatibility functions
  4. *
  5. * @link http://dokuwiki.org/template:bootstrap3
  6. * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
  7. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  8. */
  9. global $updateVersion;
  10. $dokuwiki_version = floatval($updateVersion);
  11. define('DOKU_VERSION', $dokuwiki_version);
  12. define('DOKU_VERSION_HOGFATHER', 51); // 2020-07-29
  13. define('DOKU_VERSION_GREEBO', 50); // 2018-04-22 (PHP >= 5.6)
  14. define('DOKU_VERSION_FRUSTERICK_MANNERS', 49); // 2017-02-19 (PHP >= 5.4 ???)
  15. define('DOKU_VERSION_ELENOR_OF_TSORT', 48); // 2016-06-26
  16. define('DOKU_VERSION_DETRITUS', 47); // 2015-08-10 (PHP >= 5.3.3)
  17. // Load compatibility Menu classes for pre-Greebo releases
  18. if (DOKU_VERSION > 0 && DOKU_VERSION < DOKU_VERSION_GREEBO) {
  19. define('DOKU_INC_COMPAT', realpath(dirname(__FILE__) . '/../') . '/');
  20. require DOKU_INC_COMPAT . "inc/Menu/MenuInterface.php";
  21. require DOKU_INC_COMPAT . "inc/Menu/AbstractMenu.php";
  22. require DOKU_INC_COMPAT . "inc/Menu/Item/AbstractItem.php";
  23. require DOKU_INC_COMPAT . "inc/Menu/UserMenu.php";
  24. require DOKU_INC_COMPAT . "inc/Menu/MobileMenu.php";
  25. require DOKU_INC_COMPAT . "inc/Menu/PageMenu.php";
  26. require DOKU_INC_COMPAT . "inc/Menu/SiteMenu.php";
  27. require DOKU_INC_COMPAT . "inc/Menu/DetailMenu.php";
  28. require DOKU_INC_COMPAT . "inc/Menu/Item/ImgBackto.php";
  29. require DOKU_INC_COMPAT . "inc/Menu/Item/Top.php";
  30. require DOKU_INC_COMPAT . "inc/Menu/Item/Edit.php";
  31. require DOKU_INC_COMPAT . "inc/Menu/Item/Profile.php";
  32. require DOKU_INC_COMPAT . "inc/Menu/Item/Revisions.php";
  33. require DOKU_INC_COMPAT . "inc/Menu/Item/Backlink.php";
  34. require DOKU_INC_COMPAT . "inc/Menu/Item/Back.php";
  35. require DOKU_INC_COMPAT . "inc/Menu/Item/Login.php";
  36. require DOKU_INC_COMPAT . "inc/Menu/Item/Index.php";
  37. require DOKU_INC_COMPAT . "inc/Menu/Item/Register.php";
  38. require DOKU_INC_COMPAT . "inc/Menu/Item/MediaManager.php";
  39. require DOKU_INC_COMPAT . "inc/Menu/Item/Subscribe.php";
  40. require DOKU_INC_COMPAT . "inc/Menu/Item/Recent.php";
  41. require DOKU_INC_COMPAT . "inc/Menu/Item/Media.php";
  42. require DOKU_INC_COMPAT . "inc/Menu/Item/Resendpwd.php";
  43. require DOKU_INC_COMPAT . "inc/Menu/Item/Admin.php";
  44. require DOKU_INC_COMPAT . "inc/Menu/Item/Revert.php";
  45. }
  46. // Load template class for previous "Frusterick Manners" (2017-02-19) releases
  47. if (DOKU_VERSION < DOKU_VERSION_FRUSTERICK_MANNERS) {
  48. $tpl_incdir = tpl_incdir();
  49. require $tpl_incdir . 'Template.php';
  50. require $tpl_incdir . 'SVG.php';
  51. }
  52. /**
  53. * copied from core (available since Greebo)
  54. */
  55. if (!function_exists('inlineSVG')) {
  56. function inlineSVG($file, $maxsize = 2048)
  57. {
  58. $file = trim($file);
  59. if ($file === '') {
  60. return false;
  61. }
  62. if (!file_exists($file)) {
  63. return false;
  64. }
  65. if (filesize($file) > $maxsize) {
  66. return false;
  67. }
  68. if (!is_readable($file)) {
  69. return false;
  70. }
  71. $content = file_get_contents($file);
  72. $content = preg_replace('/<!--.*?(-->)/s', '', $content); // comments
  73. $content = preg_replace('/<\?xml .*?\?>/i', '', $content); // xml header
  74. $content = preg_replace('/<!DOCTYPE .*?>/i', '', $content); // doc type
  75. $content = preg_replace('/>\s+</s', '><', $content); // newlines between tags
  76. $content = trim($content);
  77. if (substr($content, 0, 5) !== '<svg ') {
  78. return false;
  79. }
  80. return $content;
  81. }
  82. }
  83. /**
  84. * copied from core (available since Detritus)
  85. */
  86. if (!function_exists('tpl_toolsevent')) {
  87. function tpl_toolsevent($toolsname, $items, $view = 'main')
  88. {
  89. $data = array(
  90. 'view' => $view,
  91. 'items' => $items,
  92. );
  93. $hook = 'TEMPLATE_' . strtoupper($toolsname) . '_DISPLAY';
  94. $evt = new Doku_Event($hook, $data);
  95. if ($evt->advise_before()) {
  96. foreach ($evt->data['items'] as $k => $html) {
  97. echo $html;
  98. }
  99. }
  100. $evt->advise_after();
  101. }
  102. }
  103. /**
  104. * copied from core (available since Binky)
  105. */
  106. if (!function_exists('tpl_classes')) {
  107. function tpl_classes()
  108. {
  109. global $ACT, $conf, $ID, $INFO;
  110. $classes = array(
  111. 'dokuwiki',
  112. 'mode_' . $ACT,
  113. 'tpl_' . $conf['template'],
  114. !empty($_SERVER['REMOTE_USER']) ? 'loggedIn' : '',
  115. $INFO['exists'] ? '' : 'notFound',
  116. ($ID == $conf['start']) ? 'home' : '',
  117. );
  118. return join(' ', $classes);
  119. }
  120. }
  121. /**
  122. * copied from core (available since Detritus)
  123. */
  124. if (!function_exists('plugin_getRequestAdminPlugin')) {
  125. function plugin_getRequestAdminPlugin()
  126. {
  127. static $admin_plugin = false;
  128. global $ACT, $INPUT, $INFO;
  129. if ($admin_plugin === false) {
  130. if (($ACT == 'admin') && ($page = $INPUT->str('page', '', true)) != '') {
  131. $pluginlist = plugin_list('admin');
  132. if (in_array($page, $pluginlist)) {
  133. // attempt to load the plugin
  134. /** @var $admin_plugin DokuWiki_Admin_Plugin */
  135. $admin_plugin = plugin_load('admin', $page);
  136. // verify
  137. if ($admin_plugin && $admin_plugin->forAdminOnly() && !$INFO['isadmin']) {
  138. $admin_plugin = null;
  139. $INPUT->remove('page');
  140. msg('For admins only', -1);
  141. }
  142. }
  143. }
  144. }
  145. return $admin_plugin;
  146. }
  147. }