Code: Select all
<?php
/*
NP_FootNote
ã¯ã¦ãªãƒ€ã‚¤ã‚¢ãƒªãƒ¼ãªã©ã§ä½¿ç”¨ã•れる脚注
を作æˆã™ã‚‹ãƒ—ラグイン。
本文ä¸ã«(())ã§å›²ã¾ã‚ŒãŸãƒ•レーズãŒã‚ã
‚‹ã¨ã€è„𿳍ã¨ã—ã¦è¡¨ç¤ºã—ã¾ã™ã€‚
ã‚‚ã¨ã®ãƒ‡ãƒ¼ã‚¿è‡ªä½“ã¯å¤‰æ›´ã›ãšã€ãƒ‘ースã™
ã‚‹éš›ã«å¤‰æ›ã—ã¦ã„ã¾ã™ã€‚
変更履æ´
0.3:注釈ãŒãªã„記事ã«ã‚‚ç„¡é§„ãªã‚³ãƒ¼ãƒ‰ã‚’è¿½åŠ ã—ã¦ã„ãŸãƒã‚°ä¿®æ£ã€‚
0.2:æ‹¡å¼µé ˜åŸŸã«å…¥åŠ›ãŒãªã„å ´åˆç„¡é§„ãªã‚³ãƒ¼ãƒ‰ã‚’è¿½åŠ ã—ã¦ã„ãŸãƒã‚°ä¿®æ£ã€‚
0.1+:æœ¬æ–‡ã¨æ‹¡å¼µæ–‡ã¨ã§æ³¨è§£ã‚’分ã‘ã‚‹æ
Œ‡å®šã‚’オプションã«è¿½åŠ ã€‚
0.1:本文注ã®éƒ¨åˆ†ã«å…¥ã£ãŸAã‚¿ã‚°ã®title
属性ã‹ã‚‰ä¸è¦ãªæ–‡å—を削除ã™ã‚‹ã‚ˆã†ã«ã—ãŸã€‚ã¾ãŸã“ã®é
ƒ¨åˆ†ã®è¡¨ç¤º/éžè¡¨ç¤ºã‚’切り替ãˆã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’è¿½åŠ ã€‚
0.06:åŒã˜è¡Œã«(())ãŒã‚ã‚‹ã¨ä¸€ã¤ã®æ³¨ã¨ã—ã¦
ã¾ã¨ã‚られるãƒã‚°ã‚’ä¿®æ£ã€‚注内部ã§ã®æ”¹è
¡Œã‚’サãƒãƒ¼ãƒˆã€‚
0.05ï¼šæ‹¡å¼µé ˜åŸŸã®ã¿ã«æ³¨ãŒã‚ã‚‹å ´åˆã«æ³¨ãŒè¡¨ç¤ºã•れãªã„ãƒã‚°ã‚’ä¿®æ£ã€‚
0.04ï¼šæ‹¡å¼µé ˜åŸŸã¸ã®æ³¨ã«å¯¾å¿œã€‚注ãŒã‚ã‚‹å ´åˆã«ã¯æ‹¡å¼µé ˜åŸŸã«æ³¨ã‚’表示ã™ã‚‹ã‚ˆã†ã«ã—ãŸã€‚
0.03:ã¨ã‚Šã‚ãˆãšç‰ˆãƒªãƒªãƒ¼ã‚¹ã€‚
*/
class NP_FootNote extends NucleusPlugin {
function getName() {
return 'Foot Note Plugin.';
}
function getAuthor() {
return 'charlie + nakahara21';
}
function getURL()
{
return 'http://xx.nakahara21.net/';
}
function getVersion() {
return '0.3';
}
function getDescription() {
return 'ã¯ã¦ãªã€Wikiã§ä½¿ç”¨ã•れる脚注を生æˆã™ã‚‹ãƒ—
ラグインã§ã™ã€‚本文ä¸ã«((ã¨))ã§å›²ã¾ã‚ŒãŸãƒ•ãƒ
¬ãƒ¼ã‚ºãŒã‚ã‚‹ã¨ã€è„𿳍ã¨ã—ã¦è¡¨ç¤ºã—ã¾ã™ã€‚';
}
function supportsFeature($what) {
switch($what){
case 'SqlTablePrefix':
return 1;
default:
return 0;
}
}
function install() {
$this->createOption('CreateTitle','本文注ã®ãƒªãƒ³ã‚¯
ã«Titleå±žæ€§ã‚’ä»˜åŠ ã—ã¾ã™ã‹ï¼Ÿ','yesno','yes');
$this->createOption('Split','æœ¬æ–‡ã¨æ‹¡å¼µæ–‡ã§æ³¨
解を分ã‘ã¾ã™ã‹ï¼Ÿ(アイテムページã¯å¸¸ã«ã¾ã¨ã‚ã¦æœ€ä¸‹éƒ¨ã«ãªã‚Šã¾ã™)','yesno','no');
}
function getEventList() {
return array('PreItem','PreSkinParse');
}
function event_PreSkinParse($data) {
$this->type = $data['type'];
}
function event_PreItem($data) {
global $i, $id, $notelist;
$this->currentItem = &$data["item"];
$i =0;
$notelist = array();
$id = $this->currentItem->itemid;
$this->currentItem->body = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $this->currentItem->body);
if($this->getOption('Split') == 'yes' && $this->type != 'item'){
if($footnote = @join('',$notelist))
$this->currentItem->body .= '<ul class="footnote">' . $footnote . '</ul>';
$notelist = array();
}
if($this->currentItem->more){
$this->currentItem->more = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $this->currentItem->more);
if($footnote = @join('',$notelist))
$this->currentItem->more .= '<ul class="footnote">' . $footnote . '</ul>';
}elseif($footnote = @join('',$notelist)){
$this->currentItem->body .= '<ul class="footnote">' . $footnote . '</ul>';
}
}
function footnote($matches){
global $i, $id, $notelist;
$i++;
if($this->getOption('CreateTitle') == 'yes'){
$fnote2 = htmlspecialchars(strip_tags($matches[1]));
$fnote2 = preg_replace('/\r\n/s','',$fnote2);
$fnote2 = ' title="'.$fnote2.'"';
}else{
$fnote2 = '';
}
$note = '<span class="footnote"><a href="#'.$id.'-'.$i.'"'.$fnote2.'>*'.$i.'</a><a name="'.$id.'-'.$i.'f"></a></span>';
$notelist[] = '<a name="'.$id.'-'.$i.'"></a>'.'<li><a href="#'.$id.'-'.$i.'f">注'.$i.'</a>'.$matches[1].'</li>';
return $note;
}
}
?>