index.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * This file reads the style.ini of the used template and displays the
  4. * replacements defined in it. Color replacements will be displayed
  5. * visually. This should help with adjusting and using the styles
  6. * specified in the style.ini
  7. *
  8. * @author Andreas Gohr <andi@splitbrain.org>
  9. * @author Anika Henke <anika@selfthinker.org>
  10. */
  11. // phpcs:disable PSR1.Files.SideEffects
  12. if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
  13. if(!defined('NOSESSION')) define('NOSESSION',1);
  14. require_once(DOKU_INC.'inc/init.php');
  15. ?>
  16. <!DOCTYPE html>
  17. <html lang="en" dir="ltr">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. <title>Template Replacements</title>
  21. <style>
  22. body {
  23. background-color: #fff;
  24. color: #000;
  25. }
  26. caption {
  27. font-weight: bold;
  28. }
  29. td {
  30. margin: 0;
  31. padding: 0.5em 2em;
  32. font-family: monospace;
  33. font-size: 120%;
  34. border: 1px solid #fff;
  35. }
  36. tr:hover td {
  37. border: 1px solid #ccc;
  38. }
  39. .color {
  40. padding: 0.25em 1em;
  41. border: 1px #000 solid;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <?php
  47. // get merged style.ini
  48. $styleUtils = new \dokuwiki\StyleUtils($conf['template']);
  49. $ini = $styleUtils->cssStyleini();
  50. if (!empty($ini)) {
  51. echo '<table>';
  52. echo "<caption>".hsc($conf['template'])."'s style.ini</caption>";
  53. foreach($ini['replacements'] as $key => $val){
  54. echo '<tr>';
  55. echo '<td>'.hsc($key).'</td>';
  56. echo '<td>'.hsc($val).'</td>';
  57. echo '<td>';
  58. if(preg_match('/^#[0-f]{3,6}$/i',$val)){
  59. echo '<div class="color" style="background-color:'.$val.';">&#160;</div>';
  60. }
  61. echo '</td>';
  62. echo '</tr>';
  63. }
  64. echo '</table>';
  65. } else {
  66. echo "<p>Non-existent or invalid template or style.ini: <strong>".hsc($conf['template'])."</strong></p>";
  67. }
  68. ?>
  69. </body>
  70. </html>