Exemple #1
0
 function getMetadata()
 {
     $this->metadata = array();
     $mdstart = 1;
     try {
         do {
             $metadata = new MdExport($_SESSION['u'], $mdstart, 25, "");
             $metadata->only_public = TRUE;
             $flatParams = array();
             $q = array("@type = 'service'");
             list($xmlstr, $head) = $metadata->getXML($q, $flatParams);
             $this->xml->loadXML($xmlstr);
             $result = $this->xp->transformToXML($this->xml);
             //echo $result;
             eval($result);
             //echo "mdstart=$mdstart / $records\n";
             $this->metadata = array_merge($this->metadata, $md);
             $mdstart += $returned;
         } while ($records >= $mdstart);
     } catch (Exception $e) {
         echo "catalogue not connected";
         var_dump($e);
         exit;
     }
     return true;
 }
Exemple #2
0
/**
 * Tvorba souboru XML
 *
 * @param string $user
 * @param string $uuid
 * @param string $xsltemplate
 * @param string $xml_from cache|data
 * @return string XML|FALSE
 */
function getXml($user, $uuid, $xsltemplate, $xml_from = 'cache')
{
    setMickaLog("USER={$user}, UUID={$uuid}, XSL={$xsltemplate}", 'DEBUG', 'micka_lib_xml.php (getXML)');
    $xml = FALSE;
    $in = array();
    if ($uuid != '') {
        $in[] = "_UUID_ = '{$uuid}'";
        $export = new MdExport($user);
        $export->xml_from = $xml_from;
        $xml_pom = $export->getXML($in, FALSE);
        setMickaLog('XML=' . $xml_pom, 'DEBUG', 'micka_lib_xml.php (getXML)');
        if ($xsltemplate != '' && $export->xml_from == 'data' && $xml_pom != '') {
            setMickaLog('applyTemplate', 'DEBUG', 'micka_lib_xml.php (getXml)');
            $xml_pom = applyTemplate($xml_pom, $xsltemplate);
            if ($xml_pom === FALSE) {
                setMickaLog('applyTemplate === FALSE', 'ERROR', 'micka_lib_xml.php (getXml)');
                return $xml;
            }
        }
        if ($xml_pom != '') {
            $xml = $xml_pom;
        }
    }
    return $xml;
}
Exemple #3
0
 private function delete()
 {
     $export = new MdExport($usr);
     $data = $export->getData(array($this->params['QSTR']));
     //TODO zaznamy apod ...
     $c = new MdImport();
     $result = $c->dataToMd($data, 'delete');
     if ($this->params['DEBUG'] == 1) {
         var_dump($result);
     }
     return $result;
 }
Exemple #4
0
 public function getMdXmlData($uuid, $xsltemplate = 'micka2one19139.xsl')
 {
     setMickaLog("UUID={$uuid}, XSL={$xsltemplate}", 'DEBUG', 'MdRecord.getMdXmlData');
     require_once PHPPRG_DIR . '/MdExport.php';
     $rs = '';
     if ($uuid != '') {
         //$in = array();
         //$in[] = "_UUID_ = '$uuid'";
         $export = new MdExport($this->user);
         if ($this->table_mode == 'tmp') {
             $export->setTableMode('tmp');
             $xml = $export->getXmlTmpMd($uuid);
         } else {
             $in = array();
             $params = array();
             $in[] = "_UUID_ = '{$uuid}'";
             // TODO: použít params
             $export->xml_from = 'data';
             $pom = $export->getXML($in, $params, FALSE);
             $xml = $pom[0];
         }
         //setMickaLog('XML=' . $xml_pom, 'DEBUG', 'micka_lib_xml.php (getXML)');
         if ($xsltemplate == '' && $xml != '') {
             $rs = $xml;
         } elseif ($xsltemplate != '' && $xml != '') {
             setMickaLog("applyTemplate {$xsltemplate}", 'DEBUG', 'MdRecord.getMdXmlData');
             $xml = applyTemplate($xml, $xsltemplate);
             if ($xml === FALSE) {
                 setMickaLog('applyTemplate === FALSE', 'ERROR', 'MdRecord.getMdXmlData');
             } else {
                 if ($xml != '') {
                     $rs = $xml;
                 }
             }
         }
     }
     if ($rs == '') {
         setMickaLog("XML empty", 'ERROR', 'MdRecord.getMdXmlData');
     }
     return $rs;
 }
Exemple #5
0
 function run($qstring = "")
 {
     // prochazi cele repository
     $start = 1;
     $step = 50;
     $numResults = 0;
     // zpracovani dotazu
     if ($qstring) {
         $query = $this->csw->cql2sql($qstring);
     } else {
         $query = array();
     }
     do {
         $export = new MdExport($_SESSION['u'], $start, $step, "");
         list($xmlstr, $head) = $export->getXML($query, array());
         //var_dump($head); die;
         //echo $xmlstr; die();
         $this->xml->loadXML($xmlstr);
         $vety = $this->xml->getElementsByTagNameNS("http://www.isotc211.org/2005/gmd", "MD_Metadata");
         $numResults = $this->xml->documentElement->getAttribute("numberOfRecordsMatched");
         $this->refreshXpath();
         $i = 0;
         foreach ($vety as $veta) {
             $this->collectResults($veta, $head[$i]);
             $i++;
         }
         $start += $step;
     } while ($start <= $numResults);
     return $this->result;
 }
Exemple #6
0
/**
 * Funkce pro hledání a obsluhu $_SESSION['micka']['search']
 * starý způsob, používá už pouze ak=md_search
 *
 * @link       http://www.bnhelp.cz
 * @package    Micka
 * @category   Metadata
 * @version    20140530
 * @authors		 DZ
 */
function getFoundsRecords($post, $user)
{
    // ošetření vstupu XSS
    if (is_array($post)) {
        foreach ($post as $key => $value) {
            $post[$key] = htmlspecialchars($value);
        }
    }
    $rs = array();
    $rs['paginator']['records'] = 0;
    $restore = FALSE;
    // zjišťuje současný stav	hledání podle session a jeho zobrazení
    $exist_where = FALSE;
    $page_number = '';
    $form_view = -1;
    $export = FALSE;
    // řazení výsledku
    if (isset($post['sort0']) && isset($post['sort1'])) {
        setSortBy(trim($post['sort0']) . ',' . trim($post['sort1']));
    }
    // kontrola módů hledání
    if (isset($post['mode']) && ($post['mode'] == 'normal' || $post['mode'] == 'myrecords')) {
        $_SESSION['micka']['search']['mode'] = $post['mode'];
    } elseif (isset($post['mode']) && $post['mode'] == 'master') {
        $_SESSION['micka']['search']['mode'] = $post['mode'];
    } else {
        // nepodporovaný mód, vrátí nenalezeno
        if ($_SESSION['micka']['search']['mode'] == '') {
            return $rs;
        } else {
            $restore = TRUE;
        }
    }
    if (isset($_SESSION['micka']['search']['where']) && $_SESSION['micka']['search']['where'] != '') {
        $exist_where = true;
    }
    if ($_SESSION['micka']['search']['mode'] == 'master') {
        $fc = isset($post['fc']) ? $post['fc'] : '';
        // feature katalog
        $form_view = isset($post['fv']) ? $post['fv'] : '';
        // prvotní zobrazení, pokud nezadáno tak se hledá, jinak se jen zobrazí formulář
        if ($form_view == '') {
            $form_view = -1;
        } else {
            $form_view = 1;
        }
    }
    if ($restore) {
        if ($_SESSION['micka']['search']['mode'] == 'master') {
            $page_number = isset($_SESSION['micka']['search_m']['page']) ? $_SESSION['micka']['search_m']['page'] : 1;
        } else {
            $page_number = isset($_SESSION['micka']['search']['page']) ? $_SESSION['micka']['search']['page'] : 1;
        }
    } else {
        if (isset($post['pg'])) {
            $page_number = $post['pg'];
        }
    }
    if ($page_number == '') {
        $page_number = 1;
        setSessionMickaSearch($post);
    }
    // sestaveni dotazu pro hledani
    if ($_SESSION['micka']['search']['mode'] == 'myrecords') {
        $select_all = getSearchUser($user);
        $export = TRUE;
    } else {
        if ($_SESSION['micka']['search']['mode'] == 'normal' && $exist_where == FALSE) {
            $select_all = getSearchArrayNormal();
        } elseif ($form_view == -1 && $_SESSION['micka']['search']['mode'] == 'master') {
            $select_all = getSearchArrayMaster($fc);
        }
        if ($_SESSION['micka']['search']['mode'] == 'normal' && $exist_where === TRUE) {
            $select_all = $_SESSION['micka']['search']['where'];
            $page_number = 1;
            $export = TRUE;
        } elseif ($form_view == -1 && $_SESSION['micka']['search']['mode'] == 'master' || $_SESSION['micka']['search']['mode'] == 'normal') {
            $export = TRUE;
        }
    }
    if ($export) {
        // získání dat
        require_once PHPPRG_DIR . '/MdExport.php';
        $ofs = ($page_number - 1) * MAXRECORDS;
        if ($ofs > 0) {
            $ofs++;
        }
        $data = new MdExport(MICKA_USER, $ofs, MAXRECORDS, getSortBy($in = '', $ret = 'string'));
        $data->page_number = $page_number;
        $data->only_public = FALSE;
        $data->xml_from = 'summary';
        $rs = $data->getData($select_all);
        if ($rs['paginator']['records'] > 0) {
            // ulozeni stranky pro navrat pri editaci
            if (isset($_SESSION['micka']['search']['mode']) && $_SESSION['micka']['search']['mode'] == 'master') {
                $_SESSION['micka']['search_m']['page'] = $page_number;
            } else {
                $_SESSION['micka']['search']['page'] = $page_number;
            }
        }
    }
    //$rs['data']
    //$rs['paginator']
    //$rs['akce']
    return $rs;
}
Exemple #7
0
 function importService($url, $service, $user, $group_e, $group_v, $mds, $langs, $lang = 'eng', $public = 0, $updateType = '')
 {
     /*---------------------------------------------------------------------
     	Import metadat ze sluzby
     
           		$filename   nazev xml souboru
     		  	$service    nazev typu sluzby (WMS, WFS, WCS, CSW, ...) podporovano zatim WMS
     			$user       prihlaseny uzivatel
     			$group_e   	skupina pro editaci
     			$$group_v   skupina pro prohlizeni
     			$mds  		standard metadat
     			$langs    	seznam pouzitych jazyku
         		$lang		jazyk zaznamu
     			$public		zda bude zaznam verejny
         ---------------------------------------------------------------------*/
     //$mod = 'all'; // mod pro import, all importuje vse, neco jineho preskakuji uuid
     $id = "1";
     // identifikator zaznamu
     $rs = -1;
     //-----------------------------------------------
     $url = trim(htmlspecialchars_decode($url));
     if (strpos($langs, $lang) === false) {
         $langs = $lang . "|" . $langs;
     }
     // kontrola, zda je jazyk zaznamu v seznamu pouzitych jazyku
     if (!strpos(strtolower("." . $url), "http")) {
         $url = "http://" . $url;
     }
     if (!strpos(strtolower($url), "service=")) {
         if (!strpos($url, "?")) {
             $url .= "?";
         } else {
             $url .= "&";
         }
         $url .= "SERVICE=" . $service;
     }
     if (!strpos(strtolower($url), "getcapabilities")) {
         $url .= "&REQUEST=GetCapabilities";
     }
     //echo "input url= <a href='$url'>$url</a>"; //TODO potom dat do reportu
     $xp = new XsltProcessor();
     $xml = new DomDocument();
     $xsl = new DomDocument();
     @($s = file_get_contents($url));
     if (!$s) {
         exit("<br>No data/connection! " . BACKURL);
     }
     //TODO QUICK HACK - udleat pres sablony nebo DOM
     if (strpos($s, 'exception')) {
         exit("<br><br>Exception: " . $s . " " . BACKURL);
     }
     if (!@$xml->loadXML($s)) {
         exit("<br><br>Not valid service!  " . BACKURL);
     }
     $xslName = PHPINC_DIR . "/xsl/" . strtolower($service) . ".xsl";
     // vyber sablony
     $md = $this->xml2array($xml, $xslName);
     if (!$md['MD_Metadata'][0]["language"][0]["LanguageCode"][0]['@']) {
         $md['MD_Metadata'][0]["language"][0]["LanguageCode"][0]['@'] = $lang;
     }
     $url1 = $md["MD_Metadata"][0]["distributionInfo"][0]["MD_Distribution"][0]["transferOptions"][0]["MD_DigitalTransferOptions"][0]["onLine"][0]["CI_OnlineResource"][0]["linkage"][0]["@"];
     //var_dump($md);
     // --- vyhledani duplicitniho zaznamu ---
     if ($updateType == "all") {
         require PHPPRG_DIR . '/MdExport.php';
         $export = new MdExport($_SESSION['u'], 1, 10, null);
         $ddata = $export->getdata(array("@linkage = '" . $url1 . "'", "And", "@type = 'service'"));
         // nalezen záznam
         if (count($ddata["data"]) > 0) {
             if (count($ddata["data"]) > 1) {
                 echo 'More records found with this URL.';
                 foreach ($ddata["data"] as $row) {
                     echo "<br>" . $row['uuid'] . ": " . $row['title'];
                 }
                 echo '<br>The record will be added as new.';
             } else {
                 echo "found record: <b>" . $ddata["data"][0]['uuid'] . "</b> " . $ddata["data"][0]['title'];
                 $md['MD_Metadata'][0]["fileIdentifier"][0]['@'] = $ddata["data"][0]['uuid'];
             }
         }
     }
     // ulozeni dat
     $c = new MdImport();
     $c->setTableMode($this->table_mode);
     $c->mds = $mds;
     if ($group_e) {
         $c->group_e = $group_e;
     }
     if ($group_v) {
         $c->group_v = $group_v;
     }
     $c->setDataType($public);
     // nastavení veřejného záznamu
     $c->lang = $lang;
     // pokud není v datech, použije se toto nastavení jazyka
     //$c->stop_error = true; // pokud dojde k chybě při importu pokračuje
     $c->stop_error = false;
     // pokud dojde k chybě při importu pokračuje
     $rs = $c->dataToMd($md, 'update');
     return $rs;
 }