OSDN Git Service

langFile 分割
authorshizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 21 Nov 2006 08:08:01 +0000 (08:08 +0000)
committershizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 21 Nov 2006 08:08:01 +0000 (08:08 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@484 1ca29b6e-896d-4ea0-84a5-967f57386b96

trunk/NP_FootNote/NP_FootNote.php
trunk/NP_FootNote/footnote/english.php [new file with mode: 0644]
trunk/NP_FootNote/footnote/japanese-euc.php [new file with mode: 0644]
trunk/NP_FootNote/footnote/japanese-utf8.php [new file with mode: 0644]
trunk/NP_FootNote/footnote/readme.txt [new file with mode: 0644]

index fd018c3..3d7d456 100644 (file)
@@ -1,30 +1,26 @@
 <?php 
-/* 
-NP_FootNote 
-はてなダイアリーなどで使用される脚注を作成するプラグイン。 
-本文中に(())で囲まれたフレーズがあると、脚注として表示します。 
-もとのデータ自体は変更せず、パースする際に変換しています。 
-
-変更履歴 
-0.3:SecurityFix and XHTML Valid.
-0.3:注釈がない記事にも無駄なコードを追加していたバグ修正。
-0.2:拡張領域に入力がない場合無駄なコードを追加していたバグ修正。
-0.1+:本文と拡張文とで注解を分ける指定をオプションに追加。
-0.1:本文注の部分に入ったAタグのtitle属性から不要な文字を削除するようにした。またこの部分の表示/非表示を切り替えるオプションを追加。 
-0.06:同じ行に(())があると一つの注としてまとめられるバグを修正。注内部での改行をサポート。 
-0.05:拡張領域のみに注がある場合に注が表示されないバグを修正。 
-0.04:拡張領域への注に対応。注がある場合には拡張領域に注を表示するようにした。 
-0.03:とりあえず版リリース。 
-
-*/ 
+/**
+  *
+  * FOOT NOTE PLUG-IN FOR NucleusCMS
+  * PHP versions 4 and 5
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+  * as published by the Free Software Foundation; either version 2
+  * of the License, or (at your option) any later version.
+  * (see nucleus/documentation/index.html#license for more info)
+  *
+  * @author    Original Author nakahara21
+  * @copyright 2005-2006 nakahara21
+  * @license   http://www.gnu.org/licenses/gpl.txt
+  *             GNU GENERAL PUBLIC LICENSE Version 2, June 1991
+  * @version   0.32
+  * @link              http://nakahara21.com
+  *
+  **/
 class NP_FootNote extends NucleusPlugin
 {
 
-       var $bsname;
-       var $item_id;
-       var $note_id;
-       var $notelist;
-
     function getName()
     {
         return 'Foot Note Plugin.';
@@ -32,22 +28,28 @@ class NP_FootNote extends NucleusPlugin
 
     function getAuthor()
     {
-        return 'charlie + nakahara21 + shizuki';
+        $author = 'charlie, '
+                       . 'nakahara21, '
+                       . 'shizuki';
+        return $author;
     }
 
     function getURL()
     {
-        return 'http://xx.nakahara21.net/';
+        $original = 'http://nakahara21.com/';
+        $wikiPage = 'http://japan.nucleuscms.org/wiki/plugins:footnote';
+        return $wikiPage;
     }
 
     function getVersion()
     {
-        return '0.31';
+        return '0.32';
     }
 
     function getDescription()
     {
-        return 'はてな、Wikiで使用される脚注を生成するプラグインです。本文中に((と))で囲まれたフレーズがあると、脚注として表示します。';
+        $description = _FNOTE_DESC;
+        return $description;
     }
 
        function supportsFeature($what)
@@ -63,16 +65,27 @@ class NP_FootNote extends NucleusPlugin
 
        function install()
        {
-               $this->createOption('CreateTitle', '本文注のリンクにTitle属性を付加しますか?', 'yesno', 'yes');
-               $this->createOption('Split', '本文と拡張文で注解を分けますか?(アイテムページは常にまとめて最下部になります)', 'yesno', 'no');
+               $this->createOption('CreateTitle', _CLT_TITLE, 'yesno', 'yes');
+               $this->createOption('Split',       _NOTE_SPLT, 'yesno', 'no');
        }
 
        function getEventList()
        {
-               return array(
-                       'PreItem',
-                       'PreSkinParse'
-               );
+               $events = array (
+                                                'PreItem',
+                                                'PreSkinParse'
+                                               );
+               return $events;
+       }
+
+       function init()
+       {
+               $language = ereg_replace( '[\\|/]', '', getLanguageName());
+               if (file_exists($this->getDirectory()  . $language . '.php')) {
+                       include_once($this->getDirectory() . $language . '.php');
+               }else {
+                       include_once($this->getDirectory() . 'english.php');
+               }
        }
 
        function event_PreSkinParse($data)
@@ -82,48 +95,73 @@ class NP_FootNote extends NucleusPlugin
 
        function event_PreItem($data)
        {
-//             global $i, $id, $notelist;
-               global $blogid, $manager;
-//             $this->currentItem =& $data['item'];
-               $this->node_id = 0;
-               $b =& $manager->getBlog($blogid);
-               $this->bsname = $b->getShortName();
-               $this->notelist = array();
-               $this->item_id = intval($data['item']->itemid);
-               $data['item']->body = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $data['item']->body);
-               if ($this->getOption('Split') == 'yes' && $this->skinType != 'item') {
-                       if ($footnote = @join('', $this->notelist)) {
-                               $data['item']->body .= '<ul class="footnote">' . $footnote . '</ul>';
+               $skinType       =  $this->skinType;
+               $this->nodeId   =  0;
+               $this->noteList =  array();
+               $this->itemId   =  $data['item']->itemid;
+               $cData          =  array(
+                                                            &$this,
+                                                            'footnote'
+                                                           );
+               $iBody          =& $data['item']->body;
+               $iMore          =& $data['item']->more;
+               $iBody          =  preg_replace_callback("/\(\((.*)\)\)/Us",
+                                                                                                $cData,
+                                                                                                $iBody);
+               $nsplit         =  $this->getOption('Split');
+               if ($nsplit == 'yes' && $skinType != 'item') {
+                       if ($footNote = implode('', $this->noteList)) {
+                               $iBody .= '<ul class="footnote">' . $footNote . '</ul>';
                        }
-                       $this->notelist = array();
+                       $this->noteList = array();
                }
-               if ($data['item']->more) {
-                       $data['item']->more = preg_replace_callback("/\(\((.*)\)\)/Us", array(&$this, 'footnote'), $data['item']->more);
-                       if ($footnote = @join('', $this->notelist)) {
-                               $data['item']->more .= '<ul class="footnote">' . $footnote . '</ul>';
+               if ($iMore) {
+                       $iMore = preg_replace_callback("/\(\((.*)\)\)/Us",
+                                                                                  $cData,
+                                                                                  $iMore);
+                       if ($footNote = implode('', $this->noteList)) {
+                               $iMore .= '<ul class="footnote">' . $footNote . '</ul>';
                        }
-               } elseif ($footnote = @join('', $this->notelist)) {
-                       $data['item']->body .= '<ul class="footnote">' . $footnote . '</ul>';
+               } elseif ($footNote = implode('', $this->noteList)) {
+                       $iBody .= '<ul class="footnote">' . $footNote . '</ul>';
                }
        }
 
        function footnote($matches){
-//             global $i, $id, $notelist;
-               $this->node_id++;
+               global $manager;
+               $this->nodeId++;
+               $iid    =  intval($this->itemId);
+               $bid    =  getBlogIDFromItemID($iid);
+               $b      =& $manager->getBlog($bid);
+               $bsname =  $b->getShortName();
                if ($this->getOption('CreateTitle') == 'yes') {
-                       $fnote2 = htmlspecialchars(strip_tags($matches[1]));
-                       $fnote2 = preg_replace('/\r\n/s', '', $fnote2);
-                       $fnote2 = ' title="' . $fnote2 . '"';
+                       $fNote = htmlspecialchars(strip_tags($matches[1]));
+                       $fNote = preg_replace('/\r\n/s', '', $fNote);
+                       $fNote = ' title="' . $fNote . '"';
                }else{
-                       $fnote2 = '';
+                       $fNote = '';
                }
-               $note = '<span class="footnote"><a href="#' .
-                               $this->bsname . $this->item_id . '-' . $this->node_id . '"' . $fnote2 . '>*' . $this->node_id .
-                               '</a><a name="' . $this->bsname . $this->item_id . '-' . $this->node_id . 'f"></a></span>';
-               $this->notelist[] = '<a name="' . $this->bsname . $this->item_id . '-' . $this->node_id . '"></a><li><a href="#' .
-                                                       $this->bsname . $this->item_id . '-' . $this->node_id . 'f">注' . $this->node_id . '</a>' . $matches[1] . '</li>';
+               $footNoteID       = $bsname . $iid . '-' . $this->nodeId;
+               $note             = '<span class="footnote">'
+                                             . '<a'
+                                             . ' href="#' . $footNoteID . '"'
+                                             . $fNote
+                                             . ' name="' . $footNoteID . 'f"'
+                                             . ' id="'   . $footNoteID . 'f"'
+                                             . '>'
+                                             . '*' . $this->nodeid
+                                             . '</a>'
+                                             . '</span>';
+               $this->noteList[] = '<li>'
+                                             . '<a '
+                                             . 'href="#' . $footNoteID . 'f" '
+                                             . 'name="' . $footNoteID . '"'
+                                             . 'id="'   . $footNoteID . '"'
+                                             . '>'
+                                             . _NOTE_WORD . $this->nodeId
+                                             . '</a>'
+                                             . $matches[1]
+                                             . '</li>';
                return $note;
        }
 }
-
-?>
\ No newline at end of file
diff --git a/trunk/NP_FootNote/footnote/english.php b/trunk/NP_FootNote/footnote/english.php
new file mode 100644 (file)
index 0000000..f4b8802
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+       define('_FNOTE_DESC',   'This plugin provides Wiki like FootNote.'
+                                                 . '<br />'
+                          . 'If the phrase surrounded by "(("and"))"'
+                             . ' is in the text, it will display as a footnote.');
+       define('_CLT_TITLE',    'add "title" attribute ?');
+       define('_NOTE_SPLT',    'Display FootNote as own phrase ?');
+       define('_NOTE_WORD',    'note');
+       
\ No newline at end of file
diff --git a/trunk/NP_FootNote/footnote/japanese-euc.php b/trunk/NP_FootNote/footnote/japanese-euc.php
new file mode 100644 (file)
index 0000000..31f0bff
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+       define('_FNOTE_DESC',   'Wiki ¤ä ¤Ï¤Æ¤Ê ¤Ë¤¢¤ë¤è¤¦¤ÊµÓÃí¤òÀ¸À®¤¹¤ë¥×¥é¥°¥¤¥ó¤Ç¤¹'
+                                                 . '<br />'
+                          . 'ËÜʸÃæ¤Î"(("¤È"))"¤Ç¶´¤Þ¤ì¤¿Éôʬ¤ò'
+                             . 'µÓÃí¤È¤·¤Æɽ¼¨¤·¤Þ¤¹');
+       define('_CLT_TITLE',    'ËÜʸÃí¤Î¥ê¥ó¥¯¤ËTitle°À­¤òÉղä·¤Þ¤¹¤«¡©');
+       define('_NOTE_SPLT',    'ËÜʸ¤È³Èĥʸ¤ÇÃí²ò¤òʬ¤±¤Þ¤¹¤«¡©'
+                                                 . '(¥¢¥¤¥Æ¥à¥Ú¡¼¥¸¤Ï¾ï¤Ë¤Þ¤È¤á¤ÆºÇ²¼Éô¤Ë¤Ê¤ê¤Þ¤¹)');
+       define('_NOTE_WORD',    'Ãí');
+                                                 
\ No newline at end of file
diff --git a/trunk/NP_FootNote/footnote/japanese-utf8.php b/trunk/NP_FootNote/footnote/japanese-utf8.php
new file mode 100644 (file)
index 0000000..617b699
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+       define('_FNOTE_DESC',   'Wiki や はてな にあるような脚注を生成するプラグインです'
+                                                 . '<br />'
+                          . '本文中の"(("と"))"で挟まれた部分を'
+                             . '脚注として表示します');
+       define('_CLT_TITLE',    '本文注のリンクにTitle属性を付加しますか?');
+       define('_NOTE_SPLT',    '本文と拡張文で注解を分けますか?'
+                                                 . '(アイテムページは常にまとめて最下部になります)');
+       define('_NOTE_WORD',    '注');
+                                                 
\ No newline at end of file
diff --git a/trunk/NP_FootNote/footnote/readme.txt b/trunk/NP_FootNote/footnote/readme.txt
new file mode 100644 (file)
index 0000000..66def25
--- /dev/null
@@ -0,0 +1,17 @@
+NP_FootNote 
+はてなダイアリーなどで使用される脚注を作成するプラグイン。 
+本文中に(())で囲まれたフレーズがあると、脚注として表示します。 
+もとのデータ自体は変更せず、パースする際に変換しています。 
+
+変更履歴
+0.32:日本語部分の外部ファイル化
+0.31:変数の整理及び、Zend コーディング規約準拠 
+0.3 :SecurityFix and XHTML Valid.
+0.3 :注釈がない記事にも無駄なコードを追加していたバグ修正。
+0.2 :拡張領域に入力がない場合無駄なコードを追加していたバグ修正。
+0.1+:本文と拡張文とで注解を分ける指定をオプションに追加。
+0.1 :本文注の部分に入ったAタグのtitle属性から不要な文字を削除するようにした。またこの部分の表示/非表示を切り替えるオプションを追加。 
+0.06:同じ行に(())があると一つの注としてまとめられるバグを修正。注内部での改行をサポート。 
+0.05:拡張領域のみに注がある場合に注が表示されないバグを修正。 
+0.04:拡張領域への注に対応。注がある場合には拡張領域に注を表示するようにした。 
+0.03:とりあえず版リリース。