/** * Saves an item and redirects based on task * @return void */ function save() { if (!($row = parent::save())) { return $row; } $model = $this->getModel($this->get('suffix')); $error = false; $row->category_description = JRequest::getVar('category_description', '', 'post', 'string', JREQUEST_ALLOWRAW); $fieldname = 'category_full_image_new'; $userfile = JRequest::getVar($fieldname, '', 'files', 'array'); if (!empty($userfile['size'])) { if ($upload = $this->addfile($fieldname)) { $row->category_full_image = $upload->getPhysicalName(); } else { $error = true; } } if ($row->save()) { $model->setId($row->id); $this->messagetype = 'message'; $this->message = JText::_('COM_TIENDA_SAVED'); if ($error) { $this->messagetype = 'notice'; $this->message .= " :: " . $this->getError(); } $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onAfterSave' . $this->get('suffix'), array($row)); } else { $this->messagetype = 'notice'; $this->message = JText::_('COM_TIENDA_SAVE_FAILED') . " - " . $row->getError(); } }