public function read($comic, $language = 'en', $volume = 0, $chapter = "", $subchapter = 0, $team = 0, $joint = 0, $pagetext = 'page', $page = 1) { $comice = new Comic(); $comice->where('stub', $comic)->get(); if ($comice->result_count() == 0) { set_notice('warn', 'This comic doesn\'t exist.'); } if ($chapter == "") { redirect('/reader/comic/' . $comic); } $chaptere = new Chapter(); $chaptere->where('comic_id', $comice->id)->where('language', $language)->where('volume', $volume)->where('chapter', $chapter)->order_by('subchapter', 'ASC'); if (!is_int($subchapter) && $subchapter == 'page') { $current_page = $team; } else { $chaptere->where('subchapter', $subchapter); if ($team == 'page') $current_page = $joint; else { if ($team != 0) { $teame = new Team(); $teame->where('stub', $team)->get(); $chaptere->where('team_id', $teame->id); } if ($joint == 'page') $current_page = $pagetext; if ($joint != 0) { $chaptere->where('joint_id', $joint); } } } if (!isset($current_page)) { if ($page != 1) $current_page = $page; else $current_page = 1; } $chaptere->get(); if ($chaptere->result_count() == 0) { show_404(); } $pages = $chaptere->get_pages(); foreach($pages as $page) unset($page["object"]); $next_chapter = $chaptere->next(); if ($current_page > count($pages)) redirect($next_chapter); if ($current_page < 1) $current_page = 1; $chapters = new Chapter(); $chapters->where('comic_id', $comice->id)->order_by('volume', 'desc')->order_by('chapter', 'desc')->order_by('subchapter', 'desc')->get_bulk(); $comics = new Comic(); $comics->order_by('name', 'ASC')->limit(100)->get(); $this->template->set('is_reader', TRUE); $this->template->set('comic', $comice); $this->template->set('chapter', $chaptere); $this->template->set('chapters', $chapters); $this->template->set('comics', $comics); $this->template->set('current_page', $current_page); $this->template->set('pages', $pages); $this->template->set('next_chapter', $next_chapter); $this->template->title($comice->name . ' :: ' . _('Chapter') . ' ' . $chaptere->chapter); $this->template->build('read'); }
public function read($comic, $language = 'en', $volume = 0, $chapter = "", $subchapter = 0, $team = 0, $joint = 0, $pagetext = 'page', $page = 1) { $comice = new Comic(); $comice->where('stub', $comic)->get(); if ($comice->result_count() == 0) { set_notice('warn', 'This comic doesn\'t exist.'); } if ($chapter == "") { redirect('series/' . $comic); } if (!$this->_check_adult($comice)) { // or this function won't stop return FALSE; } $chaptere = new Chapter(); $chaptere->where('comic_id', $comice->id)->where('language', $language)->where('volume', $volume)->where('chapter', $chapter)->order_by('subchapter', 'ASC'); if (!is_int($subchapter) && $subchapter == 'page') { $current_page = $team; } else { $chaptere->where('subchapter', $subchapter); if ($team == 'page') { $current_page = $joint; } else { if ($team != 0) { $teame = new Team(); $teame->where('stub', $team)->get(); $chaptere->where('team_id', $teame->id); } if ($joint == 'page') { $current_page = $pagetext; } if ($joint != 0) { $chaptere->where('joint_id', $joint); } } } if (!isset($current_page)) { if ($page != 1) { $current_page = $page; } else { $current_page = 1; } } $chaptere->get(); if ($chaptere->result_count() == 0) { show_404(); } $pages = $chaptere->get_pages(); foreach ($pages as $page) { unset($page["object"]); } $next_chapter = $chaptere->next(); if ($current_page > count($pages)) { redirect($next_chapter); } if ($current_page < 1) { $current_page = 1; } $chapters = new Chapter(); $chapters->where('comic_id', $comice->id)->order_by('volume', 'desc')->order_by('chapter', 'desc')->order_by('subchapter', 'desc')->get_bulk(); $comics = new Comic(); $comics->order_by('name', 'ASC')->limit(100)->get(); $this->template->set('is_reader', TRUE); $this->template->set('comic', $comice); $this->template->set('chapter', $chaptere); $this->template->set('chapters', $chapters); $this->template->set('comics', $comics); $this->template->set('current_page', $current_page); $this->template->set('pages', $pages); $this->template->set('next_chapter', $next_chapter); $this->template->title($comice->name, _('Chapter') . ' ' . $chaptere->chapter, get_setting('fs_gen_site_title')); switch ($comice->format) { case 1: $format = 'readtoon'; break; default: $format = 'read'; } $this->template->build($format); }