Exemplo n.º 1
0
 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) {
         $item['id'] = $id;
         $item['sequence'] = $i + 1;
         // update sequence
         if (BackendBlocksModel::existsCategory($id)) {
             BackendBlocksModel::updateCategory($item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Exemplo n.º 2
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('title')->isFilled(Language::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['meta_id'] = $this->meta->save(true);
             $item['extra_id'] = $this->record['extra_id'];
             // update the item
             BackendBlocksModel::updateCategory($item);
             Model::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(Model::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
         }
     }
 }