#author("2020-12-05T14:54:42+09:00","","") ** region2.inc.php [#u332cc4f] |RIGHT:100|LEFT:360|c |~サマリ|regionプラグインのマルチライン版| |~リビジョン|1.3| |~対応バージョン|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 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 $ /** * @link http://pkom.ml/?プラグイン/region2.inc.php * @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 ?> **ライセンス [#ne9a117f] GPLv3 **コメント [#t527f9ed] #comment