function get_file_objects() { // Generate JSON File Output (Required by jQuery File Upload) header('Content-type: application/json'); header('Pragma: no-cache'); header('Cache-Control: private, no-cache'); header('Content-Disposition: inline; filename="files.json"'); $id = $this->input->post('id'); $chapter = new Chapter($id); $pages = $chapter->get_pages(); $info = array(); foreach ($pages as $page) { $info[] = array('name' => $page['filename'], 'size' => intval($page['size']), 'url' => $page['url'], 'thumbnail_url' => $page['thumb_url'], 'delete_url' => site_url("admin/series/delete/page"), 'delete_data' => $page['id'], 'delete_type' => 'POST'); } $this->output->set_output(json_encode($info)); return true; }
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'); }
/** * Returns the chapter * * Available filters: id (required) * * @author Woxxy */ function chapter_get() { if ($this->get('comic_stub') || is_numeric($this->get('comic_id')) || is_numeric($this->get('volume')) || is_numeric($this->get('chapter')) || is_numeric($this->get('subchapter')) || is_numeric($this->get('team_id')) || is_numeric($this->get('joint_id'))) { $chapter = new Chapter(); if ($this->get('comic_stub')) { $chapter->where_related('comic', 'stub', $this->get('comic_stub')); } // this mess is a complete search system through integers! if (is_numeric($this->get('comic_id'))) { $chapter->where('comic_id', $this->get('comic_id')); } if (is_numeric($this->get('volume'))) { $chapter->where('volume', $this->get('volume')); } if (is_numeric($this->get('chapter'))) { $chapter->where('chapter', $this->get('chapter')); } if (is_numeric($this->get('subchapter'))) { $chapter->where('subchapter', $this->get('subchapter')); } if (is_numeric($this->get('team_id'))) { $chapter->where('team_id', $this->get('team_id')); } if (is_numeric($this->get('joint_id'))) { $chapter->where('joint_id', $this->get('joint_id')); } // and we'll still give only one result $chapter->limit(1)->get(); } else { // check that the id is at least a valid number $this->_check_id(); $chapter = new Chapter(); // get the single chapter by id $chapter->where('id', $this->get('id'))->limit(1)->get(); } if ($chapter->result_count() == 1) { $chapter->get_comic(); $chapter->get_teams(); // the pretty array gets pages too: [comic][chapter][teams][pages] $result = array(); $result['comic'] = $chapter->comic->to_array(); $result['chapter'] = $chapter->to_array(); $result['teams'] = array(); foreach ($chapter->teams as $team) { $result['teams'][] = $team->to_array(); } // this time we get the pages $result['pages'] = $chapter->get_pages(); // all good $this->response($result, 200); // 200 being the HTTP response code } else { // the chapter with that id doesn't exist $this->response(array('error' => _('Chapter could not be found')), 404); } }
function chapter_get() { if (!$this->get('id') || !is_numeric($this->get('id'))) { $this->response(NULL, 400); } $chapter = new Chapter(); $chapter->where('id', $this->get('id'))->limit(1)->get(); if ($chapter->result_count() == 1) { $chapter->get_comic(); $chapter->get_teams(); $result = array(); $result['comic'] = $chapter->comic->to_array(); $result['chapter'] = $chapter->to_array(); $result['teams'] = array(); foreach ($chapter->teams as $team) { $result['teams'][] = $team->to_array(); } $result['pages'] = $chapter->get_pages(); $this->response($result, 200); // 200 being the HTTP response code } else { $this->response(array('error' => _('Chapter could not be found')), 404); } }
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); }