xref: /dokuwiki/lib/tpl/index.php (revision 82211c0a205d3e344a33dc29bf13e08fb15a9f2e)
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 */
11if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
12if(!defined('NOSESSION')) define('NOSESSION',1);
13require_once(DOKU_INC.'inc/init.php');
14?>
15<!DOCTYPE html>
16<html lang="en" dir="ltr">
17<head>
18    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19    <title>Template Replacements</title>
20    <style type="text/css">
21        body {
22            background-color: #fff;
23            color: #000;
24        }
25        caption {
26            font-weight: bold;
27        }
28        td {
29            margin: 0;
30            padding: 0.5em 2em;
31            font-family: monospace;
32            font-size: 120%;
33            border: 1px solid #fff;
34        }
35        tr:hover td {
36            border: 1px solid #ccc;
37        }
38        .color {
39            padding: 0.25em 1em;
40            border: 1px #000 solid;
41        }
42    </style>
43</head>
44<body>
45<?php
46// get merged style.ini
47define('SIMPLE_TEST', true); // hack to prevent css output and headers
48require_once(DOKU_INC.'lib/exe/css.php');
49$styleUtils = new \dokuwiki\StyleUtils();
50$ini = $styleUtils->cssStyleini($conf['template']);
51
52if ($ini) {
53    echo '<table>';
54    echo "<caption>".hsc($conf['template'])."'s style.ini</caption>";
55    foreach($ini['replacements'] as $key => $val){
56        echo '<tr>';
57        echo '<td>'.hsc($key).'</td>';
58        echo '<td>'.hsc($val).'</td>';
59        echo '<td>';
60        if(preg_match('/^#[0-f]{3,6}$/i',$val)){
61            echo '<div class="color" style="background-color:'.$val.';">&#160;</div>';
62        }
63        echo '</td>';
64        echo '</tr>';
65    }
66    echo '</table>';
67} else {
68    echo "<p>Non-existent or invalid template or style.ini: <strong>".hsc($conf['template'])."</strong></p>";
69}
70?>
71</body>
72</html>
73