예제 #1
0
 /**
  *
  * @return databox_field
  */
 public function save()
 {
     $connbas = $this->get_connection();
     $sql = 'UPDATE metadatas_structure SET
       `name` = :name,
       `src` = :source,
       `indexable` = :indexable,
       `readonly` = :readonly,
       `required` = :required,
       `separator` = :separator,
       `multi` = :multi,
       `business` = :business,
       `aggregable` = :aggregable,
       `report` = :report,
       `type` = :type,
       `tbranch` = :tbranch,
       `sorter` = :position,
       `thumbtitle` = :thumbtitle,
       `VocabularyControlType` = :VocabularyControlType,
       `RestrictToVocabularyControl` = :RestrictVocab,
       `label_en` = :label_en,
       `label_fr` = :label_fr,
       `label_de` = :label_de,
       `label_nl` = :label_nl
       WHERE id = :id';
     $params = [':name' => $this->name, ':source' => $this->tag->getTagname(), ':indexable' => $this->indexable ? '1' : '0', ':readonly' => $this->readonly ? '1' : '0', ':required' => $this->required ? '1' : '0', ':separator' => $this->separator, ':multi' => $this->multi ? '1' : '0', ':business' => $this->Business ? '1' : '0', ':aggregable' => $this->aggregable ? '1' : '0', ':report' => $this->report ? '1' : '0', ':type' => $this->type, ':tbranch' => $this->tbranch, ':position' => $this->position, ':thumbtitle' => $this->thumbtitle, ':VocabularyControlType' => $this->Vocabulary ? $this->Vocabulary->getType() : null, ':RestrictVocab' => $this->Vocabulary ? $this->VocabularyRestriction ? '1' : '0' : '0', ':id' => $this->id, ':label_en' => isset($this->labels['en']) ? $this->labels['en'] : null, ':label_fr' => isset($this->labels['fr']) ? $this->labels['fr'] : null, ':label_de' => isset($this->labels['de']) ? $this->labels['de'] : null, ':label_nl' => isset($this->labels['nl']) ? $this->labels['nl'] : null];
     $stmt = $connbas->prepare($sql);
     $stmt->execute($params);
     $stmt->closeCursor();
     if ($this->renamed) {
         caption_field::rename_all_metadatas($this);
         $this->renamed = false;
     }
     $dom_struct = $this->databox->get_dom_structure();
     $xp_struct = $this->databox->get_xpath_structure();
     $nodes = $xp_struct->query('/record/description/*[@meta_id=' . $this->id . ']');
     if ($nodes->length == 0) {
         $meta = $dom_struct->createElement($this->name);
         $nodes_parent = $xp_struct->query('/record/description');
         $nodes_parent->item(0)->appendChild($meta);
     } else {
         $meta = $nodes->item(0);
         if ($this->name != $meta->nodeName) {
             $old_meta = $meta;
             $meta = $dom_struct->createElement($this->name);
             $nodes_parent = $xp_struct->query('/record/description');
             $nodes_parent->item(0)->replaceChild($meta, $old_meta);
         }
     }
     $meta->setAttribute('src', $this->tag->getTagname());
     $meta->setAttribute('index', $this->indexable ? '1' : '0');
     $meta->setAttribute('readonly', $this->readonly ? '1' : '0');
     $meta->setAttribute('required', $this->required ? '1' : '0');
     $meta->setAttribute('multi', $this->multi ? '1' : '0');
     $meta->setAttribute('report', $this->report ? '1' : '0');
     $meta->setAttribute('business', $this->Business ? '1' : '0');
     $meta->setAttribute('aggregable', $this->aggregable ? '1' : '0');
     $meta->setAttribute('type', $this->type);
     $meta->setAttribute('tbranch', $this->tbranch);
     if ($this->multi) {
         $meta->setAttribute('separator', $this->separator);
     }
     $meta->setAttribute('thumbtitle', $this->thumbtitle);
     $meta->setAttribute('meta_id', $this->id);
     $meta->setAttribute('sorter', $this->position);
     $this->delete_data_from_cache();
     $this->databox->saveStructure($dom_struct);
     return $this;
 }
예제 #2
0
 public static function deleteStatus(Application $app, \databox $databox, $bit)
 {
     $status = self::getStatus($app, $databox->get_sbas_id());
     if (isset($status[$bit])) {
         $doc = $databox->get_dom_structure();
         if ($doc) {
             $xpath = $databox->get_xpath_structure();
             $entries = $xpath->query("/record/statbits/bit[@n=" . $bit . "]");
             foreach ($entries as $sbit) {
                 if ($p = $sbit->previousSibling) {
                     if ($p->nodeType == XML_TEXT_NODE && $p->nodeValue == "\n\t\t") {
                         $p->parentNode->removeChild($p);
                     }
                 }
                 if ($sbit->parentNode->removeChild($sbit)) {
                     $sql = 'UPDATE record SET status = status&(~(1<<' . $bit . '))';
                     $stmt = $databox->get_connection()->prepare($sql);
                     $stmt->execute();
                     $stmt->closeCursor();
                 }
             }
             $databox->saveStructure($doc);
             if (null !== $status[$bit]['img_off']) {
                 $app['filesystem']->remove($status[$bit]['path_off']);
             }
             if (null !== $status[$bit]['img_on']) {
                 $app['filesystem']->remove($status[$bit]['path_on']);
             }
             unset(self::$_status[$databox->get_sbas_id()]->status[$bit]);
             return true;
         }
     }
     return false;
 }