Ejemplo n.º 1
0
	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);
		}
	}
Ejemplo n.º 2
0
	public function latest($page = 1) {
		$this->template->title(_('Series list'));
		// Create a "Chapter" object. It can contain more than one chapter!
		$chapters = new Chapter();

		// Select the latest 25 released chapters
		$chapters->order_by('created', 'DESC')->limit(15);

		// Get the chapters!
		$chapters->get();
		$chapters->get_teams();
		//$chapters->get_comic();

		$this->template->set('chapters', $chapters);
		$this->template->title(_('Latest'));
		$this->template->build('latest');
	}
Ejemplo n.º 3
0
 /**
  * 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);
     }
 }
Ejemplo n.º 4
0
 public function latest($page = 1)
 {
     $this->template->title(_('Series list'));
     // Create a "Chapter" object. It can contain more than one chapter!
     $chapters = new Chapter();
     // Select the latest 25 released chapters
     $chapters->order_by('created', 'DESC')->get_paged($page, 25);
     // Get the chapters!
     //$chapters->get();
     $chapters->get_teams();
     //$chapters->get_comic();
     $this->template->set('chapters', $chapters);
     $this->template->set('show_sidebar', TRUE);
     $this->template->set('is_latest', true);
     $this->template->title(_('Latest releases'), get_setting('fs_gen_site_title'));
     $this->template->build('latest');
 }