• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

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


Commit MetaInfo

Revision9b38da2f505444912c48408179d4e65a8cb7ebe4 (tree)
Time2006-09-29 16:03:44
Authorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

未検証

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

Change Summary

Incremental Difference

--- /dev/null
+++ b/trunk/NP_ItemNaviEX/.project
@@ -0,0 +1,11 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<projectDescription>
3+ <name>NP_ItemNaviEX</name>
4+ <comment></comment>
5+ <projects>
6+ </projects>
7+ <buildSpec>
8+ </buildSpec>
9+ <natures>
10+ </natures>
11+</projectDescription>
--- /dev/null
+++ b/trunk/NP_ItemNaviEX/NP_ItemNaviEX.php
@@ -0,0 +1,466 @@
1+<?
2+/**
3+ *
4+ * BreadCrumbsList PLUG-IN FOR NucleusCMS
5+ * PHP versions 4 and 5
6+ *
7+ * @author Original Author nakahara21
8+ * @copyright 2005-2006 nakahara21
9+ * @license http://www.gnu.org/licenses/gpl.txt GNU GENERAL PUBLIC LICENSE Version 2, June 1991
10+ * @version 0.41
11+ * @link http://nakahara21.com
12+ *
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
17+ *
18+ */
19+
20+/*
21+ *
22+ * THESE PLUG-INS ARE DEDICATED TO ALL THOSE NucleusCMS USERS
23+ * WHO FIGHT CORRUPTION AND IRRATIONAL IN EVERY DAY OF THEIR LIVES.
24+ *
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+
34+
35+class NP_ItemNaviEX extends NucleusPlugin
36+{
37+ function getName()
38+ {
39+ return 'Navigation Bar';
40+ }
41+ function getAuthor()
42+ {
43+ return 'nakahara21';
44+ }
45+ function getURL()
46+ {
47+ return 'http://nakahara21.com/';
48+ }
49+ function getVersion()
50+ {
51+ return '0.99';
52+ }
53+ function getDescription()
54+ {
55+ return 'Add link to prev item and next item. Usage: &lt;%ItemNaviEX()%&gt; or &lt;%ItemNaviEX(0)%&gt;';
56+ }
57+ function supportsFeature($what)
58+ {
59+ switch($what){
60+ case 'SqlTablePrefix':
61+ return 1;
62+ default:
63+ return 0;
64+ }
65+ }
66+
67+ function scanEndKey($array)
68+ {
69+ $keys = array_keys($array);
70+ rsort($keys);
71+ return $keys[0];
72+ }
73+
74+ function createNaviLink($unitArray)
75+ {
76+ if ($unitArray[1]) {
77+ $tempLink = '<a href="' . $unitArray[1] . '">' . $unitArray[0] . '</a>';
78+ } else {
79+ $tempLink = $unitArray[0];
80+ }
81+ return $tempLink;
82+ }
83+
84+ function checkParent()
85+ {
86+ global $manager;
87+// if ($manager->pluginInstalled('NP_MultipleCategories')) {
88+// $mplugin =& $manager->getPlugin('NP_MultipleCategories');
89+// if (method_exists($mplugin,"getRequestName")) {
90+ $res = sql_query("SHOW FIELDS FROM " . sql_table('plug_multiple_categories_sub') );
91+ while ($co = mysql_fetch_assoc($res)) {
92+ if($co['Field'] == 'parentid') return TRUE;
93+ }
94+// }
95+// }
96+ }
97+
98+ function doSkinVar($skinType, $showHome = 1)
99+ {
100+ global $manager, $blog, $CONF, $itemidprev, $itemidnext, $archive, $archiveprev, $archivenext, $catid, $param, $itemid, $subcatid;
101+
102+// sanitize
103+ $itemid = intval($itemid);
104+ $catid = intval($catid);
105+ $subcatid = intval($subcatid);
106+ $itemidprev = intval($itemidprev);
107+ $itemidnext = intval($itemidnext);
108+ if (isset($archive)) {
109+ sscanf($archive,'%d-%d-%d', $y, $m, $d);
110+ // directed by shizuki
111+ if ($y && $m && $d) {
112+ $archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
113+ } elseif ($y && $m && !$d) {
114+ $archive = sprintf('%04d-%02d', $y, $m);
115+ }
116+ }
117+ if (isset($archiveprev)) {
118+ sscanf($archiveprev,'%d-%d-%d', $y, $m, $d);
119+ // directed by shizuki
120+ if ($y && $m && $d) {
121+ $archiveprev = sprintf('%04d-%02d-%02d', $y, $m, $d);
122+ } elseif ($y && $m && !$d) {
123+ $archiveprev = sprintf('%04d-%02d', $y, $m);
124+ }
125+ }
126+ if (isset($archiveprev)) {
127+ sscanf($archiveprev,'%d-%d-%d', $y, $m, $d);
128+ // directed by shizuki
129+ if ($y && $m && $d) {
130+ $archiveprev = sprintf('%04d-%02d-%02d', $y, $m, $d);
131+ } elseif ($y && $m && !$d) {
132+ $archiveprev = sprintf('%04d-%02d', $y, $m);
133+ }
134+ }
135+ if ($showHome == '') {
136+ $showHome = '1';
137+ }
138+
139+ if ($catid) {
140+ $blogid = getBlogIDFromCatID($catid);
141+ $b =& $manager->getBlog($blogid);
142+ } elseif ($blog) {
143+ $b =& $blog;
144+ } else {
145+ $b =& $manager->getBlog($CONF['DefaultBlog']);
146+ }
147+ $blogid = $b->getID();
148+ $blogid = intval($blogid);
149+
150+ $abuf = '';
151+ $mtable = "";
152+ $where .= ' and i.iblog=' . $blogid;
153+ if (!empty($catid)) {
154+ 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';
158+ $mplugin =& $manager->getPlugin('NP_MultipleCategories');
159+ if ($subcatid && method_exists($mplugin, "getRequestName")) {
160+//family
161+ if ($this->checkParent()) {
162+ $Children = array();
163+ $Children = explode('/', $subcatid . $this->getChildren($subcatid));
164+ }
165+ if ($Children[1]) {
166+ for ($i=0;$i<count($Children);$i++) {
167+ $temp_whr[] = ' p.subcategories REGEXP "(^|,)' . intval($Children[$i]) . '(,|$)" ';
168+ }
169+ $where .= ' and ';
170+ $where .= ' ( ';
171+ $where .= join(' or ', $temp_whr);
172+ $where .= ' )';
173+ }else{
174+ $where .= ' and p.subcategories REGEXP "(^|,)' . $subcatid . '(,|$)"';
175+ }
176+//family end
177+ }
178+ } else {
179+ $where .= ' and i.icat=' . $catid;
180+ }
181+ }
182+
183+ $naviUnit = array();
184+ $subNaviUnit = array();
185+ $this->linkparams = array();
186+//store Home =====================================
187+ if($showHome > 0){
188+ $naviUnit[] = array(
189+ 0 => 'Home',
190+ 1 => $CONF['IndexURL']
191+ );
192+ }
193+
194+//store Blog =====================================
195+ if ($showHome > 0 && ($blogid <> $CONF['DefaultBlog'])) {
196+// if ($showHome > 0) {
197+ $naviUnit[] = array(
198+ 0 => htmlspecialchars(getBlogNameFromID($blogid)),
199+// 0 => 'Home',
200+ 1 => createBlogidLink($blogid),
201+// 1 => $CONF['BlogURL'] . '/',
202+ 2 => createArchiveListLink($blogid)
203+ );
204+ }
205+
206+//store Category =====================================
207+ if (!empty($catid)) {
208+ $this->linkparams['catid'] = $catid;
209+ $naviUnit[] = array(
210+ 0 => htmlspecialchars($b->getCategoryName($catid)),
211+ 1 => createCategoryLink($catid),
212+// 1 => createBlogidLink($blogid, $this->linkparams),
213+ 2 => createArchiveListLink($blogid, $this->linkparams)
214+ );
215+ }
216+
217+//store subCategory =====================================
218+ if (!empty($subcatid)) {
219+ $this->linkparams[subcatid] = $subcatid;
220+ if ($manager->pluginInstalled('NP_MultipleCategories')) {
221+ $mplugin =& $manager->getPlugin('NP_MultipleCategories');
222+ if (method_exists($mplugin, "getRequestName")) {
223+ $subrequest = $mplugin->getRequestName();
224+ if($this->checkParent()){
225+ $tog = $this->getParenta($subcatid, $blogid);
226+ for($i=0;$i<count($this->r);$i++){
227+ $naviUnit[] = $this->r[$i];
228+ }
229+ $naviUnit[] = $tog;
230+ }else{
231+ $naviUnit[] = array(
232+ 0 => htmlspecialchars($mplugin->_getScatNameFromID($subcatid)),
233+ 1 => createCategoryLink($catid, array($subrequest => $subcatid)),
234+// 1 => createCategoryLink($catid, array('subcatid' => $subcatid)),
235+// 1 => createBlogidLink($blogid, $this->linkparams),
236+ 2 => createArchiveListLink($blogid, $this->linkparams)
237+ );
238+ }
239+ }
240+ }
241+ }
242+
243+//store Page =====================================
244+ if (requestVar('page')) {
245+ $naviUnit[] = array(
246+ 0 => 'Page.' . intRequestVar('page'),
247+ 2 => createArchiveListLink($blogid, $this->linkparams)
248+ );
249+ }
250+
251+//store Item =====================================
252+ if ($skinType == 'item') {
253+ $item =& $manager->getItem($itemid, 0, 0);
254+ $naviUnit[] = array(
255+ 0 => htmlspecialchars($item['title'])
256+ );
257+
258+
259+ $query = 'SELECT i.ititle, i.inumber'
260+ . ' FROM '.sql_table('item') . ' as i' . $mtable
261+ . ' WHERE i.idraft=0'
262+ . " and i.itime< '" . $item['itime'] . "' " . $where;
263+ $query .= ' ORDER BY i.itime DESC';
264+ $res = sql_query($query);
265+ if ($ares = mysql_fetch_row($res)) {
266+ $alink = createItemLink($ares[1], $this->linkparams);
267+ $subNaviUnit[1] = '<a href="' . $alink . '" rel="prev"> &laquo; ' . shorten($ares[0], 14, '...') . '</a>';
268+ }
269+
270+
271+
272+ $query = 'SELECT i.ititle, i.inumber'
273+ . ' FROM ' . sql_table('item') . ' as i' . $mtable
274+ . ' WHERE i.idraft=0'
275+ . " and i.itime> '" . $item['itime'] . "' " . $where;
276+ $query .= ' ORDER BY i.itime ASC';
277+ $res = sql_query($query);
278+ if ($ares = mysql_fetch_row($res)) {
279+ $alink = createItemLink($ares[1], $this->linkparams);
280+ $subNaviUnit[2] = '<a href="' . $alink . '" rel="next"> ' . shorten($ares[0], 14, '...') . ' &raquo;</a>';
281+ }
282+
283+
284+ }
285+
286+//store ArchiveList =====================================
287+ if ($skinType == 'archivelist' || $skinType == 'archive') {
288+ $naviUnit[] = array(
289+ 0 => 'ArchiveList',
290+ 1 => createArchiveListLink($blogid, $this->linkparams)
291+ );
292+ }
293+
294+ if ($skinType == 'archive') {
295+ sscanf($archive,'%04s-%02s-%02s', $y, $m, $d);
296+//store ArchiveMonth
297+ $archiveMonth = $y . '-' . $m;
298+ $naviUnit[] = array(
299+ 0 => htmlspecialchars($archiveMonth),
300+ 1 => createArchiveLink($blogid, $archiveMonth, $this->linkparams)
301+ );
302+ if (!$d) {
303+ $timestamp_start = mktime(0, 0, 0, $m, 1, $y);
304+ $timestamp_end = mktime(0, 0, 0, $m+1, 1, $y);
305+ $date_str = 'SUBSTRING(i.itime, 1, 7)';
306+ } else {
307+ $timestamp_start = mktime(0, 0, 0, $m, $d, $y);
308+ $timestamp_end = mktime(0, 0, 0, $m, $d+1, $y);
309+ $date_str = 'SUBSTRING(i.itime, 1, 10)';
310+//store ArchiveDay
311+ $naviUnit[] = array(
312+ 0 => htmlspecialchars($y . '-' . $m . '-' . $d),
313+ 1 => createArchiveLink($blogid, $archive, $this->linkparams)
314+ );
315+ }
316+
317+//=============================
318+ $query = 'SELECT ' . $date_str . ' as Date'
319+ . ' FROM ' . sql_table('item') . ' as i' . $mtable
320+ . ' WHERE i.idraft=0'
321+ . ' and i.itime<' . mysqldate($timestamp_start) . $where;
322+ $query .= ' GROUP BY Date';
323+ $query .= ' ORDER BY i.itime DESC';
324+ $res = sql_query($query);
325+ if ($ares = mysql_fetch_row($res)) {
326+ $prev_date = $ares[0];
327+ $prev_alink = createArchiveLink($b->getID(), $prev_date, $this->linkparams);
328+ $subNaviUnit[1] = '<a href="' . $prev_alink . '" class="prevlink" rel="prev"> &laquo; '
329+ . htmlspecialchars($prev_date) . '</a>';
330+// $abuf .= '<a href="'.$prev_alink.'" class="prevlink" rel="prev">'.$prev_date.'</a>';
331+// } else {
332+// $today_link = createBlogidLink($b->getID(), $this->linkparams);
333+// $abuf .= ' ( <a href="'.$today_link.'">Today</a> )';
334+ }
335+ $abuf .= ' | <strong>' . $archive . '</strong> ';
336+//=============================
337+ $query = 'SELECT ' . $date_str . ' as Date'
338+ . ' FROM ' . sql_table('item') . ' as i' . $mtable
339+ . ' WHERE i.idraft=0'
340+ . ' and i.itime<' . mysqldate($b->getCorrectTime())
341+ . ' and i.itime>=' . mysqldate($timestamp_end) . $where;
342+ $query .= ' GROUP BY Date';
343+ $query .= ' ORDER BY i.itime ASC';
344+ $res = sql_query($query);
345+ if($ares = mysql_fetch_row($res)) {
346+ $next_date = $ares[0];
347+ $next_alink = createArchiveLink($b->getID(), $next_date, $this->linkparams);
348+ $subNaviUnit[2] = '<a href="' . $next_alink . '" class="nextlink" rel="next">'
349+ . htmlspecialchars($next_date) . ' &raquo;</a>';
350+// $a2buf = ' | <a href="'.$next_alink.'" class="nextlink" rel="next">'.$next_date.'</a>';
351+// } else {
352+// $today_link = createBlogidLink($b->getID(), $this->linkparams);
353+// $a2buf .= ' | ( <a href="'.$today_link.'">Today</a> )';
354+ }
355+ }
356+//============================= // end of archive
357+
358+// Print subNavi
359+// todo Henceforth to template
360+// echo ' <div style="text-align: center;">';
361+// echo ' <span style="text-align:right;">';
362+ echo ' <span class="prevnextnavi">';
363+ $endKey = $this->scanEndKey($naviUnit);
364+ if ($skinType != 'archivelist' && $skinType != 'archive' && $skinType != 'item') {
365+ echo '<a href="' . $naviUnit[$endKey][2] . '">&raquo; ArchiveList</a>';
366+ }
367+ echo @join(' :: ', $subNaviUnit);
368+// echo '</div>';
369+ echo '</span>';
370+
371+// Print mainNavi
372+ unset($naviUnit[$endKey][1]);
373+ $naviVar = array_map(array(&$this, "createNaviLink"), $naviUnit);
374+ echo '<span class="breadcrumbslist">', @join(' &gt; ', $naviVar);
375+
376+//add Taginfo =====================================
377+// display selected TAGs whith link mod by shizuki
378+ if ($manager->pluginInstalled('NP_TagEX')) {
379+// if (requestVar('tag')) {
380+ $tagPlugin =& $manager->getPlugin('NP_TagEX');
381+ $requestT = $tagPlugin->getNoDecodeQuery('tag');
382+ if (!empty($requestT)) {
383+ $requestTarray = $tagPlugin->splitRequestTags($requestT);
384+ $reqAND = array_map(array(&$tagPlugin, "_rawdecode"), $requestTarray['and']);
385+ if ($requestTarray['or']) {
386+ $reqOR = array_map(array(&$tagPlugin, "_rawdecode"), $requestTarray['or']);
387+ }
388+ if ($reqOR) {
389+ $reqTags = array_merge($reqAND, $reqOR);
390+ } else {
391+ $reqTags = $reqAND;
392+ }
393+ for ($i=0;$i<count($reqTags);$i++) {
394+ $tag = trim($reqTags[$i]);
395+ $taglist[$i] = '<a href="' . $tagPlugin->creatTagLink($tag, 0) . '">'
396+ . htmlspecialchars($tag) . '</a>';
397+ }
398+ echo ' <small style="font-family:Tahoma;">';
399+ // echo ' (Tag for "'.$tagPlugin->_rawdecode(requestVar('tag')).'")';
400+ echo ' (Tag for "' . @join(' / ', $taglist) . '")';
401+ echo '</small>';
402+ }
403+ }
404+
405+ echo '</span>';
406+/*
407+*/
408+ }
409+
410+ function getParenta($subcat_id, $blogid=0)
411+ {
412+ $subcat_id = intval($subcat_id);
413+ $blogid = intval($blogid)
414+ $r = array();
415+ $que = 'SELECT scatid, parentid, sname, catid FROM %s WHERE scatid = %d';
416+ $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id))
417+// $res = sql_query("select scatid, parentid, sname, catid from ".sql_table('plug_multiple_categories_sub')." where scatid = '$subcat_id'");
418+ list ($sid, $parent, $sname, $cat_id) = mysql_fetch_row($res);
419+ if (intval($parent) != 0) {
420+ $this->r[] = $this->getParenta(intval($parent), $blogid);
421+ $this->linkparams[subcatid] = $sid;
422+ $r = array(
423+ 0 => htmlspecialchars($sname),
424+ 1 => createBlogidLink($blogid, $this->linkparams),
425+ 2 => createArchiveListLink($blogid, $this->linkparams)
426+ );
427+ }else{
428+ $this->linkparams[subcatid] = $sid;
429+ $r = array(
430+ 0 => htmlspecialchars($sname),
431+ 1 => createBlogidLink($blogid, $this->linkparams),
432+ 2 => createArchiveListLink($blogid, $this->linkparams)
433+ );
434+ }
435+ return $r;
436+ }
437+
438+ function getParent($subcat_id)
439+ {
440+ $subcat_id = intval($subcat_id);
441+ $que = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d';
442+ $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id))
443+// $res = sql_query("select scatid, parentid, sname from ".sql_table('plug_multiple_categories_sub')." where scatid = '$subcat_id'");
444+ list ($sid, $parent, $sname) = mysql_fetch_row($res);
445+ if (intval($parent) != 0) {
446+ $r = $this->getParent(intval($parent)) . " -> <a href=$subcat_id>$sname</a>";
447+ }
448+ else { $r = "<a href=$subcat_id>" . htmlspecialchars($sname) . "</a>"; }
449+ return $r;
450+ }
451+
452+
453+ function getChildren($subcat_id)
454+ {
455+ $subcat_id = intval($subcat_id);
456+ $que = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d';
457+ $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_subcat'), $subcat_id))
458+// $res = sql_query("select scatid, parentid, sname from ".sql_table('plug_multiple_categories_sub')." where parentid = '$subcat_id'");
459+ while ($so = mysql_fetch_object($res)) {
460+ $r .= $this->getChildren($so->scatid) . '/' . intval($so->scatid);
461+ }
462+ return $r;
463+ }
464+
465+}
466+?>
\ No newline at end of file
Show on old repository browser