function DynamicTreePlugins() {
    this.exportToPhp = function(node) {
        var ret = "";
        if (node) {
            if (node.childNodes) {
                node.href = node.href.replace(/'/g, "`");
                node.href = node.href.replace(/\\+$/g, "");
                node.text = node.text.replace(/'/g, "`");
                node.text = node.text.replace(/\\+$/g, "");
                ret += "?'?' => array('type'=>'folder', 'id'=>'?', 'name'=>'?', 'content'=>array(\n".format(
                    " ".repeat(4*node.getLevel()),
                    node.href, node.href, node.text
                );
                for (var i = 0; i < node.childNodes.length; ++i) {
                    ret += this.exportToPhp(node.childNodes[i]);
                }
                ret += "?))?\n".format(
                    " ".repeat(4*node.getLevel()),
                    node.isLast() ? "" : ","
                );
            } else {
                node.href = node.href.replace(/'/g, "`");
                node.href = node.href.replace(/\\+$/g, "");
                node.text = node.text.replace(/'/g, "`");
                node.text = node.text.replace(/\\+$/g, "");
                node.title = node.title.replace(/'/g, "`");
                node.title = node.title.replace(/\\+$/g, "");
                node.target = node.target.replace(/'/g, "`");
                node.target = node.target.replace(/\\+$/g, "");
                node.hreflang = node.hreflang.replace(/'/g, "`");
                node.hreflang = node.hreflang.replace(/\\+$/g, "");
                ret += "?'?' => array('type'=>'list', 'id'=>'?', 'name' => '?', 'sub_msg'=>'?', 'unsub_msg'=>'?', 'restrictions'=>'?', 'forwards'=>'?')?\n".format(" ".repeat(4*node.getLevel()), node.href, node.href, node.text, node.title, node.target, node.lang, node.hreflang, node.isLast() ? "" : ",");
            }
        } else {
            var nodes = this.tree.childNodes;
            ret += "$tree = array(\n";
            for (var i = 0; i < nodes.length; ++i) {
                ret += this.exportToPhp(nodes[i]);
            }
            ret += ");\n\n";
        }
        return ret;
    };
}

/* Repeat string n times */
if (!String.prototype.repeat) {
    String.prototype.repeat = function(n) {
        var ret = "";
        for (var i = 0; i < n; ++i) {
            ret += this;
        }
        return ret;
    };
}