Beispiel #1
0
function exec_cmd($cmd, $file, $isRELAT, $isMultiSec = FALSE, $rmHeader = 1, $finalUTF8 = TRUE)
{
    global $io_options;
    global $dayFilter;
    file_put_contents('php://stderr', "\n -- ({$cmd}) {$file}\n");
    if ($isRELAT) {
        print "\n=== {$cmd}  {$file} ===";
    }
    $dayFilter = isset($io_options['day']) ? $io_options['day'] : '';
    $doc = new domParser();
    // FALTA usar a  $io_options['normaliza'] pro XML na lib.php
    $doc->getHtmlBody($file, isset($io_options['utf8']) && $io_options['utf8']);
    $out = $doc->output($cmd, $finalUTF8, $dayFilter, $isMultiSec);
    if (!$isRELAT) {
        if ($rmHeader) {
            $out = str_replace(XML_HEADER1, '', $out);
        }
        $out = trim($out);
    }
    if (!isset($io_options['breaklines'])) {
        // na verdade no-breaklines
        $out = str_replace(['<p', '<div', '<article', '<sec', '<keys', '<days'], ["\n\n\n<p", "\n\n<div", "\n\n<article", "\n\n<sec", "\n<keys", "\n<days"], $out);
        $out = preg_replace("/[ \\t]*\n[ \\t]*/s", "\n", $out);
        // trim nas quebras de linha
    }
    $out = rmClosedFormatters($out);
    // repete limpeza já realizada no raw
    if (isset($io_options['entnum'])) {
        $out = utf2html($out);
    }
    return "{$out}\n";
}
Beispiel #2
0
 function output($MODO, $finalUTF8 = TRUE, $dayFilter = '', $isMultiSec = FALSE)
 {
     $MODO = strtolower($MODO);
     if ($MODO == 'relat3' || $MODO == 'relat4') {
         return $this->show_extractionSumary(true, $MODO);
     } elseif ($MODO == 'relat1' || $MODO == 'relat2') {
         $this->show_nodePathes();
         $this->show_cssParts();
         $this->show_xpathes();
         if ($MODO == 'relat1') {
             $this->show_extractionSumary();
         }
         return '';
         // já foi por print
     } elseif ($MODO == 'raw') {
         $this->preserveWhiteSpace = FALSE;
         $this->formatOutput = TRUE;
         $this->encoding = 'UTF-8';
         // falta template HTML5 http://www.w3.org/TR/html-polyglot/
         return rmClosedFormatters($this->saveXML());
     } elseif ($MODO == 'xml') {
         return $this->asXML($dayFilter, $isMultiSec);
     } else {
         $xmlDom = $this->asStdXML('dom', $dayFilter, $isMultiSec);
         if ($MODO == 'finalhtml') {
             return $this->asStdHtml('xml', $xmlDom, true, $dayFilter);
         } elseif ($MODO == 'finalxml') {
             if ($finalUTF8) {
                 $xmlDom->encoding = 'UTF-8';
             }
             return str_replace(['&lt;SYMBOL&gt;', '&lt;/SYMBOL&gt;'], ['<SYMBOL>', '</SYMBOL>'], $xmlDom->saveXML());
         } else {
             die("\nERRO2: MODO {$MODO} DESCONHECIDO\n");
         }
     }
 }