Example #1
0
	/**
	 * Gets the nations where the comic is licensed
	 * 
	 * @author	Woxxy
	 * @return	bool true on success
	 */
	public function get_licenses() {
		if (isset($this->licenses))
			return true;
		$license = new License();
		$this->licenses = $license->get_by_comic($this->id);
		// Check if the variable is not yet set, in order to save a databse read.
		foreach ($this->all as $item) {
			if (isset($item->licenses))
				continue;
			$license = new License();
			$item->licenses = $license->get_by_comic($item->id);
		}

		// All good, return true.
		return true;
	}
Example #2
0
 function serie($stub = NULL, $chapter_id = "")
 {
     $comic = new Comic();
     $comic->where("stub", $stub)->get();
     if ($comic->result_count() == 0) {
         set_notice('warn', _('Sorry, the series you are looking for does not exist.'));
         $this->manage();
         return false;
     }
     $this->viewdata["function_title"] = '<a href="' . site_url('/admin/series/manage/') . '">' . _('Manage') . '</a>';
     if ($chapter_id == "") {
         $this->viewdata["extra_title"][] = $comic->name;
     }
     $data["comic"] = $comic;
     if ($chapter_id != "") {
         if ($this->input->post()) {
             $chapter = new Chapter();
             $chapter->update_chapter_db($this->input->post());
             $subchapter = is_int($chapter->subchapter) ? $chapter->subchapter : 0;
             set_notice('notice', sprintf(_('Information for Chapter %s has been updated.'), $chapter->chapter . '.' . $subchapter));
         }
         $chapter = new Chapter($chapter_id);
         $data["chapter"] = $chapter;
         $team = new Team();
         $teams = $team->get_teams($chapter->team_id, $chapter->joint_id);
         $table = ormer($chapter);
         $table[] = array(_('Teams'), array('name' => 'team', 'type' => 'input', 'value' => $teams, 'help' => _('Insert the names of the teams who worked on this chapter.')));
         $table = tabler($table);
         $data["table"] = $table;
         $this->viewdata["extra_title"][] = '<a href="' . site_url('admin/series/series/' . $comic->stub) . '">' . $comic->name . '</a>';
         $this->viewdata["extra_title"][] = $chapter->name != "" ? $chapter->name : $chapter->chapter . "." . $chapter->subchapter;
         $data["pages"] = $chapter->get_pages();
         $this->viewdata["main_content_view"] = $this->load->view("admin/series/chapter.php", $data, TRUE);
         $this->load->view("admin/default.php", $this->viewdata);
         return true;
     }
     if ($this->input->post()) {
         // Prepare for stub change in case we have to redirect instead of just printing the view
         $old_comic_stub = $comic->stub;
         $comic->update_comic_db($this->input->post());
         $config['upload_path'] = 'content/cache/';
         $config['allowed_types'] = 'jpg|png|gif';
         $this->load->library('upload', $config);
         $field_name = "thumbnail";
         if (count($_FILES) > 0 && $this->upload->do_upload($field_name)) {
             $up_data = $this->upload->data();
             if (!$this->files_model->comic_thumb($comic, $up_data)) {
                 log_message("error", "Controller: series.php/serie: image failed being added to folder");
             }
             if (!unlink($up_data["full_path"])) {
                 log_message('error', 'series.php/serie: couldn\'t remove cache file ' . $data["full_path"]);
                 return false;
             }
         }
         flash_notice('notice', sprintf(_('Updated series information for %s.'), $comic->name));
         // Did we change the stub of the comic? We need to redirect to the new page then.
         if (isset($old_comic_stub) && $old_comic_stub != $comic->stub) {
             redirect('/admin/series/series/' . $comic->stub);
         }
     }
     $chapters = new Chapter();
     $chapters->where('comic_id', $comic->id)->include_related('team')->order_by('volume', 'DESC')->order_by('chapter', 'DESC')->order_by('subchapter', 'DESC')->get();
     foreach ($chapters->all as $key => $item) {
         if ($item->joint_id > 0) {
             $teams = new Team();
             $jointers = $teams->get_teams(0, $item->joint_id);
             $item->jointers = $jointers;
             unset($jointers);
             unset($teams);
         }
     }
     $data["chapters"] = $chapters;
     if ($comic->get_thumb()) {
         $comic->thumbnail = $comic->get_thumb();
     }
     $table = ormer($comic);
     $licenses = new License();
     $table[] = array(_('Licensed in'), array('name' => 'licensed', 'type' => 'nation', 'value' => $licenses->get_by_comic($comic->id), 'help' => _('Insert the nations where the series is licensed in order to limit the availability.')));
     $table = tabler($table);
     $data['table'] = $table;
     $this->viewdata["main_content_view"] = $this->load->view("admin/series/series.php", $data, TRUE);
     $this->load->view("admin/default.php", $this->viewdata);
 }