xref: /dokuwiki/lib/tpl/index.php (revision ead851a84b96ca8b022e8980362b248ec2712dfa)
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$ini = css_styleini($conf['template']);
50
51if ($ini) {
52    echo '<table>';
53    echo "<caption>".htmlspecialchars($conf['template'])."'s style.ini</caption>";
54    foreach($ini['replacements'] as $key => $val){
55        echo '<tr>';
56        echo '<td>'.htmlspecialchars($key).'</td>';
57        echo '<td>'.htmlspecialchars($val).'</td>';
58        echo '<td>';
59        if(preg_match('/^#[0-f]{3,6}$/i',$val)){
60            echo '<div class="color" style="background-color:'.$val.';">&#160;</div>';
61        }
62        echo '</td>';
63        echo '</tr>';
64    }
65    echo '</table>';
66} else {
67    echo "<p>Non-existent or invalid template or style.ini: <strong>".htmlspecialchars($conf['template'])."</strong></p>";
68}
69?>
70</body>
71</html>
72