/** When using the form filter **/
 public function getDiffAsArray($is_old = true)
 {
     if ($is_old) {
         $hstore = $this->_get('old_value');
     } else {
         $hstore = $this->_get('new_value');
     }
     $diff = new Hstore();
     $diff->import($hstore);
     $tab = $diff->getIterator();
     foreach ($tab as $key => $value) {
         if (preg_match("/_indexed\$/", $key) || preg_match("/_name_ts\$/", $key) || preg_match("/_order_by\$/", $key)) {
             $tab->offsetUnset($key);
         }
     }
     return $tab;
 }
Пример #2
0
 public function getStatus()
 {
     $hstore = new Hstore();
     $hstore->import($this->_get('status'));
     return $hstore;
 }
Пример #3
0
 public function executeEdit(sfWebRequest $request)
 {
     $staging = Doctrine::getTable('Staging')->findOneById($request->getParameter('id'));
     $this->import = Doctrine::getTable('Imports')->find($staging->getImportRef());
     if (!Doctrine::getTable('collectionsRights')->hasEditRightsFor($this->getUser(), $this->import->getCollectionRef())) {
         $this->forwardToSecureAction();
     }
     $this->fields = $staging->getFields();
     $form_fields = array();
     if ($this->fields) {
         foreach ($this->fields as $key => $values) {
             $form_fields[] = $values['fields'];
         }
     }
     if (in_array('taxon_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getTaxonParents());
         $taxon_parent = $parent->getArrayCopy();
         $taxon_parent[$staging->getTaxonLevelName()] = $staging->getTaxonName();
         $this->taxon_level_name = $staging->getTaxonLevelName();
         $this->catalogues_taxon = Doctrine::getTable('Taxonomy')->getLevelParents('Taxonomy', $taxon_parent);
     }
     if (in_array('litho_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getLithoParents());
         $parents = $parent->getArrayCopy();
         $parents[$staging->getLithoLevelName()] = $staging->getLithoName();
         $this->litho_level_name = $staging->getLithoLevelName();
         $this->catalogues_litho = Doctrine::getTable('Lithostratigraphy')->getLevelParents('Lithostratigraphy', $parents);
     }
     if (in_array('lithology_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getLithologyParents());
         $parents = $parent->getArrayCopy();
         $parents[$staging->getLithologyLevelName()] = $staging->getLithologyName();
         $this->lithology_level_name = $staging->getLithologyLevelName();
         $this->catalogues_lithology = Doctrine::getTable('Lithology')->getLevelParents('Lithology', $parents);
     }
     if (in_array('chrono_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getChronoParents());
         $parents = $parent->getArrayCopy();
         $parents[$staging->getChronoLevelName()] = $staging->getChronoName();
         $this->chrono_level_name = $staging->getChronoLevelName();
         $this->catalogues_chrono = Doctrine::getTable('Chronostratigraphy')->getLevelParents('Chronostratigraphy', $parents);
     }
     if (in_array('mineral_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getMineralParents());
         $parents = $parent->getArrayCopy();
         $parents[$staging->getMineralLevelName()] = $staging->getMineralName();
         $this->mineral_level_name = $staging->getMineralLevelName();
         $this->catalogues_mineral = Doctrine::getTable('Mineralogy')->getLevelParents('Mineralogy', $parents);
     }
     $this->form = new StagingForm($staging, array('fields' => $form_fields));
 }