• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

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


Commit MetaInfo

Revision1739c69c94c5c2dde2b78584acfe76e70190d097 (tree)
Time2006-10-02 12:27:10
Authorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

*** empty log message ***

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

Change Summary

Incremental Difference

--- a/trunk/NP_ItemNaviEX/NP_ItemNaviEX.php
+++ b/trunk/NP_ItemNaviEX/NP_ItemNaviEX.php
@@ -4,33 +4,27 @@
44 * BreadCrumbsList PLUG-IN FOR NucleusCMS
55 * PHP versions 4 and 5
66 *
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+ *
713 * @author Original Author nakahara21
814 * @copyright 2005-2006 nakahara21
915 * @license http://www.gnu.org/licenses/gpl.txt GNU GENERAL PUBLIC LICENSE Version 2, June 1991
1016 * @version 0.41
1117 * @link http://nakahara21.com
1218 *
13- * 0.41 security fix
14- * 0.4 fixed bug: numlic only
15- * 0.3 fixed bug: delete action
16- * 0.2 supports and/or query
19+ * 0.991 add sub-blog home mode
20+ * 0.99 sec fix
1721 *
18- */
19-
20-/*
22+ **************************************************************************
2123 *
2224 * THESE PLUG-INS ARE DEDICATED TO ALL THOSE NucleusCMS USERS
2325 * WHO FIGHT CORRUPTION AND IRRATIONAL IN EVERY DAY OF THEIR LIVES.
2426 *
25- */
26-
27-// plugin needs to work on Nucleus versions <=2.0 as well
28-if (!function_exists('sql_table')){
29- function sql_table($name) {
30- return 'nucleus_' . $name;
31- }
32-}
33-
27+ **************************************************************************/
3428
3529 class NP_ItemNaviEX extends NucleusPlugin
3630 {
@@ -38,22 +32,27 @@ class NP_ItemNaviEX extends NucleusPlugin
3832 {
3933 return 'Navigation Bar';
4034 }
35+
4136 function getAuthor()
4237 {
4338 return 'nakahara21';
4439 }
40+
4541 function getURL()
4642 {
4743 return 'http://nakahara21.com/';
4844 }
45+
4946 function getVersion()
5047 {
51- return '0.99';
48+ return '0.991';
5249 }
50+
5351 function getDescription()
5452 {
5553 return 'Add link to prev item and next item. Usage: &lt;%ItemNaviEX()%&gt; or &lt;%ItemNaviEX(0)%&gt;';
5654 }
55+
5756 function supportsFeature($what)
5857 {
5958 switch($what){
@@ -74,9 +73,9 @@ class NP_ItemNaviEX extends NucleusPlugin
7473 function createNaviLink($unitArray)
7574 {
7675 if ($unitArray[1]) {
77- $tempLink = '<a href="' . $unitArray[1] . '">' . $unitArray[0] . '</a>';
76+ $tempLink = '<a href="' . htmlspecialchars($unitArray[1]) . '">' . htmlspecialchars($unitArray[0]) . '</a>';
7877 } else {
79- $tempLink = $unitArray[0];
78+ $tempLink = htmlspecialchars($unitArray[0]);
8079 }
8180 return $tempLink;
8281 }
@@ -87,9 +86,11 @@ class NP_ItemNaviEX extends NucleusPlugin
8786 // if ($manager->pluginInstalled('NP_MultipleCategories')) {
8887 // $mplugin =& $manager->getPlugin('NP_MultipleCategories');
8988 // if (method_exists($mplugin,"getRequestName")) {
90- $res = sql_query("SHOW FIELDS FROM " . sql_table('plug_multiple_categories_sub') );
89+ $res = sql_query('SHOW FIELDS FROM ' . sql_table('plug_multiple_categories_sub'));
9190 while ($co = mysql_fetch_assoc($res)) {
92- if($co['Field'] == 'parentid') return TRUE;
91+ if ($co['Field'] == 'parentid') {
92+ return TRUE;
93+ }
9394 }
9495 // }
9596 // }
@@ -97,9 +98,11 @@ class NP_ItemNaviEX extends NucleusPlugin
9798
9899 function doSkinVar($skinType, $showHome = 1)
99100 {
100- global $manager, $blog, $CONF, $itemidprev, $itemidnext, $archive, $archiveprev, $archivenext, $catid, $param, $itemid, $subcatid;
101+ global $manager, $CONF, $blog, $itemid, $itemidprev, $itemidnext;
102+ global $catid, $subcatid, $archive, $archiveprev, $archivenext, $param;
101103
102104 // sanitize
105+ $y = $m = $d = '';
103106 $itemid = intval($itemid);
104107 $catid = intval($catid);
105108 $subcatid = intval($subcatid);
@@ -107,28 +110,25 @@ class NP_ItemNaviEX extends NucleusPlugin
107110 $itemidnext = intval($itemidnext);
108111 if (isset($archive)) {
109112 sscanf($archive,'%d-%d-%d', $y, $m, $d);
110- // directed by shizuki
111- if ($y && $m && $d) {
113+ if ($y && $m && !empty($d)) {
112114 $archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
113- } elseif ($y && $m && !$d) {
115+ } elseif ($y && $m && empty($d)) {
114116 $archive = sprintf('%04d-%02d', $y, $m);
115117 }
116118 }
117119 if (isset($archiveprev)) {
118120 sscanf($archiveprev,'%d-%d-%d', $y, $m, $d);
119- // directed by shizuki
120- if ($y && $m && $d) {
121+ if ($y && $m && !empty($d)) {
121122 $archiveprev = sprintf('%04d-%02d-%02d', $y, $m, $d);
122- } elseif ($y && $m && !$d) {
123+ } elseif ($y && $m && empty($d)) {
123124 $archiveprev = sprintf('%04d-%02d', $y, $m);
124125 }
125126 }
126127 if (isset($archiveprev)) {
127128 sscanf($archiveprev,'%d-%d-%d', $y, $m, $d);
128- // directed by shizuki
129- if ($y && $m && $d) {
129+ if ($y && $m && !empty($d)) {
130130 $archiveprev = sprintf('%04d-%02d-%02d', $y, $m, $d);
131- } elseif ($y && $m && !$d) {
131+ } elseif ($y && $m && empty($d)) {
132132 $archiveprev = sprintf('%04d-%02d', $y, $m);
133133 }
134134 }
@@ -144,19 +144,18 @@ class NP_ItemNaviEX extends NucleusPlugin
144144 } else {
145145 $b =& $manager->getBlog($CONF['DefaultBlog']);
146146 }
147- $blogid = $b->getID();
148- $blogid = intval($blogid);
147+ $blogid = intval($b->getID());
149148
150149 $abuf = '';
151- $mtable = "";
150+ $mtable = '';
152151 $where .= ' and i.iblog=' . $blogid;
153152 if (!empty($catid)) {
154153 if ($manager->pluginInstalled('NP_MultipleCategories')) {
155- $where .= ' and ((i.inumber=p.item_id and (p.categories REGEXP "(^|,)' . $catid . '(,|$)" or i.icat=';
156- $where .= $catid . ')) or (i.icat=' . $catid . ' and p.item_id IS NULL))';
157- $mtable = ' LEFT JOIN ' . sql_table('plug_multiple_categories') . ' as p ON i.inumber=p.item_id';
154+ $where .= ' and ((i.inumber = p.item_id and (p.categories REGEXP "(^|,)' . $catid . '(,|$)"' .
155+ ' or i.icat = ' . $catid . ')) or (i.icat = ' . $catid . ' and p.item_id IS NULL))';
156+ $mtable = ' LEFT JOIN ' . sql_table('plug_multiple_categories') . ' as p ON i.inumber = p.item_id';
158157 $mplugin =& $manager->getPlugin('NP_MultipleCategories');
159- if ($subcatid && method_exists($mplugin, "getRequestName")) {
158+ if ($subcatid && method_exists($mplugin, 'getRequestName')) {
160159 //family
161160 if ($this->checkParent()) {
162161 $Children = array();
@@ -185,7 +184,7 @@ class NP_ItemNaviEX extends NucleusPlugin
185184 $this->linkparams = array();
186185 //store Home =====================================
187186 // comment out this block when HOME is sub-blog top
188- if($showHome > 0){
187+ if ($showHome == 1) {
189188 $naviUnit[] = array(
190189 0 => 'Home',
191190 1 => $CONF['IndexURL']
@@ -193,13 +192,16 @@ class NP_ItemNaviEX extends NucleusPlugin
193192 }
194193
195194 //store Blog =====================================
196- if ($showHome > 0 && ($blogid <> $CONF['DefaultBlog'])) {
197-// if ($showHome > 0) {
195+ if ($showHome == 1 && ($blogid <> $CONF['DefaultBlog'])) {
198196 $naviUnit[] = array(
199- 0 => htmlspecialchars(getBlogNameFromID($blogid)),
200-// 0 => 'Home', // when HOME is sub-blog top
197+ 0 => getBlogNameFromID($blogid),
201198 1 => createBlogidLink($blogid),
202-// 1 => $CONF['BlogURL'] . '/', // when HOME is sub-blog top
199+ 2 => createArchiveListLink($blogid)
200+ );
201+ } elseif ($showHome >= 2) {
202+ $naviUnit[] = array(
203+ 0 => 'Home', // when HOME is sub-blog top
204+ 1 => $CONF['BlogURL'] . '/', // when HOME is sub-blog top
203205 2 => createArchiveListLink($blogid)
204206 );
205207 }
@@ -208,7 +210,7 @@ class NP_ItemNaviEX extends NucleusPlugin
208210 if (!empty($catid)) {
209211 $this->linkparams['catid'] = $catid;
210212 $naviUnit[] = array(
211- 0 => htmlspecialchars($b->getCategoryName($catid)),
213+ 0 => $b->getCategoryName($catid),
212214 1 => createCategoryLink($catid),
213215 // 1 => createBlogidLink($blogid, $this->linkparams),
214216 2 => createArchiveListLink($blogid, $this->linkparams)
@@ -217,20 +219,20 @@ class NP_ItemNaviEX extends NucleusPlugin
217219
218220 //store subCategory =====================================
219221 if (!empty($subcatid)) {
220- $this->linkparams[subcatid] = $subcatid;
221222 if ($manager->pluginInstalled('NP_MultipleCategories')) {
222223 $mplugin =& $manager->getPlugin('NP_MultipleCategories');
223- if (method_exists($mplugin, "getRequestName")) {
224- $subrequest = $mplugin->getRequestName();
225- if($this->checkParent()){
224+ if (method_exists($mplugin, 'getRequestName')) {
225+ $subrequest = $mplugin->getRequestName(array());
226+ $this->linkparams[$subrequest] = $subcatid;
227+ if ($this->checkParent()) {
226228 $tog = $this->getParenta($subcatid, $blogid);
227- for($i=0;$i<count($this->r);$i++){
229+ for ($i=0;$i<count($this->r);$i++) {
228230 $naviUnit[] = $this->r[$i];
229231 }
230232 $naviUnit[] = $tog;
231- }else{
233+ } else {
232234 $naviUnit[] = array(
233- 0 => htmlspecialchars($mplugin->_getScatNameFromID($subcatid)),
235+ 0 => $mplugin->_getScatNameFromID($subcatid),
234236 1 => createCategoryLink($catid, array($subrequest => $subcatid)),
235237 // 1 => createCategoryLink($catid, array('subcatid' => $subcatid)),
236238 // 1 => createBlogidLink($blogid, $this->linkparams),
@@ -241,7 +243,7 @@ class NP_ItemNaviEX extends NucleusPlugin
241243 }
242244 }
243245
244-//store Page =====================================
246+//store Page ===================================== todo How to get PageNo. ? ...cookie...
245247 if (requestVar('page')) {
246248 $naviUnit[] = array(
247249 0 => 'Page.' . intRequestVar('page'),
@@ -253,32 +255,34 @@ class NP_ItemNaviEX extends NucleusPlugin
253255 if ($skinType == 'item') {
254256 $item =& $manager->getItem($itemid, 0, 0);
255257 $naviUnit[] = array(
256- 0 => htmlspecialchars($item['title'])
258+ 0 => $item['title']
257259 );
258260
259261
260262 $query = 'SELECT i.ititle, i.inumber'
261- . ' FROM '.sql_table('item') . ' as i' . $mtable
262- . ' WHERE i.idraft=0'
263- . " and i.itime< '" . $item['itime'] . "' " . $where;
263+ . ' FROM ' . sql_table('item') . ' as i' . $mtable
264+ . ' WHERE i.idraft = 0'
265+ . " and i.itime < '" . $item['itime'] . "' " . $where;
264266 $query .= ' ORDER BY i.itime DESC';
265267 $res = sql_query($query);
266268 if ($ares = mysql_fetch_row($res)) {
267269 $alink = createItemLink($ares[1], $this->linkparams);
268- $subNaviUnit[1] = '<a href="' . $alink . '" rel="prev"> &laquo; ' . shorten($ares[0], 14, '...') . '</a>';
270+ $subNaviUnit[1] = '<a href="' . htmlspecialchars($alink) . '" rel="prev"> &laquo; ' .
271+ shorten($ares[0], 14, '...') . '</a>';
269272 }
270273
271274
272275
273276 $query = 'SELECT i.ititle, i.inumber'
274277 . ' FROM ' . sql_table('item') . ' as i' . $mtable
275- . ' WHERE i.idraft=0'
276- . " and i.itime> '" . $item['itime'] . "' " . $where;
278+ . ' WHERE i.idraft = 0'
279+ . " and i.itime > '" . $item['itime'] . "' " . $where;
277280 $query .= ' ORDER BY i.itime ASC';
278281 $res = sql_query($query);
279282 if ($ares = mysql_fetch_row($res)) {
280283 $alink = createItemLink($ares[1], $this->linkparams);
281- $subNaviUnit[2] = '<a href="' . $alink . '" rel="next"> ' . shorten($ares[0], 14, '...') . ' &raquo;</a>';
284+ $subNaviUnit[2] = '<a href="' . htmlspecialchars($alink) . '" rel="next"> ' .
285+ shorten($ares[0], 14, '...') . ' &raquo;</a>';
282286 }
283287
284288
@@ -293,14 +297,14 @@ class NP_ItemNaviEX extends NucleusPlugin
293297 }
294298
295299 if ($skinType == 'archive') {
296- sscanf($archive,'%04s-%02s-%02s', $y, $m, $d);
300+ sscanf($archive,'%04d-%02d-%02d', $y, $m, $d);
297301 //store ArchiveMonth
298302 $archiveMonth = $y . '-' . $m;
299303 $naviUnit[] = array(
300- 0 => htmlspecialchars($archiveMonth),
304+ 0 => $archiveMonth,
301305 1 => createArchiveLink($blogid, $archiveMonth, $this->linkparams)
302306 );
303- if (!$d) {
307+ if (empty($d)) {
304308 $timestamp_start = mktime(0, 0, 0, $m, 1, $y);
305309 $timestamp_end = mktime(0, 0, 0, $m+1, 1, $y);
306310 $date_str = 'SUBSTRING(i.itime, 1, 7)';
@@ -310,7 +314,7 @@ class NP_ItemNaviEX extends NucleusPlugin
310314 $date_str = 'SUBSTRING(i.itime, 1, 10)';
311315 //store ArchiveDay
312316 $naviUnit[] = array(
313- 0 => htmlspecialchars($y . '-' . $m . '-' . $d),
317+ 0 => $y . '-' . $m . '-' . $d,
314318 1 => createArchiveLink($blogid, $archive, $this->linkparams)
315319 );
316320 }
@@ -318,35 +322,39 @@ class NP_ItemNaviEX extends NucleusPlugin
318322 //=============================
319323 $query = 'SELECT ' . $date_str . ' as Date'
320324 . ' FROM ' . sql_table('item') . ' as i' . $mtable
321- . ' WHERE i.idraft=0'
322- . ' and i.itime<' . mysqldate($timestamp_start) . $where;
325+ . ' WHERE i.idraft = 0'
326+ . ' and i.itime < ' . mysqldate($timestamp_start) . $where;
323327 $query .= ' GROUP BY Date';
324328 $query .= ' ORDER BY i.itime DESC';
325329 $res = sql_query($query);
326330 if ($ares = mysql_fetch_row($res)) {
327- $prev_date = $ares[0];
328- $prev_alink = createArchiveLink($b->getID(), $prev_date, $this->linkparams);
329- $subNaviUnit[1] = '<a href="' . $prev_alink . '" class="prevlink" rel="prev"> &laquo; '
330- . htmlspecialchars($prev_date) . '</a>';
331+// $prev_date = $ares[0];
332+ sscanf($ares[0],'%d-%d-%d', $y, $m, $d);
333+ $prev_date = sprintf('%04d-%02d-%02d', $y, $m, $d);
334+ $prev_alink = createArchiveLink($blogid, $prev_date, $this->linkparams);
335+ $subNaviUnit[1] = '<a href="' . htmlspecialchars($prev_alink) . '" class="prevlink" rel="prev">' .
336+ ' &laquo; ' . htmlspecialchars($prev_date) . '</a>';
331337 // $abuf .= '<a href="'.$prev_alink.'" class="prevlink" rel="prev">'.$prev_date.'</a>';
332338 // } else {
333339 // $today_link = createBlogidLink($b->getID(), $this->linkparams);
334340 // $abuf .= ' ( <a href="'.$today_link.'">Today</a> )';
335341 }
336- $abuf .= ' | <strong>' . $archive . '</strong> ';
342+ $abuf .= ' | <strong>' . htmlspecialchars($archive) . '</strong> ';
337343 //=============================
338344 $query = 'SELECT ' . $date_str . ' as Date'
339345 . ' FROM ' . sql_table('item') . ' as i' . $mtable
340- . ' WHERE i.idraft=0'
341- . ' and i.itime<' . mysqldate($b->getCorrectTime())
342- . ' and i.itime>=' . mysqldate($timestamp_end) . $where;
346+ . ' WHERE i.idraft = 0'
347+ . ' and i.itime < ' . mysqldate($b->getCorrectTime())
348+ . ' and i.itime >= ' . mysqldate($timestamp_end) . $where;
343349 $query .= ' GROUP BY Date';
344350 $query .= ' ORDER BY i.itime ASC';
345351 $res = sql_query($query);
346- if($ares = mysql_fetch_row($res)) {
347- $next_date = $ares[0];
348- $next_alink = createArchiveLink($b->getID(), $next_date, $this->linkparams);
349- $subNaviUnit[2] = '<a href="' . $next_alink . '" class="nextlink" rel="next">'
352+ if ($ares = mysql_fetch_row($res)) {
353+// $next_date = $ares[0];
354+ sscanf($ares[0],'%d-%d-%d', $y, $m, $d);
355+ $next_date = sprintf('%04d-%02d-%02d', $y, $m, $d);
356+ $next_alink = createArchiveLink($blogid, $next_date, $this->linkparams);
357+ $subNaviUnit[2] = '<a href="' . htmlspecialchars($next_alink) . '" class="nextlink" rel="next">'
350358 . htmlspecialchars($next_date) . ' &raquo;</a>';
351359 // $a2buf = ' | <a href="'.$next_alink.'" class="nextlink" rel="next">'.$next_date.'</a>';
352360 // } else {
@@ -371,7 +379,7 @@ class NP_ItemNaviEX extends NucleusPlugin
371379
372380 // Print mainNavi
373381 unset($naviUnit[$endKey][1]);
374- $naviVar = array_map(array(&$this, "createNaviLink"), $naviUnit);
382+ $naviVar = array_map(array(&$this, 'createNaviLink'), $naviUnit);
375383 echo '<span class="breadcrumbslist">', @join(' &gt; ', $naviVar);
376384
377385 //add Taginfo =====================================
@@ -404,31 +412,29 @@ class NP_ItemNaviEX extends NucleusPlugin
404412 }
405413
406414 echo '</span>';
407-/*
408-*/
415+
409416 }
410417
411418 function getParenta($subcat_id, $blogid=0)
412419 {
413420 $subcat_id = intval($subcat_id);
414- $blogid = intval($blogid)
421+ $blogid = intval($blogid);
415422 $r = array();
416423 $que = 'SELECT scatid, parentid, sname, catid FROM %s WHERE scatid = %d';
417- $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id))
418-// $res = sql_query("select scatid, parentid, sname, catid from ".sql_table('plug_multiple_categories_sub')." where scatid = '$subcat_id'");
424+ $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id));
419425 list ($sid, $parent, $sname, $cat_id) = mysql_fetch_row($res);
420426 if (intval($parent) != 0) {
421427 $this->r[] = $this->getParenta(intval($parent), $blogid);
422428 $this->linkparams[subcatid] = $sid;
423429 $r = array(
424- 0 => htmlspecialchars($sname),
430+ 0 => $sname,
425431 1 => createBlogidLink($blogid, $this->linkparams),
426432 2 => createArchiveListLink($blogid, $this->linkparams)
427433 );
428434 }else{
429435 $this->linkparams[subcatid] = $sid;
430436 $r = array(
431- 0 => htmlspecialchars($sname),
437+ 0 => $sname,
432438 1 => createBlogidLink($blogid, $this->linkparams),
433439 2 => createArchiveListLink($blogid, $this->linkparams)
434440 );
@@ -436,27 +442,25 @@ class NP_ItemNaviEX extends NucleusPlugin
436442 return $r;
437443 }
438444
439- function getParent($subcat_id)
445+/* function getParent($subcat_id)
440446 {
441447 $subcat_id = intval($subcat_id);
442448 $que = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d';
443- $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id))
444-// $res = sql_query("select scatid, parentid, sname from ".sql_table('plug_multiple_categories_sub')." where scatid = '$subcat_id'");
449+ $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id));
445450 list ($sid, $parent, $sname) = mysql_fetch_row($res);
446451 if (intval($parent) != 0) {
447452 $r = $this->getParent(intval($parent)) . " -> <a href=$subcat_id>$sname</a>";
448- }
449- else { $r = "<a href=$subcat_id>" . htmlspecialchars($sname) . "</a>"; }
453+ } else {
454+ $r = "<a href=$subcat_id>" . htmlspecialchars($sname) . "</a>";
455+ }
450456 return $r;
451- }
452-
457+ }*/
453458
454459 function getChildren($subcat_id)
455460 {
456461 $subcat_id = intval($subcat_id);
457462 $que = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d';
458- $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id))
459-// $res = sql_query("select scatid, parentid, sname from ".sql_table('plug_multiple_categories_sub')." where parentid = '$subcat_id'");
463+ $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id));
460464 while ($so = mysql_fetch_object($res)) {
461465 $r .= $this->getChildren($so->scatid) . '/' . intval($so->scatid);
462466 }
Show on old repository browser