-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.php
executable file
·92 lines (79 loc) · 2.4 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
<?php
/**
* Autolink4 plugin for DokuWiki
*
* @license MIT
* @author Eli Fenton
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
/**
*
*/
class admin_plugin_autolink4 extends DokuWiki_Admin_Plugin {
//public function getInfo() {return '';}
/** @type helper_plugin_autolink4 */
protected $hlp;
public function __construct() {
/** @type helper_plugin_autolink4 $this ->hlp */
$this->hlp = plugin_load('helper', 'autolink4');
}
/**
* return sort order for position in admin menu
*/
public function getMenuSort() {
return 140;
}
/**
* handle user request
*/
public function handle() {
global $INPUT;
if ($INPUT->post->has('aldata')) {
if (!$this->hlp->saveConfigFile($INPUT->post->str('aldata'))) {
msg('Failed to save data', 1);
}
else {
// Break the cache, so that all pages are regenerated.
touch(DOKU_CONF."local.php");
}
}
}
/**
* output appropriate html
*/
public function html() {
global $lang;
$config = $this->hlp->loadConfigFile();
$lines = preg_split('/\r?\n/', $config);
$allTt = 'checked';
$allOnce = 'checked';
foreach ($lines as $line) {
if (!preg_match('/^\s*$/', $line)) {
if (!preg_match('/^.*,.*,.*,.*\btt\b.*/', $line)) {
$allTt = '';
}
if (!preg_match('/^.*,.*,.*,.*\bonce\b.*/', $line)) {
$allOnce = '';
}
}
}
echo $this->locale_xhtml('admin_help');
if (!plugin_isdisabled('autotooltip') && plugin_load('helper', 'autotooltip')) {
echo '<p><label onclick="plugin_autolink4.toggleFlag(this.querySelector(\'input\').checked, \'tt\')">';
echo '<input type="checkbox" name="tooltips" ' . $allTt . '/>';
echo '<span> ' . $lang['enable_all_tooltips'] . '</span></label></p>';
}
echo '<p><label onclick="plugin_autolink4.toggleFlag(this.querySelector(\'input\').checked, \'once\')">';
echo '<input type="checkbox" name="linkonce" ' . $allOnce . '/>';
echo '<span> ' . $lang['enable_all_once'] . '</span></label></p>';
echo '<form action="" method="post" >';
echo '<input type="hidden" name="do" value="admin" />';
echo '<input type="hidden" name="page" value="autolink4" />';
echo '<textarea class="edit plugin-autolink4__admintext" rows="15" cols="80" style="height: 500px; width: 100%" name="aldata">';
echo formtext($config);
echo '</textarea><br/><br/>';
echo '<input type="submit" value="' . $lang['btn_save'] . '" class="button" />';
echo '</form>';
}
}