Esempio n. 1
0
/**
 * generates the category menu from the menu data
 * of directory.xml
 */
function menuFromXml($xmlData, $catdir)
{
    $html = "";
    $subdir = substr($catdir, strlen("content/"));
    $xmlParser = new XPath();
    $xmlParser->importFromString($xmlData);
    $i = 1;
    while ($xmlParser->match("/menu[1]/item[{$i}]")) {
        $html .= "<span class=\"menu\">\n";
        if ($xmlParser->match("/menu[1]/item[{$i}]/file[1]")) {
            $filename = $xmlParser->getData("/menu[1]/item[{$i}]/file[1]");
            $title = getTitle($catdir . "/" . $filename);
            $link = $subdir . "/" . $filename;
            $html .= "<a href=\"index.php?p={$link}\">{$title}</a>\n";
        } elseif ($xmlParser->match("/menu[1]/item[{$i}]/raw_data[1]")) {
            $data = $xmlParser->exportAsXml("/menu[1]/item[{$i}]/raw_data[1]");
            $data = stripTag("raw_data", $data);
            $html .= $data;
        }
        $html .= "</span>\n";
        $i++;
    }
    return $html;
}
Esempio n. 2
0
 function Get2($institutionCode, $collectionCode, $catalogNumber)
 {
     if ($collectionCode != '') {
         $institution = $institutionCode . "-" . $collectionCode;
     } else {
         $institution = $institutionCode;
     }
     $url = $this->buildDIGIRQuery($institution, $catalogNumber);
     //echo $url;
     curl_setopt($this->ch, CURLOPT_URL, $url);
     $this->Call();
     storeInCache($institution, $catalogNumber, $this->result, 'xml');
     $xml = $this->result;
     //echo $xml;
     $data = '';
     $ok = false;
     if (preg_match('/<\\?xml version/', $xml)) {
         // we have XML
         $xml = preg_replace("/<response xmlns='http:\\/\\/digir.net\\/schema\\/protocol\\/2003\\/1.0'/", '<response', $xml);
         // We got XML, but did we get a hit?
         $record_count = 0;
         if (PHP_VERSION >= 5.0) {
             $dom = new DOMDocument();
             $dom->loadXML($xml);
             $xpath = new DOMXPath($dom);
             $xpath_query = "//diagnostic[@code='RECORD_COUNT']";
             $nodeCollection = $xpath->query($xpath_query);
             foreach ($nodeCollection as $node) {
                 $record_count = $node->firstChild->nodeValue;
             }
         } else {
             $xpath = new XPath();
             $xpath->importFromString($xml);
             $xpath_query = "//diagnostic[@code='RECORD_COUNT']";
             $nodeCollection = $xpath->match($xpath_query);
             foreach ($nodeCollection as $node) {
                 $record_count = $xpath->getData($node);
             }
         }
         //echo "Record count=$record_count\n";
         if ($record_count != 0) {
             //echo $xml;
             $xml = str_replace('&quot;', '\\"', $xml);
             //echo $xml;
             $xp = new XsltProcessor();
             $xsl = new DomDocument();
             $xsl->load('xsl/digir2JSON.xsl');
             $xp->importStylesheet($xsl);
             $xml_doc = new DOMDocument();
             $xml_doc->loadXML($xml);
             $json = $xp->transformToXML($xml_doc);
             //echo $json;
             $json = str_replace("{,", "{", $json);
             $json = str_replace("\n", "", $json);
             $data = json_decode($json);
             //print_r($data);
             //echo $data->status, "\n";
             // Clean weird KU stuff where they have lat=long=0
             if (isset($data->record[0]->latitude) && isset($data->record[0]->longitude)) {
                 if ($data->record[0]->latitude == 0 && $data->record[0]->longitude == 0) {
                     unset($data->record[0]->latitude);
                     unset($data->record[0]->longitude);
                 }
             }
             //print_r($data);
             if (isset($data->status)) {
                 if ($data->status == 'ok') {
                     $ok = true;
                 }
             }
         } else {
             $data->status = 'no record found';
         }
     } else {
         $data->status = 'no XML returned';
     }
     return $data;
 }
Esempio n. 3
0
 // Fire off the XPath class
 require_once APP_ROOT . '/includes/XPath.class.php';
 $XPath = new XPath();
 $XPath->importFromString($xml);
 // let the page begin.
 require_once APP_ROOT . '/includes/system_header.php';
 $tpl->set_var('title', $text['title'] . ': ' . $XPath->getData('/phpsysinfo/Vitals/Hostname') . ' (' . $XPath->getData('/phpsysinfo/Vitals/IPAddr') . ')');
 $tpl->set_var('vitals', makebox($text['vitals'], html_vitals()));
 $tpl->set_var('network', makebox($text['netusage'], html_network()));
 $tpl->set_var('hardware', makebox($text['hardware'], html_hardware()));
 $tpl->set_var('memory', makebox($text['memusage'], html_memory()));
 $tpl->set_var('filesystems', makebox($text['fs'], html_filesystems()));
 // Timo van Roermund: change the condition for showing the temperature, voltage and fans section
 $html_temp = "";
 if (!empty($sensor_program)) {
     if ($XPath->match("/phpsysinfo/MBinfo/Temperature/Item")) {
         $html_temp = html_mbtemp();
     }
     if ($XPath->match("/phpsysinfo/MBinfo/Fans/Item")) {
         $tpl->set_var('mbfans', makebox($text['fans'], html_mbfans()));
     } else {
         $tpl->set_var('mbfans', '');
     }
     if ($XPath->match("/phpsysinfo/MBinfo/Voltage/Item")) {
         $tpl->set_var('mbvoltage', makebox($text['voltage'], html_mbvoltage()));
     } else {
         $tpl->set_var('mbvoltage', '');
     }
 }
 if (isset($hddtemp_avail) && $hddtemp_avail) {
     if ($XPath->match("/phpsysinfo/HDDTemp/Item")) {
Esempio n. 4
0
// extract filename (without_path)
$var['filename'] = getPathElement($var['filepath'], -1);
// extract category-directory
if ($var['filepath'] != "") {
    $var['catdir'] = getPath($var['filepath']);
} else {
    $var['catdir'] = "foobar";
}
// setting error filepath if necsessary
if ($var['filepath'] == "") {
    $var['filepath'] = "template/" . $var['template'] . "/error_pages/404.html";
}
// setting up xml parser
$xmlParser = new XPath($var['filepath']);
// get page title
if ($xmlParser->match("/html/head/title")) {
    $var['page_title'] = $xmlParser->getData("/html/head/title");
} elseif ($xmlParser->match("/content/title[1]")) {
    $var['page_title'] = $xmlParser->getData("/content/title[1]");
} else {
    $var['page_title'] = $var['filename'];
}
$var['title'] = $var['title'] . " - " . $var['page_title'];
// get keywords
if ($xmlParser->match("//meta[@name='KEYWORDS']")) {
    $var['keywords'] = $var['keywords'] . "," . $xmlParser->getData("//meta[@name='KEYWORDS']/attribute::content");
}
// get describtion
if ($xmlParser->match("//meta[@name='DESCRIBTION']")) {
    $var['describtion'] = $xmlParser->getData("//meta[@name='DESCRIBTION']/attribute::content");
}