<?php // plugin needs to work on Nucleus versions <=2.0 as well if (!function_exists('sql_table')){ function sql_table($name) { return 'nucleus_' . $name; } } class NP_TitleList extends NucleusPlugin { function getName() { return 'Title List'; } function getAuthor() { return 'Taka'; } function getURL() { return 'http://reverb.jp/vivian/download.php?itemid=NP_TitleList'; } function getVersion() { return '0.35'; } function getDescription() { return 'Displays item index. USAGE: <%TitleList%>'; } function supportsFeature($what) { switch ($what) { case 'SqlTablePrefix': return 1; default: return 0; } } function install(){ $area = 'textarea'; $n = "\n"; if (getNucleusVersion() < 220) { $area = 'text'; $n = ""; } $this->createOption('category','Label for category drop-down list','text','Category:'); $this->createOption('allcategory','Option name of "All categories" - This is used also for the heading of results.','text','All'); $this->createOption('archive','Label for archive list','text','Archive:'); $this->createOption('allarchive','Option name of "All Archives"','text','All'); $this->createOption('archiveformat','Date format of archive list - This is used also for the heading of results.','text','%B %Y'); $this->createOption('sort','Label for sort order','text','Sort by:'); $this->createOption('newest','Option name of "Descending order"','text','Newest'); $this->createOption('oldest','Option name of "Ascending order"','text','Oldest'); $this->createOption('perpage','Label for number of display','text','Per page:'); $this->createOption('submit','Send button text','text','Submit'); $this->createOption('subcategory','Label for sub category drop-down list','text','Sub Category:'); $this->createOption('allsubcategory','Option name of "All sub categories"','text','All'); $this->createOption('heading','Heading of results. You can use <%category%>, <%separator(separate character)%>, <%archive%>.',$area,"<h2>Results: <%category%><%separator(/)%><%archive%></h2>\n"); $this->createOption('prevlink','"Prev" link text','text','«Prev'); $this->createOption('nextlink','"Next" link text','text','Next»'); $this->createOption('allhead','Template of list header',$area,"<ul class=\"titlelist\">\n"); $this->createOption('datehead','Template of month|day header. You can use <%archivelink%>, <%date%>',$area,"<li><a href=\"<%archivelink%>\"><%date(%B %Y)%></a><ul>\n"); $this->createOption('item','Template of item.You can use the fundamental variable of Nucleus item templates EXCEPT item-body variables and comment variables. However, there may also be a variable which you cannot use in them. In this case, please use the template of Nucleus.',$area,"<li><a href=\"<%itemlink%>\"><%title%></a>(<%date(%x)%>)</li>\n"); $this->createOption('datefoot','Template of month|day footer. You can use <%archivelink%>, <%date%>',$area,"</ul></li>\n"); $this->createOption('allfoot','Template of list footer',$area,"</ul>\n"); $this->createOption('locale','Locale','text',"en"); $this->createOption('showah','In Archive skin, show the heading of results','yesno',"yes"); $this->createOption('showih','In Index skin, show the heading of results','yesno',"yes"); $this->createOption('catformat','[all blogs mode] Category name format. You can use <%category%>, <%blogname%>. But you CAN NOT use character entity references and HTML tags.','text',"<%category%> on <%blogname%>"); $this->createOption('notgroup','[all blogs mode]BlogID which does not use "<optgroup>". If you want to specify two or more blogIDs, put a slash between blogIDs. (All blogIDs : write only " * "[asterisk])','text',""); $this->createOption('catseparator','[one blogs mode] If NP_MultipleCategories is installed, the separator of each category name.','text'," , "); } function init(){ $this->start = false; $this->mode = 'month'; $this->date = ''; } function doTemplateVar(&$item,$format='') { global $blog, $catid, $blogid, $archivelist; if (!$this->start || $this->mode == 'day') return; if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } $bid = intval($b->getID()); $selectbid = intRequestVar('selectbid'); $icatid = intval($catid); $tblogmode = ($this->bmode == 'all' || $this->bmode == 'bselect'); if ($tblogmode) { if ($archivelist && $icatid) { $iblogid = getBlogIDFromCatID($icatid); } elseif ($this->bmode == 'bselect' && $selectbid) { $iblogid = $selectbid; } elseif ($blogid) { $iblogid = intval($blogid); } } $new_date = date('FY',$item->timestamp); if ($new_date != $this->date) { $linkparams = array(); if ($catid) $linkparams['catid'] = $icatid; $archivedate = date('Y-m',$item->timestamp); if ($tblogmode == 'all' && $iblogid) { $alink = createArchiveLink($iblogid,$archivedate,$linkparams); } else { $alink = createArchiveLink($bid,$archivedate,$linkparams); } $format = str_replace("<[monthlink]>",$alink,$format); echo $this->_formatDate($format, $item->timestamp, "%Y-%m", $b); $this->date = $new_date; } } function doSkinVar($skinType, $mode='month', $template='', $amount=50, $navitype=1, $form=1, $bmode='', $sort='DESC', $monthlimit=0) { global $manager, $blog, $CONF, $catid, $itemid, $blogid, $archive; $noheading = 0; switch ($skinType) { case 'index': $qvar = 'blogid'; if ($this->getOption('showih') == 'no') { $noheading = 1; } break; case 'archive': $qvar = 'blogid'; if ($this->getOption('showah') == 'no') { $noheading = 1; } break; case 'archivelist': $qvar = 'archivelist'; break; default: return; } $this->start = true; //--------------------------------------------------- // The number of displays which a visitor can choose $am_array = array(10, 20, 50, 100); //---------------------------------------------------- $params = func_get_args(); if ($params[1]) { if ($params[1] == 'month' || $params[1] == 'day') { $mode = $params[1]; } else { $template = $params[1]; $mode = 'month'; if (isset($params[2])) $amount = $params[2]; if (isset($params[3])) $navitype = $params[3]; if (isset($params[4])) $form = $params[4]; if (isset($params[5])) $bmode = $params[5]; if (isset($params[6])) $sort = $params[6]; if (isset($params[7])) $monthlimit = $params[7]; } } if ($mode == 'day') $this->mode = 'day'; if (preg_match("{^[0-9\(\)@/]+$}",$template)) { $amount = $template; $template = ''; if (isset($params[2])) $navitype = $params[2]; if (isset($params[3])) $form = $params[3]; if (isset($params[4])) $bmode = $params[4]; if (isset($params[5])) $sort = $params[5]; if (isset($params[6])) $monthlimit = $params[6]; } if (preg_match("{^([0-9]+(?:\([0-9]*\))?)(?:@([0-9/]+))?$}",$amount,$matches)) { if (isset($matches[2]) && $matches[2]) { $am_array = explode("/",$matches[2]); } $amount = $matches[1]; } if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } $bid = intval($b->getID()); $selectbid = intRequestVar('selectbid'); if ($bmode == 'all') { $this->bmode = $tblogmode = 'all'; $filter = 0; $catblogname = 1; } elseif (preg_match("/^(bselect\:)?((?:<>)?[A-Za-z0-9\/]+)$/",$bmode,$matches)) { if ($matches[1]) { $this->bmode = $bmode = 'bselect'; $tblogmode = 'all'; if ($matches[2] != "all") { $filter = $matches[2]; } if (!$selectbid) { $catblogname = 1; } } else { $filter = $bmode; $this->bmode = $bmode = $tblogmode = 'all'; $catblogname = 1; } } if ($tblogmode == 'all') { if ($skinType == 'archivelist' && $catid) { $iblogid = getBlogIDFromCatID($catid); } elseif ($bmode == 'bselect' && $selectbid) { $iblogid = $selectbid; } elseif ($blogid) { $iblogid = intval($blogid); } } else { $selectbid = 0; } if ($skinType == 'archive') { if (preg_match("/^[0-9]{4}-[0-9]{2}(?:-[0-9]{2})?$/", $archive)) { $selectdate = $archive; } else { $selectdate = ''; } } elseif (preg_match("/^[0-9]{4}-[0-9]{2}(?:-[0-9]{2})?$/", getVar('date'))){ $selectdate = getVar('date'); } else { $selectdate = ''; } list($pageamount, $offset) = sscanf($amount, '%d(%d)'); if (!in_array($pageamount,$am_array)) { array_push($am_array,$pageamount); sort($am_array); } if (intRequestVar('amount')) { if (!in_array(intRequestVar('amount'),$am_array)) { $am_num = count($am_array) - 1; $pageamount = $am_array[$am_num]; } else { $pageamount = intRequestVar('amount'); } } if (getVar('sort')) $sort = strtoupper(getVar('sort')); switch ($sort) { case 'DESC': case 'ASC': $order = 'i.itime '.$sort; break; default: $order = 'i.itime DESC'; } $monthlimit = intval($monthlimit); $where = ''; $where_cat =''; $where_blog = array(); if ($tblogmode != 'all') { $where = ' and i.iblog='.$bid; $where_cat = ' and c.cblog='.$bid; $where_blog[] = 'b.bnumber='.$bid; } elseif ($filter) { $hideflg = 0; if (substr($filter,0,2) == '<>') { $filter = substr($filter,2); $hideflg = 1; } $ids = explode("/",$filter); if ($ids[0]) { foreach ($ids as $val) { if (intval($val) < 1) { $val = getBlogIDFromName($val); } $w[] = intval($val); } if ($hideflg) { $where = ' and i.iblog not in ('.implode(",",$w).')'; $where_cat = ' and c.cblog not in ('.implode(",",$w).')'; $where_blog[] = 'b.bnumber not in ('.implode(",",$w).')'; } else { if (count($w) == 1) { $catblogname = 0; } $where = ' and i.iblog in ('.implode(",",$w).')'; $where_cat = ' and c.cblog in ('.implode(",",$w).')'; $where_blog[] = 'b.bnumber in ('.implode(",",$w).')'; } } } if ($selectbid) { $where .= ' and i.iblog='.$selectbid; $where_cat .= ' and c.cblog='.$selectbid; } $minstall = $manager->pluginInstalled('NP_MultipleCategories'); $mtable = ""; $msep = $this->getOption('catseparator'); if ($catid) { if ($minstall) { $where .= ' and ((i.inumber=p.item_id and (p.categories REGEXP "(^|,)'.intval($catid).'(,|$)" or i.icat='.intval($catid).')) or (p.item_id IS NULL and i.icat='.intval($catid).'))'; $mtable = ' LEFT JOIN '.sql_table('plug_multiple_categories').' as p ON i.inumber=p.item_id'; $mplugin =& $manager->getPlugin('NP_MultipleCategories'); $senable = method_exists($mplugin,"getRequestName"); global $subcatid; if ($senable) { $hassubcats = $this->_getSubCatData($catid); if ($CONF['URLMode'] == 'pathinfo') { $subcatid = intRequestVar($mplugin->getRequestName()); $pcatid = intval($mplugin->_getParentCatID($subcatid)); if ($pcatid != $catid) $subcatid = null; } } if ($subcatid && $senable) { $where .= ' and p.subcategories REGEXP "(^|,)'.intval($subcatid).'(,|$)"'; } } else { $where .= ' and i.icat='.intval($catid); } } $catformat = '"'.addslashes($this->getOption('catformat')).'"'; $catformat = preg_replace(array('/<%category%>/','/<%blogname%>/'),array('",c.cname,"','",b.bname,"'),$catformat); /* * * * * FORM * * * * */ if ($form > 0) { $catlabel = $this->getOption('category'); $allcat = $this->getOption('allcategory'); $arclabel = $this->getOption('archive'); $allarc = $this->getOption('allarchive'); $arcformat = $this->getOption('archiveformat'); $sortlabel = $this->getOption('sort'); $newest = $this->getOption('newest'); $oldest = $this->getOption('oldest'); $numlabel = $this->getOption('perpage'); $submit = $this->getOption('submit'); $datename = ($skinType == 'archive') ? 'archive' : 'date'; $notgroup = $this->getOption('notgroup'); $notgs = array(); if ($notgroup && $notgroup != "*") { $notgs = explode("/",$notgroup); $notgs = array_map("intval",$notgs); } ?> <form method="get" action="<?php echo $CONF['Self']?>"> <div class="searchoption"> <input type="hidden" name="<?php echo $qvar ?>" value="<?php echo $bid ?>" /> <label for="titlelist_catid"><?php echo $catlabel ?></label> <?php if ($bmode == 'bselect') { ?> <select name="selectbid" id="titlelist_catid"> <option value=""><?php echo $allcat ?></option> <?php } else { ?> <select name="catid" id="titlelist_catid"> <option value=""><?php echo $allcat ?></option> <?php } if ($tblogmode != 'all') { $this->showCategorySelect($where_cat, $b->getCorrectTime()); } else { if ($contentslist != null && strstr($contentslist->getVersion(),'table')) { $query = 'SELECT b.bnumber, b.bname' .' FROM '.sql_table('plug_contentslist_rank').' as p, '.sql_table('blog').' as b' .' WHERE p.rid=b.bnumber and p.blog=1'; if (count($where_blog) > 0) { $query .= ' and '.implode(" and ",$where_blog); } $query .= ' GROUP BY b.bname ORDER BY p.rank, bname ASC'; } else { $query = 'SELECT b.bnumber, b.bname' .' FROM '.sql_table('blog').' as b'; if (count($where_blog) > 0) { $query .= ' WHERE '.implode(" and ",$where_blog); } $query .= ' GROUP BY b.bname ORDER BY bname ASC'; } $blogs = sql_query($query); if ($bmode == 'all') { while ($oBlog = mysql_fetch_object($blogs)) { if ($notgroup != "*" && !in_array($oBlog->bnumber,$notgs)) { echo ' <optgroup label="',htmlspecialchars($oBlog->bname),'">'."\n"; } $this->showCategorySelect(' and c.cblog='.$oBlog->bnumber, $b->getCorrectTime()); if ($notgroup != "*" && !in_array($oBlog->bnumber,$notgs)) { echo ' </optgroup>'."\n"; } } } else { while ($oBlog = mysql_fetch_object($blogs)) { $myblog = $oBlog->bnumber; if ($myblog == $selectbid) $myblog .= '" selected = "selected'; echo ' <option value="'.$myblog.'">'.htmlspecialchars($oBlog->bname).'</option>'."\n"; } } } ?> </select> <label for="titlelist_date"><?php echo $arclabel ?></label> <select name="<?php echo $datename ?>" id="titlelist_date" title="Select <?php echo $mode ?>"> <option value=""><?php echo $allarc ?></option> <?php $query = 'SELECT i.itime as itime, SUBSTRING(i.itime,1,4) AS Year, SUBSTRING(i.itime,6,2) AS Month, SUBSTRING(itime,9,2) as Day FROM '.sql_table('item'). ' as i'.$mtable . ' WHERE i.idraft=0' ; $timestamp_end = mysqldate($b->getCorrectTime()); $query .= ' and i.itime<=' . $timestamp_end; if ($monthlimit) { sscanf($timestamp_end,'"%d-%d-%d %s"',$y,$m,$d,$temp); $timestamp_start = mktime(0,0,0,$m-$monthlimit,$d,$y); $query .= ' and i.itime>=' . mysqldate($timestamp_start); } $query .= $where .' GROUP BY Year, Month'; if ($mode == 'day') $query .= ', Day'; $query .= ' ORDER BY itime DESC'; $res = sql_query($query); while ($o = mysql_fetch_object($res)) { $timestamp = strtotime($o->itime); if ($mode == day) { $mydate = date("Y-m-d",$timestamp); $strdate = $this->_formatDate($arcformat,$timestamp,"%Y-%m-%d",$b); } else { $mydate = date("Y-m",$timestamp); $strdate = $this->_formatDate($arcformat,$timestamp,"%Y-%m",$b); } if ($mydate == $selectdate) { echo ' <option selected="selected" value="'.$mydate.'">'.$strdate.'</option>'; } else { echo ' <option value="'.$mydate.'">'.$strdate.'</option>'; } } ?> </select><br /> <label for="titlelist_sort"><?php echo $sortlabel ?></label> <select name="sort" id="titlelist_sort" title="The order of the date"> <option value="desc"<?php echo ($sort=='DESC') ? ' selected="selected"' : '' ?>><?php echo $newest ?></option> <option value="asc"<?php echo ($sort=='ASC') ? ' selected="selected"' : '' ?>><?php echo $oldest ?></option> </select> <label for="titlelist_amount"><?php echo $numlabel ?></label> <select name="amount" id="titlelist_amount" title="The number of displays per page"> <?php for ($i=0; $i<count($am_array); $i++) { if ($am_array[$i] == $pageamount) { echo ' <option value="'.$am_array[$i].'" selected="selected">'.$am_array[$i].'</option>'."\n"; } else { echo ' <option value="'.$am_array[$i].'">'.$am_array[$i].'</option>'."\n"; } } ?> </select> <input type="submit" value="<?php echo $submit ?>" class="formbutton" /> </div> </form> <?php //--------------------------------------------------- // heading if (!$noheading) { $heading = $this->getOption('heading'); if ($catid || $selectbid) { if ($tblogmode != 'all') { $catname = $b->getCategoryName($catid); } elseif ($selectbid) { $catname = quickQuery('SELECT bname as result FROM '. sql_table('blog').' WHERE bnumber='.$selectbid); } elseif ($catblogname) { $catname = quickQuery('SELECT concat('.$catformat.') as result FROM '. sql_table('category').' as c,' . sql_table('blog').' as b WHERE c.catid='.intval($catid).' and b.bnumber = c.cblog'); } else { $catname = quickQuery('SELECT cname as result FROM '. sql_table('category').' WHERE catid='.intval($catid)); } $heading = preg_replace("/<%category%>/",htmlspecialchars($catname),$heading); } else { $heading = preg_replace("/<%category%>/",$allcat,$heading); } if($selectdate) { sscanf($selectdate,'%d-%d-%d',$y,$m,$d); if ($d) { $timestamp = mktime(0,0,0,$m,$d,$y); $strdate = $this->_formatDate($arcformat,$timestamp,"%Y-%m-%d",$b); } else { $timestamp = mktime(0,0,0,$m,1,$y); $strdate = $this->_formatDate($arcformat,$timestamp,"%Y-%m",$b); } $heading = preg_replace(array("/<%separator\(([^\)]+)\)%>/","/<%archive%>/"),array("\$1",$strdate),$heading); } else { $heading = preg_replace(array("/<%separator(?:\([^\)]*\))%>/","/<%archive%>/"),"",$heading); } echo $heading; } //--------------------------------------------------- } if ($catid && $form > 0 && $senable && $hassubcats) { ?> <form method="get" action="<?php echo $CONF['Self']?>" class="subcategory-select"> <div class="searchoption"> <input type="hidden" name="<?php echo $qvar ?>" value="<?php echo $bid ?>" /> <input type="hidden" name="catid" value="<?php echo $catid ?>" /> <input type="hidden" name="amount" value="<?php echo $pageamount ?>" /> <?php if ($selectdate) echo '<input type="hidden" name="'.$datename.'" value="'.htmlspecialchars($selectdate).'" />'."\n"; ?> <input type="hidden" name="sort" value="<?php echo strtolower($sort) ?>" /> <label for="titlelist_subcatid"><?php echo $this->getOption('subcategory') ?></label> <select name="subcatid" id="titlelist_subcatid"> <option value=""><?php echo $this->getOption('allsubcategory') ?></option> <?php foreach ($hassubcats as $k => $v) { echo '<option value="'.intval($k).'"'; if ($k == $subcatid) echo ' selected="selected"'; echo '>'.htmlspecialchars($v).'</option>'."\n"; } ?> </select> <input type="submit" value="<?php echo $submit ?>" class="formbutton" /> </div> </form> <?php } $numlabel = $this->getOption('perpage'); /* * * * * PAGE SWITCH * * * * */ $hidden = ' <input type="hidden" name="'.$qvar.'" value="'.$bid.'" />'."\n"; if ($catid) { $linkparams = array('catid' => intval($catid)); $hidden .= ' <input type="hidden" name="catid" value="'.intval($catid).'" />'."\n"; if ($senable && $subcatid) { $linkparams['subcatid'] = $subcatid; $hidden .= ' <input type="hidden" name="subcatid" value="'.$subcatid.'" />'."\n"; } } if ($selectdate) { $hidden .= ' <input type="hidden" name="date" value="'.htmlspecialchars($selectdate).'" />'."\n"; sscanf($selectdate,'%d-%d-%d',$y,$m,$d); if ($d) { $timestamp_start = mktime(0,0,0,$m,$d,$y); $timestamp_end = mktime(0,0,0,$m,$d+1,$y); } else { $timestamp_start = mktime(0,0,0,$m,1,$y); $timestamp_end = mktime(0,0,0,$m+1,1,$y); } $where .= ' and i.itime>=' . mysqldate($timestamp_start) . ' and i.itime<' . mysqldate($timestamp_end); } elseif($timestamp_start) { $where .= ' and i.itime>=' . mysqldate($timestamp_start) . ' and i.itime<=' . $timestamp_end; } else { $selectdate = ''; $where .= ' and i.itime<=' . mysqldate($b->getCorrectTime()); } $hidden .= ' <input type="hidden" name="sort" value="'.strtolower($sort).'" />'."\n"; $startpos = 0; $uri = sprintf("%s%s%s","http://",serverVar("HTTP_HOST"),serverVar("REQUEST_URI")); list($pagelink, $currentpage) = explode("page=",$uri); $currentpage = intval($currentpage); $pagelink = rawurldecode($pagelink); $pagelink = stripslashes($pagelink); $pagelink = preg_replace('|[^a-z0-9-~+_.?#=&;,/:@%]|i', '', $pagelink); if(intval($currentpage)>0){ $startpos = (intval($currentpage)-1) * $pageamount; } else { $currentpage = 1; $uri = parse_url($pagelink); if($uri['query']){ $pagelink .= '&'; $pagelink = str_replace('&&','&',$pagelink); $pagelink = str_replace('&&','&',$pagelink); }else{ $pagelink .= '?'; } } $query = 'SELECT COUNT(DISTINCT i.inumber)' . ' FROM '.sql_table('item') .' as i'. $mtable . ' WHERE i.idraft=0' . $where; $totalamount = 0; $entries = sql_query($query); if ($row = mysql_fetch_row($entries)) $totalamount = $row[0]; if (!$selectdate && $pagelimit && ($pagelimit*$pageamount < $totalamount)) { $totalamount = $pagelimit*$pageamount; } if($offset){ $startpos += $offset; $totalamount -= $offset; } $totalpages = ceil($totalamount/$pageamount); if ($startpos > $totalamount) { $currentpage = $totalpages; $startpos = $totalamount-$pageamount; } // change $buf = <<<EOD <form method="get" action="{$CONF['Self']}" class="navi"> <div class="pageswitch"> $hidden $numlabel <select name="amount" title="The number of displays per page" onchange="this.form.submit()"> EOD; for ($i=0; $i<count($am_array); $i++) { if ($am_array[$i] == $pageamount) { $buf .= ' <option value="'.$am_array[$i].'" selected="selected">'.$am_array[$i].'</option>'."\n"; } else { $buf .= ' <option value="'.$am_array[$i].'">'.$am_array[$i].'</option>'."\n"; } } $buf .= <<<EOD </select> <noscript> <div class="noscript"> <input type="submit" value="SET" /> </div> </noscript> EOD; $currentpage > 1 ? $prevpage = $currentpage - 1 : $prevpage = 0; $nextpage = $currentpage + 1; if($prevpage){ $prevpagelink = $pagelink. 'page=' . $prevpage; $buf .= "\n".' <a href="'.$prevpagelink.'" title="Previous page" rel="prev">'.$this->getOption('prevlink').'</a>'."\n"; } // type2 ---------- if($navitype >= 2){ $buf .= ' | '; for($i=1; $i<=$totalpages; $i++){ if($i == $currentpage){ $buf .= " <strong class=\"current\">{$currentpage}</strong> .\n"; }elseif($totalpages<10 || $i<4 || $i>$totalpages-3){ $buf .= ' <a href="'.$pagelink. 'page=' . $i.'">'.$i.'</a> .'."\n"; }else{ if($i<$currentpage-1 || $i>$currentpage+1){ if(($i==4 && ($currentpage>5 || $currentpage==1)) || $i==$currentpage+2){ $buf .= '. .'."\n"; } }else{ $buf .= ' <a href="'.$pagelink. 'page=' . $i.'">'.$i.'</a>'; } } } } // type2 end ------- if($totalpages >= $nextpage){ $nextpagelink = $pagelink. 'page=' . $nextpage; if ($prevpage || $navitype >= 2) $buf .= ' | '; $buf .= '<a href="'.$nextpagelink.'" title="Next page" rel="next">'.$this->getOption('nextlink').'</a>'."\n"; } elseif ($navitype >= 2) { $buf .= ' | '; } $buf .= "\n </div>\n</form>\n"; if ($navitype > 0) echo $buf; /* * * * * TITLE LIST * * * * */ if ($totalamount) { if ($bmode != 'all') { $where .= ' and b.bnumber = c.cblog'; } if ($template) { $query = 'SELECT DISTINCT(i.inumber) as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, UNIX_TIMESTAMP(i.itime) as timestamp, i.itime, i.imore as more, m.mnumber as authorid, i.icat as catid, i.iclosed as closed' ; } else { $query = 'SELECT DISTINCT(i.inumber) as itemid, i.ititle as title, UNIX_TIMESTAMP(i.itime) as timestamp, i.itime, i.icat as catid, m.mname as author, m.mrealname as authorname, m.mnumber as authorid' ; } if ($bmode == 'all') { $query .= ', concat('.$catformat.') as category'; } else { $query .= ', c.cname as category'; } $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c, '.sql_table('blog').' as b'.$mtable; $query .= ' WHERE i.iauthor=m.mnumber and i.icat=c.catid and i.idraft=0'; if ($bmode == 'all') { $query .= ' and b.bnumber = c.cblog'; } $query .= $where . ' ORDER BY '.$order; if ($pageamount > 0){ $query .= ' LIMIT ' . $startpos .',' . $pageamount; } //====== if ($template) { $b->showUsingQuery($template, $query, 0, 1, 1); //====== } else { $actions = new ITEMACTIONS($b); $parser = new PARSER($actions->getDefinedActions(),$actions); $actions->setParser($parser); if ($lc = $this->getOption('locale')) { setlocale(LC_TIME,$lc); } echo $this->getOption('allhead'); $it = $this->getOption('item'); if ($catid) { $it = preg_replace("/<%if\(category\)%>(.+(?=<%else%>))?(?:<%else%>.*)?<%endif%>/","$1",$it); } else { $it = preg_replace("/<%if\(category\)%>(?:.+(?=<%else%>))?<%else%>(.+(?=<%endif%>))?<%endif%>/","$1",$it); } $res = sql_query($query); while ($item = mysql_fetch_object($res)) { $item->timestamp = strtotime($item->itime); $actions->setCurrentItem($item); $data = array(); if ($mode == 'day') { $archivedate = date('Y-m-d',$item->timestamp); $arc = date('dFY',$item->timestamp); } else { $archivedate = date('Y-m',$item->timestamp); $arc = date('FY',$item->timestamp); } if ($tblogmode == 'all' && $iblogid) { $alink = createArchiveLink($iblogid,$archivedate,$linkparams); } else { $alink = createArchiveLink($bid,$archivedate,$linkparams); } if ($old_arc != $arc) { if ($old_arc) { $df = preg_replace("/<%archivelink%>/", $alink, $this->getOption('datefoot')); $parser->parse($df); } $dh = preg_replace("/<%archivelink%>/", $alink, $this->getOption('datehead')); $parser->parse($dh); } if ($minstall && !$catblogname && ($multicatlist = $this->_getMultiCategories($item->itemid))) { $cat_string = $this->_getCatNameFromID($item->catid); $itemcats = explode(",",$multicatlist); $extra_cat_string = array(); foreach ($itemcats as $aCat){ if ( intval($aCat) != intval($item->catid) ) $extra_cat_string[] = $this->_getCatNameFromID($aCat); } if (count($extra_cat_string)) { $cat_string .= $msep.join($msep,$extra_cat_string); } $it_i = str_replace("<%category%>",$cat_string,$it); } else { $it_i = $it; } $parser->parse($it_i); $old_arc = $arc; } mysql_free_result($res); $df = preg_replace("/<%archivelink%>/", $alink, $this->getOption('datefoot')); $parser->parse($df); echo $this->getOption('allfoot'); } } else { echo "<p>No results</p>\n"; } if ($navitype > 0) echo "\n".$buf; $this->start = false; } // doSkinVar end function _getCatNameFromID($id){ return quickQuery('SELECT cname as result FROM '.sql_table('category').' WHERE catid='.intval($id)); } function _getMultiCategories($itemid){ $query = "SELECT categories FROM ".sql_table('plug_multiple_categories')." WHERE item_id=".intval($itemid); $result = sql_query($query); if(mysql_num_rows($result)==0) return; $row = mysql_fetch_row($result); return $row[0]; } function _getSubCatData($catid){ $res = sql_query('SELECT scatid, sname FROM '.sql_table('plug_multiple_categories_sub').' WHERE catid='.intval($catid)); if(!$res) return false; $sdata = array(); while ($o = mysql_fetch_object($res)) { $count = quickQuery('SELECT count(*) as result FROM '.sql_table('plug_multiple_categories').' WHERE subcategories REGEXP "(^|,)'.intval($o->scatid).'(,|$)"'); if (intval($count) > 0) { $sdata[$o->scatid] = $o->sname; } } if (count($sdata) < 1) return false; return $sdata; } function showCategorySelect($where, $time) { global $manager, $catid; if ($manager->pluginInstalled('NP_ContentsList')) { $contentslist =& $manager->getPlugin('NP_ContentsList'); } else { $contentslist = null; } if ($contentslist != null && (strstr($contentslist->getVersion(),'table') || $contentslist->getVersion() >= 2.0)) { $query = 'SELECT c.catid as catid, c.cname as cname' .' FROM '.sql_table('category').' as c, '.sql_table('item').' as i, ' . sql_table('plug_contentslist_rank').' as p' .' WHERE p.rid=c.catid and p.blog=0'.$where; if ($contentslist->getVersion() >= 2.0) { $query .= ' and p.rank<='.$contentslist->get('catmaxrank'); } $query .=' GROUP BY c.cname ' .' ORDER BY p.rank, catid ASC'; } else { $query = 'SELECT c.catid as catid, c.cname as cname' .' FROM '.sql_table('category').' as c, '.sql_table('item').' as i'; if ($where != "") { $query .= ' WHERE '.substr($where,5); } $query .= ' GROUP BY c.cname ' .' ORDER BY cname ASC'; } $res = sql_query($query); $minstall = $manager->pluginInstalled('NP_MultipleCategories'); while ($o = mysql_fetch_object($res)) { $mycatid = intval($o->catid); $cq = 'SELECT count(*) as result FROM '.sql_table('item').' as i'; if ($minstall) { $cq .= ' LEFT JOIN '.sql_table('plug_multiple_categories').' as p ON i.inumber=p.item_id'; $cq .= ' WHERE ((i.inumber=p.item_id and (p.categories REGEXP "(^|,)'.$mycatid.'(,|$)" or i.icat='.$mycatid.')) or (p.item_id IS NULL and i.icat='.$mycatid.'))'; } else { $cq .= ' WHERE i.icat='.$mycatid; } $cq .= ' and i.itime<=' . mysqldate($time) . ' and i.idraft=0'; $catamount = quickQuery($cq); if (intval($catamount) < 1) { continue; } if ($mycatid == $catid) $mycatid .= '" selected = "selected'; echo ' <option value="'.$mycatid.'">'.htmlspecialchars($o->cname).'</option>'."\n"; } } function _formatDate($format, $timestamp, $defaultFormat, &$blog) { if (getNucleusVersion() < 322) { return formatDate($format, $timestamp, $defaultFormat); } else { return formatDate($format, $timestamp, $defaultFormat, $blog); } } } ?>