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 (BackendCatalogModel::existsSpecification($id)) {
             BackendCatalogModel::updateSpecification($id, $item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
예제 #2
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $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'] = BL::getWorkingLanguage();
             $item['meta_id'] = $this->meta->save(true);
             // save the data
             BackendCatalogModel::updateSpecification($item['id'], $item);
             //--Add the languages
             foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
                 $itemLanguage = array();
                 $itemLanguage['id'] = $item['id'];
                 $itemLanguage['language'] = $language;
                 $itemLanguage['title'] = $this->frm->getField('title_' . $language)->getValue();
                 BackendCatalogModel::updateSpecificationLanguage($itemLanguage, $language);
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_specification', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('specifications') . '&report=edited-specification&var=' . urlencode($this->frm->getField('title_nl')->getValue()) . '&highlight=row-' . $item['id']);
         }
     }
 }