Exemple #1
0
$autopipeline = $unescapedPosts["autopipeline"];
if (!preg_match($badCharactersPattern, $autopipeline)) {
    webServiceError('autopipeline contains bad characters. Was "' . revealXml($autopipeline) . '"');
}
$allhtml = '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><body>' . $allhtml . '</body></html>';
$transformDirectory = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'transform' . DIRECTORY_SEPARATOR;
$htmlPagesXsltPath = $transformDirectory . 'htmlpages-to-html.xsl';
$allhtml = characterEntityToNCR($allhtml);
$html = xsltTransform($allhtml, $htmlPagesXsltPath);
if (!$html) {
    webServiceError("Unable to rebuild document, either because I was given invalid XML or there was a programming error.<hr />Document was:<blockquote>" . str_replace("\n", "<br />", str_replace(" ", '&nbsp;', revealXml($allhtml))) . "</blockquote>");
}
//displayXmlString($html);
$docbookBodyXsltPath = $transformDirectory . 'html-to-docbook-body.xsl';
$docbookBody = xsltTransform($html, $docbookBodyXsltPath);
$docbookBody = removeXmlDeclaration($docbookBody);
$docbookBody = preg_replace("/<docvert-remove-me[^>]*?>/", '', $docbookBody);
$docbookBody = preg_replace("/<\\/docvert-remove-me[^>]*?>/", '', $docbookBody);
//displayXmlString($docbookBody);
//displayXmlString(file_get_contents($docbookBodyXsltPath));
$allDocumentsPreviewDirectory = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'writable' . DIRECTORY_SEPARATOR . $documentPathParts[0] . DIRECTORY_SEPARATOR;
$previewDirectory = $allDocumentsPreviewDirectory . $documentPathParts[1] . DIRECTORY_SEPARATOR;
$unitTestResults = $previewDirectory . 'test.html';
if (file_exists($unitTestResults)) {
    silentlyUnlink($unitTestResults);
}
$zipsInPreviewDirectory = glob($allDocumentsPreviewDirectory . '*.zip');
if (count($zipsInPreviewDirectory)) {
    foreach ($zipsInPreviewDirectory as $zipInPreviewDirectory) {
        silentlyUnlink($zipInPreviewDirectory);
        if (file_exists($zipInPreviewDirectory)) {
Exemple #2
0
/**
 * Prints the xml string to the screen in such a way that Firefox will render it
 * as an XML tree (useful for debugging xml)
 * WARNING! To get Firefox to render it as an XML tree it must significantly mangle
 * the XML. Read the code and understand the replacements.
*/
function displayXmlString($xmlString, $withFilter = true)
{
    if ($withFilter) {
        if (substr(trim($xmlString), 0, 1) != '<') {
            $xmlString = file_get_contents($xmlString);
        }
        $xmlString = removeXmlDeclaration($xmlString);
        $xmlString = trim($xmlString);
        $xmlString = str_replace('xmlns', 'xmlnamespace', $xmlString);
        $xmlString = str_replace(':', '-colon-', $xmlString);
        $xmlString = str_replace('<!--', 'DOCVERT-XML-START-COMMENT', $xmlString);
        $xmlString = str_replace('-->', 'DOCVERT-XML-END-COMMENT', $xmlString);
        $xmlString = str_replace('--', '-hyphen-hyphen-', $xmlString);
        $xmlString = str_replace('DOCVERT-XML-START-COMMENT', '<!--', $xmlString);
        $xmlString = str_replace('DOCVERT-XML-END-COMMENT', '-->', $xmlString);
        $xmlString = preg_replace("/<!([^>]*?)>/si", "<!-- \\1 -->", $xmlString);
        $xmlString = characterEntityToNCR($xmlString);
        $xmlString = '<root>DOCVERT NOTE: This document has been changed in order to display as an XML tree. A root node has been added, colons have been changed to "-colon-" and XML namespaces (xmlns) have been changed to "xmlnamespace". More changes have been made, see ~core/lib.php and displayXmlString() for the specifics. ' . "\n" . $xmlString . "\n" . '</root>';
    }
    header('Content-type: text/xml');
    die($xmlString);
}