-<?
+<?php
/**
*
* BreadCrumbsList PLUG-IN FOR NucleusCMS
* @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.41
- * @link http://nakahara21.com
+ * @version 0.992
+ * @link http://japan.nucleuscms.org/wiki/plugins:itemnaviex
*
- * 0.991 add sub-blog home mode
- * 0.99 sec fix
+ * 0.992 display mode '0' fix
+ * 0.991 add sub-blog home mode
+ * 0.99 sec fix
*
**************************************************************************
*
function getURL()
{
- return 'http://nakahara21.com/';
+ return 'http://japan.nucleuscms.org/wiki/plugins:itemnaviex';
}
function getVersion()
{
- return '0.991';
+ return '0.992';
}
function getDescription()
- {
- return 'Add link to prev item and next item. Usage: <%ItemNaviEX()%> or <%ItemNaviEX(0)%>';
+ {
+ $description = 'Add link to prev item and next item. '
+ . 'Usage: <%ItemNaviEX%> or <%ItemNaviEX(0)%>'
+ . ' or <%ItemNaviEX(1)%> or <%ItemNaviEX(2)%>';
+ return $description;
}
function supportsFeature($what)
{
- switch($what){
+ switch ($what) {
case 'SqlTablePrefix':
return 1;
default:
function createNaviLink($unitArray)
{
if ($unitArray[1]) {
- $tempLink = '<a href="' . htmlspecialchars($unitArray[1]) . '">' . htmlspecialchars($unitArray[0]) . '</a>';
+ $tempLink = '<a href="' . htmlspecialchars($unitArray[1], ENT_QUOTES, _CHARSET) . '">'
+ . htmlspecialchars($unitArray[0], ENT_QUOTES, _CHARSET) . '</a>';
} else {
- $tempLink = htmlspecialchars($unitArray[0]);
+ $tempLink = htmlspecialchars($unitArray[0], ENT_QUOTES, _CHARSET);
}
return $tempLink;
}
// if ($manager->pluginInstalled('NP_MultipleCategories')) {
// $mplugin =& $manager->getPlugin('NP_MultipleCategories');
// if (method_exists($mplugin,"getRequestName")) {
- $res = sql_query('SHOW FIELDS FROM ' . sql_table('plug_multiple_categories_sub'));
+ $query = 'SHOW FIELDS FROM ' . sql_table('plug_multiple_categories_sub');
+ $res = sql_query($query);
while ($co = mysql_fetch_assoc($res)) {
if ($co['Field'] == 'parentid') {
return TRUE;
// sanitize
$y = $m = $d = '';
- $itemid = intval($itemid);
- $catid = intval($catid);
- $subcatid = intval($subcatid);
+ $itemid = intval($itemid);
+ $catid = intval($catid);
+ $subcatid = intval($subcatid);
$itemidprev = intval($itemidprev);
$itemidnext = intval($itemidnext);
if (isset($archive)) {
if ($y && $m && !empty($d)) {
$archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
} elseif ($y && $m && empty($d)) {
- $archive = sprintf('%04d-%02d', $y, $m);
+ $archive = sprintf('%04d-%02d', $y, $m);
}
}
if (isset($archiveprev)) {
if ($y && $m && !empty($d)) {
$archiveprev = sprintf('%04d-%02d-%02d', $y, $m, $d);
} elseif ($y && $m && empty($d)) {
- $archiveprev = sprintf('%04d-%02d', $y, $m);
+ $archiveprev = sprintf('%04d-%02d', $y, $m);
}
}
if (isset($archiveprev)) {
if ($y && $m && !empty($d)) {
$archiveprev = sprintf('%04d-%02d-%02d', $y, $m, $d);
} elseif ($y && $m && empty($d)) {
- $archiveprev = sprintf('%04d-%02d', $y, $m);
+ $archiveprev = sprintf('%04d-%02d', $y, $m);
}
}
if ($showHome == '') {
- $showHome = '1';
+ $showHome = 1;
+ } else {
+ $showHome = intval($showHome);
}
if ($catid) {
}
$blogid = intval($b->getID());
- $abuf = '';
+ $abuf = '';
$mtable = '';
$where .= ' and i.iblog=' . $blogid;
if (!empty($catid)) {
if ($manager->pluginInstalled('NP_MultipleCategories')) {
- $where .= ' and ((i.inumber = p.item_id and (p.categories REGEXP "(^|,)' . $catid . '(,|$)"' .
- ' or i.icat = ' . $catid . ')) or (i.icat = ' . $catid . ' and p.item_id IS NULL))';
- $mtable = ' LEFT JOIN ' . sql_table('plug_multiple_categories') . ' as p ON i.inumber = p.item_id';
+ $where .= ' and ((i.inumber = p.item_id'
+ . ' and (p.categories REGEXP "(^|,)' . $catid . '(,|$)"'
+ . ' or i.icat = ' . $catid . '))'
+ . ' or (i.icat = ' . $catid
+ . ' and p.item_id IS NULL))';
+ $mtable = ' LEFT JOIN ' . sql_table('plug_multiple_categories') . ' as p'
+ . ' ON i.inumber = p.item_id';
$mplugin =& $manager->getPlugin('NP_MultipleCategories');
if ($subcatid && method_exists($mplugin, 'getRequestName')) {
//family
$where .= ' and i.icat=' . $catid;
}
}
-
- $naviUnit = array();
- $subNaviUnit = array();
+ $naviUnit = array();
+ $subNaviUnit = array();
$this->linkparams = array();
//store Home =====================================
// comment out this block when HOME is sub-blog top
if ($showHome == 1) {
+ $defBlogid =intval($CONF['DefaultBlog']);
$naviUnit[] = array(
0 => 'Home',
- 1 => $CONF['IndexURL'],
+ 1 => createBlogidLink($defBlogid),
2 => createArchiveListLink($blogid)
);
}
1 => createBlogidLink($blogid),
2 => createArchiveListLink($blogid)
);
- } elseif ($showHome >= 2) {
+ } elseif ($showHome >= 2 || ($showHome == 0 && ($catid || $itemid))) {
$naviUnit[] = array(
- 0 => 'Home', // when HOME is sub-blog top
- 1 => $CONF['BlogURL'] . '/', // when HOME is sub-blog top
+ 0 => 'Home', // when HOME is sub-blog top
+ 1 => createBlogidLink($blogid), // when HOME is sub-blog top
2 => createArchiveListLink($blogid)
);
}
$this->linkparams[$subrequest] = $subcatid;
if ($this->checkParent()) {
$tog = $this->getParenta($subcatid, $blogid);
- for ($i=0;$i<count($this->r);$i++) {
+ for ($i=0; $i<count($this->r); $i++) {
$naviUnit[] = $this->r[$i];
}
$naviUnit[] = $tog;
}
//store Page ===================================== todo How to get PageNo. ? ...cookie...
- if (requestVar('page')) {
+ if (intRequestVar('page') != 0) {
$naviUnit[] = array(
0 => 'Page.' . intRequestVar('page'),
2 => createArchiveListLink($blogid, $this->linkparams)
0 => $item['title']
);
-
$query = 'SELECT i.ititle, i.inumber'
- . ' FROM ' . sql_table('item') . ' as i' . $mtable
- . ' WHERE i.idraft = 0'
- . " and i.itime < '" . $item['itime'] . "' " . $where;
- $query .= ' ORDER BY i.itime DESC';
- $res = sql_query($query);
+ . ' FROM ' . sql_table('item') . ' as i' . $mtable
+ . ' WHERE i.idraft = 0'
+ . " and i.itime < '" . $item['itime'] . "' " . $where
+ . ' ORDER BY i.itime DESC';
+ $res = sql_query($query);
if ($ares = mysql_fetch_row($res)) {
- $alink = createItemLink($ares[1], $this->linkparams);
- $subNaviUnit[1] = '<a href="' . htmlspecialchars($alink) . '" rel="prev"> « ' .
- shorten($ares[0], 14, '...') . '</a>';
+ $alink = createItemLink($ares[1], $this->linkparams);
+ $subNaviUnit[1] = '<a href="'
+ . htmlspecialchars($alink, ENT_QUOTES, _CHARSET)
+ . '" rel="prev"> « '
+ . shorten($ares[0], 14, '...')
+ . '</a>';
}
-
-
$query = 'SELECT i.ititle, i.inumber'
- . ' FROM ' . sql_table('item') . ' as i' . $mtable
- . ' WHERE i.idraft = 0'
- . " and i.itime > '" . $item['itime'] . "' " . $where;
- $query .= ' ORDER BY i.itime ASC';
- $res = sql_query($query);
+ . ' FROM ' . sql_table('item') . ' as i' . $mtable
+ . ' WHERE i.idraft = 0'
+ . " and i.itime > '" . $item['itime'] . "' " . $where
+ . ' ORDER BY i.itime ASC';
+ $res = sql_query($query);
if ($ares = mysql_fetch_row($res)) {
- $alink = createItemLink($ares[1], $this->linkparams);
- $subNaviUnit[2] = '<a href="' . htmlspecialchars($alink) . '" rel="next"> ' .
- shorten($ares[0], 14, '...') . ' »</a>';
+ $alink = createItemLink($ares[1], $this->linkparams);
+ $subNaviUnit[2] = '<a href="'
+ . htmlspecialchars($alink, ENT_QUOTES, _CHARSET)
+ . '" rel="next"> '
+ . shorten($ares[0], 14, '...')
+ . ' »</a>';
}
-
}
//store ArchiveList =====================================
1 => createArchiveLink($blogid, $archiveMonth, $this->linkparams)
);
if (empty($d)) {
- $timestamp_start = mktime(0, 0, 0, $m, 1, $y);
- $timestamp_end = mktime(0, 0, 0, $m+1, 1, $y);
- $date_str = 'SUBSTRING(i.itime, 1, 7)';
+ $timestamp_start = mktime(0, 0, 0, $m, 1, $y);
+ $timestamp_end = mktime(0, 0, 0, $m+1, 1, $y);
+ $date_str = 'SUBSTRING(i.itime, 1, 7)';
} else {
- $timestamp_start = mktime(0, 0, 0, $m, $d, $y);
- $timestamp_end = mktime(0, 0, 0, $m, $d+1, $y);
- $date_str = 'SUBSTRING(i.itime, 1, 10)';
+ $timestamp_start = mktime(0, 0, 0, $m, $d, $y);
+ $timestamp_end = mktime(0, 0, 0, $m, $d+1, $y);
+ $date_str = 'SUBSTRING(i.itime, 1, 10)';
//store ArchiveDay
$naviUnit[] = array(
0 => $y . '-' . $m . '-' . $d,
//=============================
$query = 'SELECT ' . $date_str . ' as Date'
- . ' FROM ' . sql_table('item') . ' as i' . $mtable
- . ' WHERE i.idraft = 0'
- . ' and i.itime < ' . mysqldate($timestamp_start) . $where;
- $query .= ' GROUP BY Date';
- $query .= ' ORDER BY i.itime DESC';
- $res = sql_query($query);
+ . ' FROM ' . sql_table('item') . ' as i' . $mtable
+ . ' WHERE i.idraft = 0'
+ . ' and i.itime < ' . mysqldate($timestamp_start) . $where
+ . ' GROUP BY Date'
+ . ' ORDER BY i.itime DESC';
+ $res = sql_query($query);
if ($ares = mysql_fetch_row($res)) {
// $prev_date = $ares[0];
sscanf($ares[0], '%d-%d-%d', $y, $m, $d);
if (empty($d)) {
- $prev_date = sprintf('%04d-%02d', $y, $m);
+ $prev_date = sprintf('%04d-%02d', $y, $m);
} else {
$prev_date = sprintf('%04d-%02d-%02d', $y, $m, $d);
}
$prev_alink = createArchiveLink($blogid, $prev_date, $this->linkparams);
- $subNaviUnit[1] = '<a href="' . htmlspecialchars($prev_alink) . '" class="prevlink" rel="prev">' .
- ' « ' . htmlspecialchars($prev_date) . '</a>';
+ $subNaviUnit[1] = '<a href="'
+ . htmlspecialchars($prev_alink, ENT_QUOTES, _CHARSET)
+ . '" class="prevlink" rel="prev">'
+ . ' « '
+ . htmlspecialchars($prev_date, ENT_QUOTES, _CHARSET)
+ . '</a>';
// $abuf .= '<a href="'.$prev_alink.'" class="prevlink" rel="prev">'.$prev_date.'</a>';
// } else {
// $today_link = createBlogidLink($b->getID(), $this->linkparams);
// $abuf .= ' ( <a href="'.$today_link.'">Today</a> )';
}
- $abuf .= ' | <strong>' . htmlspecialchars($archive) . '</strong> ';
+ $abuf .= ' | <strong>' . htmlspecialchars($archive, ENT_QUOTES, _CHARSET) . '</strong> ';
//=============================
$query = 'SELECT ' . $date_str . ' as Date'
- . ' FROM ' . sql_table('item') . ' as i' . $mtable
- . ' WHERE i.idraft = 0'
- . ' and i.itime < ' . mysqldate($b->getCorrectTime())
- . ' and i.itime >= ' . mysqldate($timestamp_end) . $where;
- $query .= ' GROUP BY Date';
- $query .= ' ORDER BY i.itime ASC';
- $res = sql_query($query);
+ . ' FROM ' . sql_table('item') . ' as i' . $mtable
+ . ' WHERE i.idraft = 0'
+ . ' and i.itime < ' . mysqldate($b->getCorrectTime())
+ . ' and i.itime >= ' . mysqldate($timestamp_end) . $where
+ . ' GROUP BY Date'
+ . ' ORDER BY i.itime ASC';
+ $res = sql_query($query);
if ($ares = mysql_fetch_row($res)) {
// $next_date = $ares[0];
sscanf($ares[0],'%d-%d-%d', $y, $m, $d);
if (empty($d)) {
- $next_date = sprintf('%04d-%02d', $y, $m);
+ $next_date = sprintf('%04d-%02d', $y, $m);
} else {
$next_date = sprintf('%04d-%02d-%02d', $y, $m, $d);
}
- $next_alink = createArchiveLink($blogid, $next_date, $this->linkparams);
- $subNaviUnit[2] = '<a href="' . htmlspecialchars($next_alink) . '" class="nextlink" rel="next">'
- . htmlspecialchars($next_date) . ' »</a>';
+ $next_alink = createArchiveLink($blogid, $next_date, $this->linkparams);
+ $subNaviUnit[2] = '<a href="'
+ . htmlspecialchars($next_alink, ENT_QUOTES, _CHARSET)
+ . '" class="nextlink" rel="next">'
+ . htmlspecialchars($next_date, ENT_QUOTES, _CHARSET)
+ . ' »</a>';
// $a2buf = ' | <a href="'.$next_alink.'" class="nextlink" rel="next">'.$next_date.'</a>';
// } else {
// $today_link = createBlogidLink($b->getID(), $this->linkparams);
}
echo @join(' :: ', $subNaviUnit);
// echo '</div>';
- echo '</span>';
+ echo '</span><br />';
// Print mainNavi
unset($naviUnit[$endKey][1]);
if ($manager->pluginInstalled('NP_TagEX')) {
// if (requestVar('tag')) {
$tagPlugin =& $manager->getPlugin('NP_TagEX');
- $requestT = $tagPlugin->getNoDecodeQuery('tag');
+ $requestT = $tagPlugin->getNoDecodeQuery('tag');
if (!empty($requestT)) {
$requestTarray = $tagPlugin->splitRequestTags($requestT);
- $reqAND = array_map(array(&$tagPlugin, "_rawdecode"), $requestTarray['and']);
+ $reqAND = array_map(array(&$tagPlugin, "_rawdecode"), $requestTarray['and']);
if ($requestTarray['or']) {
$reqOR = array_map(array(&$tagPlugin, "_rawdecode"), $requestTarray['or']);
}
for ($i=0;$i<count($reqTags);$i++) {
$tag = trim($reqTags[$i]);
$taglist[$i] = '<a href="' . $tagPlugin->creatTagLink($tag, 0) . '">'
- . htmlspecialchars($tag) . '</a>';
+ . htmlspecialchars($tag, ENT_QUOTES, _CHARSET) . '</a>';
}
echo ' <small style="font-family:Tahoma;">';
// echo ' (Tag for "'.$tagPlugin->_rawdecode(requestVar('tag')).'")';
function getParenta($subcat_id, $blogid=0)
{
$subcat_id = intval($subcat_id);
- $blogid = intval($blogid);
- $r = array();
- $que = 'SELECT scatid, parentid, sname, catid FROM %s WHERE scatid = %d';
- $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id));
+ $blogid = intval($blogid);
+ $r = array();
+ $que = 'SELECT scatid, parentid, sname, catid FROM %s WHERE scatid = %d';
+ $que = sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id);
+ $res = sql_query($que);
list ($sid, $parent, $sname, $cat_id) = mysql_fetch_row($res);
if (intval($parent) != 0) {
- $this->r[] = $this->getParenta(intval($parent), $blogid);
+ $this->r[] = $this->getParenta(intval($parent), $blogid);
$this->linkparams[subcatid] = $sid;
$r = array(
0 => $sname,
1 => createBlogidLink($blogid, $this->linkparams),
2 => createArchiveListLink($blogid, $this->linkparams)
- );
+ );
}else{
$this->linkparams[subcatid] = $sid;
$r = array(
0 => $sname,
1 => createBlogidLink($blogid, $this->linkparams),
2 => createArchiveListLink($blogid, $this->linkparams)
- );
+ );
}
return $r;
}
function getParent($subcat_id)
{
$subcat_id = intval($subcat_id);
- $que = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d';
- $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id));
+ $que = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d';
+ $que = sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id);
+ $res = sql_query($que);
list ($sid, $parent, $sname) = mysql_fetch_row($res);
if (intval($parent) != 0) {
$r = $this->getParent(intval($parent)) . " -> <a href=$subcat_id>$sname</a>";
function getChildren($subcat_id)
{
$subcat_id = intval($subcat_id);
- $que = 'SELECT scatid, parentid, sname FROM %s WHERE parentid = %d';
- $res = sql_query(sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id));
+ $que = 'SELECT scatid, parentid, sname FROM %s WHERE parentid = %d';
+ $que = sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id);
+ $res = sql_query($que);
while ($so = mysql_fetch_object($res)) {
$r .= $this->getChildren($so->scatid) . '/' . intval($so->scatid);
}
}
}
-?>