showCategoryList($param1,$param2,$catid); } function doTemplateVar(&$item,$param1='',$param2=''){ $this->showCategoryList($param1,$param2,$item->catid); } function doTemplateCommentsVar(&$item,&$comment,$param1='',$param2=''){ $this->showCategoryList($param1,$param2,$item->catid); } function showCategoryList($template,$shName,$catid) { global $CONF, $manager, $blog; if ($shName) { $res = sql_query('select * FROM '.sql_table('blog').' WHERE bshortname="'.addslashes($shName).'"'); $data = mysql_fetch_assoc($res); mysql_free_result($res); $b = new BLOG($data['bnumber']); } else if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } if ($template=='catname') { $catname = $b->getCategoryName($catid); $i = strpos($catname, '-->'); if ($i!==False) { echo substr($catname,$i+3); return; } else { echo $catname; return; } } $shName = $b->getShortName(); // here is the query $offset_date = $b->getCorrectTime(); $query = 'SELECT a.catid, a.cdesc, a.cname, count(b.ititle) as ammount FROM '. sql_table('category').' a, '.sql_table('item').' b, '.sql_table('blog'). ' c WHERE a.catid = b.icat and b.iblog = c.bnumber and b.itime <= '. mysqldate($offset_date).' and b.idraft = \'0\' and c.bshortname = "'. $shName.'" GROUP BY a.cname ORDER BY 2'; $numPosts = mysql_query($query); // count the number $this->numInAll=0; while($row = mysql_fetch_object($numPosts)){ $this->numInCategory[(integer)$row->catid]=$row->ammount; $this->numInCategory[0]+=$row->ammount; } mysql_free_result ($numPosts); // determine arguments next to catids // I guess this can be done in a better way, but it works global $archive, $archivelist; $linkparams = array(); if ($archive) { $linkparams['blogid'] = $b->getID(); $linkparams['archive'] = $archive; } else if ($archivelist) { $linkparams['blogid'] = $b->getID(); $linkparams['archives'] = $archivelist; } else { $linkparams['blogid'] = $b->getID(); } $blogurl = createBlogLink($b->getURL(), $linkparams); $template =& $manager->getTemplate($template); echo TEMPLATE::fill($template['CATLIST_HEADER'], array( 'blogid' => $b->getID(), 'blogurl' => $blogurl, 'self' => $CONF['Self'] )); $query = 'SELECT catid, cdesc as catdesc, cname as catname FROM '.sql_table('category').' WHERE cblog=' . $b->getID() . ' ORDER BY cname ASC'; $res = sql_query($query); while ($data = mysql_fetch_assoc($res)) { // setting tab $depth='0'; $option=''; $i=strpos($data['catname'],'',$i); if ($i!==False && $j!==False) { $rem=substr($data['catname'],$i,$j-$i+3); $data['catname']=substr($data['catname'],0,$i).substr($data['catname'],$j+3,strlen($data['catname'])-$j-3); $i=strpos($rem,'('); $j=strpos($rem,')',$i); if ($i!==False && $j!==False) { $depth=substr($rem,$i+1,$j-$i-1); $option=substr($rem,$j+1, -3); } } else { $rem=''; } if (($rem!='')&&($rem!='')) { if ($option=='all'){ $data['catid'] = 0; } $numberOfItem=(integer)$this->numInCategory[ $data['catid'] ]; if ($numberOfItem==0) { $data['stat'] = '2'; } else if ($data['catid']==$catid) { $data['stat'] = $catid ? '1' : '0'; } else { $data['stat'] = '0'; } $data['blogid'] = $b->getID(); $data['blogurl'] = $blogurl; $data['catlink'] = createCategoryLink($data['catid'], $linkparams); $data['self'] = $CONF['Self']; $data['depth'] = $depth; $data['tab'] = str_repeat(' ', $depth); $temp = TEMPLATE::fill($template['CATLIST_LISTITEM'],$data); if ($numberOfItem==0) { $temp=eregi_replace('','',$temp); $temp=eregi_replace(']*)>','',$temp); } else { $temp=eregi_replace('',"($numberOfItem)",$temp); } echo strftime($temp,$current->itime); } } mysql_free_result($res); echo TEMPLATE::fill($template['CATLIST_FOOTER'], array( 'blogid' => $b->getID(), 'blogurl' => $blogurl, 'self' => $CONF['Self'] )); } } ?>