Пример #1
0
    $xml = addslashes(htmlentities(str_replace("\n", "
", $xmlNode->ownerDocument->saveXML($xmlNode))));
    // Loads the template into a single string
    $template = mxUtils::readFile("template.html");
    // Replaces the placeholder in the template with the XML data
    // which is then parsed into the graph model. Note: In a production
    // environment you should use a template engine instead.
    $page = str_replace("%graph%", $xml, $template);
    // Makes sure there is no caching on the client side
    header("Pragma: no-cache");
    // HTTP 1.0
    header("Cache-control: private, no-cache, no-store");
    header("Expires: 0");
    echo $page;
}
// Uses a local font so that all examples work on all platforms. This can be
// changed to vera on Mac or arial on Windows systems.
mxConstants::$DEFAULT_FONTFAMILY = "ttf/verah.ttf";
// If you can't get the fonts to render try using one of the following:
//mxConstants::$DEFAULT_FONTFAMILY = "C:\WINDOWS\Fonts\arial.ttf";
//mxConstants::$DEFAULT_FONTFAMILY = "verah"; putenv("GDFONTPATH=".realpath("./ttf"));
//mxConstants::$TTF_ENABLED = false;
// Handles save image request
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $xml = urldecode($_POST["xml"]);
    // Creates a PNG representation of the file
    $image = mxGraphViewImageReader::convert($xml, "#FFFFFF");
    header("Content-Type: image/png");
    echo mxUtils::encodeImage($image);
} else {
    main();
}
Пример #2
0
        $model->add($parent, $e1, 0);
    } catch (Exception $e) {
        $model->endUpdate();
        throw $e;
    }
    $model->endUpdate();
    $doc = mxUtils::createXmlDocument();
    $enc = new mxCodec($doc);
    $node = $enc->encode($model);
    $xml1 = $doc->saveXML($node);
    $doc = mxUtils::parseXml($xml1);
    $dec = new mxCodec($doc);
    $dec->decode($doc->documentElement, $model);
    $doc = mxUtils::createXmlDocument();
    $enc = new mxCodec($doc);
    $node = $enc->encode($model);
    $xml2 = $doc->saveXML($node);
    if ($xml1 == $xml2) {
        echo "Test Passed: " . htmlentities($xml1);
    } else {
        echo "Test Failed: <br>xml1=" . htmlentities($xml1) . "<br>xml2=" . htmlentities($xml2);
    }
}
// Uses a local font so that all examples work on all platforms. This can be
// changed to vera on Mac or arial on Windows systems.
mxConstants::$DEFAULT_FONTFAMILY = "verah";
putenv("GDFONTPATH=" . realpath("../examples/ttf"));
// If you can't get the fonts to render try using one of the following:
//mxConstants::$DEFAULT_FONTFAMILY = "C:\WINDOWS\Fonts\arial.ttf";
//mxConstants::$TTF_ENABLED = false;
main();