Example #1
0
 /**
  *  Určení jazyka, který se použije pro výběr dat.
  *  Priorita: 1. MICKA_LANG, 2. ENG, 3. první v pořadí
  *
  * @param string $langs seznam jazyků z tabulky MD.langs
  * @return string
  */
 private function getLangValue($langs)
 {
     if (substr_count($langs, MICKA_LANG) > 0) {
         return MICKA_LANG;
     }
     if (getCountLang($langs) == 1) {
         return $langs;
     } else {
         $md_langs = getMdLangs($langs);
         if (array_search('eng', $md_langs) === FALSE) {
             return $md_langs[0];
         } else {
             return 'eng';
         }
     }
 }
Example #2
0
 private function printMDXML($value_arr, $level = 0, $el_end = '', $pom_multi = 0)
 {
     $level++;
     $i = 0;
     foreach ($value_arr as $key => $item) {
         if ($level == 1) {
             // načtení hlavičky záznamu
             $this->recno_in = $key;
         }
         if (is_numeric($key) && $level > 1) {
             // opakovaná položka
             $this->opak = $key;
             //pořadí opakování
             if ($key > 0) {
                 $key_arr = array_keys($value_arr);
                 // 0 nemusí být první!
                 if ($key > $key_arr[0]) {
                     $pom_multi = 1;
                 }
             }
         }
         if (!is_numeric($key) && $key[0] != '!') {
             // elementy
             if (isset($this->level_pom) && $this->level_pom > $level) {
                 // ukončující elementy
                 while ($this->level_pom > $level) {
                     $this->rs_xml .= "</" . end($this->pom_arr) . ">";
                     $this->level_pom = $this->level_pom - 2;
                     array_pop($this->pom_arr);
                 }
             }
             if ($pom_multi) {
                 // ukončující a nový element pro opakované položky
                 $this->rs_xml .= "</" . end($this->pom_arr) . ">";
                 $this->rs_xml .= "<" . end($this->pom_arr) . ">";
                 $pom_multi = 0;
             }
             if ($key == 'MD_Metadata') {
                 // zápis hlavičky záznamu do XML
                 $recno_in = $this->recno_in;
                 $this->rs_xml .= "<" . $key . " uuid=\"" . $this->md[$recno_in]['uuid'] . "\"" . " langs=\"" . getCountLang($this->md[$recno_in]['lang']) . "\"" . " updated=\"" . $this->md[$recno_in]['updated'] . "\"" . " x1=\"" . $this->md[$recno_in]['x1'] . "\"" . " x2=\"" . $this->md[$recno_in]['x2'] . "\"" . " y1=\"" . $this->md[$recno_in]['y1'] . "\"" . " y2=\"" . $this->md[$recno_in]['y2'] . "\"" . ">";
                 $this->rs_xml .= getMdOtherLangs($this->md[$recno_in]['lang'], 'xxx');
             } elseif ($key == 'metadata') {
                 // zápis hlavičky záznamu do XML
                 $recno_in = $this->recno_in;
                 $this->rs_xml .= "<" . $key . " uuid=\"" . $this->md[$recno_in]['uuid'] . "\"" . " langs=\"" . getCountLang($this->md[$recno_in]['lang']) . "\"" . " updated=\"" . $this->md[$recno_in]['updated'] . "\"" . " x1=\"" . $this->md[$recno_in]['x1'] . "\"" . " x2=\"" . $this->md[$recno_in]['x2'] . "\"" . " y1=\"" . $this->md[$recno_in]['y1'] . "\"" . " y2=\"" . $this->md[$recno_in]['y2'] . "\"" . ">";
             } elseif ($key == 'featureCatalogue') {
                 // zápis hlavičky záznamu do XML
                 $recno_in = $this->recno_in;
                 $this->rs_xml .= "<" . $key . " uuid=\"" . $this->md[$recno_in]['uuid'] . "\"" . ">";
             } else {
                 // nový element
                 $this->rs_xml .= "<{$key}>";
             }
             $el_end = $key;
             $this->pom_arr[] = $key;
             // zásobník elementů (používá se na ukončování)
         }
         if (is_array($item)) {
             $this->printMDXML($item, $level, $el_end, $pom_multi);
         } else {
             $this->level_pom = $level;
             if ($key[0] == '!' && strlen($key) == 4) {
                 // hodnota LANG
                 if ($i == 0) {
                     // první hodnota se stejným levelem
                     if ($pom_multi) {
                         // ukončující a nový element pro opakované položky
                         $this->rs_xml .= "</" . end($this->pom_arr) . ">";
                         $this->rs_xml .= "<" . end($this->pom_arr) . ">";
                         $pom_multi = 0;
                     }
                     if (substr($key, 1, 3) != 'xxx') {
                         $of = strlen($this->rs_xml) - (strlen(end($this->pom_arr)) + 2);
                         // odstranění posledního elementu
                         $pom1 = trim(substr($this->rs_xml, $of));
                         // bude přidán s parametrem LANG
                         if ($pom1 == "<" . end($this->pom_arr) . ">") {
                             $this->rs_xml = substr($this->rs_xml, 0, strlen($this->rs_xml) - (strlen(end($this->pom_arr)) + 2));
                         }
                         $por_i = '';
                         // TODO: zobecnit, nemusí to být jen keyword
                         if (end($this->pom_arr) == 'keyword') {
                             $por_i = ' i="' . $this->opak . '"';
                         }
                         $this->rs_xml .= "<" . end($this->pom_arr) . "{$por_i} lang='" . substr($key, 1, 3) . "'>" . htmlspecialchars($item);
                         // přidání LANG
                     } else {
                         $this->rs_xml .= htmlspecialchars($item);
                         // zápis hodnoty
                     }
                     $i = 1;
                 } else {
                     // další hodnota se stejným levelem, nebude se odstraňovat poslední element, zopakuje se
                     if (substr($key, 1, 3) != 'xxx') {
                         $por_i = '';
                         if (end($this->pom_arr) == 'keyword') {
                             $por_i = ' i="' . $this->opak . '"';
                         }
                         $this->rs_xml .= "</" . end($this->pom_arr) . ">";
                         $this->rs_xml .= "<" . end($this->pom_arr) . "{$por_i} lang='" . substr($key, 1, 3) . "'>";
                     } else {
                         $this->rs_xml .= "</" . end($this->pom_arr) . ">";
                         $this->rs_xml .= "<" . end($this->pom_arr) . ">";
                     }
                     $this->rs_xml .= htmlspecialchars($item);
                     // zápis hodnoty
                 }
             }
         }
     }
     //end foreach
     $level--;
     if ($level == 0) {
         // Ukončovací elementy
         if (isset($this->pom_arr) && count($this->pom_arr) > 0) {
             $this->pom_arr = array_reverse($this->pom_arr);
             // Výpis zásobníku v opačném pořadí
             foreach ($this->pom_arr as $value) {
                 $this->rs_xml .= "</{$value}>";
             }
         }
     }
 }