Example #1
0
 /**
  * Construct elements and texts from an array.
  * The array should contain an attribute's name in index part
  * and a attribute's text in value part.
  * @access public
  * @param array $prm_array Contains attributes and texts
  * @return null
  */
 public function fromArray($prm_array)
 {
     if (is_array($prm_array)) {
         foreach ($prm_array as $index => $element) {
             if (is_array($element)) {
                 if (isset($element['element_name'])) {
                     $index = $element['element_name'];
                     unset($element['element_name']);
                 }
                 $this->startElement($index);
                 if (isset($element['attributes'])) {
                     foreach ($element['attributes'] as $key => $value) {
                         $this->writeAttribute($key, $value);
                     }
                     unset($element['attributes']);
                     if (count($element) === 1 && isset($element[0])) {
                         $element = $element[0];
                     }
                 }
                 if (!is_array($element)) {
                     $this->text(forceUTF8(mb_convert_encoding($element, 'HTML-ENTITIES', 'UTF-8')));
                 } else {
                     $this->fromArray($element);
                 }
                 $this->endElement();
             } else {
                 $this->setElement($index, $element);
             }
         }
     }
 }
Example #2
0
 $doc_combo = explode('://', $doc);
 $prefix = $doc_combo[0];
 $doc = isset($doc_combo[1]) ? $doc_combo[1] : $doc;
 $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
 $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
 switch ($where) {
     case DCTL_DB_NAME:
         $what = isset($_REQUEST['q']) ? $_REQUEST['q'] : $what;
         $selector = $block;
         $returnText .= getRetrieverDB($doc, $what, $selector);
         break;
     case 'palette':
         $returnText .= getRetrievePalette($doc, $where);
         break;
     case 'navigator':
         forceUTF8($high);
         $configFile = simplexml_load_file($high, 'SimpleXMLElement', DCTL_XML_LOADER);
         $high = '';
         $node = $configFile->xpath('menu[@xslt="' . $what . '"]');
         $label = $node[0]['label'];
         $desc = (string) $node[0]->div->asXML();
         $label = $label . DISTINCT_SEP . $desc;
         $filter = explode(',', (string) $node[0]['package_kind']);
         $returnText .= getRetrieveNavigator($doc, $where, $what, $label, $filter);
         break;
     default:
         $returnText1 = '';
         $xslt = $what . '.xsl';
         switch ($what) {
             case MASTRO_RETRIEVE:
                 $xslt = 'query_by_block.xsl';
Example #3
0
                 foreach ($select as $field => $label) {
                     if (isset($_REQUEST[$field])) {
                         $value = $_REQUEST[$field];
                         if ($field == 'package_work' && $value == '') {
                             $value = $_REQUEST['source_author'] . ' - ' . $_REQUEST['source_title_main'];
                         }
                         $value = stripslashes($value);
                         $value = trim(preg_replace('/' . WS . WS . '+/', ' ', $value));
                         $value = htmlentities($value, ENT_QUOTES, 'UTF-8');
                         $value = preg_replace('/' . WS . WS . '+/', '<lb />', $value);
                         $value = stripslashes($value);
                         $contents = str_ireplace($field . ' ""', $field . ' "' . $value . '"', $contents);
                     }
                 }
                 doBackup($header2);
                 if (file_put_contents($header2, forceUTF8($contents, $header2)) !== FALSE) {
                     @chmod($header2, CHMOD);
                     $resultMsg .= '<span class="ok">Ho aggiornato le informazioni per "' . $package_short . '"</span><br />';
                 } else {
                     $resultMsg .= '<span class="error">ERRORE: non riesco a scrivere il file "' . $header2 . '" ... aggiornamento non riuscito!</span><br />';
                 }
             } else {
                 $resultMsg .= '<span class="error">ERRORE: non riesco a trovare il file "' . $header1 . '" ... aggiornamento non riuscito!</span><br />';
             }
         }
     }
 }
 //
 // CREATE PART
 if ($isCreatePart) {
     if ($package_id != '') {
Example #4
0
function transformXMLwithXSLT($mastro = '', $doc = '', $where = '', $xslt = '', $block = '', $curr_at = '', $curr_high = '', $label = '', $mode = '')
{
    $dump = false;
    $html_resource = '';
    $db_resource = '';
    $docz = '';
    switch (true) {
        case is_array($block):
            return '';
            break;
        case preg_match('/^</', substr($block, 0, 10)):
            $db_resource = $block;
            $block = '';
            $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
            $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
            break;
        case preg_match('/\\.xml$/', $doc):
            global $exist;
            $docz = explode(DISTINCT_SEP, $doc);
            foreach ($docz as $doc) {
                // IDENTIFICA IL DOC
                $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
                $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
                $xml_resource = XMLDB_PATH_BASE . $db_collection . DB_PATH_SEP . $doc;
                $ext = substr(str_ireplace('.xml', '', $doc), -4, 4);
                // CARICA IL DOC
                $debugTime = microtime(true);
                $xquery = DCTL_XQUERY_BASE;
                $xquery .= ' let $node := ()';
                switch (true) {
                    case stripos($xslt, 'collection_by_package') !== false:
                        $xquery .= ' let $node := doc("' . $xml_resource . '")/tei:TEI/tei:text/tei:body//tei:div[. != ""][1] ';
                        $xquery .= ' let $node := <stub doc="' . $doc . '" rend="{$node/@rend}">{$node}</stub> ';
                        break;
                    case stripos($xslt, 'image_by_div') !== false:
                        $xquery .= ' let $node := doc("' . $xml_resource . '")//id("' . $block . '") ';
                        $xquery .= ' let $node := <stub doc="' . $doc . '" rend="{$node/@rend}">{$node}</stub> ';
                        break;
                    case stripos($xslt, 'image_by_package') !== false:
                        $xquery .= ' let $node := doc("' . $xml_resource . '")/tei:TEI/tei:text//tei:div[tei:figure]';
                        $xquery .= '[count(ancestor-or-self::tei:div) = 1]';
                        $xquery .= ' ';
                        break;
                    case stripos($xslt, 'index_by_character') !== false:
                        $xquery .= ' let $node := doc("' . $xml_resource . '")/tei:TEI/tei:text//tei:div//(tei:name | tei:rs)[@ana |= "func_character"] ';
                        break;
                    case stripos($xslt, 'index_by_place') !== false:
                        $xquery .= ' let $node := doc("' . $xml_resource . '")/tei:TEI/tei:text//tei:div//(tei:name | tei:rs)[@ana |= "func_place"] ';
                        break;
                    case stripos($xslt, 'index_by_object') !== false:
                        $xquery .= ' let $node := doc("' . $xml_resource . '")/tei:TEI/tei:text//tei:div//(tei:name | tei:rs)[@ana |= "func_object"] ';
                        break;
                    case stripos($xslt, 'index_by_setting') !== false:
                        $xquery .= ' let $node := doc("' . $xml_resource . '")/tei:TEI/tei:text//tei:div//dctl:settings[@ana != ""] ';
                        break;
                    case stripos($xslt, 'character_by_block') !== false:
                    case stripos($xslt, 'setting_by_block') !== false:
                        switch (true) {
                            case stripos($xslt, 'character_by_block') !== false:
                                $context = '(tei:name | tei:rs)[@ana |= "func_character"][(@key = "' . $block . '") | (@n = "' . $block . '")]';
                                break;
                            case stripos($xslt, 'setting_by_block') !== false:
                                $context = 'dctl:settings[@ana |= "' . $block . '"]';
                                break;
                        }
                        // IDENTIFICA IL DOC
                        $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
                        $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
                        $xml_resource = XMLDB_PATH_BASE . $db_collection;
                        $allowedExt = array();
                        getPackageList($exist, $xml_resource, &$packageList, $allowedExt);
                        $xquery .= ' let $node := for $doc in xmldb:document(';
                        $iter = -1;
                        foreach ($packageList as $package) {
                            ++$iter;
                            if ($iter > 0) {
                                $xquery .= ', ';
                            }
                            $xquery .= '"' . $package['path'] . '"';
                        }
                        $xquery .= '), $item in $doc/tei:TEI/tei:text//' . $context;
                        $xquery .= ' ';
                        $xquery .= ' let $docNAME := util:document-name($item) ';
                        $xquery .= ' let $block := tei:getBlock($item) ';
                        $xquery .= ' let $blockID := $block/@xml:id ';
                        $xquery .= ' let $parentID := tei:getParent($item)/@xml:id ';
                        //$item/ancestor-or-self::tei:div[last()]/@xml:id
                        $xquery .= ' let $date := $doc/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:biblFull[contains(@n,\'source\')]/tei:publicationStmt/tei:date[1] ';
                        $xquery .= ' let $head := ';
                        $xquery .= ' if ($item/ancestor-or-self::tei:div[1]/@rend) ';
                        $xquery .= ' then ';
                        $xquery .= ' $item/ancestor-or-self::tei:div[1]/@rend ';
                        $xquery .= ' else ';
                        $xquery .= ' $block/@rend ';
                        $xquery .= ' order by $blockID, $date, $docNAME, $head, $item ';
                        $xquery .= ' return ';
                        $xquery .= ' <tei:div ';
                        $xquery .= 'ref="{$docNAME}' . DISTINCT_SEP . '{string($blockID)}' . DISTINCT_SEP . '{string($parentID)}' . DISTINCT_SEP . '{string($item/@xml:id)}' . DISTINCT_SEP . '{local-name($item)}' . DISTINCT_SEP . '{string($item/@ana)}" rend="{string($head)}"';
                        $xquery .= ' >';
                        $xquery .= ' {$item} ';
                        $xquery .= ' </tei:div>';
                        break;
                    case stripos($xslt, 'ecphrasis_by_div') !== false:
                        $context = 'id("' . $block . '")//*[@ana |= "verbfig_ecphrasis"][substring-after(@xml:id, ".") = "001" or substring-after(@xml:id, ".") = ""]';
                        //
                        $xquery .= ' let $node := for $doc in xmldb:document(';
                        $xquery .= '"' . $xml_resource . '"';
                        $xquery .= '), $item in $doc/tei:TEI/tei:text//' . $context;
                        $xquery .= ' ';
                        $xquery .= ' let $docNAME := util:document-name($item) ';
                        $xquery .= ' let $block := tei:getBlock($item) ';
                        $xquery .= ' let $blockID := $block/@xml:id ';
                        $xquery .= ' let $parentID := tei:getParent($block)/@xml:id ';
                        //$item/ancestor-or-self::tei:div[last()]/@xml:id
                        $xquery .= ' let $date := $doc/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:biblFull[contains(@n,\'source\')]/tei:publicationStmt/tei:date[1] ';
                        $xquery .= ' let $head := ';
                        $xquery .= ' if ($item/@rend) ';
                        $xquery .= ' then ';
                        $xquery .= ' $item/@rend ';
                        $xquery .= ' else ';
                        $xquery .= ' $item/ancestor-or-self::tei:div[1]/@rend ';
                        //						$xquery .= ' order by $blockID, $date, $docNAME, $head, $item ';
                        $xquery .= ' return ';
                        $xquery .= ' <tei:div ';
                        $xquery .= 'ref="{$docNAME}' . DISTINCT_SEP . '{string($parentID)}' . DISTINCT_SEP . '{string($blockID)}' . DISTINCT_SEP . '{string($item/@xml:id)}' . DISTINCT_SEP . '{local-name($item)}' . DISTINCT_SEP . '{string($item/@ana)}" rend="{string($head)}"';
                        $xquery .= ' >';
                        $xquery .= ' {$item} ';
                        $xquery .= ' </tei:div>';
                        break;
                    case stripos($xslt, 'scene_by_package') !== false:
                        // sia IMG che PTX
                        $context = '(dctl:item | tei:div[@type="dctlObject"][count(./descendant::dctl:item) = 0 and count(ancestor::tei:div[@type="dctlObject"]) = 0])';
                        $xquery .= ' let $node := for $doc in xmldb:document(';
                        $xquery .= '"' . $xml_resource . '"';
                        $xquery .= '), $item in $doc/tei:TEI/tei:text//' . $context;
                        $xquery .= ' ';
                        $xquery .= ' let $docNAME := util:document-name($item) ';
                        $xquery .= ' let $block := $item/descendant-or-self::tei:div[1] ';
                        //tei:getBlock($item)
                        $xquery .= ' let $blockID := $block/@xml:id ';
                        $xquery .= ' let $parentID := $item/ancestor-or-self::tei:div[last()]/@xml:id ';
                        $xquery .= ' let $date := $doc/tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:biblFull[contains(@n,\'source\')]/tei:publicationStmt/tei:date[1] ';
                        $xquery .= ' let $head := ';
                        $xquery .= ' if ($item/ancestor-or-self::tei:div[1]/@rend) ';
                        $xquery .= ' then ';
                        $xquery .= ' $item/ancestor-or-self::tei:div[1]/@rend ';
                        $xquery .= ' else ';
                        $xquery .= ' $block/@rend ';
                        // 						$xquery .= ' let $image := if (count($item//tei:graphic) = 0) ';
                        // 						$xquery .= ' then ';
                        // 						$xquery .= ' $item/ancestor-or-self::tei:figure[tei:graphic][1] ';
                        // 						$xquery .= ' else ';
                        // 						$xquery .= ' () ';
                        //$xquery .= ' order by $blockID, $date, $docNAME, $head, $item ';
                        $xquery .= ' return ';
                        $xquery .= ' <tei:div ';
                        $xquery .= ' ref="{$docNAME}' . DISTINCT_SEP . '{string($parentID)}' . DISTINCT_SEP . '{string($blockID)}' . DISTINCT_SEP . '{string($item/@xml:id)}' . DISTINCT_SEP . '{local-name($item)}' . DISTINCT_SEP . '{string($item/@ana)}" rend="{string($head)}"';
                        $xquery .= ' >';
                        // 						$xquery .= ' {($image, $item)} ';
                        $xquery .= ' {$item} ';
                        $xquery .= ' </tei:div>';
                        break;
                    case stripos($xslt, 'edition') !== false:
                        $xquery .= ' let $node := doc("' . $xml_resource . '")//tei:teiHeader ';
                        break;
                    case stripos($xslt, 'navigator') !== false:
                        if ($block != '') {
                            $xquery .= ' let $node_c := tei:getBlock(doc("' . $xml_resource . '")/id("' . $block . '")) ';
                        } else {
                            $xquery .= ' let $node_c := doc("' . $xml_resource . '")/tei:TEI/tei:text//tei:div[. != ""][1] ';
                        }
                        $xquery .= ' let $node_p := $node_c/preceding-sibling::tei:div[1] ';
                        $xquery .= ' let $node_n := $node_c/following-sibling::tei:div[1] ';
                        $xquery .= ' let $node := ("<stub>", $node_p, $node_c, $node_n, "</stub>") ';
                        break;
                    default:
                        if ($block != '') {
                            $omissis = '';
                            //', "<p class=\'omissis\' />"';
                            $partial = preg_match('/(.*)((\\.\\d\\d\\d)$)/', $block, $matches);
                            if ($partial) {
                                $xquery .= ' let $nodes := for $node in doc("' . $xml_resource . '")//*[substring-after(@xml:id, "' . $matches[1] . '.")] ';
                            } else {
                                $xquery .= ' let $nodes := for $node in doc("' . $xml_resource . '")/id("' . $block . '") ';
                            }
                            $xquery .= ' let $block := tei:getParent($node) ';
                            $xquery .= ' return ';
                            $xquery .= ' if (local-name($node)="div") ';
                            $xquery .= ' then ';
                            $xquery .= ' ($node';
                            if ($partial) {
                                $xquery .= $omissis;
                            }
                            $xquery .= ') ';
                            $xquery .= ' else  ';
                            $xquery .= ' ("<div type=\'", $block/@type, "\'><head><index><term>", $block/@n, "</term></index></head><p>", $node';
                            $xquery .= ', "</p></div>"';
                            if ($partial) {
                                $xquery .= $omissis;
                            }
                            $xquery .= ') ';
                            if ($partial) {
                                $xquery .= ' let $node := ("<div>"';
                                $xquery .= $omissis;
                                $xquery .= ', $nodes, "</div>") ';
                            } else {
                                $xquery .= ' let $node := $nodes ';
                            }
                        } else {
                            if ($where == 'navigator') {
                                $context = 'doc("' . $xml_resource . '")/tei:TEI/tei:text';
                                switch (true) {
                                    // 								 case (stripos($xslt, 'menu_div') !== false):
                                    // 										$xquery .= ' let $nodes := for $node in ';
                                    // 								  $context .= '//tei:div[count(ancestor::tei:div) < 2]';
                                    // 										$xquery .= $context.' ';
                                    // 										$xquery .= ' let $block := $node ';
                                    // 										$xquery .= ' return ';
                                    // 								  $xquery .= ' ("<div type=\'", $block/@type, "\'><head><index><term>", $block/@n, "</term></index></head><p></p></div>") ';
                                    // 										$xquery .= ' let $node := ("<stub>", $nodes, "</stub>") ';
                                    // 								  break;
                                    default:
                                        $xquery .= ' let $node := ';
                                        $xquery .= $context . ' ';
                                        break;
                                }
                            } else {
                                $xquery .= ' let $node := doc("' . $xml_resource . '")/tei:TEI/tei:text/tei:body//tei:div[. != ""][1] ';
                            }
                        }
                        break;
                }
                $xquery .= ' return $node ';
                $result = $exist->xquery($xquery);
                $err = $exist->getError();
                $resultXML = (array) $result["XML"];
                foreach ($resultXML as $node) {
                    $db_resource .= $node;
                }
                if (preg_match('/failed/', $err)) {
                    dump($err);
                }
            }
            if (count($docz) > 1 || stripos($xslt, 'by_') !== false) {
                $db_resource = '<stub>' . $db_resource . '</stub>';
            }
            //  dump($xquery);
            if ($dump) {
                dump($db_resource);
            }
            break;
        default:
            // $db_resource = $doc;
            break;
    }
    //  CARICA IN DOM
    if ($db_resource) {
        $dom = new DOMDocument('1.0', 'UTF-8');
        $dom->preserveWhiteSpace = false;
        if ($dom->loadXML($db_resource, DCTL_XML_LOADER)) {
            $xml_resource = $dom;
        } else {
            die('<div class="error">! cannot DOM load resource: ' . $doc . '</div>');
        }
        //  CARICA XSLT
        $xsl_resource = '';
        $xslt_path = '';
        switch ($mastro) {
            case MASTRO_RETRIEVE:
                $xslt_path = DCTL_MASTRO_RETRIEVE_XSLT;
                break;
            case MASTRO_DISPLAY:
                $xslt_path = DCTL_MASTRO_DISPLAY_XSLT;
                break;
            default:
                die('<div class="error">! cannot load xslt path: ' . $mastro . '</div>');
                break;
        }
        $base = str_ireplace($xslt_path, '', $xslt);
        $xslt = $xslt_path . $base;
        if ($db_collection) {
            $xslt2 = str_ireplace($base, $db_collection . SYS_PATH_SEP . $base, $xslt);
            if (is_file($xslt2)) {
                $xslt = $xslt2;
            }
        }
        if (is_file($xslt)) {
            $dom = new DOMDocument('1.0', 'UTF-8');
            $dom->preserveWhiteSpace = false;
            forceUTF8($xslt);
            if ($dom->load($xslt, DCTL_XML_LOADER)) {
                $xsl_resource = $dom;
            } else {
                die('<div class="error">! cannot load resource: ' . $xslt . '</div>');
            }
        } else {
            die('<div class="error">! cannot find resource: ' . $xslt . '</div>');
        }
        // TRAFORMA DOC CON XSLT
        $proc = new XSLTProcessor();
        $proc->registerPHPFunctions();
        $proc->importStyleSheet($xsl_resource);
        $proc->setParameter('', 'doc', $doc);
        $proc->setParameter('', 'block', $block);
        $proc->setParameter('', 'at', $curr_at);
        $proc->setParameter('', 'high', $curr_high);
        $proc->setParameter('', 'where', $where);
        $proc->setParameter('', 'label', $label);
        $proc->setParameter('', 'mode', $mode);
        $html_resource .= $proc->transformToXML($xml_resource);
        // stripNamespaces(&$xml_resource);
        if (DCTL_DEBUG) {
            dump(substr(microtime(true) - $debugTime, 0, 5));
        }
    } else {
        //		die('<div class="error">! cannot DB load resource: '.$doc.'</div>');
    }
    if (DCTL_DEBUG) {
        dump(substr(microtime(true) - $debugTime, 0, 5));
    }
    return forceUTF8($html_resource);
}
Example #5
0
function wctl_loader(&$text_result, $f_content, $option = "", $putBR = TRUE, $DEBUG = FALSE)
{
    global $string;
    $text_done = false;
    if ($f_content != '') {
        if (stripos($f_content, 'sitemap') !== false) {
            global $area;
            global $curr_area;
            global $curr_lang;
            $content = '';
            $content .= '<?xml version="1.0" encoding="UTF-8" ?>';
            $content .= '<!DOCTYPE wctl SYSTEM "' . DCTL_SITEMAP_DTDS . '">';
            $content .= '<wctl>';
            $content .= '<wctl_page>';
            $content .= '<wctl_caption>' . $area[$curr_lang]['00'] . '</wctl_caption>';
            $content .= '<wctl_title>www.ctl.sns.it</wctl_title>';
            $content .= '<wctl_summary />';
            $content .= '<wctl_text>';
            foreach ($area[$curr_lang] as $key => $what) {
                if ($key != '00') {
                    $length = strlen($key);
                    $level = intval($length / 2);
                    for ($i = 1; $i <= $length; $i++) {
                        $content .= "&#160;";
                    }
                    $tag_b = '';
                    $tag_e = '';
                    // $what = ucwords($what);
                    switch ($level) {
                        case '1':
                            $tag_b = '<br /><strong>';
                            $tag_e = '</strong>';
                            break;
                        case '2':
                            $tag_b = '<em>';
                            $tag_e = '</em>';
                            break;
                        default:
                            $level = 0;
                            break;
                    }
                    $content .= $tag_b . "<a href=\"" . $_SERVER['PHP_SELF'] . "?lang=" . $curr_lang . "&amp;area=" . $key . "\" title=\"\">";
                    $content .= '<img src="' . DCTL_IMAGES . 'map_l' . $level . '.gif" alt="(open level)" />' . $what . '</a>' . $tag_e . '<br />';
                }
            }
            $content .= '</wctl_text>';
            $content .= '<wctl_note />';
            $content .= '<wctl_icon />';
            $content .= '</wctl_page>';
            $content .= '</wctl>';
            $f_handle = fopen($f_content, "wb");
            fwrite($f_handle, $content);
            fclose($f_handle);
            @chmod($f_content, CHMOD);
        }
        forceUTF8($f_content);
        if (!($xml = simplexml_load_file($f_content, 'SimpleXMLElement', DCTL_XML_LOADER))) {
            $text_result .= "<b class='wctl_error'>" . $f_content . "</b> : not valid or couldn't open xml file...";
            $text_done = false;
        }
        // hack to work around php 5.0's problems with default namespaces and xpath()
        $xml['xmlns'] = '';
        $htop = 16;
        switch ($option) {
            case CMS_VIEWMODE_PROJ:
                // PROGETTI
                $text_result .= '<div id="wctl_icon01"><img id="wctl_preview01" src="' . WEB_WCTL_ICONS . 'camillo.gif" alt="(preview icon)" height="250" /></div>';
                $text_result .= "<div id=\"wctl_summary01\">&#160;</div>";
                $text_result .= '<a class="go_top" href="#top" title=""><img src="' . DCTL_IMAGES . 'up.gif" alt="(go top icon)" height="' . $htop . '" /></a>';
                break;
            case CMS_VIEWMODE_LIST:
                // ATTIVITA
                $text_result .= '<a class="go_top" href="#top" title=""><img src="' . DCTL_IMAGES . 'up.gif" alt="(go top icon)" height="' . $htop . '" /></a>';
                break;
            default:
                // PAGE
                break;
        }
        if ($putBR) {
            $text_result .= '<br />';
        }
        $text_result .= wctl_loader_recurse($option, $xml, '');
        if ($putBR) {
            $text_result .= '<br />';
        }
        $text_done = true;
    }
    return $text_done;
}
Example #6
0
     }
     break;
 case 'palette':
     $title = 'Palette';
     $goto = $title;
     $returnText .= '<div class="box_head">';
     $returnText .= '<h2 class="page_curr" rel="' . $db_collection . '-' . $goto . '">' . $title . '</h2>';
     generateVerticalString($title, $goto, $db_collection, true);
     $returnText .= '</div>';
     $returnText .= getDisplayPalette($doc, $where, $what, $block, $at, $high, $label, $terms);
     break;
 case 'navigator':
     if ($what == '') {
         $what = 'menu_edition.xsl';
     }
     forceUTF8($config);
     $configFile = simplexml_load_file($config, 'SimpleXMLElement', DCTL_XML_LOADER);
     $node = $configFile->xpath('menu[@xslt="' . $what . '"]');
     $label = $node[0]['label'];
     $desc = (string) $node[0]->div->asXML();
     $label = $label . DISTINCT_SEP . $desc;
     $returnText .= getDisplayNavigator($doc, $where, $what, $block, $at, $high, $label, $terms);
     break;
 default:
     $returnText .= '<div class="box">';
     switch ($prefix) {
         case 'img':
             $rend = $label;
             $label = stripslashes($label);
             $label = explode(DISTINCT_SEP, $label);
             $alt = isset($label[0]) ? $label[0] : '';
Example #7
0
function get_n_from_xml_id($xml_id, $collection_id, $package)
{
    //used in publication of key_items to get the value of the "n" attribute.
    // stolen from other code, we construct the path to the _mapper file.
    $file_mapper = DCTL_PROJECT_PATH . $collection_id . SYS_PATH_SEP . DCTL_FILE_MAPPER;
    // we read the code, strip the obnoxious header and footer (which would break the
    // DOMDocument creation) and add a root element to make a "valid" xml to search through.
    $file_content = file_get_contents($file_mapper);
    $file_content = preg_replace('/' . WS . '+/', ' ', $file_content);
    $from = stripos($file_content, '%BEGIN%') + strlen('%BEGIN% -->');
    $to = stripos($file_content, '%END%') - strlen('<-- ') - $from - 1;
    $text_content = substr($file_content, $from, $to);
    $xml_dom = new DOMDocument('1.0', 'UTF-8');
    $xml_dom->preserveWhiteSpace = false;
    forceUTF8($text_content);
    $xml_dom->loadXML('<root>' . $text_content . '</root>');
    // this is the @target content we're after
    $target_to_find = 'xml://' . $collection_id . '/' . $package . '/' . $xml_id;
    $xquery = "//*[contains(@target, '" . $target_to_find . "') and @n != '']";
    $xpath = new DOMXPath($xml_dom);
    $result = $xpath->query($xquery)->item(0);
    if (is_a($result, 'DOMElement')) {
        return $result->getAttribute('n');
    } else {
        // maybe the searched item wasn't found ?
        return '';
    }
}
Example #8
0
function get_dbIconclass($theKey, $theAttribute)
{
    global $mysql_dbIconclass;
    $theAttribute = str_ireplace(' ', '', $theAttribute);
    $text = '';
    if ($theKey != '') {
        $query = 'SELECT  * FROM tNAME WHERE tNAME.id="' . $theKey . '"';
        $result = mysql_query($query, $mysql_dbIconclass) or die("Error in query: {$query}.  " . mysql_error());
        if (mysql_num_rows($result) == 1) {
            $row = mysql_fetch_array($result, MYSQL_ASSOC);
            switch ($theAttribute) {
                case 'name':
                    $text = $row['name'];
                    break;
                case 'iconclass':
                    $text = $row['iconclass'];
                    break;
                default:
                    $text = '???';
                    break;
            }
        }
    }
    return forceUTF8(strval(ucfirst(trim($text))), '', false);
}