function lib_booklist(&$ctag, &$refObj, $getcontent = 0) { global $dsql, $envs, $cfg_dbprefix, $cfg_cmsurl; //属性处理 $attlist = "row|12,booktype|-1,titlelen|30,orderby|lastpost,author|,keyword|"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); if (!$dsql->IsTable("{$cfg_dbprefix}story_books")) { return '没安装连载模块'; } $addquery = ''; if (empty($innertext)) { if ($getcontent == 0) { $innertext = GetSysTemplets('booklist.htm'); } else { $innertext = GetSysTemplets('bookcontentlist.htm'); } } //图书类型 if ($booktype != -1) { $addquery .= " And b.booktype='{$booktype}' "; } //推荐 if ($orderby == 'commend') { $addquery .= " And b.iscommend=1 "; $orderby = 'lastpost'; } //作者条件 if (!empty($author)) { $addquery .= " And b.author like '{$author}' "; } //关键字条件 if (!empty($keyword)) { $keywords = explode(',', $keyword); $keywords = array_unique($keywords); if (count($keywords) > 0) { $addquery .= " And ("; } foreach ($keywords as $v) { $addquery .= " CONCAT(b.author,b.bookname,b.keywords) like '%{$v}%' OR"; } $addquery = ereg_replace(" OR\$", "", $addquery); $addquery .= ")"; } $clist = ''; $query = "Select b.id,b.catid,b.ischeck,b.booktype,b.iscommend,b.click,b.bookname,b.lastpost,\r\n \t\tb.author,b.mid,b.litpic,b.pubdate,b.weekcc,b.monthcc,b.description,c.classname,c.classname as typename,c.booktype as catalogtype\r\n \t\tFrom `#@__story_books` b left join `#@__story_catalog` c on c.id=b.catid\r\n \t\twhere b.postnum>0 And b.ischeck>0 {$addquery} order by b.{$orderby} desc limit 0, {$row}"; $dsql->SetQuery($query); $dsql->Execute(); $ndtp = new DedeTagParse(); $ndtp->SetNameSpace('field', '[', ']'); $GLOBALS['autoindex'] = 0; while ($row = $dsql->GetArray()) { $GLOBALS['autoindex']++; $row['title'] = $row['bookname']; $ndtp->LoadString($innertext); //获得图书最新的一个更新章节 $row['contenttitle'] = ''; $row['contentid'] = ''; if ($getcontent == 1) { $nrow = $dsql->GetOne("Select id,title,chapterid From `#@__story_content` where bookid='{$row['id']}' order by id desc "); $row['contenttitle'] = $nrow['title']; $row['contentid'] = $nrow['id']; } if ($row['booktype'] == 1) { $row['contenturl'] = $cfg_cmspath . '/book/show-photo.php?id=' . $row['contentid']; } else { $row['contenturl'] = $cfg_cmspath . '/book/story.php?id=' . $row['contentid']; } //动态网址 $row['dmbookurl'] = $cfg_cmspath . '/book/book.php?id=' . $row['id']; //静态网址 $row['bookurl'] = $row['url'] = GetBookUrl($row['id'], $row['bookname']); $row['catalogurl'] = $cfg_cmspath . '/book/list.php?id=' . $row['catid']; $row['cataloglink'] = "<a href='{$row['catalogurl']}'>{$row['classname']}</a>"; $row['booklink'] = "<a href='{$row['bookurl']}'>{$row['bookname']}</a>"; $row['contentlink'] = "<a href='{$row['contenturl']}'>{$row['contenttitle']}</a>"; $row['imglink'] = "<a href='{$row['bookurl']}'><img src='{$row['litpic']}' width='{$imgwidth}' height='{$imgheight}' border='0' /></a>"; if ($row['ischeck'] == 2) { $row['ischeck'] = '已完成连载'; } else { $row['ischeck'] = '连载中...'; } if ($row['booktype'] == 0) { $row['booktypename'] = '小说'; } else { $row['booktypename'] = '漫画'; } if (is_array($ndtp->CTags)) { foreach ($ndtp->CTags as $tagid => $ctag) { $tagname = $ctag->GetTagName(); if (isset($row[$tagname])) { $ndtp->Assign($tagid, $row[$tagname]); } else { $ndtp->Assign($tagid, ''); } } } $clist .= $ndtp->GetResult(); } return $clist; }
function GetBookList($num = 12, $booktype = '-1', $titlelen = 24, $orderby = 'lastpost', $catid = 0, $bookid = 0, $author = '', $getcontent = 0, $innertext = '', $pagesize = 0, $imgwidth = 90, $imgheight = 110) { global $cfg_cmspath; if (empty($num)) { $num = 12; } if ($booktype == '') { $booktype = -1; } if (empty($titlelen)) { $titlelen = 24; } if (empty($orderby)) { $orderby = 'lastpost'; } else { $orderby = eregi_replace('[^a-z]', '', $orderby); } if (empty($bookid)) { $bookid = 0; } $addquery = ''; if (empty($innertext)) { //普通图书列表 if ($getcontent == 0) { $innertext = GetSysTemplets('book_booklist.htm'); } else { if ($getcontent == -1) { $innertext = GetSysTemplets('book_booklist_m.htm'); } else { $innertext = GetSysTemplets('book_contentlist.htm'); } } } if ($booktype != -1) { $addquery .= " And b.booktype='{$booktype}' "; } if ($bookid > 0) { $addquery .= " And b.id<>'{$bookid}' "; } if ($orderby == 'commend') { $addquery .= " And b.iscommend=1 "; $orderby = 'lastpost'; } if ($catid > 0) { $addquery .= " And (b.catid='{$catid}' Or b.bcatid='{$catid}') "; } //分页、搜索列表选项 if ($getcontent == -1) { if (empty($pagesize)) { $this->PageSize = 20; } else { $this->PageSize = $pagesize; } $limitnum = $this->PageSize * ($this->PageNo - 1) . ',' . $this->PageSize; } else { $limitnum = $num; } if (!empty($this->Keys['author'])) { $author = $this->Keys['author']; } if (!empty($author)) { $addquery .= " And b.author like '{$author}' "; } //关键字条件 if (!empty($this->Keys['keyword'])) { $keywords = explode(' ', $this->Keys['keyword']); $keywords = array_unique($keywords); if (count($keywords) > 0) { $addquery .= " And ("; } foreach ($keywords as $v) { $addquery .= " CONCAT(b.author,b.bookname,b.keywords) like '%{$v}%' OR"; } $addquery = ereg_replace(" OR\$", "", $addquery); $addquery .= ")"; } $clist = ''; $query = "Select SQL_CALC_FOUND_ROWS b.id,b.catid,b.ischeck,b.booktype,b.iscommend,b.click,b.bookname,b.lastpost,\r\n \t\tb.author,b.mid,b.litpic,b.pubdate,b.weekcc,b.monthcc,b.description,c.classname,c.classname as typename,c.booktype as catalogtype\r\n \t\tFrom #@__story_books b left join #@__story_catalog c on c.id=b.catid\r\n \t\twhere b.postnum>0 And b.ischeck>0 {$addquery} order by b.{$orderby} desc limit {$limitnum}"; $this->dsql->SetQuery($query); $this->dsql->Execute(); //统计记录数 if ($this->TotalResult == -1 && $getcontent == -1) { $row = $this->dsql->GetOne("SELECT FOUND_ROWS() as dd "); $this->TotalResult = $row['dd']; $this->TotalPage = ceil($this->TotalResult / $this->PageSize); } $ndtp = new DedeTagParse(); $ndtp->SetNameSpace("field", "[", "]"); $GLOBALS['autoindex'] = 0; while ($row = $this->dsql->GetArray()) { $GLOBALS['autoindex']++; $row['title'] = $row['bookname']; $ndtp->LoadString($innertext); //获得图书最新的一个更新章节 $row['contenttitle'] = ''; $row['contentid'] = ''; if ($getcontent == 1) { $nrow = $this->GetNewContent($row['id']); $row['contenttitle'] = $nrow['title']; $row['contentid'] = $nrow['id']; //echo "{$row['contenttitle']} 0 {$row['contentid']}"; } if ($row['booktype'] == 1) { $row['contenturl'] = $cfg_cmspath . '/book/show-photo.php?id=' . $row['contentid']; } else { $row['contenturl'] = $cfg_cmspath . '/book/story.php?id=' . $row['contentid']; } //动态网址 $row['dmbookurl'] = $cfg_cmspath . '/book/book.php?id=' . $row['id']; //静态网址 $row['bookurl'] = $row['url'] = GetBookUrl($row['id'], $row['bookname']); $row['catalogurl'] = $cfg_cmspath . '/book/list.php?id=' . $row['catid']; $row['cataloglink'] = "<a href='{$row['catalogurl']}'>{$row['classname']}</a>"; $row['booklink'] = "<a href='{$row['bookurl']}'>{$row['bookname']}</a>"; $row['contentlink'] = "<a href='{$row['contenturl']}'>{$row['contenttitle']}</a>"; $row['imglink'] = "<a href='{$row['bookurl']}'><img src='{$row['litpic']}' width='{$imgwidth}' height='{$imgheight}' border='0' /></a>"; if ($row['ischeck'] == 2) { $row['ischeck'] = '已完成连载'; } else { $row['ischeck'] = '连载中...'; } if ($row['booktype'] == 0) { $row['booktypename'] = '小说'; } else { $row['booktypename'] = '漫画'; } if (is_array($ndtp->CTags)) { foreach ($ndtp->CTags as $tagid => $ctag) { $tagname = $ctag->GetTagName(); if (isset($row[$tagname])) { $ndtp->Assign($tagid, $row[$tagname]); } else { $ndtp->Assign($tagid, ''); } } } $clist .= $ndtp->GetResult(); } return $clist; }