summaryrefslogtreecommitdiff
path: root/lib/plugins/styler/admin.php
blob: 4be2153ab746ccd6cedcdd19e75638bde21269ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
 * DokuWiki Plugin styler (Admin Component)
 *
 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
 * @author  Andreas Gohr <andi@splitbrain.org>
 */

// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

class admin_plugin_styler extends DokuWiki_Admin_Plugin {

    /**
     * @return int sort number in admin menu
     */
    public function getMenuSort() {
        return 1000;
    }

    /**
     * @return bool true if only access for superuser, false is for superusers and moderators
     */
    public function forAdminOnly() {
        return true;
    }

    /**
     * Should carry out any processing required by the plugin.
     */
    public function handle() {
    }

    /**
     * Render HTML output, e.g. helpful text and a form
     */
    public function html() {
        echo '<div id="plugin__styler">';
        $this->form();
        echo '</div>';
    }

    /**
     * Create the actual editing form
     */
    public function form() {
        global $conf;
        $tpl = $conf['template'];
        define('SIMPLE_TEST',1); // hack, ideally certain functions should be moved out of css.php
        require_once(DOKU_INC.'lib/exe/css.php');
        $styleini = css_styleini($conf['template'], true);
        $replacements = $styleini['replacements'];

        ptln('<h1>'.$this->getLang('menu').'</h1>');

        if (empty($replacements)) {
            echo '<p class="error">Sorry, this template does not support this functionality.</p>';
        } else {
            echo '<p>Intro blah... for the currently active template ("'.$tpl.'")... not all variables preview...</p>';

            echo '<form class="styler" method="post">';
            echo '<h2>Template variables</h2>';
            echo '<table>';
            foreach($replacements as $key => $value){
                echo '<tr>';
                echo '<td>'.$key.'</td>';
                echo '<td><input name="tpl['.hsc($key).']" value="'.hsc($value).'" />';
                echo '</tr>';
            }
            echo '</table>';
            echo '<input type="submit" name="do[styler_plugin_preview]" value="preview">';
            echo '<input type="submit" name="do[styler_plugin_reset]" value="reset current">'; #FIXME only if preview.ini exists
            echo '<input type="submit" name="do[styler_plugin_revert]" value="revert to original">'; #FIXME only if local.ini exists
            echo '<input type="submit" name="do[styler_plugin_save]" value="save">';
            echo '</form>';
        }
    }

}

// vim:ts=4:sw=4:et: