自作プラグイン/accordion.inc.php
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
** accordion.inc.php [#yfb9b0c7]
|RIGHT:100|LEFT:360|c
|~サマリ|見出し版の折りたたみプラグイン|
|~リビジョン|1.3|
|~対応バージョン|1.5.x|
|~投稿者|[[K]]|
|~投稿日|&new{2020-12-05 (土) 15:06:10};|
**概要 [#h746ca22]
WIKIWIKIにあるような見出し版折りたたみ(アコーディオン)プ...
[[自作プラグイン/region.inc.php]]を基にして作りました。
**ダウンロード [#jc7bdd76]
-http://pkom-files.22web.org/download.php?file=plugin...
上記のURLからダウンロードしてPukiWikiのplugin/に入れてく...
**コード [#yd2c7cc8]
以下のコードをコピーしてaccordion.inc.phpという名前で保存...
-accordion.inc.php
<?php
// $Id: accordion.inc.php,v 1.3 2020/12/01 23:20:41 K Ex...
/**
* @link http://pkom.ml/?%E3%83%97%E3%83%A9%E3%82%B0%...
* @author K
* @license http://www.gnu.org/licenses/gpl.ja.html GPL
*/
// region.inc.php(author:xxxxx) https://pukiwiki.osd...
function plugin_accordion_convert()
{
static $builder = 0;
if( $builder==0 ) $builder = new AccordionPluginHTMLBui...
$builder->setDefaultSettings();
if (func_num_args() >= 3){
$args = func_get_args();
$builder->setDescription( array_shift($args) );
$builder->setHeading( 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", $conten...
$contents1 = explode("\n",$contents1);
return $builder->build()
.convert_html($contents1)
.<<<EOD
</td></tr></table>
EOD;
}
class AccordionPluginHTMLBuilder
{
var $description;
var $heading;
var $isopened;
var $scriptVarName;
var $callcount;
function AccordionPluginHTMLBuilder() {
$this->callcount = 0;
$this->setDefaultSettings();
}
function setDefaultSettings(){
$this->description = "...";
$this->heading = "h2";
$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", "", $thi...
$this->description = preg_replace( "/<\/p>$/i", "", $t...
}
function setHeading($heading){
if ($heading == "1"){$this->heading = "h2";}
else if ($heading == "2"){$this->heading = "h3";}
else if ($heading == "3"){$this->heading = "h4";}
else if ($heading == "4"){$this->heading = "h5";}
}
function build(){
$this->callcount++;
$html = array();
array_push( $html, $this->buildButtonHtml() );
array_push( $html, $this->buildContentHtml() );
return join($html);
}
function buildButtonHtml(){
$button = ($this->isopened) ? "-" : "+";
//white style
//cursor:pointer;font-family: "MS Pゴシック",...
//black style
//cursor:pointer;font-family: "MS Pゴシック",...
//default style
//cursor:pointer;font-family: "MS Pゴシック",...
return <<<EOD
<{$this->heading}><span id=acd_button$this->callcoun...
onclick="
if(document.getElementById('acd_content$this->callcount...
document.getElementById('acd_content$this->callcount')...
document.getElementById('acd_button$this->callcount')....
}else{
document.getElementById('acd_content$this->callcount')...
document.getElementById('acd_button$this->callcount')....
}
">$button</span> $this->description</{$this->headi...
<table><tr>
EOD;
}
function buildContentHtml(){
$contentstyle = ($this->isopened) ? "display:block;" :...
return <<<EOD
<td id=acd_content$this->callcount style="{$contentstyle...
EOD;
}
}// end class RegionPluginHTMLBuilder
?>
**ライセンス [#d3402fb8]
-GPLv3
**コメント [#tf9f2eb1]
#comment
終了行:
** accordion.inc.php [#yfb9b0c7]
|RIGHT:100|LEFT:360|c
|~サマリ|見出し版の折りたたみプラグイン|
|~リビジョン|1.3|
|~対応バージョン|1.5.x|
|~投稿者|[[K]]|
|~投稿日|&new{2020-12-05 (土) 15:06:10};|
**概要 [#h746ca22]
WIKIWIKIにあるような見出し版折りたたみ(アコーディオン)プ...
[[自作プラグイン/region.inc.php]]を基にして作りました。
**ダウンロード [#jc7bdd76]
-http://pkom-files.22web.org/download.php?file=plugin...
上記のURLからダウンロードしてPukiWikiのplugin/に入れてく...
**コード [#yd2c7cc8]
以下のコードをコピーしてaccordion.inc.phpという名前で保存...
-accordion.inc.php
<?php
// $Id: accordion.inc.php,v 1.3 2020/12/01 23:20:41 K Ex...
/**
* @link http://pkom.ml/?%E3%83%97%E3%83%A9%E3%82%B0%...
* @author K
* @license http://www.gnu.org/licenses/gpl.ja.html GPL
*/
// region.inc.php(author:xxxxx) https://pukiwiki.osd...
function plugin_accordion_convert()
{
static $builder = 0;
if( $builder==0 ) $builder = new AccordionPluginHTMLBui...
$builder->setDefaultSettings();
if (func_num_args() >= 3){
$args = func_get_args();
$builder->setDescription( array_shift($args) );
$builder->setHeading( 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", $conten...
$contents1 = explode("\n",$contents1);
return $builder->build()
.convert_html($contents1)
.<<<EOD
</td></tr></table>
EOD;
}
class AccordionPluginHTMLBuilder
{
var $description;
var $heading;
var $isopened;
var $scriptVarName;
var $callcount;
function AccordionPluginHTMLBuilder() {
$this->callcount = 0;
$this->setDefaultSettings();
}
function setDefaultSettings(){
$this->description = "...";
$this->heading = "h2";
$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", "", $thi...
$this->description = preg_replace( "/<\/p>$/i", "", $t...
}
function setHeading($heading){
if ($heading == "1"){$this->heading = "h2";}
else if ($heading == "2"){$this->heading = "h3";}
else if ($heading == "3"){$this->heading = "h4";}
else if ($heading == "4"){$this->heading = "h5";}
}
function build(){
$this->callcount++;
$html = array();
array_push( $html, $this->buildButtonHtml() );
array_push( $html, $this->buildContentHtml() );
return join($html);
}
function buildButtonHtml(){
$button = ($this->isopened) ? "-" : "+";
//white style
//cursor:pointer;font-family: "MS Pゴシック",...
//black style
//cursor:pointer;font-family: "MS Pゴシック",...
//default style
//cursor:pointer;font-family: "MS Pゴシック",...
return <<<EOD
<{$this->heading}><span id=acd_button$this->callcoun...
onclick="
if(document.getElementById('acd_content$this->callcount...
document.getElementById('acd_content$this->callcount')...
document.getElementById('acd_button$this->callcount')....
}else{
document.getElementById('acd_content$this->callcount')...
document.getElementById('acd_button$this->callcount')....
}
">$button</span> $this->description</{$this->headi...
<table><tr>
EOD;
}
function buildContentHtml(){
$contentstyle = ($this->isopened) ? "display:block;" :...
return <<<EOD
<td id=acd_content$this->callcount style="{$contentstyle...
EOD;
}
}// end class RegionPluginHTMLBuilder
?>
**ライセンス [#d3402fb8]
-GPLv3
**コメント [#tf9f2eb1]
#comment
ページ名: