Exemple #1
0
 function feeds($format = NULL)
 {
     //if (is_null($format))
     //	redirect('reader/feeds/rss');
     $this->load->helper('xml');
     $chapters = new Chapter();
     // filter with orderby
     $chapters->order_by('created', 'DESC');
     // get the generic chapters and the comic coming with them
     $chapters->limit(25)->get();
     $chapters->get_comic();
     if ($chapters->result_count() > 0) {
         // let's create a pretty array of chapters [comic][chapter][teams]
         $result['chapters'] = array();
         foreach ($chapters->all as $key => $chapter) {
             $result['chapters'][$key]['title'] = $chapter->comic->title() . ' ' . $chapter->title();
             $result['chapters'][$key]['thumb'] = $chapter->comic->get_thumb();
             $result['chapters'][$key]['href'] = $chapter->href();
             $result['chapters'][$key]['created'] = $chapter->created;
             $chapter->get_teams();
             foreach ($chapter->teams as $item) {
                 $result['chapters'][$key]['teams'] = implode(' | ', $item->to_array());
             }
         }
     } else {
         show_404();
     }
     $data['encoding'] = 'utf-8';
     $data['feed_name'] = get_setting('fs_gen_site_title');
     $data['feed_url'] = site_url('feeds/rss');
     $data['page_description'] = get_setting('fs_gen_site_title') . ' RSS feed';
     $data['page_language'] = get_setting('fs_gen_lang') ? get_setting('fs_gen_lang') : 'en_EN';
     $data['posts'] = $result;
     if ($format == "atom") {
         header("Content-Type: application/atom+xml");
         $this->load->view('atom', $data);
         return TRUE;
     }
     header("Content-Type: application/rss+xml");
     $this->load->view('rss', $data);
 }
Exemple #2
0
	function joint_get() {
		if (!$this->get('id') || !is_numeric($this->get('id'))) {
			$this->response(NULL, 400);
		}

		if (!$this->get('page') || !is_numeric($this->get('page')) || $this->get('page') < 1)
			$page = 1;
		else
			$page = (int) $this->get('page');

		$page = ($page * 100) - 100;

		$joint = new Joint();
		$joint->where('joint_id', $this->get('id'))->limit(1)->get();

		if ($joint->result_count() == 1) {

			$team = new Team();
			$teams = $team->get_teams(0, $this->get('id'));

			$result = array();
			foreach ($teams as $item) {
				$result['teams'][] = $item->to_array();
			}

			$chapters = new Chapter();
			$chapters->where('joint_id', $joint->joint_id);
			$chapters->limit(100, $page)->get();
			$chapters->get_comic();

			$result['chapters'] = array();
			foreach ($chapters->all as $key => $chapter) {
				$result['chapters'][$key]['comic'] = $chapter->comic->to_array();
				$result['chapters'][$key]['chapter'] = $chapter->to_array();
				$result['chapters'][$key]['teams'] = $result['teams'];
			}

			$this->response($result, 200); // 200 being the HTTP response code
		} else {
			$this->response(array('error' => _('Team could not be found')), 404);
		}
	}
Exemple #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);
     }
 }
Exemple #4
0
 function tools_check_library()
 {
     $type = $this->input->post('type');
     if ($type != 'page' && $type != 'chapter') {
         show_404();
     }
     $page = $this->input->post('page');
     if (!is_numeric($page)) {
         show_404();
     }
     $repair = FALSE;
     if ($this->input->post('repair') == 'repair') {
         $repair = TRUE;
     }
     if ($type == 'page') {
         $count = 300;
         if ($repair) {
             $count = 50;
         }
         $items = new Page();
     }
     if ($type == 'chapter') {
         $count = 15;
         if ($repair) {
             $count = 2;
         }
         $items = new Chapter();
     }
     $offset = $page * $count - $count;
     $items->limit($count, $offset)->get_iterated();
     if ($items->result_count() == 0) {
         if ($type == 'chapter') {
             $pages = new Page();
             $pages_count = $pages->count();
             $this->output->set_output(json_encode(array('status' => 'done', 'pages_count' => $pages_count)));
         } else {
             $this->output->set_output(json_encode(array('status' => 'done')));
         }
         return TRUE;
     }
     foreach ($items as $item) {
         $item->check($repair);
     }
     $warnings = array();
     foreach ($this->notices as $notice) {
         if ($notice['type'] == 'error') {
             if (!$this->input->is_cli_request()) {
                 $this->output->set_output(json_encode(array('status' => 'error', 'message' => $notice['message'])));
             }
             return FALSE;
         }
         if ($notice['type'] == 'warning') {
             $warnings[] = $notice['message'];
         }
     }
     $this->output->set_output(json_encode(array('status' => count($warnings) > 0 ? 'warning' : 'success', 'messages' => $warnings, 'processed' => $items->result_count())));
 }