/** * Load the form */ private function loadForm() { if ($this->getParameter('id') != null) { // get the translation $translation = BackendLocaleModel::get($this->getParameter('id', 'int')); // if not empty, set the filter if (!empty($translation)) { // we are copying the given translation $isCopy = true; } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing' . $this->filterQuery); } } else { $isCopy = false; } // create form $this->frm = new BackendForm('add', BackendModel::createURLForAction() . $this->filterQuery); // create and add elements $this->frm->addDropdown('application', array('backend' => 'Backend', 'frontend' => 'Frontend'), $isCopy ? $translation['application'] : $this->filter['application']); $this->frm->addDropdown('module', BackendModel::getModulesForDropDown(false), $isCopy ? $translation['module'] : $this->filter['module']); $this->frm->addDropdown('type', BackendLocaleModel::getTypesForDropDown(), $isCopy ? $translation['type'] : $this->filter['type'][0]); $this->frm->addText('name', $isCopy ? $translation['name'] : $this->filter['name']); $this->frm->addTextarea('value', $isCopy ? $translation['value'] : $this->filter['value'], null, null, null, true); $this->frm->addDropdown('language', BackendLanguage::getWorkingLanguages(), $isCopy ? $translation['language'] : $this->filter['language'][0]); }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendLocaleModel::exists($this->id) && BackendAuthentication::getUser()->isGod()) { parent::execute(); // filter options $this->setFilter(); // get data $this->record = (array) BackendLocaleModel::get($this->id); // delete item BackendLocaleModel::delete(array($this->id)); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id)); // build redirect URL $redirectUrl = BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['name'] . ' (' . strtoupper($this->record['language']) . ')') . $this->filterQuery; // item was deleted, so redirect $this->redirect($redirectUrl); } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
/** * Get the data */ private function getData() { $this->record = BackendLocaleModel::get($this->id); }