Esempio n. 1
0
 /**
  * Removes the compressed file from the disk and database
  * 
  * @author Woxxy
  * @returns bool 
  */
 function remove()
 {
     $chapter = new Chapter($this->chapter_id);
     $chapter->get_comic();
     if (file_exists("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $this->filename)) {
         if (!@unlink("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $this->filename)) {
             log_message('error', 'remove: error when trying to unlink() the compressed ZIP');
             return FALSE;
         }
     }
     $this->delete();
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 function delete($type, $id = 0)
 {
     if (!isAjax()) {
         $this->output->set_output(_('You can\'t delete chapters from outside the admin panel through this link.'));
         log_message("error", "Controller: series.php/remove: failed serie removal");
         return false;
     }
     $id = intval($id);
     switch ($type) {
         case "serie":
             $comic = new Comic();
             $comic->where('id', $id)->get();
             $title = $comic->name;
             if (!$comic->remove()) {
                 flash_notice('error', sprintf(_('Failed to delete the series %s.'), $title));
                 log_message("error", "Controller: series.php/remove: failed serie removal");
                 $this->output->set_output(json_encode(array('href' => site_url("admin/series/manage"))));
                 return false;
             }
             flash_notice('notice', 'The serie ' . $comic->name . ' has been removed');
             $this->output->set_output(json_encode(array('href' => site_url("admin/series/manage"))));
             break;
         case "chapter":
             $chapter = new Chapter($id);
             $title = $chapter->chapter;
             if (!($comic = $chapter->remove())) {
                 flash_notice('error', sprintf(_('Failed to delete chapter %s.'), $chapter->comic->chapter));
                 log_message("error", "Controller: series.php/remove: failed chapter removal");
                 $this->output->set_output(json_encode(array('href' => site_url("admin/series/series/" . $comic->stub))));
                 return false;
             }
             set_notice('notice', 'Chapter deleted.');
             $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $comic->stub))));
             break;
         case "page":
             $page = new Page($this->input->post('id'));
             $page->get_chapter();
             $page->chapter->get_comic();
             if (!($data = $page->remove_page())) {
                 log_message("error", "Controller: series.php/remove: failed page removal");
                 return false;
             }
             $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $page->chapter->comic->stub . "/" . $page->chapter->id))));
             break;
         case "allpages":
             $chapter = new Chapter($id);
             $chapter->get_comic();
             if (!$chapter->remove_all_pages()) {
                 log_message("error", "Controller: series.php/remove: failed all pages removal");
                 return false;
             }
             $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $chapter->comic->stub . "/" . $chapter->id))));
             break;
     }
 }
Esempio n. 4
0
	/**
	 * Removes the compressed file from the disk and database
	 * 
	 * @author Woxxy
	 * @returns bool 
	 */
	function remove() {
		$chapter = new Chapter();
		$chapter->where('id', $this->chapter_id)->get();
		$chapter->get_comic();
		unlink("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $this->filename);
		$this->delete();
	}
Esempio n. 5
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);
		}
	}
Esempio n. 6
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);
     }
 }
Esempio n. 7
0
	function delete($type, $id = 0) {
		if (!isAjax()) {
			echo _('You can\'t delete chapters from outside the admin panel through this link.');
			log_message("error", "Controller: comics.php/remove: failed comic removal");
			return false;
		}
		$id = intval($id);

		switch ($type) {
			case("comic"):
				$comic = new Comic();
				$comic->where('id', $id)->get();
				if (!$comic->remove()) {
					log_message("error", "Controller: comics.php/remove: failed comic removal");
					return false;
				}
				flash_notice('notice', 'The comic ' . $comic->name . ' has been removed');
				echo json_encode(array('href' => site_url("admin/comics/manage")));
				break;
			case("chapter"):
				$chapter = new Chapter($id);
				if (!$comic = $chapter->remove()) {
					log_message("error", "Controller: comics.php/remove: failed chapter removal");
					return false;
				}
				set_notice('notice', 'Chapter deleted.');
				echo json_encode(array('href' => site_url("admin/comics/comic/" . $comic->stub)));
				break;
			case("page"):
				$page = new Page($this->input->post('id'));
				$page->get_chapter();
				$comic = new Chapter($chapter->comic_id);
				if (!$data = $page->remove_page()) {
					log_message("error", "Controller: comics.php/remove: failed page removal");
					return false;
				}
				echo json_encode(array('href' => site_url("admin/comics/comic/" . $page->chapter->comic->stub . "/" . $page->chapter->id)));
				break;
			case("allpages"):
				$chapter = new Chapter($id);
				$chapter->get_comic();
				if (!$chapter->remove_all_pages()) {
					log_message("error", "Controller: comics.php/remove: failed all pages removal");
					return false;
				}
				echo json_encode(array('href' => site_url("admin/comics/comic/" . $chapter->comic->stub . "/" . $chapter->id)));
				break;
		}
	}