/** * Edit content item * * @return string */ public function editItem() { // Incoming $id = Request::getInt('aid', 0); $props = Request::getVar('p', ''); // Parse props for curation $parts = explode('-', $props); $block = isset($parts[0]) ? $parts[0] : 'content'; $step = isset($parts[1]) && is_numeric($parts[1]) && $parts[1] > 0 ? $parts[1] : 1; $element = isset($parts[2]) && is_numeric($parts[2]) && $parts[2] > 0 ? $parts[2] : 0; if ($this->_task == 'editauthor') { // Get author information $row = new \Components\Publications\Tables\Author($this->_database); $error = Lang::txt('PLG_PROJECTS_PUBLICATIONS_CONTENT_ERROR_LOAD_AUTHOR'); $layout = 'author'; } else { // Load attachment $row = new \Components\Publications\Tables\Attachment($this->_database); $error = Lang::txt('PLG_PROJECTS_PUBLICATIONS_CONTENT_ERROR_EDIT_CONTENT'); $layout = 'attachment'; } // We need attachment record if (!$id || !$row->load($id)) { $this->setError($error); } // Load publication $pub = new \Components\Publications\Models\Publication(NULL, NULL, $row->publication_version_id); if (!$pub->exists()) { $this->setError($error); } // Make sure the publication belongs to the project if (!$pub->belongsToProject($this->model->get('id'))) { $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_ERROR_PROJECT_ASSOC')); } // On error if ($this->getError()) { // Output error $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'error')); $view->title = ''; $view->option = $this->_option; $view->setError($this->getError()); return $view->loadTemplate(); } // Set curation $pub->setCuration(); // On success $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'edititem', 'layout' => $layout)); // Get project path if ($this->_task != 'editauthor') { $view->path = $pub->project()->repo()->get('path'); } $view->step = $step; $view->block = $block; $view->element = $element; $view->database = $this->_database; $view->option = $this->_option; $view->project = $this->model; $view->pub = $pub; $view->row = $row; $view->backUrl = Request::getVar('HTTP_REFERER', NULL, 'server'); $view->ajax = Request::getInt('ajax', 0); $view->props = $props; return $view->loadTemplate(); }