-
Notifications
You must be signed in to change notification settings - Fork 49
/
admin.php
executable file
·124 lines (101 loc) · 4.17 KB
/
admin.php
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* @author Myron Turner <[email protected]>
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
*/
require_once(DOKU_INC . 'lib/plugins/ckgedit/scripts/css6.php');
class admin_plugin_ckgedit extends DokuWiki_Admin_Plugin {
private $tpl_inc;
private $template;
private $alt;
function __construct() {
global $conf;
$this->template = $conf['template'];
$this->tpl_inc = tpl_incdir();
}
function handle() {
if (!isset($_REQUEST['cmd'])) return; // first time - nothing to do
$this->output = 'invalid';
if (!checkSecurityToken()) return;
if (!is_array($_REQUEST['cmd'])) return;
switch (key($_REQUEST['cmd'])) {
case 'stylesheet' : {
$this->alt = "";
$this->output = 'style_sheet_msg';
break;
}
case 'alt_stylesheet' : {
$this->alt = $_REQUEST['templates'];
$this->output = 'alt_style_sheet_msg';
break;
}
}
}
/**
* output appropriate html
*/
function html() {
ptln('<div id = "ckg_styl_sheet" style = "display:none">');
echo $this->locale_xhtml('style');
ptln('</div>');
ptln('<button type = "button" id = "Infobut" onclick="jQuery(\'#ckg_styl_sheet\').toggle(800,ckg_admininfo(this));">');
echo $this->getLang('stylesheet_oinfo');
ptln('</button>');
ptln('<form action="'.wl($ID).'" method="post">');
// output hidden values to ensure dokuwiki will return back to this plugin
ptln(' <input type="hidden" name="do" value="admin" />');
ptln(' <input type="hidden" name="page" value="'.$this->getPluginName().'" />');
formSecurityToken();
//Current style sheet
ptln('<p style = "line-height: 200%;">' . $this->getLang('default_stylesheet') . ': (' .$this->template . ')<br />');
ptln('<label for="ckg_save_ss">' .$this->getLang('checkbox').'</label>');
ptln('<input type="checkbox" name="ckg_save_ss"> ');
ptln('<input type="submit" name="cmd[stylesheet]" value="'.$this->getLang('style_sheet').'" /></p>');
// Other style sheet
$alt_val = isset($this->alt)?$this->alt: "" ;
ptln('<p style = "line-height: 200%;">' . $this->getLang('alt_stylesheet') .'<br />');
ptln('<select name="templates" style = "line-height:100%">');
echo $this->templates( $alt_val );
ptln('</select>');
ptln('<input type="submit" name="cmd[alt_stylesheet]" value="'.$this->getLang('style_sheet').'" />');
ptln('</form></p>');
if($this->output && $this->output == 'style_sheet_msg') {
$path = $this->tpl_inc;
ptln(htmlspecialchars($this->getLang($this->output)). " " .$this->template);
$retv = css_ckg_out($path);
$this->message($path, $retv);
}
else if($this->output && $this->output == 'alt_style_sheet_msg') {
ptln(htmlspecialchars($this->getLang($this->output)). " " .$this->alt);
$path = str_replace('tpl/'.$this->template, 'tpl/'.$this->alt,$this->tpl_inc);
$retv = css_ckg_out($path,$this->alt);
$this->message($path, $retv);
}
}
function message($path, $which) {
$messages = array(
"Stylesheet saved to $path" . 'Styles/_style.css',
"Failed to save stylesheet to $path" . 'Styles/_style.css'
);
$color = $which == 0? '#333': 'blue';
ptln('<br /><span style = "color:'.$color. ';">'.htmlspecialchars($messages[$which]).'</span>');
}
function templates($selected="") {
$dir = dirname($this->tpl_inc);
$files = scandir($dir);
$dir .= '/';
$list = "<option value='' >Select</option>";
foreach ($files AS $file) {
if($file == '.' || $file == '..' || $file == $this->template) continue;
$entry = $dir . $file;
if(!is_writable($entry)) continue;
if(is_dir ($entry ) ) {
if($file == $selected) {
$list .= "<option value='$file' selected>$file</option>";
}
else $list .= "<option value='$file' >$file</option>";
}
}
return $list;
}
}