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