/** * Displays a question response for editing * * @param mixed $row * @return void */ public function editTask($row = null) { Request::setVar('hidemainmenu', 1); // Incoming $section = Request::getInt('section_id', 0); $this->view->section = new Section($this->database); $this->view->section->load($section); if (!is_object($row)) { $id = Request::getVar('id', array(0)); if (is_array($id)) { $id = !empty($id) ? intval($id[0]) : 0; } $row = new Category($this->database); $row->load($id); } $this->view->row = $row; if (!$this->view->row->id) { $this->view->row->created_by = User::get('id'); $this->view->row->section_id = $section; $this->view->row->scope = $this->view->section->scope; $this->view->row->scope_id = $this->view->section->scope_id; } $this->view->sections = array(); $sections = $this->view->section->getRecords(); if ($sections) { foreach ($sections as $s) { $ky = $s->scope . ' (' . $s->scope_id . ')'; if ($s->scope == 'site') { $ky = '[ site ]'; } if (!isset($this->view->sections[$ky])) { $this->view->sections[$ky] = array(); } $this->view->sections[$ky][] = $s; asort($this->view->sections[$ky]); } } else { $default = new Section($this->database); $default->loadDefault($this->view->section->scope, $this->view->section->scope_id); $this->view->sections[] = $default; } asort($this->view->sections); \User::setState('com_forum.edit.category.data', array('id' => $this->view->row->get('id'), 'asset_id' => $this->view->row->get('asset_id'))); $m = new AdminCategory(); $this->view->form = $m->getForm(); // Output the HTML $this->view->setLayout('edit')->display(); }
/** * Displays a question response for editing * * @param mixed $post * @return void */ public function editTask($post = null) { Request::setVar('hidemainmenu', 1); // Incoming $id = Request::getVar('id', array(0)); $parent = Request::getInt('parent', 0); $this->view->parent = $parent; if (is_array($id)) { $id = intval($id[0]); } // Incoming if (!is_object($post)) { $post = new Post($this->database); $post->load($id); } $this->view->row = $post; if (!$id) { $this->view->row->parent = $parent; $this->view->row->created_by = User::get('id'); } if ($this->view->row->parent) { $filters = array('category_id' => $this->view->row->category_id, 'sort' => 'title', 'sort_Dir' => 'ASC', 'limit' => 100, 'start' => 0, 'parent' => 0); $this->view->threads = $this->view->row->getRecords($filters); } // Get the category $this->view->category = new Category($this->database); $this->view->category->load($this->view->row->category_id); if (!$this->view->category->id) { // No category? Load a default blank catgory $this->view->category->loadDefault(); } $this->view->cateories = array(); $categories = $this->view->category->getRecords(); if ($categories) { foreach ($categories as $c) { if (!isset($this->view->cateories[$c->section_id])) { $this->view->cateories[$c->section_id] = array(); } $this->view->cateories[$c->section_id][] = $c; asort($this->view->cateories[$c->section_id]); } } // Get the section $this->view->section = new Section($this->database); $this->view->section->load($this->view->category->section_id); if (!$this->view->section->id) { // No section? Load a default blank section $this->view->section->loadDefault(); } // Get the sections for this group $this->view->sections = array(); $sections = $this->view->section->getRecords(); if ($sections) { foreach ($sections as $s) { $ky = $s->scope . ' (' . $s->scope_id . ')'; if ($s->scope == 'site') { $ky = '[ site ]'; } if (!isset($this->view->sections[$ky])) { $this->view->sections[$ky] = array(); } $s->categories = isset($this->view->cateories[$s->id]) ? $this->view->cateories[$s->id] : array(); //$this->view->category->getRecords(array('section_id'=>$s->id)); $this->view->sections[$ky][] = $s; asort($this->view->sections[$ky]); } } else { $default = new Section($this->database); $default->loadDefault($this->view->section->scope, $this->view->section->scope_id); $this->view->sections[] = $default; } asort($this->view->sections); \User::setState('com_forum.edit.thread.data', array('id' => $this->view->row->get('id'), 'asset_id' => $this->view->row->get('asset_id'))); $m = new AdminThread(); $this->view->form = $m->getForm(); // Get tags on this article $this->view->tModel = new Tags($this->view->row->id); $this->view->tags = $this->view->tModel->render('string'); // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } $this->view->setLayout('edit')->display(); }