• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの


Commit MetaInfo

Revision5eb961bebfdafa35918469689e2c6d1b381c43b7 (tree)
Time2006-11-21 17:08:01
Authorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

langFile 分割

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@484 1ca29b6e-896d-4ea0-84a5-967f57386b96

Change Summary

Incremental Difference

--- a/trunk/NP_FootNote/NP_FootNote.php
+++ b/trunk/NP_FootNote/NP_FootNote.php
@@ -1,30 +1,26 @@
11 <?php
2-/*
3-NP_FootNote
4-はてなダイアリーなどで使用される脚注を作成するプラグイン。
5-本文中に(())で囲まれたフレーズがあると、脚注として表示します。
6-もとのデータ自体は変更せず、パースする際に変換しています。
7-
8-変更履歴
9-0.3:SecurityFix and XHTML Valid.
10-0.3:注釈がない記事にも無駄なコードを追加していたバグ修正。
11-0.2:拡張領域に入力がない場合無駄なコードを追加していたバグ修正。
12-0.1+:本文と拡張文とで注解を分ける指定をオプションに追加。
13-0.1:本文注の部分に入ったAタグのtitle属性から不要な文字を削除するようにした。またこの部分の表示/非表示を切り替えるオプションを追加。
14-0.06:同じ行に(())があると一つの注としてまとめられるバグを修正。注内部での改行をサポート。
15-0.05:拡張領域のみに注がある場合に注が表示されないバグを修正。
16-0.04:拡張領域への注に対応。注がある場合には拡張領域に注を表示するようにした。
17-0.03:とりあえず版リリース。
18-
19-*/
2+/**
3+ *
4+ * FOOT NOTE PLUG-IN FOR NucleusCMS
5+ * PHP versions 4 and 5
6+ *
7+ * This program is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU General Public License
9+ * as published by the Free Software Foundation; either version 2
10+ * of the License, or (at your option) any later version.
11+ * (see nucleus/documentation/index.html#license for more info)
12+ *
13+ * @author Original Author nakahara21
14+ * @copyright 2005-2006 nakahara21
15+ * @license http://www.gnu.org/licenses/gpl.txt
16+ * GNU GENERAL PUBLIC LICENSE Version 2, June 1991
17+ * @version 0.32
18+ * @link http://nakahara21.com
19+ *
20+ **/
2021 class NP_FootNote extends NucleusPlugin
2122 {
2223
23- var $bsname;
24- var $item_id;
25- var $note_id;
26- var $notelist;
27-
2824 function getName()
2925 {
3026 return 'Foot Note Plugin.';
@@ -32,22 +28,28 @@ class NP_FootNote extends NucleusPlugin
3228
3329 function getAuthor()
3430 {
35- return 'charlie + nakahara21 + shizuki';
31+ $author = 'charlie, '
32+ . 'nakahara21, '
33+ . 'shizuki';
34+ return $author;
3635 }
3736
3837 function getURL()
3938 {
40- return 'http://xx.nakahara21.net/';
39+ $original = 'http://nakahara21.com/';
40+ $wikiPage = 'http://japan.nucleuscms.org/wiki/plugins:footnote';
41+ return $wikiPage;
4142 }
4243
4344 function getVersion()
4445 {
45- return '0.31';
46+ return '0.32';
4647 }
4748
4849 function getDescription()
4950 {
50- return 'はてな、Wikiで使用される脚注を生成するプラグインです。本文中に((と))で囲まれたフレーズがあると、脚注として表示します。';
51+ $description = _FNOTE_DESC;
52+ return $description;
5153 }
5254
5355 function supportsFeature($what)
@@ -63,16 +65,27 @@ class NP_FootNote extends NucleusPlugin
6365
6466 function install()
6567 {
66- $this->createOption('CreateTitle', '本文注のリンクにTitle属性を付加しますか?', 'yesno', 'yes');
67- $this->createOption('Split', '本文と拡張文で注解を分けますか?(アイテムページは常にまとめて最下部になります)', 'yesno', 'no');
68+ $this->createOption('CreateTitle', _CLT_TITLE, 'yesno', 'yes');
69+ $this->createOption('Split', _NOTE_SPLT, 'yesno', 'no');
6870 }
6971
7072 function getEventList()
7173 {
72- return array(
73- 'PreItem',
74- 'PreSkinParse'
75- );
74+ $events = array (
75+ 'PreItem',
76+ 'PreSkinParse'
77+ );
78+ return $events;
79+ }
80+
81+ function init()
82+ {
83+ $language = ereg_replace( '[\\|/]', '', getLanguageName());
84+ if (file_exists($this->getDirectory() . $language . '.php')) {
85+ include_once($this->getDirectory() . $language . '.php');
86+ }else {
87+ include_once($this->getDirectory() . 'english.php');
88+ }
7689 }
7790
7891 function event_PreSkinParse($data)
@@ -82,48 +95,73 @@ class NP_FootNote extends NucleusPlugin
8295
8396 function event_PreItem($data)
8497 {
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($data['item']->itemid);
93- $data['item']->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)) {
96- $data['item']->body .= '<ul class="footnote">' . $footnote . '</ul>';
98+ $skinType = $this->skinType;
99+ $this->nodeId = 0;
100+ $this->noteList = array();
101+ $this->itemId = $data['item']->itemid;
102+ $cData = array(
103+ &$this,
104+ 'footnote'
105+ );
106+ $iBody =& $data['item']->body;
107+ $iMore =& $data['item']->more;
108+ $iBody = preg_replace_callback("/\(\((.*)\)\)/Us",
109+ $cData,
110+ $iBody);
111+ $nsplit = $this->getOption('Split');
112+ if ($nsplit == 'yes' && $skinType != 'item') {
113+ if ($footNote = implode('', $this->noteList)) {
114+ $iBody .= '<ul class="footnote">' . $footNote . '</ul>';
97115 }
98- $this->notelist = array();
116+ $this->noteList = array();
99117 }
100- if ($data['item']->more) {
101- $data['item']->more = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $data['item']->more);
102- if ($footnote = @join('', $this->notelist)) {
103- $data['item']->more .= '<ul class="footnote">' . $footnote . '</ul>';
118+ if ($iMore) {
119+ $iMore = preg_replace_callback("/\(\((.*)\)\)/Us",
120+ $cData,
121+ $iMore);
122+ if ($footNote = implode('', $this->noteList)) {
123+ $iMore .= '<ul class="footnote">' . $footNote . '</ul>';
104124 }
105- } elseif ($footnote = @join('', $this->notelist)) {
106- $data['item']->body .= '<ul class="footnote">' . $footnote . '</ul>';
125+ } elseif ($footNote = implode('', $this->noteList)) {
126+ $iBody .= '<ul class="footnote">' . $footNote . '</ul>';
107127 }
108128 }
109129
110130 function footnote($matches){
111-// global $i, $id, $notelist;
112- $this->node_id++;
131+ global $manager;
132+ $this->nodeId++;
133+ $iid = intval($this->itemId);
134+ $bid = getBlogIDFromItemID($iid);
135+ $b =& $manager->getBlog($bid);
136+ $bsname = $b->getShortName();
113137 if ($this->getOption('CreateTitle') == 'yes') {
114- $fnote2 = htmlspecialchars(strip_tags($matches[1]));
115- $fnote2 = preg_replace('/\r\n/s', '', $fnote2);
116- $fnote2 = ' title="' . $fnote2 . '"';
138+ $fNote = htmlspecialchars(strip_tags($matches[1]));
139+ $fNote = preg_replace('/\r\n/s', '', $fNote);
140+ $fNote = ' title="' . $fNote . '"';
117141 }else{
118- $fnote2 = '';
142+ $fNote = '';
119143 }
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>';
144+ $footNoteID = $bsname . $iid . '-' . $this->nodeId;
145+ $note = '<span class="footnote">'
146+ . '<a'
147+ . ' href="#' . $footNoteID . '"'
148+ . $fNote
149+ . ' name="' . $footNoteID . 'f"'
150+ . ' id="' . $footNoteID . 'f"'
151+ . '>'
152+ . '*' . $this->nodeid
153+ . '</a>'
154+ . '</span>';
155+ $this->noteList[] = '<li>'
156+ . '<a '
157+ . 'href="#' . $footNoteID . 'f" '
158+ . 'name="' . $footNoteID . '"'
159+ . 'id="' . $footNoteID . '"'
160+ . '>'
161+ . _NOTE_WORD . $this->nodeId
162+ . '</a>'
163+ . $matches[1]
164+ . '</li>';
125165 return $note;
126166 }
127167 }
128-
129-?>
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_FootNote/footnote/english.php
@@ -0,0 +1,9 @@
1+<?php
2+ define('_FNOTE_DESC', 'This plugin provides Wiki like FootNote.'
3+ . '<br />'
4+ . 'If the phrase surrounded by "(("and"))"'
5+ . ' is in the text, it will display as a footnote.');
6+ define('_CLT_TITLE', 'add "title" attribute ?');
7+ define('_NOTE_SPLT', 'Display FootNote as own phrase ?');
8+ define('_NOTE_WORD', 'note');
9+
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_FootNote/footnote/japanese-euc.php
@@ -0,0 +1,10 @@
1+<?php
2+ define('_FNOTE_DESC', 'Wiki や はてな にあるような脚注を生成するプラグインです'
3+ . '<br />'
4+ . '本文中の"(("と"))"で挟まれた部分を'
5+ . '脚注として表示します');
6+ define('_CLT_TITLE', '本文注のリンクにTitle属性を付加しますか?');
7+ define('_NOTE_SPLT', '本文と拡張文で注解を分けますか?'
8+ . '(アイテムページは常にまとめて最下部になります)');
9+ define('_NOTE_WORD', '注');
10+
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_FootNote/footnote/japanese-utf8.php
@@ -0,0 +1,10 @@
1+<?php
2+ define('_FNOTE_DESC', 'Wiki や はてな にあるような脚注を生成するプラグインです'
3+ . '<br />'
4+ . '本文中の"(("と"))"で挟まれた部分を'
5+ . '脚注として表示します');
6+ define('_CLT_TITLE', '本文注のリンクにTitle属性を付加しますか?');
7+ define('_NOTE_SPLT', '本文と拡張文で注解を分けますか?'
8+ . '(アイテムページは常にまとめて最下部になります)');
9+ define('_NOTE_WORD', '注');
10+
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_FootNote/footnote/readme.txt
@@ -0,0 +1,17 @@
1+NP_FootNote
2+はてなダイアリーなどで使用される脚注を作成するプラグイン。
3+本文中に(())で囲まれたフレーズがあると、脚注として表示します。
4+もとのデータ自体は変更せず、パースする際に変換しています。
5+
6+変更履歴
7+0.32:日本語部分の外部ファイル化
8+0.31:変数の整理及び、Zend コーディング規約準拠
9+0.3 :SecurityFix and XHTML Valid.
10+0.3 :注釈がない記事にも無駄なコードを追加していたバグ修正。
11+0.2 :拡張領域に入力がない場合無駄なコードを追加していたバグ修正。
12+0.1+:本文と拡張文とで注解を分ける指定をオプションに追加。
13+0.1 :本文注の部分に入ったAタグのtitle属性から不要な文字を削除するようにした。またこの部分の表示/非表示を切り替えるオプションを追加。
14+0.06:同じ行に(())があると一つの注としてまとめられるバグを修正。注内部での改行をサポート。
15+0.05:拡張領域のみに注がある場合に注が表示されないバグを修正。
16+0.04:拡張領域への注に対応。注がある場合には拡張領域に注を表示するようにした。
17+0.03:とりあえず版リリース。
Show on old repository browser