Skip to content

Commit 6416fe7

Browse files
author
Pitan MAD
committed
add plugins
1 parent 3fd4eb1 commit 6416fe7

32 files changed

+5099
-0
lines changed

accordion.inc.php

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?php
2+
// $Id: accordion.inc.php,v 1.3 2020/12/01 23:20:41 K Exp $
3+
4+
/**
5+
* @link http://pkom.ml/?%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3/accordion.inc.php
6+
* @author K
7+
* @license http://www.gnu.org/licenses/gpl.ja.html GPL
8+
*/
9+
10+
// region.inc.php(author:xxxxx) https://pukiwiki.osdn.jp/?%E8%87%AA%E4%BD%9C%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3/region.inc.php
11+
12+
function plugin_accordion_convert()
13+
{
14+
static $builder = 0;
15+
if( $builder==0 ) $builder = new AccordionPluginHTMLBuilder();
16+
17+
$builder->setDefaultSettings();
18+
19+
if (func_num_args() >= 3){
20+
$args = func_get_args();
21+
$builder->setDescription( array_shift($args) );
22+
$builder->setHeading( array_shift($args) );
23+
foreach( $args as $value ){
24+
if( preg_match("/^open/i", $value) ){
25+
$builder->setOpened();
26+
}elseif( preg_match("/^close/i", $value) ){
27+
$builder->setClosed();
28+
}
29+
}
30+
}
31+
$args = func_get_args();
32+
$contents1 = $args[func_num_args()-1];
33+
$contents1 = preg_replace("/\r\n|\r/", "\n", $contents1);
34+
$contents1 = explode("\n",$contents1);
35+
36+
return $builder->build()
37+
.convert_html($contents1)
38+
.<<<EOD
39+
</td></tr></table>
40+
EOD;
41+
}
42+
43+
class AccordionPluginHTMLBuilder
44+
{
45+
var $description;
46+
var $heading;
47+
var $isopened;
48+
var $scriptVarName;
49+
var $callcount;
50+
51+
function AccordionPluginHTMLBuilder() {
52+
$this->callcount = 0;
53+
$this->setDefaultSettings();
54+
}
55+
function setDefaultSettings(){
56+
$this->description = "...";
57+
$this->heading = "h2";
58+
$this->isopened = false;
59+
}
60+
function setClosed(){ $this->isopened = false; }
61+
function setOpened(){ $this->isopened = true; }
62+
function setDescription($description){
63+
$this->description = convert_html($description);
64+
$this->description = preg_replace( "/^<p>/i", "", $this->description);
65+
$this->description = preg_replace( "/<\/p>$/i", "", $this->description);
66+
}
67+
function setHeading($heading){
68+
if ($heading == "1"){$this->heading = "h2";}
69+
else if ($heading == "2"){$this->heading = "h3";}
70+
else if ($heading == "3"){$this->heading = "h4";}
71+
else if ($heading == "4"){$this->heading = "h5";}
72+
}
73+
function build(){
74+
$this->callcount++;
75+
$html = array();
76+
array_push( $html, $this->buildButtonHtml() );
77+
array_push( $html, $this->buildContentHtml() );
78+
return join($html);
79+
}
80+
81+
function buildButtonHtml(){
82+
$button = ($this->isopened) ? "-" : "+";
83+
//white style
84+
//cursor:pointer;font-family: "MS Pゴシック", "MS PGothic", "ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro", Osaka, arial, verdana, sans-serif;padding:1px 4px;border:gray 1px solid;border-radius:3px;background-color:white;color:gray
85+
86+
//black style
87+
//cursor:pointer;font-family: "MS Pゴシック", "MS PGothic", "ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro", Osaka, arial, verdana, sans-serif;padding:1px 4px;border:black 1px solid;border-radius:3px;background-color:black;color:white
88+
89+
//default style
90+
//cursor:pointer;font-family: "MS Pゴシック", "MS PGothic", "ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro", Osaka, arial, verdana, sans-serif;padding:1px 4px;border:gray 1px solid;color:gray;
91+
return <<<EOD
92+
93+
<{$this->heading}><span id=acd_button$this->callcount style='cursor:pointer;font-family: "MS Pゴシック", "MS PGothic", "ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro", Osaka, arial, verdana, sans-serif;padding:1px 4px;border:gray 1px solid;color:gray;'
94+
onclick="
95+
if(document.getElementById('acd_content$this->callcount').style.display!='inline'){
96+
document.getElementById('acd_content$this->callcount').style.display='inline';
97+
document.getElementById('acd_button$this->callcount').innerHTML='-';
98+
}else{
99+
document.getElementById('acd_content$this->callcount').style.display='none';
100+
document.getElementById('acd_button$this->callcount').innerHTML='+';
101+
}
102+
">$button</span>&nbsp;$this->description</{$this->heading}>
103+
<table><tr>
104+
EOD;
105+
}
106+
function buildContentHtml(){
107+
$contentstyle = ($this->isopened) ? "display:block;" : "display:none;";
108+
return <<<EOD
109+
<td id=acd_content$this->callcount style="{$contentstyle}">
110+
EOD;
111+
}
112+
113+
}// end class RegionPluginHTMLBuilder
114+
115+
?>

alert.inc.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
// $Id: alert.inc.php,v 1.0 2020/10/22 16:11:20 K Exp $
3+
4+
function plugin_alert_inline()
5+
{
6+
$args = func_get_args();
7+
$arg1 = $args[0];
8+
$arg2 = $args[1];
9+
$arg1 = str_replace("\"","&quot;",$arg1);
10+
$arg1 = str_replace("'","\&#39;",$arg1);
11+
return "<a href=\"javascript:alert('".$arg1."');\">".$arg2."</a>";
12+
}
13+
function plugin_alert_convert()
14+
{
15+
return call_user_func_array('plugin_alert_inline', func_get_args());
16+
}
17+
?>

bgcolor.inc.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
$filedata="<?php
3+
function plugin_bgcolor_convert(){
4+
\$args = func_get_args();
5+
\$bg_r = hexdec(substr(\$args[0], 0, 2));
6+
\$bg_g = hexdec(substr(\$args[0], 2, 2));
7+
\$bg_b = hexdec(substr(\$args[0], 4, 2));
8+
\$bg_a = hexdec(substr(\$args[0], 6, 2));
9+
\$font_r = hexdec(substr(\$args[1], 0, 2));
10+
\$font_g = hexdec(substr(\$args[1], 2, 2));
11+
\$font_b = hexdec(substr(\$args[1], 4, 2));
12+
\$font_a = hexdec(substr(\$args[1], 6, 2));
13+
if (empty(substr(\$args[0], 6, 2))){
14+
\$bg_a = \"1\";
15+
}else{
16+
\$bg_a = \$bg_a / 255;
17+
}
18+
if (empty(substr(\$args[1], 6, 2))){
19+
\$font_a = \"1\";
20+
}else{
21+
\$font_a = \$font_a / 255;
22+
}
23+
if (\$args == null){
24+
\$string = <<<EOD
25+
<p>使い方が正しくありません。RGBA:&#35;bgcolor(000000ff(背景色),ffffffff(文字色)) RGB:&#35;bgcolor(000000(背景色),ffffff(文字色))</p>
26+
EOD;
27+
}else{
28+
\$string = <<<EOD
29+
<style>
30+
body{
31+
background-color:rgba(\$bg_r, \$bg_g, \$bg_b, \$bg_a);
32+
color:rgba(\$font_r, \$font_g, \$font_b, \$font_a);
33+
}
34+
</style>
35+
EOD;
36+
}
37+
return \$string;
38+
}
39+
?>";
40+
$temp = tmpfile();
41+
file_put_contents($temp.$filename, $filedata);
42+
header('Content-Type: application/octet-stream');
43+
header("Content-Disposition: attachment; filename=bgcolor.inc.php");
44+
readfile($temp.$filename);
45+
unlink($temp.$filename);
46+
?>

button.inc.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/////////////////////////////////////////////////
3+
// PukiWiki - Yet another WikiWikiWeb clone.
4+
//
5+
// $Id: button.inc.php,v 1.1 2020/10/21 16:51:32 reimy.author_K.mod Exp $
6+
7+
function plugin_button_inline()
8+
{
9+
$body = implode(func_get_args());
10+
return "<button type=\"button\" style=\"text-indent:0px;line-height:1em;vertical-align:middle\">{$body}</button>";
11+
}
12+
function plugin_button_convert() {
13+
return call_user_func_array('plugin_button_inline', func_get_args());
14+
}
15+
?>

commentplus.inc.php

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?php
2+
define('PLUGIN_COMMENTplus_DIRECTION_DEFAULT', '1'); // 1: above 0: below
3+
define('PLUGIN_COMMENTplus_SIZE_MSG', 70);
4+
define('PLUGIN_COMMENTplus_SIZE_NAME', 15);
5+
// ----
6+
define('PLUGIN_COMMENTplus_FORMAT_MSG', '$msg');
7+
define('PLUGIN_COMMENTplus_FORMAT_NAME', '[[$name]]');
8+
define('PLUGIN_COMMENTplus_FORMAT_NOW', '&new{$now};');
9+
define('PLUGIN_COMMENTplus_FORMAT_STRING', "\x08MSG\x08 -- \x08NAME\x08 \x08NOW\x08");
10+
11+
function plugin_commentplus_action()
12+
{
13+
global $vars, $now, $_title_updated, $_no_name;
14+
global $_msg_commentplus_collided, $_title_commentplus_collided;
15+
global $_commentplus_plugin_fail_msg;
16+
17+
if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
18+
19+
if (! isset($vars['msg'])) return array('msg'=>'', 'body'=>''); // Do nothing
20+
21+
$vars['msg'] = str_replace("\n", '', $vars['msg']); // Cut LFs
22+
$head = '';
23+
$match = array();
24+
if (preg_match('/^(-{1,2})-*\s*(.*)/', $vars['msg'], $match)) {
25+
$head = & $match[1];
26+
$vars['msg'] = & $match[2];
27+
}
28+
if ($vars['msg'] == '') return array('msg'=>'', 'body'=>''); // Do nothing
29+
30+
$commentplus = str_replace('$msg', $vars['msg'], PLUGIN_COMMENTplus_FORMAT_MSG);
31+
if(isset($vars['name']) || ($vars['nodate'] != '1')) {
32+
$_name = (! isset($vars['name']) || $vars['name'] == '') ? $_no_name : $vars['name'];
33+
if ($_name == null){
34+
$_name = 'Anonymous';
35+
}
36+
$_name = ($_name == '') ? '' : str_replace('$name', $_name, PLUGIN_COMMENTplus_FORMAT_NAME);
37+
$_now = ($vars['nodate'] == '1') ? '' :
38+
str_replace('$now', $now, PLUGIN_COMMENTplus_FORMAT_NOW);
39+
$commentplus = str_replace("\x08MSG\x08", $commentplus, PLUGIN_COMMENTplus_FORMAT_STRING);
40+
$commentplus = str_replace("\x08NAME\x08", $_name, $commentplus);
41+
$commentplus = str_replace("\x08NOW\x08", $_now, $commentplus);
42+
}
43+
$commentplus = '-' . $head . ' ' . $commentplus;
44+
45+
$postdata = '';
46+
$commentplus_no = 0;
47+
$above = (isset($vars['above']) && $vars['above'] == '1');
48+
$commentplus_added = FALSE;
49+
foreach (get_source($vars['refer']) as $line) {
50+
if (! $above) $postdata .= $line;
51+
if (preg_match('/^#commentplus/i', $line) && $commentplus_no++ == $vars['commentplus_no']) {
52+
$commentplus_added = TRUE;
53+
54+
if ($above) {
55+
$postdata = rtrim($postdata) . "\n" .
56+
$commentplus . "\n" .
57+
"\n"; // Insert one blank line above #commment, to avoid indentation
58+
} else {
59+
$postdata = rtrim($postdata) . "\n" .
60+
$commentplus . "\n";
61+
}
62+
}
63+
if ($above) $postdata .= $line;
64+
}
65+
$title = $_title_updated;
66+
$body = '';
67+
if ($commentplus_added) {
68+
// new commentplus added
69+
if (md5(get_source($vars['refer'], TRUE, TRUE)) !== $vars['digest']) {
70+
$title = $_title_commentplus_collided;
71+
$body = $_msg_commentplus_collided . make_pagelink($vars['refer']);
72+
}
73+
// require "iplog.php";//IPLOGを入れてる場合のみ可能
74+
// addLog($commentplus,'コメント+');
75+
page_write($vars['refer'], $postdata);
76+
} else {
77+
// failed to add the commentplus
78+
$title = $_title_commentplus_collided;
79+
$body = $_commentplus_plugin_fail_msg . make_pagelink($vars['refer']);
80+
}
81+
$retvars['msg'] = $title;
82+
$retvars['body'] = $body;
83+
$vars['page'] = $vars['refer'];
84+
return $retvars;
85+
}
86+
87+
function plugin_commentplus_convert()
88+
{
89+
global $vars, $digest, $_btn_comment, $_btn_name, $_msg_commentplus;
90+
static $numbers = array();
91+
static $commentplus_cols = PLUGIN_COMMENTplus_SIZE_MSG;
92+
93+
if (PKWK_READONLY) return ''; // Show nothing
94+
95+
$page = $vars['page'];
96+
if (! isset($numbers[$page])) $numbers[$page] = 0;
97+
$commentplus_no = $numbers[$page]++;
98+
99+
$options = func_num_args() ? func_get_args() : array();
100+
if (in_array('noname', $options)) {
101+
$nametags = '<label for="_p_commentplus_commentplus_' . $commentplus_no . '">' .
102+
$_msg_commentplus . '</label>';
103+
} else {
104+
$nametags = '<label for="_p_commentplus_name_' . $commentplus_no . '">' .
105+
$_btn_name . '</label>' .
106+
'<input type="text" name="name" id="_p_commentplus_name_' .
107+
$commentplus_no . '" size="' . PLUGIN_COMMENTplus_SIZE_NAME .
108+
'" />' . "\n";
109+
}
110+
$nodate = in_array('nodate', $options) ? '1' : '0';
111+
$above = in_array('above', $options) ? '1' :
112+
(in_array('below', $options) ? '0' : PLUGIN_COMMENTplus_DIRECTION_DEFAULT);
113+
114+
$script = get_page_uri($page);
115+
$s_page = htmlsc($page);
116+
$string = <<<EOD
117+
<br />
118+
<form action="$script" method="post" class="_p_commentplus_form">
119+
<div>
120+
<input type="hidden" name="plugin" value="commentplus" />
121+
<input type="hidden" name="refer" value="$s_page" />
122+
<input type="hidden" name="commentplus_no" value="$commentplus_no" />
123+
<input type="hidden" name="nodate" value="$nodate" />
124+
<input type="hidden" name="above" value="$above" />
125+
<input type="hidden" name="digest" value="$digest" />
126+
$nametags
127+
<input type="text" name="msg" id="_p_commentplus_commentplus_{$commentplus_no}"
128+
size="$commentplus_cols" required />
129+
<input type="submit" name="commentplus" value="$_btn_comment" />
130+
</div>
131+
</form>
132+
<script>
133+
function inputToCommentplusArea(input_text) {
134+
document.getElementById('_p_commentplus_commentplus_{$commentplus_no}').value += input_text;
135+
}
136+
function inputToCommentplusArea2(input_text1,input_text2,input_text3) {
137+
size = window.prompt("サイズ:", "10");
138+
text1 = window.prompt("テキスト:", "");
139+
document.getElementById('_p_commentplus_commentplus_{$commentplus_no}').value += input_text1 + size + input_text2 + text1 + input_text3;
140+
}
141+
function inputToCommentplusAreaURL(input_text1,input_text2,input_text3) {
142+
text1 = window.prompt("テキスト:", "");
143+
url1 = window.prompt("URL:", "http://");
144+
document.getElementById('_p_commentplus_commentplus_{$commentplus_no}').value += "[["+text1+">"+url1+"]]";
145+
}
146+
147+
</script>
148+
<a href="javascript:inputToCommentplusArea('&br;')">[改行]</a>&nbsp;
149+
<a href="javascript:inputToCommentplusArea('&attachref();')">[添付]</a>&nbsp;
150+
<a href="javascript:inputToCommentplusArea2('&size(','){','};')">[サイズ]</a>&nbsp;
151+
<a href="javascript:inputToCommentplusAreaURL()">[URL]</a>&nbsp;
152+
153+
<a href="javascript:inputToCommentplusArea('&smile&#59;')"><img src="./image/face/smile.png"/></a>&nbsp;
154+
<a href="javascript:inputToCommentplusArea('&bigsmile&#59;')"><img src="./image/face/bigsmile.png"/></a>&nbsp;
155+
<a href="javascript:inputToCommentplusArea('&huh&#59;')"><img src="./image/face/huh.png"/></a>&nbsp;
156+
<a href="javascript:inputToCommentplusArea('&oh&#59;')"><img src="./image/face/oh.png"/></a>&nbsp;
157+
<a href="javascript:inputToCommentplusArea('&wink&#59;')"><img src="./image/face/wink.png"/></a>&nbsp;
158+
<a href="javascript:inputToCommentplusArea('&sad&#59;')"><img src="./image/face/sad.png"/></a>&nbsp;
159+
<a href="javascript:inputToCommentplusArea('&heart&#59;')"><img src="./image/face/heart.png"/></a>&nbsp;
160+
EOD;
161+
//顔文字↑
162+
return $string;
163+
}

0 commit comments

Comments
 (0)