/** * Save changes to a screenshot * * @return void */ public function saveTask() { // Incoming parent ID $pid = Request::getInt('pid', 0); $version = Request::getVar('version', 'dev'); $vid = Request::getInt('vid', 0); if (!$pid) { $this->setError(Lang::txt('COM_TOOLS_CONTRIBUTE_NO_ID')); $this->displayTask($pid, $version); return; } // Incoming $file = Request::getVar('filename', ''); $title = preg_replace('/\\s+/', ' ', Request::getVar('title', '')); // Instantiate a new screenshot object $ss = new \Components\Resources\Tables\Screenshot($this->database); $shot = $ss->getScreenshot($file, $pid, $vid); $files = $ss->getFiles($pid, $vid); if ($shot) { // update entry $ss->loadFromFilename($file, $pid, $vid); } else { // make new entry $ss->versionid = $vid; $ordering = $ss->getLastOrdering($pid, $vid); $ss->ordering = $ordering ? $ordering + 1 : count($files) + 1; // put in the end $ss->filename = $file; $ss->resourceid = $pid; } $ss->title = preg_replace('/"((.)*?)"/i', "“\\1”", $title); if (!$ss->store()) { $this->setError($ss->getError()); } // Push through to the screenshot view $this->displayTask($pid, $version); }