mxgraph 开发笔记

http://www.mxgraph.com/mxgraph.html

http://10.224.37.192/mxgraph/javascript/examples/grapheditor/www/index.php?filename=/tmp/zhouyu.xml


index.php

<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]-->
<!DOCTYPE html>
<html>
<head>
    <title>Graph Editor</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="styles/grapheditor.css">
        <script type="text/javascript">
                // Public global variables
                var MAX_REQUEST_SIZE = 10485760;
                var MAX_WIDTH = 6000;
                var MAX_HEIGHT = 6000;

                // URLs for save and export
                var EXPORT_URL = '/export.php';
                var SAVE_URL = '/save.php';
                var OPEN_URL = '/open.php';
                var RESOURCES_PATH = 'resources';
                var RESOURCE_BASE = RESOURCES_PATH + '/grapheditor';
                var STENCIL_PATH = 'stencils';
                var IMAGE_PATH = 'images';
                var STYLE_PATH = 'styles';
                var CSS_PATH = 'styles';
                var OPEN_FORM = 'open.html';

                // Specifies connection mode for touch devices (at least one should be true)
                var tapAndHoldStartsConnection = true;
                var showConnectorImg = true;


                // Parses URL parameters. Supported parameters are:
                // - lang=xy: Specifies the language of the user interface.
                // - touch=1: Enables a touch-style user interface.
                // - storage=local: Enables HTML5 local storage.
                var urlParams = (function(url)
                {
                        var result = new Object();
                        var idx = url.lastIndexOf('?');

                        if (idx > 0)
                        {
                                var params = url.substring(idx + 1).split('&');

                                for (var i = 0; i < params.length; i++)
                                {
                                        idx = params[i].indexOf('=');

                                        if (idx > 0)
                                        {
                                                result[params[i].substring(0, idx)] = params[i].substring(idx + 1);
                                        }
                                }
                        }

                        return result;
                })(window.location.href);

                // Sets the base path, the UI language via URL param and configures the
                // supported languages to avoid 404s. The loading of all core language
                // resources is disabled as all required resources are in grapheditor.
                // properties. Note that in this example the loading of two resource
                // files (the special bundle and the default bundle) is disabled to
                // save a GET request. This requires that all resources be present in
                // the special bundle.
                mxLoadResources = false;
                mxBasePath = '../../../src';
                mxLanguage = urlParams['lang'];
                mxLanguages = ['de'];
        </script>
        <script type="text/javascript" src="../../../src/js/mxClient.js"></script>
        <script type="text/javascript" src="js/Editor.js"></script>
        <script type="text/javascript" src="js/Graph.js"></script>
        <script type="text/javascript" src="js/EditorUi.js"></script>
        <script type="text/javascript" src="js/Actions.js"></script>
        <script type="text/javascript" src="js/Menus.js"></script>
        <script type="text/javascript" src="js/Sidebar.js"></script>
        <script type="text/javascript" src="js/Toolbar.js"></script>
        <script type="text/javascript" src="js/Dialogs.js"></script>
        <script type="text/javascript" src="jscolor/jscolor.js"></script>
</head>
<body class="geEditor">
        <script type="text/javascript">
                // Extends EditorUi to update I/O action states
                (function()
                {
                        var editorUiInit = EditorUi.prototype.init;

                        EditorUi.prototype.init = function()
                        {
                                editorUiInit.apply(this, arguments);
                                this.actions.get('export').setEnabled(false);

                                // Updates action states which require a backend
                                if (!useLocalStorage)
                                {
                                        mxUtils.post(OPEN_URL, '', mxUtils.bind(this, function(req)
                                        {
                                                var enabled = true;
                                                this.actions.get('open').setEnabled(enabled || fileSupport);
                                                this.actions.get('import').setEnabled(enabled || fileSupport);
                                                this.actions.get('save').setEnabled(enabled);
                                                this.actions.get('saveAs').setEnabled(enabled);
                                                this.actions.get('export').setEnabled(enabled);
                                        }));
                                }
                        };
                })();
                ieditor = new Editor();
                var idoc = mxUtils.parseXml('<?PHP
                        $filename = $_GET['filename'];
                        if ( $filename != NULL && file_exists($filename)) {
                                $body = file_get_contents($filename);
                                print urldecode($body);
                        }
                 ?>');
                var inode = idoc.documentElement;
                ieditor.setGraphXml(inode);
                new EditorUi(ieditor);
        </script>
</body>
</html>

[root@slimqa192 www]# cat /var/www/html/save.php
<?php


$filename = $_POST["filename"];
$xml = $_POST["xml"];
if ($xml != null && $filename != null) {
        $fh=fopen("/tmp/${filename}","w");
        fputs($fh, stripslashes($xml));
        fclose($fh);
}


print "file saved to /tmp/${filename}!";


//phpinfo();
?>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值