Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの
Revision | 68c48d6f6e23ff538b7bebd5bd6c53d6e99d86a4 (tree) |
---|---|
Time | 2006-10-02 17:36:14 |
Author | shizuki <shizuki@1ca2...> |
Commiter | shizuki |
変数の変更
サニタイズは不要?
todo 言語ファイルの分離
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@396 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -6,6 +6,7 @@ NP_FootNote | ||
6 | 6 | もとのデータ自体は変更せず、パースする際に変換しています。 |
7 | 7 | |
8 | 8 | 変更履歴 |
9 | +0.3:SecurityFix and XHTML Valid. | |
9 | 10 | 0.3:注釈がない記事にも無駄なコードを追加していたバグ修正。 |
10 | 11 | 0.2:拡張領域に入力がない場合無駄なコードを追加していたバグ修正。 |
11 | 12 | 0.1+:本文と拡張文とで注解を分ける指定をオプションに追加。 |
@@ -16,26 +17,42 @@ NP_FootNote | ||
16 | 17 | 0.03:とりあえず版リリース。 |
17 | 18 | |
18 | 19 | */ |
19 | -class NP_FootNote extends NucleusPlugin { | |
20 | - | |
21 | - function getName() { | |
22 | - return 'Foot Note Plugin.'; | |
23 | - } | |
24 | - function getAuthor() { | |
25 | - return 'charlie + nakahara21'; | |
26 | - } | |
27 | - function getURL() | |
28 | - { | |
29 | - return 'http://xx.nakahara21.net/'; | |
30 | - } | |
31 | - function getVersion() { | |
32 | - return '0.3'; | |
33 | - } | |
34 | - function getDescription() { | |
35 | - return 'はてな、Wikiで使用される脚注を生成するプラグインです。本文中に((と))で囲まれたフレーズがあると、脚注として表示します。'; | |
36 | - } | |
37 | - function supportsFeature($what) { | |
38 | - switch($what){ | |
20 | +class NP_FootNote extends NucleusPlugin | |
21 | +{ | |
22 | + | |
23 | + var $bsname; | |
24 | + var $item_id; | |
25 | + var $note_id; | |
26 | + var $notelist; | |
27 | + | |
28 | + function getName() | |
29 | + { | |
30 | + return 'Foot Note Plugin.'; | |
31 | + } | |
32 | + | |
33 | + function getAuthor() | |
34 | + { | |
35 | + return 'charlie + nakahara21 + shizuki'; | |
36 | + } | |
37 | + | |
38 | + function getURL() | |
39 | + { | |
40 | + return 'http://xx.nakahara21.net/'; | |
41 | + } | |
42 | + | |
43 | + function getVersion() | |
44 | + { | |
45 | + return '0.31'; | |
46 | + } | |
47 | + | |
48 | + function getDescription() | |
49 | + { | |
50 | + return 'はてな、Wikiで使用される脚注を生成するプラグインです。本文中に((と))で囲まれたフレーズがあると、脚注として表示します。'; | |
51 | + } | |
52 | + | |
53 | + function supportsFeature($what) | |
54 | + { | |
55 | + switch ($what) { | |
39 | 56 | case 'SqlTablePrefix': |
40 | 57 | return 1; |
41 | 58 | default: |
@@ -44,54 +61,69 @@ class NP_FootNote extends NucleusPlugin { | ||
44 | 61 | } |
45 | 62 | |
46 | 63 | |
47 | - function install() { | |
48 | - $this->createOption('CreateTitle','本文注のリンクにTitle属性を付加しますか?','yesno','yes'); | |
49 | - $this->createOption('Split','本文と拡張文で注解を分けますか?(アイテムページは常にまとめて最下部になります)','yesno','no'); | |
50 | - } | |
64 | + function install() | |
65 | + { | |
66 | + $this->createOption('CreateTitle', '本文注のリンクにTitle属性を付加しますか?', 'yesno', 'yes'); | |
67 | + $this->createOption('Split', '本文と拡張文で注解を分けますか?(アイテムページは常にまとめて最下部になります)', 'yesno', 'no'); | |
68 | + } | |
51 | 69 | |
52 | - function getEventList() { | |
53 | - return array('PreItem','PreSkinParse'); | |
54 | - } | |
70 | + function getEventList() | |
71 | + { | |
72 | + return array( | |
73 | + 'PreItem', | |
74 | + 'PreSkinParse' | |
75 | + ); | |
76 | + } | |
55 | 77 | |
56 | - function event_PreSkinParse($data) { | |
57 | - $this->type = $data['type']; | |
78 | + function event_PreSkinParse($data) | |
79 | + { | |
80 | + $this->skinType = $data['type']; | |
58 | 81 | } |
59 | 82 | |
60 | - function event_PreItem($data) { | |
61 | - global $i, $id, $notelist; | |
62 | - $this->currentItem = &$data["item"]; | |
63 | - $i =0; | |
64 | - $notelist = array(); | |
65 | - $id = $this->currentItem->itemid; | |
66 | - $this->currentItem->body = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $this->currentItem->body); | |
67 | - if($this->getOption('Split') == 'yes' && $this->type != 'item'){ | |
68 | - if($footnote = @join('',$notelist)) | |
83 | + function event_PreItem($data) | |
84 | + { | |
85 | +// global $i, $id, $notelist; | |
86 | + global $blogid, $manager; | |
87 | +// $this->currentItem =& $data['item']; | |
88 | + $this->node_id = 0; | |
89 | + $b =& $manager->getBlog($blogid); | |
90 | + $this->bsname = $b->getShortName(); | |
91 | + $this->notelist = array(); | |
92 | + $this->item_id = intval($this->currentItem->itemid); | |
93 | + $this->currentItem->body = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $data['item']->body); | |
94 | + if ($this->getOption('Split') == 'yes' && $this->skinType != 'item') { | |
95 | + if ($footnote = @join('', $this->notelist)) { | |
69 | 96 | $this->currentItem->body .= '<ul class="footnote">' . $footnote . '</ul>'; |
70 | - $notelist = array(); | |
97 | + } | |
98 | + $this->notelist = array(); | |
71 | 99 | } |
72 | - if($this->currentItem->more){ | |
73 | - $this->currentItem->more = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $this->currentItem->more); | |
74 | - if($footnote = @join('',$notelist)) | |
100 | + if ($this->currentItem->more) { | |
101 | + $this->currentItem->more = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $data['item']->more); | |
102 | + if ($footnote = @join('', $this->notelist)) { | |
75 | 103 | $this->currentItem->more .= '<ul class="footnote">' . $footnote . '</ul>'; |
76 | - }elseif($footnote = @join('',$notelist)){ | |
104 | + } | |
105 | + } elseif ($footnote = @join('', $this->notelist)) { | |
77 | 106 | $this->currentItem->body .= '<ul class="footnote">' . $footnote . '</ul>'; |
78 | 107 | } |
79 | - } | |
108 | + } | |
80 | 109 | |
81 | 110 | function footnote($matches){ |
82 | - global $i, $id, $notelist; | |
83 | - $i++; | |
84 | - if($this->getOption('CreateTitle') == 'yes'){ | |
111 | +// global $i, $id, $notelist; | |
112 | + $this->node_id++; | |
113 | + if ($this->getOption('CreateTitle') == 'yes') { | |
85 | 114 | $fnote2 = htmlspecialchars(strip_tags($matches[1])); |
86 | - $fnote2 = preg_replace('/\r\n/s','',$fnote2); | |
87 | - $fnote2 = ' title="'.$fnote2.'"'; | |
115 | + $fnote2 = preg_replace('/\r\n/s', '', $fnote2); | |
116 | + $fnote2 = ' title="' . $fnote2 . '"'; | |
88 | 117 | }else{ |
89 | 118 | $fnote2 = ''; |
90 | 119 | } |
91 | - $note = '<span class="footnote"><a href="#'.$id.'-'.$i.'"'.$fnote2.'>*'.$i.'</a><a name="'.$id.'-'.$i.'f"></a></span>'; | |
92 | - $notelist[] = '<a name="'.$id.'-'.$i.'"></a>'.'<li><a href="#'.$id.'-'.$i.'f">注'.$i.'</a>'.$matches[1].'</li>'; | |
120 | + $note = '<span class="footnote"><a href="#' . | |
121 | + $this->bsname . $this->item_id . '-' . $this->node_id . '"' . $fnote2 . '>*' . $this->node_id . | |
122 | + '</a><a name="' . $this->bsname . $this->item_id . '-' . $this->node_id . 'f"></a></span>'; | |
123 | + $$this->notelist[] = '<a name="' . $this->bsname . $this->item_id . '-' . $this->node_id . '"></a><li><a href="#' . | |
124 | + $this->bsname . $this->item_id . '-' . $this->node_id . 'f">注' . $this->node_id . '</a>' . $matches[1] . '</li>'; | |
93 | 125 | return $note; |
94 | - | |
95 | 126 | } |
96 | -} | |
127 | +} | |
128 | + | |
97 | 129 | ?> |
\ No newline at end of file |