function add_new_chapter() { $this->viewdata["function_title"] = '<a href="#">' . _("Add New") . '</a>'; if ($this->input->post()) { $chapter = new Chapter(); if ($chapter->add($this->input->post())) { $subchapter = is_int($chapter->subchapter) ? $chapter->subchapter : 0; flash_notice('notice', sprintf(_('Chapter %s has been added to %s.'), $chapter->chapter . '.' . $subchapter, $chapter->comic->name)); redirect('/admin/series/series/' . $chapter->comic->stub . '/' . $chapter->id); } } $this->viewdata["extra_title"][] = _("Chapter"); // Obtain All Comics $comics = new Comic(); $comics->order_by('name', 'ASC')->get(); // Generate Dropdown Array $dropdown = array(); foreach ($comics->all as $comic) { $dropdown[$comic->id] = $comic->name; } // Setup Comics Dropdown $chapter = new Chapter(); $chapter->validation['comic_id']['label'] = _('Series'); $chapter->validation['comic_id']['type'] = 'dropdowner'; $chapter->validation['comic_id']['values'] = $dropdown; $chapter->validation['comic_id']['help'] = _('Add chapter to selected series.'); $table = ormer($chapter); $table[] = array(_('Teams'), array('name' => 'team', 'type' => 'input', 'value' => array('value' => get_setting('fs_gen_default_team')), 'help' => _('Insert the names of the teams who worked on this chapter.'))); $table = tabler($table, FALSE, TRUE); $data["form_title"] = _('Add New Chapter'); $data["table"] = $table; $this->viewdata["main_content_view"] = $this->load->view("admin/form.php", $data, TRUE); $this->load->view("admin/default.php", $this->viewdata); return true; }
function add_team() { // only admins and mods are allowed to create teams if (!$this->tank_auth->is_allowed()) { show_404(); } // save the data if POST if ($post = $this->input->post()) { $team = new Team(); $team->update_team($this->input->post()); flash_notice('notice', 'Added the team ' . $team->name . '.'); redirect('/admin/members/teams/' . $team->stub); } $team = new Team(); // set title and subtitle $this->viewdata["function_title"] = '<a href="' . site_url("/admin/members/teams") . '">' . _('Teams') . '</a>'; $this->viewdata["extra_title"][] = _('Add New'); // transform the Datamapper array to a form $result = ormer($team); $result = tabler($result, FALSE, TRUE); $data['form_title'] = _('Add New Team'); $data['table'] = $result; // print out $this->viewdata["main_content_view"] = $this->load->view('admin/form', $data, TRUE); $this->load->view("admin/default", $this->viewdata); }
function add_team() { if ($post = $this->input->post()) { $team = new Team(); $team->update_team($this->input->post()); redirect('/admin/members/teams/' . $team->stub); } $team = new Team(); $this->viewdata["function_title"] = "Team"; $this->viewdata["extra_title"][] = 'New'; $result = ormer($team); $result = tabler($result, FALSE, TRUE); $data['table'] = $result; $this->viewdata["main_content_view"] = $this->load->view('admin/form', $data, TRUE); $this->load->view("admin/default", $this->viewdata); }
function add_new($stub = "") { $this->viewdata["function_title"] = _("Add new"); //$stub stands for $comic, but there's already a $comic here if ($stub != "") { if ($this->input->post()) { $chapter = new Chapter(); if ($chapter->add($this->input->post())) { redirect('/admin/comics/comic/' . $chapter->comic->stub . '/' . $chapter->id); } } $comic = new Comic(); $comic->where('stub', $stub)->get(); $this->viewdata["extra_title"][] = _("Chapter in") . ' ' . $comic->name; $chapter = new Chapter(); $chapter->comic_id = $comic->id; $table = ormer($chapter); $table[] = array( _('Teams'), array( 'name' => 'team', 'type' => 'input', 'value' => array('value' => get_setting('fs_gen_default_team')), 'help' => _('Insert the names of the teams who worked on this chapter.') ) ); $table = tabler($table, FALSE, TRUE); $data["table"] = $table; $this->viewdata["main_content_view"] = $this->load->view("admin/form.php", $data, TRUE); $this->load->view("admin/default.php", $this->viewdata); return true; } else { $comic = new Comic(); if ($this->input->post()) { if ($comic->add($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: comics.php/add_new: image failed being added to folder"); } if (!unlink($up_data["full_path"])) { log_message('error', 'comics.php/add_new: couldn\'t remove cache file ' . $data["full_path"]); return false; } } redirect('/admin/comics/comic/' . $comic->stub); } } $table = ormer($comic); $table[] = array( _('Licensed in'), array( 'name' => 'licensed', 'type' => 'nation', 'value' => array(), 'help' => _('Insert the nations where the comic is licensed in order to limit the availability.') ) ); $table = tabler($table, FALSE, TRUE); $data['table'] = $table; $this->viewdata["extra_title"][] = _("Comic"); $this->viewdata["main_content_view"] = $this->load->view("admin/form.php", $data, TRUE); $this->load->view("admin/default.php", $this->viewdata); } }