Example #1
0
    private function preprocessChapterInfo($comicId, $chapterInfo)
    {
        $chapterList = array();
        if (empty($chapterInfo)) {
            return $chapterList;
        }
        $picModel = new PictureModel();
        //使用一次查询代替循环查询来获取有效可显示的章节列表
        $validListByPic = $picModel->getValidItemList($comicId);
        //数据预处理
        foreach ($chapterInfo as $chapter) {
            $picList = $picModel->getPictureList($comicId, $chapter['chapter_id']);
            $url = Utils::GetImageUrl($picList[0]['source_path'], 0);
            foreach ($picList as $pic) {
                if ($pic['state'] == 3) {
                    $url = Utils::makeDowloadUrl($comicId, $pic['chapter_id'], $pic['picture_id']);
                    $url = str_replace(array("swc2", "swc"), array("mif600", "mif2"), $url);
                    break;
                }
            }
            if (!in_array($chapter['chapter_id'], $validListByPic)) {
                continue;
            }
            $chapterList[] = array('chapter_id' => $chapter['chapter_id'], 'fimage' => $url, 'seq_no' => $chapter['seq_no'], 'url' => "/ComicView/index/id/{$comicId}/cid/{$chapter['chapter_id']}", 'ftitle' => $chapter['title'], 'date' => date("Y.m.d", $chapter['create_time']));
        }
        return $chapterList;
    }
}
$event = new Event();
$event->index();