-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckarea.inc.php
More file actions
65 lines (60 loc) · 2.08 KB
/
checkarea.inc.php
File metadata and controls
65 lines (60 loc) · 2.08 KB
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
<?php
// $Id: checkarea.inc.php,v 1.00 2021/02/12 18:46:44 K Exp $
/**
* @link http://pkom.ml/?プラグイン/checkarea.inc.php
* @author K
* @license http://www.gnu.org/licenses/gpl.ja.html GPL
*/
function plugin_checkarea_convert(){
$args = func_get_args();
return call_user_func_array('plugin_checkarea_inline', $args);
}
function plugin_checkarea_inline(){
global $vars;
static $n = 0;
$args = func_get_args();
if($args[0] == 'submit'){
return <<<EOD
<form id="checkarea" method="post">
<input type="hidden" name="cmd" value="checkarea" />
<input type="hidden" name="refer" value="{$vars['page']}" />
<input type="submit" name="checkarea_submit" value="チェックエリア更新" />
</form>
EOD;
}elseif($args[0] == 'true'){
$checked = 'checked';
}else{
$checked = '';
}
++$n;
return <<<EOD
<input type="checkbox" name="checkarea_{$n}" form="checkarea" {$checked} />
EOD;
}
function plugin_checkarea_action(){
global $vars, $_title_updated, $_msg_comment_collided;
$source = get_source($vars['refer'], TRUE, TRUE);
$source = preg_replace_callback('/(&)checkarea(?:\((.*?)\))?;/', function($m){return plugin_checkarea_replace($m);}, $source);
$source = preg_replace_callback('/(\#)checkarea(?:\((.*?)\)|([|]|$))/', function($m){return plugin_checkarea_replace($m);}, $source);
page_write($vars['refer'], $source);
$vars['page'] = $vars['refer'];
return array('msg' => $_title_updated, 'body' => '');
}
function plugin_checkarea_replace($m){
global $vars;
static $n = 0;
if($m[2] == 'submit'){
return $m[0];
}else{
++$n;
if($vars['checkarea_' . (string)$n] == 'on'){
if($m[1] == '#'){return "#checkarea(true)" . ($m[2] == '|' ? '|' : '');}
if($m[1] == '&'){return "&checkarea(true);";}
return $m[0];
}else{
if($m[1] == '#'){return "#checkarea(false)";}
if($m[1] == '&'){return "&checkarea(false);";}
return $m[0];
}
}
}