[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/tpl/ -> index.php (source)

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