Beispiel #1
0
 private function updateCatelog($cate_id)
 {
     $dir = WEBPATH . '/' . $this->app;
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $cate = getCategory($cate_id);
     if (empty($cate)) {
         exit("不存在的分类");
     }
     if ($cate['fid'] == 0) {
         $level = 'fid';
     } else {
         $level = $cid;
     }
     $c = getContentCount($this->app, $cate_id, 'fid');
     $pager = new Swoole\Pager(array('total' => $c, 'perpage' => $this->swoole->config->cms['pagesize']));
     for ($i = 1; $i <= $pager->totalpage; $i++) {
         $html = getHtmlList($this->app, $cate_id, $i, $level);
         $filename = $dir . '/list_' . $cate_id . '_' . $i . '.html';
         file_put_contents($filename, $html);
     }
 }
Beispiel #2
0
function getContentCount($cat_id, &$total, $inDB){

    $sql = "SELECT c.*, IFNULL(COUNT(i.id), 0) as content_count
            FROM cms_uc_cats c
            LEFT JOIN cms_uc_items i ON i.category_id = c.id AND i.published = 1
            WHERE (c.parent_id = {$cat_id}) AND c.published = 1
            GROUP BY i.category_id
            ORDER BY c.title";

    $result = $inDB->query($sql);

    if ( !$inDB->num_rows($result)>0 ){ return ''; }

    while($cat = $inDB->fetch_assoc($result)){
        $total   += $cat['content_count'];
        getContentCount($cat['id'], $total, $inDB);
    }

    return ;

}