#author("2020-12-05T14:54:42+09:00","","") #author("2021-07-07T13:15:43+09:00","","") ** region2.inc.php [#u332cc4f] |RIGHT:100|LEFT:360|c |~サマリ|regionプラグインのマルチライン版| |~リビジョン|1.3| |~リビジョン|1.4| |~対応バージョン|1.5.x| |~投稿者|[[K]]| |~投稿日|&new{2020-12-05 (土) 14:51:34};| **概要 [#p2cec0ca] [[region.inc.php>自作プラグイン/region.inc.php]]のマルチライン版 **使い方 [#hc0d6290] ***書式 [#acae45ff] #region2(折りたたみ){{ 折りたたむ文字列など }} **ダウンロード [#o8aecba7] 予め、PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACKを0にしてください。 -http://pkom.ml/?%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3/region2.inc.php //-http://pkom.ml/?%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3/region2.inc.php -https://github.com/PTOM76/PukiWiki-Plugins/releases/download/region2v1.4/region2.inc.php PukiWiki本体のpluginフォルダに以下のコードをコピーしてregion2.inc.phpとして保存するか、上記のURLの「ダウンロードはこちら」からダウンロードし、pluginフォルダに入れてください。 -region2.inc.php ***コード [#u0cfca2f] <?php // $Id: region2.inc.php,v 1.3 2020/11/11 07:09:33 K,xxxxx Exp $ // $Id: region2.inc.php,v 1.4 2021/07/07 00:00:00 K,xxxxx Exp $ /** * @link http://pkom.ml/?プラグイン/region2.inc.php * @author K,xxxxx * @license http://www.gnu.org/licenses/gpl.ja.html GPL */ // サマリー(true) or 開くボタン(false) で開閉 define('PLUGIN_REGION2_CLICK_SUMMARY', false); // falseで<head>に、trueで<body>にスタイルの要素を生成します define('PLUGIN_REGION2_COMPATIBILITY_STYLE', false); // スタイルシートの定義 define('PLUGIN_REGION2_STYLE', <<<EOD .rgn2_btn { cursor:pointer; font-family: "MS Pゴシック", "MS PGothic", "ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro", Osaka, arial, verdana, sans-serif; padding:3px 6px; border:gray 1px solid; color:gray; } .rgn2_summary { color:gray; padding:1px 4px; border:gray 1px solid; } EOD); function plugin_region2_convert() { static $builder = 0; if( $builder==0 ) $builder = new Region2PluginHTMLBuilder(); $builder->setDefaultSettings(); if (func_num_args() >= 2){ if ($builder == 0) $builder = new Region2Plugin(); $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(); $builder -> setDescription( array_shift($args) ); foreach( $args as $value ) { if (preg_match("/^open/i", $value)) { $builder -> setOpened(); continue; } if (preg_match("/^close/i", $value)) { $builder -> setClosed(); continue; } } } $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; $args = func_get_args(); $contents = $args[func_num_args()-1]; $contents = preg_replace("/\r\n|\r/", "\n", $contents); $contents = explode("\n", $contents); return $builder -> build() .convert_html($contents) .<<<EOD </td></tr></table> EOD; } class Region2PluginHTMLBuilder class Region2Plugin { var $description; var $isopened; var $scriptVarName; var $callcount; function Region2PluginHTMLBuilder() { $this->callcount = 0; $this->setDefaultSettings(); private $description; private $isOpened; private $scriptVarName; private $callCount; public function __construct() { $this -> callCount = 0; $this -> setDefaultSettings(); } function setDefaultSettings(){ $this->description = "..."; $this->isopened = false; public 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); public function setClosed() { $this -> isOpened = false; } public function setOpened() { $this -> isOpened = true; } public 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++; public 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() ); if ($this -> callCount <= 1) { $style = "<style>\n" . PLUGIN_REGION2_STYLE . "\n</style>\n"; if (PLUGIN_REGION2_COMPATIBILITY_STYLE) { array_push($html, $style); } else { global $head_tags; $head_tags[] .= $style; } } 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) ? "-" : "+"; private 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='+'; <table cellpadding=1 cellspacing=2><tr> <td valign="top"> <span class="rgn2_btn" id="rgn2_button{$this -> callCount}" onclick=" {$this -> getJavaScriptTag()} ">$button</span> </td> EOD; } ">$button</span> </td> EOD; } function buildBracketHtml(){ $bracketstyle = ($this->isopened) ? "border-style: solid none solid solid;" : "border-style:none;"; private 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; <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;"; private function buildSummaryHtml() { $summaryStyle = ($this -> isOpened) ? "display:none;" : "display:block;"; $onClick = PLUGIN_REGION2_CLICK_SUMMARY ? 'onclick="' . $this -> getJavaScriptTag() . '"' : ""; return <<<EOD <td id=rgn2_summary$this->callcount style="color:gray;border:gray 1px solid;{$summarystyle}">$this->description</td> EOD; <td class="rgn2_summary" id=rgn2_summary{$this -> callCount} $onClick style="{$summaryStyle}">{$this -> description}</td> EOD; } function buildContentHtml(){ $contentstyle = ($this->isopened) ? "display:block;" : "display:none;"; private function buildContentHtml() { $contentStyle = ($this -> isOpened) ? "display:block;" : "display:none;"; return <<<EOD <td valign=top id=rgn2_content$this->callcount style="{$contentstyle}"> EOD; <td valign="top" id=rgn2_content{$this -> callCount} style="{$contentStyle}"> EOD; } }// end class RegionPluginHTMLBuilder ?> private function getJavaScriptTag() { return <<<EOD 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='+'; } EOD; } } **ライセンス [#ne9a117f] GPLv3 **コメント [#t527f9ed] #comment