/** * Execute the action */ public function execute() { parent::execute(); // get parameters $newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string')); // list id $ids = (array) explode(',', rtrim($newIdSequence, ',')); // loop id's and set new sequence foreach ($ids as $i => $id) { // build item $item['id'] = (int) $id; // change sequence $item['sequence'] = $i + 1; // update sequence if (BackendFaqModel::existsCategory($item['id'])) { BackendFaqModel::updateCategory($item); } } // success output $this->output(self::OK, null, 'sequence updated'); }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->meta->setUrlCallback('Backend\\Modules\\Faq\\Engine\\Model', 'getURLForCategory', array($this->record['id'])); $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); $this->meta->validate(); if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['language'] = $this->record['language']; $item['title'] = $this->frm->getField('title')->getValue(); $item['extra_id'] = $this->record['extra_id']; $item['meta_id'] = $this->meta->save(true); // update the item BackendFaqModel::updateCategory($item); BackendModel::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('Categories') . '&report=edited-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }