Beispiel #1
0
function perform_xslt($xml, $s, $islast, $isfirst, $param_path)
{
    global $base_path, $charset;
    $transform = "{$base_path}/admin/convert/imports/" . $param_path . "/" . $s['XSLFILE'][0]['value'];
    //Si c'est la première transformation, on rajoute les entêtes
    if ($isfirst) {
        if ($s['ENCODING']) {
            $xml1 = "<?xml version=\"1.0\" encoding=\"" . $s['ENCODING'] . "\"?>\n<" . $s['ROOTELEMENT'][0]["value"];
        } else {
            $xml1 = "<?xml version=\"1.0\" encoding=\"{$charset}\"?>\n<" . $s['ROOTELEMENT'][0]["value"];
        }
        if ($s["NAMESPACE"]) {
            $xml1 .= " xmlns:" . $s["NAMESPACE"][0]["ID"] . "='" . $s["NAMESPACE"][0]["value"] . "' ";
        }
        $xml1 .= ">\n" . $xml . "\n</" . $s['ROOTELEMENT'][0]['value'] . ">";
        $xml = $xml1;
    }
    $f = fopen($transform, "r");
    $xsl = fread($f, filesize($transform));
    fclose($f);
    //Création du processeur
    $xh = xslt_create();
    //Encodage = $charset
    if (defined("ICONV_IMPL")) {
        xslt_set_encoding($xh, "{$charset}");
    }
    // Traite le document
    if ($result = @xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array("/_xml" => $xml, "/_xsl" => $xsl))) {
        $r['VALID'] = true;
        $r['DATA'] = $result;
        $r['ERROR'] = "";
        //Si c'est la dernière transformation, on supprime les entêtes et l'élément root
        if ($islast) {
            $p = preg_match("/<" . $s['TNOTICEELEMENT'][0]['value'] . "(?:\\ [^>]*|)>/", $r["DATA"], $m, PREG_OFFSET_CAPTURE);
            if ($p) {
                $r['DATA'] = "  " . substr($r['DATA'], $m[0][1]);
            }
            $p1 = 0;
            $p = 0;
            while ($p !== false) {
                $p1 = $p;
                $p = @strpos($r['DATA'], "</" . $s['TNOTICEELEMENT'][0]['value'] . ">", $p1 + strlen("</" . $s['TNOTICEELEMENT'][0]['value'] . ">"));
            }
            if ($p1 !== false && $p1 != 0) {
                $r['DATA'] = substr($r['DATA'], 0, $p1 + strlen($s['TNOTICEELEMENT'][0]['value']) + 3) . "\n";
            }
        }
    } else {
        $r['VALID'] = false;
        $r['DATA'] = "";
        $r['ERROR'] = "Sorry, notice could not be transformed by {$transform} the reason is that " . xslt_error($xh) . " and the error code is " . xslt_errno($xh);
    }
    xslt_free($xh);
    return $r;
}
Beispiel #2
0
 function transform()
 {
     $args = array("/_stylesheet", $this->xsl, "/_xmlinput", $this->xml, "/_output", 0, 0);
     if ($err = xslt_run($this->processor, "arg:/_stylesheet", "arg:/_xmlinput", "arg:/_output", 0, $args)) {
         $output = xslt_fetch_result($this->processor, "arg:/_output");
         $this->setOutput($output);
     } else {
         $this->setError(xslt_error($this->processor));
         $this->setErrorCode(xslt_errno($this->processor));
     }
 }
Beispiel #3
0
 function transform()
 {
     $args = array('/_xml' => $this->xml, '/_xsl' => $this->xsl);
     $result = xslt_process($this->processor, 'arg:/_xml', 'arg:/_xsl', NULL, $args);
     if ($result) {
         $this->setOutput($result);
     } else {
         //            $err = "Error: " . xslt_error ($this->processor) . " Errorcode: " . xslt_errno ($this->processor);
         $this->setError(xslt_error($this->processor));
         $this->setErrorCode(xslt_errno($this->processor));
     }
 }
Beispiel #4
0
 function transform()
 {
     global $ilLog;
     $this->__init();
     $this->fo_string = @xslt_process($this->xslt_handler, "arg:/_xml", "arg:/_xsl", null, $this->xslt_args, $this->xslt_params);
     if (strlen($error_msg = xslt_error($this->xslt_handler))) {
         $ilLog->write("Error generating pdf: " . $error_msg);
         return false;
     }
     xslt_free($this->xslt_handler);
     return true;
 }
Beispiel #5
0
function output($output)
{
    /* Falls die Seite als HTML ausgegeben werden soll */
    /* Eine Weiche einbauen, fals die XSLT Extension nicht geladen ist -> 
       http://koders.com/php/fidB0434D36F01703F9ACAB5E21065E315FE44D2C57.aspx?s=xslt_process
       http://koders.com/php/fid78371B5F37DAE258E3258B91CC791A712CBF2AAC.aspx?s=xslt_process
       */
    if (isset($_SESSION['variables']['extention']) and $_SESSION['variables']['extention'] == "html" and IS_XSLT) {
        if (version_compare(phpversion(), "5.0", ">")) {
            $processor = new XSLTProcessor();
            $xmlDom = new DOMDocument();
            $xslDom = new DOMDocument();
            $xmlDom->loadXML($output);
            $xslDom->load(BIN_DIR . "xslt/index.xsl");
            $processor->importstylesheet($xslDom);
            /* Transformiert den Output
               :TODO: Fehlerabfrage der Resultates
               :ATTENTION: eventuell werden die im XSL-File includeten Dateien falsch eingebunden*/
            $result = $processor->transformtoxml($xmlDom);
        } else {
            /* PHP4 XSLT Prozessor, ist auch unter PHP5 erreichbar, nur langsamer */
            /* XSL File auslesen und Content ueberschreiben */
            $filename = "xslt/main.xsl";
            $handle = fopen($filename, "r");
            $xsl_contents = fread($handle, filesize($filename));
            fclose($handle);
            /* :TODO: Anpassen des xsc fuer die Uebergabe des Templatefiles */
            // $xsl = sprintf($xsl_contents, $_SESSION['variables']['template_content']);
            $xsl = $xsl_contents;
            /* Stylesheet uebergeben */
            $processor_arguments = array('/_xml' => $output, '/_xsl' => $xsl);
            $processor = xslt_create();
            xslt_set_encoding($processor, 'ISO-8859-1');
            xslt_set_base($processor, 'file://' . BIN_DIR . 'xslt/');
            /* Transformiert den Output */
            $result = xslt_process($processor, 'arg:/_xml', 'arg:/_xsl', NULL, $processor_arguments);
            if (!$result && xslt_errno($processor) > 0) {
                $result = sprintf("Kann XSLT Dokument nicht umarbeiten [%d]: %s", xslt_errno($processor), xslt_error($processor));
            }
            xslt_free($processor);
        }
        /* Gibt das HTML-Dokument aus */
        echo $result;
    } else {
        header("Content-Type: text/xml");
        echo $output;
    }
}
/**
 * Transformation générique d'un document XML via XSLT
 * @param string $filename nom du fichier source
 * @param string $filename_source nom du fichier en sortie
 * @param string $stylesheet nom de la feuille XSLT
 * @param array $params paramètres à passer à la feuille XSLT
 * @access private
 * @return boolean vrai quand tout se passe bien
 */
function _output_xsl_generic_transform($filename, $filename_cible, $stylesheet, $params = array())
{
    /* Attention : code hautement toxique, il a fallu aller fouiller
       dans les sources de PHP pour découvrir une grande partie des engins
       nucléaires en jeu ici et rien ne garantit leur stabilité. Désolé pour
       le développement durable, c'est pas trop ça ici. */
    $xh = xslt_create();
    $result = xslt_process($xh, $filename, PATH_INCLUDE . "xslt/" . $stylesheet, $filename_cible, array(), $params);
    if (!$result) {
        $msgerr = 'Erreur XSLT ' . xslt_errno($xh) . ' : ' . xslt_error($xh);
        xslt_free($xh);
        return false;
    } else {
        return true;
    }
}
Beispiel #7
0
function xsltTransform($xmlString, $xsltPath, $xsltArguments = null)
{
    if (!file_exists($xsltPath)) {
        webserviceError('&error-xslt-path-not-found;', 500, array('path' => $xsltPath));
    }
    $result = null;
    $xsltEnabledStatus = getXsltEnabledStatus();
    switch ($xsltEnabledStatus) {
        case 'php5':
            $xslt = new XSLTProcessor();
            $xsltDocument = new DOMDocument();
            $xsltDocument->load($xsltPath);
            $xslt->importStyleSheet($xsltDocument);
            if (is_array($xsltArguments)) {
                foreach ($xsltArguments as $key => $value) {
                    $xslt->setParameter('', $key, $value);
                }
            }
            $errorLevelToDescribeMerelyDeprecatedWarnings = 999999;
            $xmlDocument = new DOMDocument();
            $xmlDocument->loadXML($xmlString);
            $result = $xslt->transformToXML($xmlDocument);
            break;
        case 'php4':
            $xsltproc = xslt_create();
            $xmlString = array('/_xml' => $xmlString);
            $xsltPath = 'file://' . $xsltPath;
            $result = @xslt_process($xsltproc, 'arg:/_xml', $xsltPath, NULL, $xmlString, $xsltArguments) or webServiceError('&error-xslt-processor-error;', 500, array('path' => $xsltPath, 'errorMessage' => xslt_error($xsltproc)));
            if (empty($result) or xslt_error($xsltproc) != null) {
                webServiceError('&error-xslt-processor-error;', 500, array('path' => $xsltPath, 'errorMessage' => xslt_error($xsltproc)));
            }
            xslt_free($xsltproc);
            break;
        default:
            $commandLineMessage = '';
            $phpVersion = getPhpVersion();
            if ($phpVersion >= 5) {
                webServiceError('&error-xslt-not-available;');
            } else {
                webServiceError('&error-php5-required;', 500, array('phpVersion' => $phpVersion));
            }
    }
    return $result;
}
Beispiel #8
0
function doTransform($xmlfilename, $xslfilename)
{
    $xh = xslt_create();
    if (!$xh) {
        echo "<p>ERROR: unable to invoke php's xslt processor";
        return;
    }
    $root = 'file://' . $_SERVER['DOCUMENT_ROOT'];
    $result = xslt_process($xh, $root . $xmlfilename, $root . $xslfilename);
    if ($result) {
        header("Content-type: application/ms-excel");
        //header("Content-type: application/vnd.ms-excel");
        header('Content-Disposition: attachment; filename="' . $GLOBALS['outfile'] . '.xls";');
        echo $result;
    } else {
        echo "<p>ERROR: unable to transform " . $xmlfilename;
        echo "<br>" . xslt_error($xh);
    }
    xslt_free($xh);
}
 function transform()
 {
     $args = array('/_xml' => $this->xml, '/_xsl' => $this->xsl);
     $result = xslt_process($this->processor, 'arg:/_xml', 'arg:/_xsl', NULL, $args);
     if (xslt_error($this->processor) != '') {
         echo "class.XSLTransformer41.php<br>";
         echo "xslt_error:" . xslt_error($this->processor) . "<br>";
         echo "result:" . $result . "<br>";
     }
     if (strlen($result) == 0) {
         echo "class.XSLTransformer41.php<br>";
         echo "xslt_error:" . xslt_error($this->processor) . "<br>";
         echo "result:" . $result . "<br>";
     }
     if ($result) {
         $this->setOutput($result);
     } else {
         echo "class.XSLTransformer41.php<br>";
         $err = "<br/>Error: " . xslt_error($this->processor) . "<br/>Errorcode: " . xslt_errno($this->processor);
         $this->setError($err);
     }
 }
 static function transformPHP4(&$InformationArray)
 {
     // create the XSLT processor^M
     $xh = xslt_create() or die("Could not create XSLT processor");
     // Process the document
     $result = xslt_process($xh, $InformationArray['fileBase'] . $InformationArray['xml_file'], $InformationArray['fileBase'] . $InformationArray['xslt_file'], $InformationArray['fileBase'] . $InformationArray['out_file']);
     if (!$result) {
         // Something croaked. Show the error
         $InformationArray['error'] = "Cannot process XSLT document: " . xslt_errno($xh) . " " . xslt_error($xh);
     }
     // Destroy the XSLT processor
     xslt_free($xh);
 }
Beispiel #11
0
 function transform()
 {
     /* apply replacements on xml and xsl strings after process transformation */
     if ($this->replacements != "") {
         $this->xml = $this->processReplace($this->xml);
         $this->xsl = $this->processReplace($this->xsl);
     }
     //debug("transform xml",$this->xml);
     //debug("transform xsl",$this->xsl);
     $args = array('/_xml' => $this->xml, '/_xsl' => $this->xsl);
     $result = xslt_process($this->processor, 'arg:/_xml', 'arg:/_xsl', NULL, $args);
     //debug("transform res",$result);
     if ($result) {
         $this->setOutput($result);
         return true;
     } else {
         $this->setError(xslt_error($this->processor));
         $this->setErrorCode(xslt_errno($this->processor));
         return false;
     }
 }
 /**
  * @return string
  */
 public function getExchangeContent()
 {
     if (!file_exists($this->getXSLPath())) {
         return '';
     }
     $output = '';
     $xsl_file_content = file_get_contents($this->getXSLPath());
     $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
     if (strlen($xsl_file_content) && strlen($xsl)) {
         $args = array('/_xml' => $xsl_file_content, '/_xsl' => $xsl);
         $xh = xslt_create();
         $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
         xslt_error($xh);
         xslt_free($xh);
     }
     $output = preg_replace("/<\\?xml[^>]+?>/", "", $output);
     // dirty hack: the php xslt processing seems not to recognize the following
     // replacements, so we do it in the code as well
     $output = str_replace("&#xA0;", "<br />", $output);
     $output = str_replace("&#160;", "<br />", $output);
     return $output;
 }
}

// We do have cache
else {
$phpfilename = "$xml_cache/$path/index.php";
if (!hasCache($xmlfilename,$xslfilename,$phpfilename) || filesize($phpfilename) == 0) {
  print "<div style='color: #888888;'>Processing (and caching) file with stylesheet</div>";
  @unlink($phpfilename);
  flush();
  //print nl2br(htmlentities("$xmlcontent"));

  $tmpfile = "$phpfilename.tmp";
//  print "\n($xmlfilename to $tmpfile)";
  if (!@xslt_process($xslt,$xmlfilename,"$xslfilename",$tmpfile,null,$xsl_params)) {
      @unlink($phpfilename);
      fatal_error("xslt error: " . xslt_error($xslt) . "</div>");
    }

  //  chdir($cwd);
  rename($tmpfile,$phpfilename) || $phpfilename = $tmpfile;
}

include($phpfilename);
}

print "</div>\n";


if ($write_access) {
?>
<div id="s_div" class="status">
Beispiel #14
0
 /**
  * Convert a print output to XSL-FO
  *
  * @param string $print_output The print output
  * @return string XSL-FO code
  * @access public
  */
 function processPrintoutput2FO($print_output)
 {
     if (extension_loaded("tidy")) {
         $config = array("indent" => false, "output-xml" => true, "numeric-entities" => true);
         $tidy = new tidy();
         $tidy->parseString($print_output, $config, 'utf8');
         $tidy->cleanRepair();
         $print_output = tidy_get_output($tidy);
         $print_output = preg_replace("/^.*?(<html)/", "\\1", $print_output);
     } else {
         $print_output = str_replace("&nbsp;", "&#160;", $print_output);
         $print_output = str_replace("&otimes;", "X", $print_output);
     }
     $xsl = file_get_contents("./Modules/Test/xml/question2fo.xsl");
     // additional font support
     $xsl = str_replace('font-family="Helvetica, unifont"', 'font-family="' . $GLOBALS['ilSetting']->get('rpc_pdf_font', 'Helvetica, unifont') . '"', $xsl);
     $args = array('/_xml' => $print_output, '/_xsl' => $xsl);
     $xh = xslt_create();
     $params = array();
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
     xslt_error($xh);
     xslt_free($xh);
     return $output;
 }
require_once "include/xrai.inc";
set_time_limit(360);
$file = $_REQUEST["file"];
$phpfilename = "{$xml_cache}/{$file}-treeview.php";
$xmlfilename = "{$xml_documents}/{$file}.xml";
$xslfilename = "xsl/treeview.xsl";
// $do_debug = true;
$tmpfile = "";
if ($dodebug || !hasCache($xmlfilename, $xslfilename, $phpfilename) || filesize($phpfilename) == 0) {
    @unlink($phpfilename);
    //print nl2br(htmlentities("$xmlcontent"));
    if (!file_exists($xmlfilename)) {
        fatal_error("File {$xmlfilename} does not exist");
    }
    $tmpfilename = "{$phpfilename}.tmp";
    $xslp = array("baseurl" => "{$base_url}/");
    if (!@xslt_process($xslt, "{$xmlfilename}", "{$xslfilename}", "{$tmpfilename}", $params, $xslp)) {
        @unlink("{$phpfilename}.tmp");
        fatal_error("XSLT error (1): " . xslt_error($xslt));
    }
    $phpfilename_cache = $phpfilename;
    $phpfilename = $tmpfilename;
}
if (!is_file("{$phpfilename}")) {
    fatal_error("<div>Can't find processed XML file ({$phpfilename}). Please try to reload page or <a href='{$base_url}/informations.php'>report a bug</a>.</div>");
}
// set_error_handler("include_error_handler")
readfile($phpfilename);
if ($phpfilename_cache) {
    @rename("{$tmpfile}", $phpfilename_cache);
}
Beispiel #16
0
// This has to precede the inclusion of the header file.
$langID = getLangID('it');
//require ('FiaHeader.html');
// $params = array (
//        'contentID' => $_GET['myID'],
//        'expandID'  => $_GET['expand'],
//        'langID' => $langID
// );
$params = array('contentID' => $_GET['myID'], 'expandID' => $_GET['expand'], 'highlight' => $_GET['highlight'], 'langID' => $langID);
require '../header.php';
require 'FiaNavigation.php';
echo '<div id="text">';
// Allocate a new XSLT processor
//$xh = xslt_create();
//xslt_set_encoding ($xh, 'UTF-8');
// Process the document, returning the result into the $result variable
//$result = xslt_process($xh, 'itFiammetta.xml', 'itFiaShowText.xsl', NULL, array(), $params);
// $result = xslt_process($xh, 'itFiammetta.xml', 'itFiaShowText.xsl');
$result = runXSLT($langID . 'Fiammetta.xml', 'FiaShowText.xsl', $params);
if ($result) {
    // echo "<pre>\n";
    echo $result;
    //echo "</pre>\n";
} else {
    echo "Sorry, transformation could not be performed" . xslt_error($xh);
    echo " error code " . xslt_errno($xh);
}
//xslt_free($xh);
echo '</div>';
$last_modified = filemtime($_SERVER["SCRIPT_FILENAME"]);
require '../footer.php';
 /**
  * output media
  */
 function ilMedia()
 {
     global $ilUser;
     $this->tpl->setCurrentBlock("ContentStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
     } else {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
     }
     $this->tpl->parseCurrentBlock();
     $this->renderPageTitle();
     // set style sheets
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     } else {
         $style_name = $ilUser->getPref("style") . ".css";
         $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
     }
     $this->tpl->setCurrentBlock("ilMedia");
     //$int_links = $page_object->getInternalLinks();
     $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
     $link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
     $link_xml .= $this->getLinkTargetsXML();
     //echo "<br><br>".htmlentities($link_xml);
     require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $media_obj = new ilObjMediaObject($_GET["mob_id"]);
     if (!empty($_GET["pg_id"])) {
         require_once "./Modules/LearningModule/classes/class.ilLMPage.php";
         $pg_obj = $this->getLMPage($_GET["pg_id"]);
         $pg_obj->buildDom();
         $xml = "<dummy>";
         // todo: we get always the first alias now (problem if mob is used multiple
         // times in page)
         $xml .= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
         $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
         $xml .= $link_xml;
         $xml .= "</dummy>";
     } else {
         $xml = "<dummy>";
         // todo: we get always the first alias now (problem if mob is used multiple
         // times in page)
         $xml .= $media_obj->getXML(IL_MODE_ALIAS);
         $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
         $xml .= $link_xml;
         $xml .= "</dummy>";
     }
     //echo htmlentities($xml); exit;
     // todo: utf-header should be set globally
     //header('Content-type: text/html; charset=UTF-8');
     $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
     $args = array('/_xml' => $xml, '/_xsl' => $xsl);
     $xh = xslt_create();
     //echo "<b>XML:</b>".htmlentities($xml);
     // determine target frames for internal links
     //$pg_frame = $_GET["frame"];
     if (!$this->offlineMode()) {
         $wb_path = ilUtil::getWebspaceDir("output") . "/";
     } else {
         $wb_path = "";
     }
     $mode = $_GET["cmd"] == "fullscreen" ? "fullscreen" : "media";
     $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output", $this->offlineMode());
     $fullscreen_link = $this->getLink($this->lm->getRefId(), "fullscreen");
     $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path, 'link_params' => "ref_id=" . $this->lm->getRefId(), 'fullscreen_link' => $fullscreen_link, 'ref_id' => $this->lm->getRefId(), 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
     echo xslt_error($xh);
     xslt_free($xh);
     // unmask user html
     $this->tpl->setVariable("MEDIA_CONTENT", $output);
     // add js
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php";
     ilObjMediaObjectGUI::includePresentationJS($this->tpl);
 }
 /**
  * show fullscreen view of media object
  */
 function showMediaFullscreen($a_style_id = 0)
 {
     $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
     $this->tpl->setCurrentBlock("ContentStyle");
     $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", 0);
     $this->tpl->parseCurrentBlock();
     $this->tpl->setVariable("PAGETITLE", " - " . ilObject::_lookupTitle($_GET["mob_id"]));
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $this->tpl->setCurrentBlock("ilMedia");
     require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
     if (!empty($_GET["pg_id"])) {
         include_once "./Services/COPage/classes/class.ilPageObjectFactory.php";
         $pg_obj = ilPageObjectFactory::getInstance($this->obj->getParentType(), $_GET["pg_id"]);
         $pg_obj->buildDom();
         $xml = "<dummy>";
         // todo: we get always the first alias now (problem if mob is used multiple
         // times in page)
         $xml .= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
         $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
         $xml .= "</dummy>";
     } else {
         $xml = "<dummy>";
         $xml .= $media_obj->getXML(IL_MODE_ALIAS);
         $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
         $xml .= "</dummy>";
     }
     //echo htmlentities($xml); exit;
     $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
     $args = array('/_xml' => $xml, '/_xsl' => $xsl);
     $xh = xslt_create();
     //echo "<b>XML:</b>".htmlentities($xml);
     // determine target frames for internal links
     //$pg_frame = $_GET["frame"];
     $wb_path = ilUtil::getWebspaceDir("output") . "/";
     $mode = "fullscreen";
     $params = array('mode' => $mode, 'webspace_path' => $wb_path);
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
     echo xslt_error($xh);
     xslt_free($xh);
     // unmask user html
     $this->tpl->setVariable("MEDIA_CONTENT", $output);
 }
Beispiel #19
0
 function error()
 {
     return @xslt_error();
 }
Beispiel #20
0
 function record_to_xml_unimarc($record, $style_sheets, $charset)
 {
     global $xslt_base_path;
     global $debug;
     if ($debug) {
         highlight_string(print_r($record, true));
     }
     //		file_put_contents('dublincoreextended1.xml', $record);
     $xh = xslt_create();
     //		echo $charset;
     xslt_set_encoding($xh, $charset);
     $result = $record;
     foreach ($style_sheets as $style_sheet) {
         if ($debug) {
             echo '<h3>' . $style_sheet . '</h3>';
         }
         /* Traitement du document */
         $arguments = array('/_xml' => $result, '/_xsl' => $style_sheet);
         $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
         if ($debug) {
             highlight_string(print_r($result, true));
         }
         if (!$result) {
             $this->error = true;
             $this->error_message = "Sorry, notice could not be transformed by {$style_sheet} the reason is that " . xslt_error($xh) . " and the error code is " . xslt_errno($xh);
         }
     }
     xslt_free($xh);
     return $result;
 }
$transform = "simpletest.org.xslt";
$source_paths = array("../../docs/wiki/", "en" => "../../docs/source/en/", "fr" => "../../docs/source/fr/");
$destination_path = "../../../../simpletest.org/wiki/data/";
foreach ($source_paths as $lang => $source_path) {
    if (!is_int($lang)) {
        $prefix = $lang . '-';
    }
    $dir = opendir($source_path);
    while (($file = readdir($dir)) !== false) {
        if (!preg_match('/\\.xml$/', $file)) {
            continue;
        }
        $source = $source_path . $file;
        $destination = $destination_path . $prefix . preg_replace('/\\.xml$/', '.txt', basename($source));
        $xsltProcessor = xslt_create();
        $fileBase = 'file://' . getcwd() . '/';
        xslt_set_base($xsltProcessor, $fileBase);
        $result = xslt_process($xsltProcessor, $source, $transform);
        $result = preg_replace("/((<a href=\")([a-z_]*)(\\.php\">))/", "<a href=\"doku.php?id=fr-\\3\">", $result);
        if ($result) {
            $handle = fopen($destination, "w+");
            fwrite($handle, $result);
            fclose($handle);
            echo "succès pour " . $destination . "<br />";
        } else {
            echo "erreur pour " . $destination . " : " . xslt_error($xh) . "<br />";
        }
        xslt_free($xsltProcessor);
    }
    closedir($dir);
}
 /**
  * show media object
  */
 function media($a_mode = "media")
 {
     $this->tpl =& new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
     //$int_links = $page_object->getInternalLinks();
     $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
     // later
     //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
     $link_xlm = "";
     require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
     $xml = "<dummy>";
     // todo: we get always the first alias now (problem if mob is used multiple
     // times in page)
     $xml .= $media_obj->getXML(IL_MODE_ALIAS);
     $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
     $xml .= $link_xml;
     $xml .= "</dummy>";
     $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
     $args = array('/_xml' => $xml, '/_xsl' => $xsl);
     $xh = xslt_create();
     if (!$this->offlineMode()) {
         $enlarge_path = ilUtil::getImagePath("enlarge.png", false, "output");
         $wb_path = ilUtil::getWebspaceDir("output") . "/";
     } else {
         $enlarge_path = "images/enlarge.png";
         $wb_path = "";
     }
     $mode = $a_mode;
     $this->ctrl->setParameter($this, "obj_type", "MediaObject");
     $fullscreen_link = $this->getLink($_GET["ref_id"], "fullscreen");
     $this->ctrl->clearParameters($this);
     $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path, 'link_params' => "ref_id=" . $_GET["ref_id"], 'fullscreen_link' => $fullscreen_link, 'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
     echo xslt_error($xh);
     xslt_free($xh);
     // unmask user html
     $this->tpl->setVariable("MEDIA_CONTENT", $output);
     $this->tpl->parseCurrentBlock();
     if ($this->offlineMode()) {
         $html = $this->tpl->get();
         return $html;
     }
 }
Beispiel #23
0
        $fd = fopen('xml/note/' . $file . '.xml', 'r');
        while (!feof($fd)) {
            $line1 = fgets($fd);
            if ($cpt == 0) {
                if (match_tag('titre', $line1)) {
                    fputs($fdc, "<titre>" . extract_text('titre', $line1) . " [Compilation]</titre>\n");
                } else {
                    if (!match_tag('note', $line1) and !match_tag('meta_note', $line1) and !match_tag('statut', $line1) and !match_tag('date_creation', $line1) and !match_tag('date_modification', $line1) and !match_tag('auteur', $line1) and !match_tag('contributeurs', $line1) and !match_tag('contributeur', $line1) and !match_tag('relecteur', $line1) and !match_tag('nom', $line1) and !match_tag('prenom', $line1) and !isComment($line1)) {
                        fputs($fdc, $line1);
                    }
                }
            } else {
                if (!match_tag('note', $line1) and !match_tag('meta_note', $line1) and !match_tag('statut', $line1) and !match_tag('date_creation', $line1) and !match_tag('date_modification', $line1) and !match_tag('auteur', $line1) and !match_tag('contributeurs', $line1) and !match_tag('contributeur', $line1) and !match_tag('relecteur', $line1) and !match_tag('nom', $line1) and !match_tag('prenom', $line1) and !match_tag('titre', $line1) and !isComment($line1)) {
                    fputs($fdc, $line1);
                }
            }
        }
        $cpt++;
    }
    fputs($fdc, '</note>');
    $xh = xslt_create();
    if (xslt_process($xh, "xml/note/{$titre}.xml", "xsl/note/note.xsl", "gen/note/{$titre}.xml")) {
        include 'template1.php';
        readfile("gen/note/{$titre}.xml");
        include 'template2.php';
    } else {
        echo "Error : " . xslt_error($xh) . " and the ";
        echo "error code is " . xslt_errno($xh);
    }
    xslt_free($xh);
}
 function process($xml = null, $xsl = null, $param = array())
 {
     if ($xml) {
         $this->_xml = $xml;
     }
     if ($xsl) {
         $this->_xsl = $xsl;
     }
     $xml = trim($xml);
     $xsl = trim($xsl);
     if (!is_array($param)) {
         $param = array();
     }
     if (!_XSLT_AVAILABLE_) {
         return false;
     }
     //dont let process continue if no xsl functionality exists
     //DOMXML Extension
     if (_USING_DOMXML_XSLT_) {
         // Set up error handling
         $ehOLD = ini_set('html_errors', false);
         set_error_handler('trapXSLError');
         $xmldoc = domxml_open_mem($this->_xml, DOMXML_LOAD_PARSING, $xmlErrors);
         $xsldoc = domxml_xslt_stylesheet($this->_xsl);
         if (is_object($xmldoc) && is_object($xsldoc)) {
             $result = $xsldoc->process($xmldoc, $param);
             $result = $xsldoc->result_dump_mem($result);
         }
         // Restore error handling
         ini_set('html_errors', $ehOLD);
         restore_error_handler();
         //Process the errors while opening the XML
         while ($e = @array_shift($xmlErrors)) {
             $this->__error("2", $e['errormessage'], "xml", $e['line']);
         }
         //Use one of the custom error handlers to grab a list of processing errors
         $errors = trapXMLError(null, null, null, null, null, true);
         //Process the rest of the errors
         while ($error = @array_shift($errors)) {
             $this->__error($error['number'], $error['message'], $error['type'], $error['line']);
         }
         unset($xmldoc);
         unset($xsldoc);
         //PHP4/5 XSL Extension
     } else {
         $arguments = array('/_xml' => $this->_xml, '/_xsl' => $this->_xsl);
         $xsltproc = xslt_create();
         ##Make sure a bad document() call doesnt break the site
         if (PHP_VERSION < 5) {
             xslt_setopt($xsltproc, XSLT_SABOPT_IGNORE_DOC_NOT_FOUND);
         }
         $result = @xslt_process($xsltproc, 'arg:/_xml', 'arg:/_xsl', null, $arguments, $param);
         if (PHP_VERSION >= 5) {
             //Use one of the custom error handlers to grab a list of processing errors
             $errors = trapXMLError(null, null, null, null, null, true);
             while ($error = @array_shift($errors)) {
                 $this->__error($error['number'], $error['message'], $error['type'], $error['line']);
             }
         } else {
             if (!$result && xslt_errno($xsltproc) > 0) {
                 $this->__error(xslt_errno($xsltproc), xslt_error($xsltproc));
             }
         }
         xslt_free($xsltproc);
     }
     return $result;
 }
 function transform()
 {
     $err = "";
     if (getenv("ENV_SOCKET") == "true") {
         $result = $this->socket->transform($this->xsl, $this->xml);
         if (strlen($result) < 3) {
             $args = array('/_xml' => $this->xml, '/_xsl' => $this->xsl);
             $result = xslt_process($this->processor, 'arg:/_xml', 'arg:/_xsl', NULL, $args);
             if ($result) {
                 $this->byJava = 'false';
                 $this->setOutput($result . "<!--transformed by PHP-->");
             } else {
                 $err = "Error: " . xslt_error($this->processor) . " Errorcode: " . xslt_errno($this->processor);
                 $this->setError($err);
             }
         } else {
             $this->byJava = 'true';
             $this->setOutput($result . "<!--transformed by JAVA " . date("h:m:s d-m-Y") . "-->");
         }
     } else {
         $args = array('/_xml' => $this->xml, '/_xsl' => $this->xsl);
         $result = xslt_process($this->processor, 'arg:/_xml', 'arg:/_xsl', NULL, $args);
         if ($result) {
             $this->byJava = 'false';
             $this->setOutput($result . "<!--transformed by PHP " . date("h:m:s d-m-Y") . "-->");
         } else {
             $err = "Error: " . xslt_error($this->processor) . " Errorcode: " . xslt_errno($this->processor);
             $this->setError($err);
         }
     }
     if ($err) {
         var_dump($err);
         var_dump($this->xsl);
         var_dump($this->xml);
     }
 }
 private function generatePreview()
 {
     $xml = $this->getXMLContent();
     $dom = @domxml_open_mem($xml, DOMXML_LOAD_PARSING, $error);
     $xpc = xpath_new_context($dom);
     $path = "////PlaceHolder";
     $res =& xpath_eval($xpc, $path);
     foreach ($res->nodeset as $item) {
         $height = $item->get_attribute("Height");
         $height = eregi_replace("px", "", $height);
         $height = $height / 10;
         $item->set_attribute("Height", $height . "px");
     }
     $xsl = file_get_contents($this->getXSLPath());
     $xml = $dom->dump_mem(0, "UTF-8");
     $args = array('/_xml' => $xml, '/_xsl' => $xsl);
     $xh = xslt_create();
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
     xslt_error($xh);
     xslt_free($xh);
     return $output;
 }
Beispiel #27
0
 /**
  * Use PHP4's xslt extension to do the XSL transformation
  * @param $xml mixed
  * @param $xmlType integer
  * @param $xsl mixed
  * @param $xslType integer
  * @param $resultType integer
  * @return string return type for PHP4 is always string or "false" on error.
  */
 function &_transformPHP4(&$xml, $xmlType, &$xsl, $xslType, $resultType)
 {
     $falseVar = false;
     // PHP4 doesn't support DOM
     if ($xmlType == XSL_TRANSFORMER_DOCTYPE_DOM || $xslType == XSL_TRANSFORMER_DOCTYPE_DOM || $resultType == XSL_TRANSFORMER_DOCTYPE_DOM) {
         return $falseVar;
     }
     // Create the processor
     $processor = xslt_create();
     xslt_set_encoding($processor, XSLT_PROCESSOR_ENCODING);
     // Create arguments for string types (if any)
     $arguments = array();
     if ($xmlType == XSL_TRANSFORMER_DOCTYPE_STRING) {
         $arguments['/_xml'] = $xml;
         $xml = 'arg:/_xml';
     }
     if ($xslType == XSL_TRANSFORMER_DOCTYPE_STRING) {
         $arguments['/_xsl'] = $xsl;
         $xsl = 'arg:/_xsl';
     }
     if (empty($arguments)) {
         $arguments = null;
     }
     // Do the transformation
     $resultXML = xslt_process($processor, $xml, $xsl, null, $arguments, $this->parameters);
     // Error handling
     if (!$resultXML) {
         $this->addError("Cannot process XSLT document [%d]: %s", xslt_errno($processor), xslt_error($processor));
         return $falseVar;
     }
     // DOM is not supported in PHP4 so we can always directly return the string result
     return $resultXML;
 }
Beispiel #28
0
<?php

$x = xslt_create();
$res = xslt_process($x, 'data.rss', 'rss.xsl');
if (!$res) {
    echo xslt_error($x);
}
echo $res;
xslt_free($x);
Beispiel #29
0
/**
 * Atom 0.3 を RSS 1.0 に変換する(PHP4, XSLT)
 */
function atom_to_rss_by_xslt($input, $stylesheet, $output)
{
    $xh = xslt_create();
    if (!@xslt_process($xh, $input, $stylesheet, $output)) {
        $errmsg = xslt_errno($xh) . ': ' . xslt_error($xh);
        P2Util::pushInfoHtml('<p>p2 error: XSLT - AtomをRSSに変換できませんでした。(' . $errmsg . ')</p>');
        xslt_free($xh);
        return FALSE;
    }
    xslt_free($xh);
    return FileCtl::file_read_contents($output);
}
 /**
  * Static render table function
  */
 static function _renderTable($content, $a_mode = "table_edit", $a_submode = "", $a_table_obj = null)
 {
     global $ilUser;
     $content = "<dummy>" . $content . "</dummy>";
     $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
     $args = array('/_xml' => $content, '/_xsl' => $xsl);
     $xh = xslt_create();
     //echo "<b>XML</b>:".htmlentities($content).":<br>";
     //echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
     $med_disabled_path = ilUtil::getImagePath("media_disabled.png");
     $wb_path = ilUtil::getWebspaceDir("output");
     $enlarge_path = ilUtil::getImagePath("enlarge.png");
     $params = array('mode' => $a_mode, 'med_disabled_path' => $med_disabled_path, 'media_mode' => $ilUser->getPref("ilPageEditor_MediaMode"), 'media_mode' => 'disable', 'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path);
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
     echo xslt_error($xh);
     xslt_free($xh);
     // unmask user html
     $output = str_replace("&lt;", "<", $output);
     $output = str_replace("&gt;", ">", $output);
     $output = str_replace("&amp;", "&", $output);
     if ($a_mode == "table_edit" && !is_null($a_table_obj)) {
         switch ($a_submode) {
             case "style":
                 $output = ilPCTableGUI::_addStyleCheckboxes($output, $a_table_obj);
                 break;
             case "alignment":
                 $output = ilPCTableGUI::_addAlignmentCheckboxes($output, $a_table_obj);
                 break;
             case "width":
                 $output = ilPCTableGUI::_addWidthInputs($output, $a_table_obj);
                 break;
             case "span":
                 $output = ilPCTableGUI::_addSpanInputs($output, $a_table_obj);
                 break;
         }
     }
     return '<div style="float:left;">' . $output . '</div>';
 }