-
Notifications
You must be signed in to change notification settings - Fork 0
/
region2.inc.php
119 lines (105 loc) · 3.53 KB
/
region2.inc.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
<?php
// $Id: region2.inc.php,v 1.3 2020/11/11 07:09:33 K,xxxxx Exp $
/**
* @link http://pkom.ml/
* @author K,xxxxx
* @license http://www.gnu.org/licenses/gpl.ja.html GPL
*/
function plugin_region2_convert()
{
static $builder = 0;
if( $builder==0 ) $builder = new Region2PluginHTMLBuilder();
$builder->setDefaultSettings();
if (func_num_args() >= 2){
$args = func_get_args();
$builder->setDescription( array_shift($args) );
foreach( $args as $value ){
if( preg_match("/^open/i", $value) ){
$builder->setOpened();
}elseif( preg_match("/^close/i", $value) ){
$builder->setClosed();
}
}
}
$args = func_get_args();
$contents1 = $args[func_num_args()-1];
$contents1 = preg_replace("/\r\n|\r/", "\n", $contents1);
$contents1 = explode("\n",$contents1);
return $builder->build()
.convert_html($contents1)
.<<<EOD
</td></tr></table>
EOD;
}
class Region2PluginHTMLBuilder
{
var $description;
var $isopened;
var $scriptVarName;
var $callcount;
function Region2PluginHTMLBuilder() {
$this->callcount = 0;
$this->setDefaultSettings();
}
function setDefaultSettings(){
$this->description = "...";
$this->isopened = false;
}
function setClosed(){ $this->isopened = false; }
function setOpened(){ $this->isopened = true; }
function setDescription($description){
$this->description = convert_html($description);
$this->description = preg_replace( "/^<p>/i", "", $this->description);
$this->description = preg_replace( "/<\/p>$/i", "", $this->description);
}
function build(){
$this->callcount++;
$html = array();
array_push( $html, $this->buildButtonHtml() );
array_push( $html, $this->buildBracketHtml() );
array_push( $html, $this->buildSummaryHtml() );
array_push( $html, $this->buildContentHtml() );
return join($html);
}
function buildButtonHtml(){
$button = ($this->isopened) ? "-" : "+";
return <<<EOD
<table cellpadding=1 cellspacing=2><tr>
<td valign=top>
<span id=rgn2_button$this->callcount style="cursor:pointer;font:normal 15px MS Pゴシック;border:gray 1px solid;"
onclick="
if(document.getElementById('rgn2_summary$this->callcount').style.display!='none'){
document.getElementById('rgn2_summary$this->callcount').style.display='none';
document.getElementById('rgn2_content$this->callcount').style.display='block';
document.getElementById('rgn2_bracket$this->callcount').style.borderStyle='solid none solid solid';
document.getElementById('rgn2_button$this->callcount').innerHTML='-';
}else{
document.getElementById('rgn2_summary$this->callcount').style.display='block';
document.getElementById('rgn2_content$this->callcount').style.display='none';
document.getElementById('rgn2_bracket$this->callcount').style.borderStyle='none';
document.getElementById('rgn2_button$this->callcount').innerHTML='+';
}
">$button</span>
</td>
EOD;
}
function buildBracketHtml(){
$bracketstyle = ($this->isopened) ? "border-style: solid none solid solid;" : "border-style:none;";
return <<<EOD
<td id=rgn2_bracket$this->callcount style="font-size:1pt;border:gray 1px;{$bracketstyle}"> </td>
EOD;
}
function buildSummaryHtml(){
$summarystyle = ($this->isopened) ? "display:none;" : "display:block;";
return <<<EOD
<td id=rgn2_summary$this->callcount style="color:gray;border:gray 1px solid;{$summarystyle}">$this->description</td>
EOD;
}
function buildContentHtml(){
$contentstyle = ($this->isopened) ? "display:block;" : "display:none;";
return <<<EOD
<td valign=top id=rgn2_content$this->callcount style="{$contentstyle}">
EOD;
}
}// end class RegionPluginHTMLBuilder
?>