4 * FOOT NOTE PLUG-IN FOR NucleusCMS
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)
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
18 * @link http://nakahara21.com
21 class NP_FootNote extends NucleusPlugin
26 return 'Foot Note Plugin.';
39 $original = 'http://nakahara21.com/';
40 $wikiPage = 'http://japan.nucleuscms.org/wiki/plugins:footnote';
49 function getDescription()
51 $description = _FNOTE_DESC;
55 function supportsFeature($what)
58 case 'SqlTablePrefix':
68 $this->createOption('CreateTitle', _CLT_TITLE, 'yesno', 'yes');
69 $this->createOption('Split', _NOTE_SPLT, 'yesno', 'no');
72 function getEventList()
83 $language = ereg_replace( '[\\|/]', '', getLanguageName());
84 if (file_exists($this->getDirectory() . $language . '.php')) {
85 include_once($this->getDirectory() . $language . '.php');
87 include_once($this->getDirectory() . 'english.php');
91 function event_PreSkinParse($data)
93 $this->skinType = $data['type'];
96 function event_PreItem($data)
98 $skinType = $this->skinType;
100 $this->noteList = array();
101 $this->itemId = $data['item']->itemid;
106 $iBody =& $data['item']->body;
107 $iMore =& $data['item']->more;
108 $iBody = preg_replace_callback("/\(\((.*)\)\)/Us",
111 $nsplit = $this->getOption('Split');
112 if ($nsplit == 'yes' && $skinType != 'item') {
113 if ($footNote = implode('', $this->noteList)) {
114 $iBody .= '<ul class="footnote">' . $footNote . '</ul>';
116 $this->noteList = array();
119 $iMore = preg_replace_callback("/\(\((.*)\)\)/Us",
122 if ($footNote = implode('', $this->noteList)) {
123 $iMore .= '<ul class="footnote">' . $footNote . '</ul>';
125 } elseif ($footNote = implode('', $this->noteList)) {
126 $iBody .= '<ul class="footnote">' . $footNote . '</ul>';
130 function footnote($matches){
133 $iid = intval($this->itemId);
134 $bid = getBlogIDFromItemID($iid);
135 $b =& $manager->getBlog($bid);
136 $bsname = $b->getShortName();
137 if ($this->getOption('CreateTitle') == 'yes') {
138 $fNote = htmlspecialchars(strip_tags($matches[1]));
139 $fNote = preg_replace('/\r\n/s', '', $fNote);
140 $fNote = ' title="' . $fNote . '"';
144 $footNoteID = $bsname . $iid . '-' . $this->nodeId;
145 $note = '<span class="footnote">'
147 . ' href="#' . $footNoteID . '"'
149 . ' name="' . $footNoteID . 'f"'
150 . ' id="' . $footNoteID . 'f"'
152 . '*' . $this->nodeid
155 $this->noteList[] = '<li>'
157 . ' href="#' . $footNoteID . 'f"'
158 . ' name="' . $footNoteID . '"'
159 . ' id="' . $footNoteID . '"'
161 . _NOTE_WORD . $this->nodeId