]> git.mjollnir.org Git - s9y.git/commitdiff
Added directory tree view widget (JS) to the Media Selector
authorgarvinhicking <garvinhicking>
Thu, 6 Apr 2006 14:00:02 +0000 (14:00 +0000)
committergarvinhicking <garvinhicking>
Thu, 6 Apr 2006 14:00:02 +0000 (14:00 +0000)
24 files changed:
bundled-libs/YahooUI/treeview/YAHOO.js [new file with mode: 0644]
bundled-libs/YahooUI/treeview/license.txt [new file with mode: 0644]
bundled-libs/YahooUI/treeview/treeview.js [new file with mode: 0644]
deployment/serendipity_editor.js
docs/NEWS
include/admin/images.inc.php
include/functions.inc.php
include/functions_images.inc.php
serendipity_admin_image_selector.php
serendipity_editor.js
templates/default/treeview/lm.gif [new file with mode: 0644]
templates/default/treeview/lmh.gif [new file with mode: 0644]
templates/default/treeview/ln.gif [new file with mode: 0644]
templates/default/treeview/loading.gif [new file with mode: 0644]
templates/default/treeview/lp.gif [new file with mode: 0644]
templates/default/treeview/lph.gif [new file with mode: 0644]
templates/default/treeview/screen.css [new file with mode: 0644]
templates/default/treeview/tm.gif [new file with mode: 0644]
templates/default/treeview/tmh.gif [new file with mode: 0644]
templates/default/treeview/tn.gif [new file with mode: 0644]
templates/default/treeview/tp.gif [new file with mode: 0644]
templates/default/treeview/tph.gif [new file with mode: 0644]
templates/default/treeview/tree.css [new file with mode: 0644]
templates/default/treeview/vline.gif [new file with mode: 0644]

diff --git a/bundled-libs/YahooUI/treeview/YAHOO.js b/bundled-libs/YahooUI/treeview/YAHOO.js
new file mode 100644 (file)
index 0000000..33e3ff4
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+Copyright (c) 2006 Yahoo! Inc. All rights reserved.
+version 0.9.0
+*/
+
+/**
+ * @class The Yahoo global namespace
+ */
+var YAHOO = function() {
+
+    return {
+
+        /**
+         * Yahoo presentation platform utils namespace
+         */
+        util: {},
+
+        /**
+         * Yahoo presentation platform widgets namespace
+         */
+        widget: {},
+
+        /**
+         * Yahoo presentation platform examples namespace
+         */
+        example: {},
+
+        /**
+         * Returns the namespace specified and creates it if it doesn't exist
+         *
+         * YAHOO.namespace("property.package");
+         * YAHOO.namespace("YAHOO.property.package");
+         *
+         * Either of the above would create YAHOO.property, then
+         * YAHOO.property.package
+         *
+         * @param  {String} sNameSpace String representation of the desired
+         *                             namespace
+         * @return {Object}            A reference to the namespace object
+         */
+        namespace: function( sNameSpace ) {
+
+            if (!sNameSpace || !sNameSpace.length) {
+                return null;
+            }
+
+            var levels = sNameSpace.split(".");
+
+            var currentNS = YAHOO;
+
+            // YAHOO is implied, so it is ignored if it is included
+            for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
+                currentNS[levels[i]] = currentNS[levels[i]] || {};
+                currentNS = currentNS[levels[i]];
+            }
+
+            return currentNS;
+
+        }
+    };
+
+} ();
+
diff --git a/bundled-libs/YahooUI/treeview/license.txt b/bundled-libs/YahooUI/treeview/license.txt
new file mode 100644 (file)
index 0000000..03ff644
--- /dev/null
@@ -0,0 +1,35 @@
+Software License Agreement (BSD License)\r
+\r
+Copyright (c) 2006, Yahoo! Inc.\r
+All rights reserved.\r
+\r
+Redistribution and use of this software in source and binary forms, with \r
+or without modification, are permitted provided that the following \r
+conditions are met:\r
+\r
+* Redistributions of source code must retain the above\r
+  copyright notice, this list of conditions and the\r
+  following disclaimer.\r
+\r
+* Redistributions in binary form must reproduce the above\r
+  copyright notice, this list of conditions and the\r
+  following disclaimer in the documentation and/or other\r
+  materials provided with the distribution.\r
+\r
+* Neither the name of Yahoo! Inc. nor the names of its\r
+  contributors may be used to endorse or promote products\r
+  derived from this software without specific prior\r
+  written permission of Yahoo! Inc.\r
+\r
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS \r
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED \r
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A \r
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER \r
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, \r
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, \r
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \r
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF \r
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING \r
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS \r
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
diff --git a/bundled-libs/YahooUI/treeview/treeview.js b/bundled-libs/YahooUI/treeview/treeview.js
new file mode 100644 (file)
index 0000000..d80b9ab
--- /dev/null
@@ -0,0 +1,1490 @@
+/*
+Copyright (c) 2006 Yahoo! Inc. All rights reserved.
+version 0.9.0
+*/
+
+/**
+ * @class Contains the tree view metadata and the root node.  This is an
+ * ordered tree; child nodes will be displayed in the order created, and
+ * there currently is no way to change this.
+ *
+ * @constructor
+ * @todo prune, graft, reload, repaint
+ * @param {string} id The id of the element that the tree will be inserted
+ * into.
+ */
+YAHOO.widget.TreeView = function(id) {
+       if (id) { this.init(id); }
+};
+
+YAHOO.widget.TreeView.prototype = {
+
+    /**
+     * The id of tree container element
+     *
+     * @type String
+     */
+    id: null,
+
+    /**
+     * Flat collection of all nodes in this tree
+     *
+     * @type YAHOO.widget.Node[]
+     * @private
+     */
+    _nodes: null,
+
+    /**
+     * We lock the tree control while waiting for the dynamic loader to return
+     *
+     * @type boolean
+     */
+    locked: false,
+
+    /**
+     * The animation to use for expanding children, if any
+     *
+     * @type string
+     * @private
+     */
+    _expandAnim: null,
+
+    /**
+     * The animation to use for collapsing children, if any
+     *
+     * @type string
+     * @private
+     */
+    _collapseAnim: null,
+
+    /**
+     * The current number of animations that are executing
+     *
+     * @type int
+     * @private
+     */
+    _animCount: 0,
+
+    /**
+     * The maximum number of animations to run at one time.
+     *
+     * @type int
+     */
+    _maxAnim: 2,
+
+    /**
+     * Sets up the animation for expanding children
+     *
+     * @param {string} the type of animation (acceptable constants in YAHOO.widget.TVAnim)
+     */
+    setExpandAnim: function(type) {
+        if (YAHOO.widget.TVAnim.isValid(type)) {
+            this._expandAnim = type;
+        }
+    },
+
+    /**
+     * Sets up the animation for collapsing children
+     *
+     * @param {string} the type of animation (acceptable constants in YAHOO.widget.TVAnim)
+     */
+    setCollapseAnim: function(type) {
+        if (YAHOO.widget.TVAnim.isValid(type)) {
+            this._collapseAnim = type;
+        }
+    },
+
+    /**
+     * Perform the expand animation if configured, or just show the
+     * element if not configured or too many animations are in progress
+     *
+     * @param el {HTMLElement} the element to animate
+     * @return {boolean} true if animation could be invoked, false otherwise
+     */
+    animateExpand: function(el) {
+
+        if (this._expandAnim && this._animCount < this._maxAnim) {
+            // this.locked = true;
+            var tree = this;
+            var a = YAHOO.widget.TVAnim.getAnim(this._expandAnim, el,
+                            function() { tree.expandComplete(); });
+            if (a) {
+                ++this._animCount;
+                a.animate();
+            }
+
+            return true;
+        }
+
+        return false;
+    },
+
+    /**
+     * Perform the collapse animation if configured, or just show the
+     * element if not configured or too many animations are in progress
+     *
+     * @param el {HTMLElement} the element to animate
+     * @return {boolean} true if animation could be invoked, false otherwise
+     */
+    animateCollapse: function(el) {
+
+        if (this._collapseAnim && this._animCount < this._maxAnim) {
+            // this.locked = true;
+            var tree = this;
+            var a = YAHOO.widget.TVAnim.getAnim(this._collapseAnim, el,
+                            function() { tree.collapseComplete(); });
+            if (a) {
+                ++this._animCount;
+                a.animate();
+            }
+
+            return true;
+        }
+
+        return false;
+    },
+
+    /**
+     * Function executed when the expand animation completes
+     */
+    expandComplete: function() {
+        --this._animCount;
+        // this.locked = false;
+    },
+
+    /**
+     * Function executed when the collapse animation completes
+     */
+    collapseComplete: function() {
+        --this._animCount;
+        // this.locked = false;
+    },
+
+    /**
+     * Initializes the tree
+     *
+     * @parm {string} id the id of the element that will hold the tree
+     * @private
+     */
+    init: function(id) {
+
+        this.id = id;
+        this._nodes = new Array();
+
+        // store a global reference
+        YAHOO.widget.TreeView.trees[id] = this;
+
+        // Set up the root node
+        this.root = new YAHOO.widget.RootNode(this);
+
+
+    },
+
+    /**
+     * Renders the tree boilerplate and visible nodes
+     */
+    draw: function() {
+        var html = this.root.getHtml();
+        document.getElementById(this.id).innerHTML = html;
+        this.firstDraw = false;
+    },
+
+    /**
+     * Nodes register themselves with the tree instance when they are created.
+     *
+     * @param node {YAHOO.widget.Node} the node to register
+     * @private
+     */
+    regNode: function(node) {
+        this._nodes[node.index] = node;
+    },
+
+    /**
+     * Returns the root node of this tree
+     *
+     * @return {YAHOO.widget.Node} the root node
+     */
+    getRoot: function() {
+        return this.root;
+    },
+
+    /**
+     * Configures this tree to dynamically load all child data
+     *
+     * @param {function} fnDataLoader the function that will be called to get the data
+     */
+    setDynamicLoad: function(fnDataLoader) {
+        // this.root.dataLoader = fnDataLoader;
+        // this.root._dynLoad = true;
+        this.root.setDynamicLoad(fnDataLoader);
+    },
+
+    /**
+     * Expands all child nodes.  Note: this conflicts with the "multiExpand"
+     * node property.  If expand all is called in a tree with nodes that
+     * do not allow multiple siblings to be displayed, only the last sibling
+     * will be expanded.
+     */
+    expandAll: function() {
+        if (!this.locked) {
+            this.root.expandAll();
+        }
+    },
+
+    /**
+     * Collapses all expanded child nodes in the entire tree.
+     */
+    collapseAll: function() {
+        if (!this.locked) {
+            this.root.collapseAll();
+        }
+    },
+
+    /**
+     * Returns a node in the tree that has the specified index (this index
+     * is created internally, so this function probably will only be used
+     * in html generated for a given node.)
+     *
+     * @param {int} nodeIndex the index of the node wanted
+     * @return {YAHOO.widget.Node} the node with index=nodeIndex, null if no match
+     */
+    getNodeByIndex: function(nodeIndex) {
+        var n = this._nodes[nodeIndex];
+        return (n) ? n : null;
+    },
+
+    /**
+     * Returns a node that has a matching property and value in the data
+     * object that was passed into its constructor.  Provides a flexible
+     * way for the implementer to get a particular node.
+     *
+     * @param {object} property the property to search (usually a string)
+     * @param {object} value the value we want to find (usuall an int or string)
+     * @return {YAHOO.widget.Node} the matching node, null if no match
+     */
+    getNodeByProperty: function(property, value) {
+        for (var i in this._nodes) {
+            var n = this._nodes[i];
+            if (n.data && value == n.data[property]) {
+                return n;
+            }
+        }
+
+        return null;
+    },
+
+    /**
+     * Abstract method that is executed when a node is expanded
+     *
+     * @param node {YAHOO.widget.Node} the node that was expanded
+     */
+    onExpand: function(node) { },
+
+    /**
+     * Abstract method that is executed when a node is collapsed
+     *
+     * @param node {YAHOO.widget.Node} the node that was collapsed.
+     */
+    onCollapse: function(node) { }
+
+};
+
+/**
+ * Global cache of tree instances
+ *
+ * @type Array
+ * @private
+ */
+YAHOO.widget.TreeView.trees = [];
+
+/**
+ * Global method for getting a tree by its id.  Used in the generated
+ * tree html.
+ *
+ * @param treeId {String} the id of the tree instance
+ * @return {TreeView} the tree instance requested, null if not found.
+ */
+YAHOO.widget.TreeView.getTree = function(treeId) {
+       var t = YAHOO.widget.TreeView.trees[treeId];
+       return (t) ? t : null;
+};
+
+YAHOO.widget.TreeView.nodeCount = 0;
+
+/**
+ * Global method for getting a node by its id.  Used in the generated
+ * tree html.
+ *
+ * @param treeId {String} the id of the tree instance
+ * @param nodeIndex {String} the index of the node to return
+ * @param return {YAHOO.widget.Node} the node instance requested, null if not found
+ */
+YAHOO.widget.TreeView.getNode = function(treeId, nodeIndex) {
+       var t = YAHOO.widget.TreeView.getTree(treeId);
+       return (t) ? t.getNodeByIndex(nodeIndex) : null;
+};
+
+/**
+ * Adds an event.  Replace with event manager when available
+ *
+ * @param el the elment to bind the handler to
+ * @param {string} sType the type of event handler
+ * @param {function} fn the callback to invoke
+ * @param {boolean} capture if true event is capture phase, bubble otherwise
+ */
+YAHOO.widget.TreeView.addHandler = function (el, sType, fn, capture) {
+       capture = (capture) ? true : false;
+       if (el.addEventListener) {
+               el.addEventListener(sType, fn, capture);
+       } else if (el.attachEvent) {
+               el.attachEvent("on" + sType, fn);
+       } else {
+               el["on" + sType] = fn;
+       }
+};
+
+/**
+ * Attempts to preload the images defined in the styles used to draw the tree by
+ * rendering off-screen elements that use the styles.
+ */
+YAHOO.widget.TreeView.preload = function() {
+
+       var styles = [
+               "ygtvtn",
+               "ygtvtm",
+               "ygtvtmh",
+               "ygtvtp",
+               "ygtvtph",
+               "ygtvln",
+               "ygtvlm",
+               "ygtvlmh",
+               "ygtvlp",
+               "ygtvlph",
+               "ygtvloading"
+               ];
+
+       var sb = [];
+
+       for (var i = 0; i < styles.length; ++i) {
+               sb[sb.length] = '<span class="' + styles[i] + '">&nbsp;</span>';
+       }
+
+       var f = document.createElement("div");
+       var s = f.style;
+       s.position = "absolute";
+       s.top = "-1000px";
+       s.left = "-1000px";
+       f.innerHTML = sb.join("");
+
+       document.body.appendChild(f);
+};
+
+YAHOO.widget.TreeView.addHandler(window,
+                "load", YAHOO.widget.TreeView.preload);
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * @class Abstract node class
+ * @constructor
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {YAHOO.widget.Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ */
+YAHOO.widget.Node = function(oData, oParent, expanded) {
+       if (oParent) { this.init(oData, oParent, expanded); }
+};
+
+YAHOO.widget.Node.prototype = {
+
+    /**
+     * The index for this instance obtained from global counter in YAHOO.widget.TreeView.
+     *
+     * @type int
+     */
+    index: 0,
+
+    /**
+     * This node's child node collection.
+     *
+     * @type YAHOO.widget.Node[]
+     */
+    children: null,
+
+    /**
+     * Tree instance this node is part of
+     *
+     * @type YAHOO.widget.TreeView
+     */
+    tree: null,
+
+    /**
+     * The data linked to this node.  This can be any object or primitive
+     * value, and the data can be used in getNodeHtml().
+     *
+     * @type object
+     */
+    data: null,
+
+    /**
+     * Parent node
+     *
+     * @type YAHOO.widget.Node
+     */
+    parent: null,
+
+    /**
+     * The depth of this node.  We start at -1 for the root node.
+     *
+     * @type int
+     */
+    depth: -1,
+
+    /**
+     * The href for the node's label.  If one is not specified, the href will
+     * be set so that it toggles the node.
+     *
+     * @type string
+     */
+    href: null,
+
+    /**
+     * The label href target, defaults to current window
+     *
+     * @type string
+     */
+    target: "_self",
+
+    /**
+     * The node's expanded/collapsed state
+     *
+     * @type boolean
+     */
+    expanded: false,
+
+    /**
+     * Can multiple children be expanded at once?
+     *
+     * @type boolean
+     */
+    multiExpand: true,
+
+    /**
+     * Should we render children for a collapsed node?  It is possible that the
+     * implementer will want to render the hidden data...  @todo verify that we
+     * need this, and implement it if we do.
+     *
+     * @type boolean
+     */
+    renderHidden: false,
+
+    /**
+     * Flag that is set to true the first time this node's children are rendered.
+     *
+     * @type boolean
+     */
+    childrenRendered: false,
+
+    /**
+     * This node's previous sibling
+     *
+     * @type YAHOO.widget.Node
+     */
+    previousSibling: null,
+
+    /**
+     * This node's next sibling
+     *
+     * @type YAHOO.widget.Node
+     */
+    nextSibling: null,
+
+    /**
+     * We can set the node up to call an external method to get the child
+     * data dynamically.
+     *
+     * @type boolean
+     * @private
+     */
+    _dynLoad: false,
+
+    /**
+     * Function to execute when we need to get this node's child data.
+     *
+     * @type function
+     */
+    dataLoader: null,
+
+    /**
+     * This is true for dynamically loading nodes while waiting for the
+     * callback to return.
+     *
+     * @type boolean
+     */
+    isLoading: false,
+
+    /**
+     * The toggle/branch icon will not show if this is set to false.  This
+     * could be useful if the implementer wants to have the child contain
+     * extra info about the parent, rather than an actual node.
+     *
+     * @type boolean
+     */
+    hasIcon: true,
+
+    /**
+     * Initializes this node, gets some of the properties from the parent
+     *
+     * @param oData {object} a string or object containing the data that will
+     * be used to render this node
+     * @param oParent {YAHOO.widget.Node} this node's parent node
+     * @param expanded {boolean} the initial expanded/collapsed state
+     */
+    init: function(oData, oParent, expanded) {
+        this.data              = oData;
+        this.children  = [];
+        this.index             = YAHOO.widget.TreeView.nodeCount;
+        ++YAHOO.widget.TreeView.nodeCount;
+        this.expanded  = expanded;
+
+        // oParent should never be null except when we create the root node.
+        if (oParent) {
+            this.tree                  = oParent.tree;
+            this.parent                        = oParent;
+            this.href                  = "javascript:" + this.getToggleLink();
+            this.depth                 = oParent.depth + 1;
+            this.multiExpand   = oParent.multiExpand;
+
+            oParent.appendChild(this);
+        }
+    },
+
+    /**
+     * Appends a node to the child collection.
+     *
+     * @param node {YAHOO.widget.Node} the new node
+     * @return {YAHOO.widget.Node} the child node
+     * @private
+     */
+    appendChild: function(node) {
+        if (this.hasChildren()) {
+            var sib = this.children[this.children.length - 1];
+            sib.nextSibling = node;
+            node.previousSibling = sib;
+        }
+
+        this.tree.regNode(node);
+        this.children[this.children.length] = node;
+        return node;
+
+    },
+
+    /**
+     * Returns a node array of this node's siblings, null if none.
+     *
+     * @return YAHOO.widget.Node[]
+     */
+    getSiblings: function() {
+        return this.parent.children;
+    },
+
+    /**
+     * Shows this node's children
+     */
+    showChildren: function() {
+        if (!this.tree.animateExpand(this.getChildrenEl())) {
+            if (this.hasChildren()) {
+                this.getChildrenEl().style.display = "";
+            }
+        }
+    },
+
+    /**
+     * Hides this node's children
+     */
+    hideChildren: function() {
+
+        if (!this.tree.animateCollapse(this.getChildrenEl())) {
+            this.getChildrenEl().style.display = "none";
+        }
+    },
+
+    /**
+     * Returns the id for this node's container div
+     *
+     * @return {string} the element id
+     */
+    getElId: function() {
+        return "ygtv" + this.index;
+    },
+
+    /**
+     * Returns the id for this node's children div
+     *
+     * @return {string} the element id for this node's children div
+     */
+    getChildrenElId: function() {
+        return "ygtvc" + this.index;
+    },
+
+    /**
+     * Returns the id for this node's toggle element
+     *
+     * @return {string} the toggel element id
+     */
+    getToggleElId: function() {
+        return "ygtvt" + this.index;
+    },
+
+    /**
+     * Returns this node's container html element
+     *
+     * @return {Object} the container html element
+     */
+    getEl: function() {
+        return document.getElementById(this.getElId());
+    },
+
+    /**
+     * Returns the div that was generated for this node's children
+     *
+     * @return {Object} this node's children div
+     */
+    getChildrenEl: function() {
+        return document.getElementById(this.getChildrenElId());
+    },
+
+    /**
+     * Returns the element that is being used for this node's toggle.
+     *
+     * @return {Object} this node's toggel html element
+     */
+    getToggleEl: function() {
+        return document.getElementById(this.getToggleElId());
+    },
+
+    /**
+     * Generates the link that will invoke this node's toggle method
+     *
+     * @return {string} the javascript url for toggling this node
+     */
+    getToggleLink: function() {
+        return "YAHOO.widget.TreeView.getNode(\'" + this.tree.id + "\'," +
+            this.index + ").toggle()";
+    },
+
+    /**
+     * Hides this nodes children (creating them if necessary), changes the
+     * toggle style.
+     */
+    collapse: function() {
+        // Only collapse if currently expanded
+        if (!this.expanded) { return; }
+
+        if (!this.getEl()) {
+            this.expanded = false;
+            return;
+        }
+
+        // hide the child div
+        this.hideChildren();
+        this.expanded = false;
+
+        if (this.hasIcon) {
+            this.getToggleEl().className = this.getStyle();
+        }
+
+        // fire the collapse event handler
+        this.tree.onCollapse(this);
+    },
+
+    /**
+     * Shows this nodes children (creating them if necessary), changes the
+     * toggle style, and collapses its siblings if multiExpand is not set.
+     */
+    expand: function() {
+        // Only expand if currently collapsed.
+        if (this.expanded) { return; }
+
+        if (!this.getEl()) {
+            this.expanded = true;
+            return;
+        }
+
+        if (! this.childrenRendered) {
+            this.getChildrenEl().innerHTML = this.renderChildren();
+        }
+
+        this.expanded = true;
+        if (this.hasIcon) {
+            this.getToggleEl().className = this.getStyle();
+        }
+
+        // We do an extra check for children here because the lazy
+        // load feature can expose nodes that have no children.
+
+        // if (!this.hasChildren()) {
+        if (this.isLoading) {
+            this.expanded = false;
+            return;
+        }
+
+        if (! this.multiExpand) {
+            var sibs = this.getSiblings();
+            for (var i=0; i<sibs.length; ++i) {
+                if (sibs[i] != this && sibs[i].expanded) {
+                    sibs[i].collapse();
+                }
+            }
+        }
+
+        this.showChildren();
+
+        // fire the expand event handler
+        this.tree.onExpand(this);
+    },
+
+    /**
+     * Returns the css style name for the toggle
+     *
+     * @return {string} the css class for this node's toggle
+     */
+    getStyle: function() {
+        if (this.isLoading) {
+            return "ygtvloading";
+        } else {
+            // location top or bottom, middle nodes also get the top style
+            var loc = (this.nextSibling) ? "t" : "l";
+
+            // type p=plus(expand), m=minus(collapase), n=none(no children)
+            var type = "n";
+            if (this.hasChildren(true) || this.isDynamic()) {
+                type = (this.expanded) ? "m" : "p";
+            }
+
+            return "ygtv" + loc + type;
+        }
+    },
+
+    /**
+     * Returns the hover style for the icon
+     * @return {string} the css class hover state
+     */
+    getHoverStyle: function() {
+        var s = this.getStyle();
+        if (this.hasChildren(true) && !this.isLoading) {
+            s += "h";
+        }
+        return s;
+    },
+
+    /**
+     * Recursively expands all of this node's children.
+     */
+    expandAll: function() {
+        for (var i=0;i<this.children.length;++i) {
+            var c = this.children[i];
+            if (c.isDynamic()) {
+                alert("Not supported (lazy load + expand all)");
+                break;
+            } else if (! c.multiExpand) {
+                alert("Not supported (no multi-expand + expand all)");
+                break;
+            } else {
+                c.expand();
+                c.expandAll();
+            }
+        }
+    },
+
+    /**
+     * Recursively collapses all of this node's children.
+     */
+    collapseAll: function() {
+        for (var i=0;i<this.children.length;++i) {
+            this.children[i].collapse();
+            this.children[i].collapseAll();
+        }
+    },
+
+    /**
+     * Configures this node for dynamically obtaining the child data
+     * when the node is first expanded.
+     *
+     * @param fmDataLoader {function} the function that will be used to get the data.
+     */
+    setDynamicLoad: function(fnDataLoader) {
+        this.dataLoader = fnDataLoader;
+        this._dynLoad = true;
+    },
+
+    /**
+     * Evaluates if this node is the root node of the tree
+     *
+     * @return {boolean} true if this is the root node
+     */
+    isRoot: function() {
+        return (this == this.tree.root);
+    },
+
+    /**
+     * Evaluates if this node's children should be loaded dynamically.  Looks for
+     * the property both in this instance and the root node.  If the tree is
+     * defined to load all children dynamically, the data callback function is
+     * defined in the root node
+     *
+     * @return {boolean} true if this node's children are to be loaded dynamically
+     */
+    isDynamic: function() {
+        var lazy = (!this.isRoot() && (this._dynLoad || this.tree.root._dynLoad));
+        return lazy;
+    },
+
+    /**
+     * Checks if this node has children.  If this node is lazy-loading and the
+     * children have not been rendered, we do not know whether or not there
+     * are actual children.  In most cases, we need to assume that there are
+     * children (for instance, the toggle needs to show the expandable
+     * presentation state).  In other times we want to know if there are rendered
+     * children.  For the latter, "checkForLazyLoad" should be false.
+     *
+     * @param checkForLazyLoad {boolean} should we check for unloaded children?
+     * @return {boolean} true if this has children or if it might and we are
+     * checking for this condition.
+     */
+    hasChildren: function(checkForLazyLoad) {
+        return ( this.children.length > 0 ||
+                (checkForLazyLoad && this.isDynamic() && !this.childrenRendered) );
+    },
+
+    /**
+     * Expands if node is collapsed, collapses otherwise.
+     */
+    toggle: function() {
+        if (!this.tree.locked && ( this.hasChildren(true) || this.isDynamic()) ) {
+            if (this.expanded) { this.collapse(); } else { this.expand(); }
+        }
+    },
+
+    /**
+     * Returns the markup for this node and its children.
+     *
+     * @return {string} the markup for this node and its expanded children.
+     */
+    getHtml: function() {
+        var sb = [];
+        sb[sb.length] = '<div class="ygtvitem" id="' + this.getElId() + '">';
+        sb[sb.length] = this.getNodeHtml();
+        sb[sb.length] = this.getChildrenHtml();
+        sb[sb.length] = '</div>';
+        return sb.join("");
+    },
+
+    /**
+     * Called when first rendering the tree.  We always build the div that will
+     * contain this nodes children, but we don't render the children themselves
+     * unless this node is expanded.
+     *
+     * @return {string} the children container div html and any expanded children
+     * @private
+     */
+    getChildrenHtml: function() {
+        var sb = [];
+        sb[sb.length] = '<div class="ygtvchildren"';
+        sb[sb.length] = ' id="' + this.getChildrenElId() + '"';
+        if (!this.expanded) {
+            sb[sb.length] = ' style="display:none;"';
+        }
+        sb[sb.length] = '>';
+
+        // Don't render the actual child node HTML unless this node is expanded.
+        if (this.hasChildren(true) && this.expanded) {
+            sb[sb.length] = this.renderChildren();
+        }
+
+        sb[sb.length] = '</div>';
+
+        return sb.join("");
+    },
+
+    /**
+     * Generates the markup for the child nodes.  This is not done until the node
+     * is expanded.
+     *
+     * @return {string} the html for this node's children
+     * @private
+     */
+    renderChildren: function() {
+
+
+        var node = this;
+
+        if (this.isDynamic() && !this.childrenRendered) {
+            this.isLoading = true;
+            this.tree.locked = true;
+
+            if (this.dataLoader) {
+                setTimeout(
+                    function() {
+                        node.dataLoader(node,
+                            function() {
+                                node.loadComplete();
+                            });
+                    }, 10);
+
+            } else if (this.tree.root.dataLoader) {
+
+                setTimeout(
+                    function() {
+                        node.tree.root.dataLoader(node,
+                            function() {
+                                node.loadComplete();
+                            });
+                    }, 10);
+
+            } else {
+                return "Error: data loader not found or not specified.";
+            }
+
+            return "";
+
+        } else {
+            return this.completeRender();
+        }
+    },
+
+    /**
+     * Called when we know we have all the child data.
+     * @return {string} children html
+     */
+    completeRender: function() {
+        var sb = [];
+
+        for (var i=0; i < this.children.length; ++i) {
+            sb[sb.length] = this.children[i].getHtml();
+        }
+
+        this.childrenRendered = true;
+
+        return sb.join("");
+    },
+
+    /**
+     * Load complete is the callback function we pass to the data provider
+     * in dynamic load situations.
+     */
+    loadComplete: function() {
+        this.getChildrenEl().innerHTML = this.completeRender();
+        this.isLoading = false;
+        this.expand();
+        this.tree.locked = false;
+    },
+
+    /**
+     * Returns this node's ancestor at the specified depth.
+     *
+     * @param {int} depth the depth of the ancestor.
+     * @return {YAHOO.widget.Node} the ancestor
+     */
+    getAncestor: function(depth) {
+        if (depth >= this.depth || depth < 0)  {
+            return null;
+        }
+
+        var p = this.parent;
+
+        while (p.depth > depth) {
+            p = p.parent;
+        }
+
+        return p;
+    },
+
+    /**
+     * Returns the css class for the spacer at the specified depth for
+     * this node.  If this node's ancestor at the specified depth
+     * has a next sibling the presentation is different than if it
+     * does not have a next sibling
+     *
+     * @param {int} depth the depth of the ancestor.
+     * @return {string} the css class for the spacer
+     */
+    getDepthStyle: function(depth) {
+        return (this.getAncestor(depth).nextSibling) ?
+            "ygtvdepthcell" : "ygtvblankdepthcell";
+    },
+
+    /**
+     * Get the markup for the node.  This is designed to be overrided so that we can
+     * support different types of nodes.
+     *
+     * @return {string} the html for this node
+     */
+    getNodeHtml: function() {
+        return "";
+    }
+
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * @class A custom YAHOO.widget.Node that handles the unique nature of
+ * the virtual, presentationless root node.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ */
+YAHOO.widget.RootNode = function(oTree) {
+       // Initialize the node with null params.  The root node is a
+       // special case where the node has no presentation.  So we have
+       // to alter the standard properties a bit.
+       this.init(null, null, true);
+
+       /**
+        * For the root node, we get the tree reference from as a param
+        * to the constructor instead of from the parent element.
+        *
+        * @type YAHOO.widget.TreeView
+        */
+       this.tree = oTree;
+};
+YAHOO.widget.RootNode.prototype = new YAHOO.widget.Node();
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.RootNode.prototype.getNodeHtml = function() {
+       return "";
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * @class The default node presentation.  The first parameter should be
+ * either a string that will be used as the node's label, or an object
+ * that has a string propery called label.  By default, the clicking the
+ * label will toggle the expanded/collapsed state of the node.  By
+ * changing the href property of the instance, this behavior can be
+ * changed so that the label will go to the specified href.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {YAHOO.widget.Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ */
+YAHOO.widget.TextNode = function(oData, oParent, expanded) {
+       if (oParent) {
+               this.init(oData, oParent, expanded);
+               this.setUpLabel(oData);
+       }
+};
+
+YAHOO.widget.TextNode.prototype = new YAHOO.widget.Node();
+
+/**
+ * The CSS class for the label href.  Defaults to ygtvlabel, but can be
+ * overridden to provide a custom presentation for a specific node.
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.labelStyle = "ygtvlabel";
+
+/**
+ * The derived element id of the label for this node
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.labelElId = null;
+
+/**
+ * The text for the label.  It is assumed that the oData parameter will
+ * either be a string that will be used as the label, or an object that
+ * has a property called "label" that we will use.
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.label = null;
+
+/**
+ * Sets up the node label
+ *
+ * @param oData string containing the label, or an object with a label property
+ */
+YAHOO.widget.TextNode.prototype.setUpLabel = function(oData) {
+       if (typeof oData == "string") {
+               oData = { label: oData };
+       }
+       this.label = oData.label;
+
+       // update the link
+       if (oData.href) {
+               this.href = oData.href;
+       }
+
+       // set the target
+       if (oData.target) {
+               this.target = oData.target;
+       }
+
+       this.labelElId = "ygtvlabelel" + this.index;
+};
+
+/**
+ * Returns the label element
+ *
+ * @return {object} the element
+ */
+YAHOO.widget.TextNode.prototype.getLabelEl = function() {
+       return document.getElementById(this.labelElId);
+};
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.TextNode.prototype.getNodeHtml = function() {
+       var sb = new Array();
+
+       sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">';
+       sb[sb.length] = '<tr>';
+
+       for (i=0;i<this.depth;++i) {
+               // sb[sb.length] = '<td class="ygtvdepthcell">&nbsp;</td>';
+               sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '">&nbsp;</td>';
+       }
+
+       var getNode = 'YAHOO.widget.TreeView.getNode(\'' +
+                                       this.tree.id + '\',' + this.index + ')';
+
+       sb[sb.length] = '<td';
+       // sb[sb.length] = ' onselectstart="return false"';
+       sb[sb.length] = ' id="' + this.getToggleElId() + '"';
+       sb[sb.length] = ' class="' + this.getStyle() + '"';
+       if (this.hasChildren(true)) {
+               sb[sb.length] = ' onmouseover="this.className=';
+               sb[sb.length] = getNode + '.getHoverStyle()"';
+               sb[sb.length] = ' onmouseout="this.className=';
+               sb[sb.length] = getNode + '.getStyle()"';
+       }
+       sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '">&nbsp;';
+       sb[sb.length] = '</td>';
+       sb[sb.length] = '<td>';
+       sb[sb.length] = '<a';
+       sb[sb.length] = ' id="' + this.labelElId + '"';
+       sb[sb.length] = ' class="' + this.labelStyle + '"';
+       sb[sb.length] = ' href="' + this.href + '"';
+       sb[sb.length] = ' target="' + this.target + '"';
+       if (this.hasChildren(true)) {
+               sb[sb.length] = ' onmouseover="document.getElementById(\'';
+               sb[sb.length] = this.getToggleElId() + '\').className=';
+               sb[sb.length] = getNode + '.getHoverStyle()"';
+               sb[sb.length] = ' onmouseout="document.getElementById(\'';
+               sb[sb.length] = this.getToggleElId() + '\').className=';
+               sb[sb.length] = getNode + '.getStyle()"';
+       }
+       sb[sb.length] = ' >';
+       sb[sb.length] = this.label;
+       sb[sb.length] = '</a>';
+       sb[sb.length] = '</td>';
+       sb[sb.length] = '</tr>';
+       sb[sb.length] = '</table>';
+
+       return sb.join("");
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * @class menu-specific implementation that differs in that only one sibling
+ * can be expanded at a time.
+ * @extends YAHOO.widget.TextNode
+ * @constructor
+ */
+YAHOO.widget.MenuNode = function(oData, oParent, expanded) {
+       if (oParent) {
+               this.init(oData, oParent, expanded);
+               this.setUpLabel(oData);
+       }
+
+       // Menus usually allow only one branch to be open at a time.
+       this.multiExpand = false;
+
+};
+
+YAHOO.widget.MenuNode.prototype = new YAHOO.widget.TextNode();
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * @class This implementation takes either a string or object for the
+ * oData argument.  If is it a string, we will use it for the display
+ * of this node (and it can contain any html code).  If the parameter
+ * is an object, we look for a parameter called "html" that will be
+ * used for this node's display.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {YAHOO.widget.Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ * @param hasIcon {boolean} specifies whether or not leaf nodes should
+ * have an icon
+ */
+YAHOO.widget.HTMLNode = function(oData, oParent, expanded, hasIcon) {
+       if (oParent) {
+               this.init(oData, oParent, expanded);
+               this.initContent(oData, hasIcon);
+       }
+};
+
+YAHOO.widget.HTMLNode.prototype = new YAHOO.widget.Node();
+
+/**
+ * The CSS class for the label href.  Defaults to ygtvlabel, but can be
+ * overridden to provide a custom presentation for a specific node.
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.contentStyle = "ygtvhtml";
+
+/**
+ * The generated id that will contain the data passed in by the implementer.
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.contentElId = null;
+
+/**
+ * The HTML content to use for this node's display
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.content = null;
+
+/**
+ * Sets up the node label
+ *
+ * @param {object} html string or object containing a html field
+ * @param {boolean} hasIcon determines if the node will be rendered with an
+ * icon or not
+ */
+YAHOO.widget.HTMLNode.prototype.initContent = function(oData, hasIcon) {
+       if (typeof oData == "string") {
+               oData = { html: oData };
+       }
+
+       this.html = oData.html;
+       this.contentElId = "ygtvcontentel" + this.index;
+       this.hasIcon = hasIcon;
+};
+
+/**
+ * Returns the outer html element for this node's content
+ *
+ * @return {Object} the element
+ */
+YAHOO.widget.HTMLNode.prototype.getContentEl = function() {
+       return document.getElementById(this.contentElId);
+};
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.HTMLNode.prototype.getNodeHtml = function() {
+       var sb = new Array();
+
+       sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">';
+       sb[sb.length] = '<tr>';
+
+       for (i=0;i<this.depth;++i) {
+               sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '">&nbsp;</td>';
+       }
+
+       if (this.hasIcon) {
+               sb[sb.length] = '<td';
+               sb[sb.length] = ' id="' + this.getToggleElId() + '"';
+               sb[sb.length] = ' class="' + this.getStyle() + '"';
+               sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '">&nbsp;';
+               if (this.hasChildren(true)) {
+                       sb[sb.length] = ' onmouseover="this.className=';
+                       sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'';
+                       sb[sb.length] = this.tree.id + '\',' + this.index +  ').getHoverStyle()"';
+                       sb[sb.length] = ' onmouseout="this.className=';
+                       sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'';
+                       sb[sb.length] = this.tree.id + '\',' + this.index +  ').getStyle()"';
+               }
+               sb[sb.length] = '</td>';
+       }
+
+       sb[sb.length] = '<td';
+       sb[sb.length] = ' id="' + this.contentElId + '"';
+       sb[sb.length] = ' class="' + this.contentStyle + '"';
+       sb[sb.length] = ' >';
+       sb[sb.length] = this.html;
+       sb[sb.length] = '</td>';
+       sb[sb.length] = '</tr>';
+       sb[sb.length] = '</table>';
+
+       return sb.join("");
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * Static factory class for tree view expand/collapse animations
+ */
+YAHOO.widget.TVAnim = new function() {
+       /**
+        * Constant for the fade in animation
+        *
+        * @type string
+        */
+       this.FADE_IN  = "YAHOO.widget.TVFadeIn";
+
+       /**
+        * Constant for the fade out animation
+        *
+        * @type string
+        */
+       this.FADE_OUT = "YAHOO.widget.TVFadeOut";
+
+       /**
+        * Returns a ygAnim instance of the given type
+        *
+        * @param type {string} the type of animation
+        * @param el {HTMLElement} the element to element (probably the children div)
+        * @param callback {function} function to invoke when the animation is done.
+        * @return {ygAnim} the animation instance
+        */
+       this.getAnim = function(type, el, callback) {
+               switch (type) {
+                       case this.FADE_IN:      return new YAHOO.widget.TVFadeIn(el, callback);
+                       case this.FADE_OUT:     return new YAHOO.widget.TVFadeOut(el, callback);
+                       default:                        return null;
+               }
+       };
+
+       /**
+        * Returns true if the specified animation class is available
+        *
+        * @param type {string} the type of animation
+        * @return {boolean} true if valid, false if not
+        */
+       this.isValid = function(type) {
+               return ( "undefined" != eval("typeof " + type) );
+       };
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * 1/2 second fade-in
+ *
+ * @constructor
+ * @param el {HTMLElement} the element to animate
+ * @param callback {function} function to invoke when the animation is finished
+ */
+YAHOO.widget.TVFadeIn = function(el, callback) {
+       /**
+        * The animation dom ref
+        */
+       this.el = el;
+
+       /**
+        * the callback to invoke when the animation is complete
+        *
+        * @type function
+        */
+       this.callback = callback;
+
+       /**
+        * @private
+        */
+};
+
+/**
+ * Performs the animation
+ */
+YAHOO.widget.TVFadeIn.prototype = {
+    animate: function() {
+        var tvanim = this;
+
+        var s = this.el.style;
+        s.opacity = 0.1;
+        s.filter = "alpha(opacity=10)";
+        s.display = "";
+
+        // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
+        var dur = 0.4;
+        // var a = new ygAnim_Fade(this.el, dur, 1);
+        // a.setStart(0.1);
+        // a.onComplete = function() { tvanim.onComplete(); };
+
+        // var a = new YAHOO.util.Anim(this.el, 'opacity', 0.1, 1);
+        var a = new YAHOO.util.Anim(this.el, {opacity: {from: 0.1, to: 1, unit:""}}, dur);
+        a.onComplete.subscribe( function() { tvanim.onComplete(); } );
+        a.animate();
+    },
+
+    /**
+     * Clean up and invoke callback
+     */
+    onComplete: function() {
+        this.callback();
+    }
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * 1/2 second fade out
+ *
+ * @constructor
+ * @param el {HTMLElement} the element to animate
+ * @param callback {Function} function to invoke when the animation is finished
+ */
+YAHOO.widget.TVFadeOut = function(el, callback) {
+       /**
+        * The animation dom ref
+        */
+       this.el = el;
+
+       /**
+        * the callback to invoke when the animation is complete
+        *
+        * @type function
+        */
+       this.callback = callback;
+
+       /**
+        * @private
+        */
+};
+
+/**
+ * Performs the animation
+ */
+YAHOO.widget.TVFadeOut.prototype = {
+    animate: function() {
+        var tvanim = this;
+        // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
+        var dur = 0.4;
+        // var a = new ygAnim_Fade(this.el, dur, 0.1);
+        // a.onComplete = function() { tvanim.onComplete(); };
+
+        // var a = new YAHOO.util.Anim(this.el, 'opacity', 1, 0.1);
+        var a = new YAHOO.util.Anim(this.el, {opacity: {from: 1, to: 0.1, unit:""}}, dur);
+        a.onComplete.subscribe( function() { tvanim.onComplete(); } );
+        a.animate();
+    },
+
+    /**
+     * Clean up and invoke callback
+     */
+    onComplete: function() {
+        var s = this.el.style;
+        s.display = "none";
+        // s.opacity = 1;
+        s.filter = "alpha(opacity=100)";
+        this.callback();
+    }
+};
+
index c7549711ca99fc2410c4b8a7254e9b3a9af69071..fa927da4ec0fc11ee802a1ed9b2ed1d4ecd1a188 100644 (file)
@@ -72,7 +72,7 @@ function wrapSelectionWithLink(txtarea) {
          document.getElementById && getMozSelection(txtarea) == "") {
         var my_desc = prompt("Enter Description", '');
     }
-    
+
     var my_title = prompt("Enter title/tooltip:", "");
 
        html_title = "";
@@ -142,7 +142,7 @@ function serendipity_insLink (area) {
         area.focus();
         return;
     }
-    
+
        html_title = "";
     if (my_title != "") {
                html_title = ' title="' + my_title + '"';
@@ -194,8 +194,8 @@ function serendipity_imageSelector_done(textarea)
     }
 
     if (f['serendipity[filename_only]'] && f['serendipity[filename_only]'].value == 'true') {
-        self.opener.serendipity_imageSelector_addToElement(img, f['serendipity[htmltarget]'].value);
-        self.close();
+        parent.self.opener.serendipity_imageSelector_addToElement(img, f['serendipity[htmltarget]'].value);
+        parent.self.close();
         return true;
     }
 
@@ -232,14 +232,14 @@ function serendipity_imageSelector_done(textarea)
         block = insert;
     }
 
-    if (self.opener.editorref) {
-        self.opener.editorref.surroundHTML(block, '');
+    if (parent.self.opener.editorref) {
+        parent.self.opener.editorref.surroundHTML(block, '');
     } else {
-       
-        self.opener.serendipity_imageSelector_addToBody(block, textarea);
+
+        parent.self.opener.serendipity_imageSelector_addToBody(block, textarea);
     }
 
-    self.close();
+    parent.self.close();
 }
 
 // -->
index 4fc4d47b9081f83f9ccd3ff7b99f6c3b4cd00915..cb9add9ae9c5fecf2d8d00f8a5447b98c2634c60 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 1.1-alpha1()
 ------------------------------------------------------------------------
 
+   * Added directory tree view widget (JS) to the Media Selector
+     (garvinhicking)
+
    * Create a new index on the plugin DB table, optimize fetching config
      values for plugins. Load language file when permissions could not
      allow reading the config file. (garvinhicking)
index 23efa34c1e9f38a4f83cb9885dc90f44dd07368f..0d14c9cc2c049b670e94fa24f4736d67e49b539b 100644 (file)
@@ -91,7 +91,7 @@ switch ($serendipity['GET']['adminAction']) {
                     'thumb'  => $serendipity['thumbSuffix'],
                     'fthumb' => $file['thumbnail_name']
                 ));
-                
+
                 serendipity_plugin_api::hook_event('backend_media_rename', $renameValues);
 
                 // Rename file
@@ -191,7 +191,7 @@ switch ($serendipity['GET']['adminAction']) {
                     $fp = fopen($tempfile, 'w');
                     fwrite($fp, $fContent);
                     fclose($fp);
-                      
+
                     $image_id = @serendipity_insertHotlinkedImageInDatabase($tfile, $serendipity['POST']['imageurl'], $authorid, null, $tempfile);
                     printf(HOTLINK_DONE. '<br />', $serendipity['POST']['imageurl'], $tfile);
                     serendipity_plugin_api::hook_event('backend_image_addHotlink', $tempfile);
@@ -207,7 +207,7 @@ switch ($serendipity['GET']['adminAction']) {
                         'thumb'     => $serendipity['thumbSuffix']
                     ));
                     serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
-                    
+
                     foreach($thumbs as $thumb) {
                         // Create thumbnail
                         if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$tindex], $thumb['thumbSize'], $thumb['thumb']) ) {
@@ -226,7 +226,7 @@ switch ($serendipity['GET']['adminAction']) {
         if (!is_array($serendipity['POST']['target_filename'])) {
             break;
         }
-        
+
         foreach($serendipity['POST']['target_filename'] AS $idx => $target_filename) {
             $uploadfile = &$_FILES['serendipity']['name']['userfile'][$idx];
             $uploadtmp  = &$_FILES['serendipity']['tmp_name']['userfile'][$idx];
@@ -238,7 +238,7 @@ switch ($serendipity['GET']['adminAction']) {
                 // skip empty array
                 continue;
             }
-            
+
             $tfile = serendipity_uploadSecure(basename($tfile));
 
                if (serendipity_isActiveFile($tfile)) {
@@ -246,10 +246,10 @@ switch ($serendipity['GET']['adminAction']) {
                 echo '<br />';
                 continue;
             }
-    
+
             $serendipity['POST']['target_directory'][$idx] = serendipity_uploadSecure($serendipity['POST']['target_directory'][$idx], true, true);
             $target = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'][$idx] . $tfile;
-    
+
             if (file_exists($target)) {
                 echo '(' . $target . ') ' . ERROR_FILE_EXISTS_ALREADY;
                 echo '<br />';
@@ -259,13 +259,13 @@ switch ($serendipity['GET']['adminAction']) {
                     printf(FILE_UPLOADED . '<br />', $uploadfile, $target);
                     @umask(0000);
                     @chmod($target, 0664);
-    
+
                     $thumbs = array(array(
                         'thumbSize' => $serendipity['thumbSize'],
                         'thumb'     => $serendipity['thumbSuffix']
                     ));
                     serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
-                    
+
                     foreach($thumbs as $thumb) {
                         // Create thumbnail
                         if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$idx], $thumb['thumbSize'], $thumb['thumb']) ) {
@@ -315,11 +315,11 @@ switch ($serendipity['GET']['adminAction']) {
                 'relpath' => $use_dir
             )
         );
-        
+
         if (!serendipity_directoryACL($checkpath, 'write')) {
             return;
         }
-        
+
         if (!empty($serendipity['POST']['save'])) {
             serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $use_dir);
             serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'], $use_dir);
@@ -334,7 +334,7 @@ switch ($serendipity['GET']['adminAction']) {
     <div class="image_directory_edit"><strong><?php echo MANAGE_DIRECTORIES ?></strong></div>
     <br />
     <form id="image_directory_edit_form" method="POST" action="?serendipity[adminModule]=images&amp;serendipity[adminAction]=directoryEdit&amp;serendipity[dir]=<?php echo htmlspecialchars($serendipity['GET']['dir']) ?>">
-    <?php echo serendipity_setFormToken(); ?> 
+    <?php echo serendipity_setFormToken(); ?>
     <input type="hidden" name="serendipity[oldDir]" value="<?php echo $use_dir; ?>" />
     <table cellpadding="5">
         <tr>
@@ -354,7 +354,7 @@ switch ($serendipity['GET']['adminAction']) {
                 </select>
             </td>
         </tr>
-    
+
         <tr>
             <td><label for="write_authors"><?php echo PERM_WRITE; ?></label></td>
             <td>
@@ -390,7 +390,7 @@ switch ($serendipity['GET']['adminAction']) {
     <br />
     <br />
     <form id="image_directory_delete_form" method="POST" action="?serendipity[adminModule]=images&amp;serendipity[adminAction]=directoryDoDelete&amp;serendipity[dir]=<?php echo htmlspecialchars($serendipity['GET']['dir']) ?>">
-    <?php echo serendipity_setFormToken(); ?> 
+    <?php echo serendipity_setFormToken(); ?>
     <table cellpadding="5">
         <tr>
             <td width="100"><strong><?php echo NAME ?></strong></td>
@@ -424,6 +424,8 @@ switch ($serendipity['GET']['adminAction']) {
             printf(DIRECTORY_CREATED, $serendipity['POST']['name']);
             @umask(0000);
             @chmod($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir, 0777);
+            serendipity_ACLGrant(0, 'directory', 'read', array(0), $new_dir . '/');
+            serendipity_ACLGrant(0, 'directory', 'write', array(0), $new_dir . '/');
         } else {
             printf(DIRECTORY_WRITE_ERROR, $new_dir);
         }
@@ -450,7 +452,7 @@ switch ($serendipity['GET']['adminAction']) {
     <br />
     <br />
     <form id="image_directory_create_form" method="POST" action="?serendipity[adminModule]=images&amp;serendipity[adminAction]=directoryDoCreate">
-    <?php echo serendipity_setFormToken(); ?> 
+    <?php echo serendipity_setFormToken(); ?>
     <table cellpadding="5">
         <tr>
             <td><?php echo NAME ?></td>
@@ -608,10 +610,10 @@ switch ($serendipity['GET']['adminAction']) {
                 columncount    = fields.childNodes[3].childNodes[0];
             } else if (fields.childNodes[1].childNodes[1].childNodes[0].childNodes[3] == null) {
                // This is Safari.
-                userfile       = fields.childNodes[1].childNodes[1].childNodes[0].childNodes[1].childNodes[0]; 
+                userfile       = fields.childNodes[1].childNodes[1].childNodes[0].childNodes[1].childNodes[0];
                 targetfilename = fields.childNodes[1].childNodes[1].childNodes[2].childNodes[1].childNodes[0];
                 targetdir      = fields.childNodes[1].childNodes[1].childNodes[3].childNodes[1].childNodes[0];
-                columncount    = fields.childNodes[3].childNodes[0];            
+                columncount    = fields.childNodes[3].childNodes[0];
             } else {
                 // This is Mozilla.
                 userfile       = fields.childNodes[1].childNodes[1].childNodes[0].childNodes[3].childNodes[0];
@@ -620,16 +622,16 @@ switch ($serendipity['GET']['adminAction']) {
                 columncount    = fields.childNodes[3].childNodes[0];
             }
         }
-        
+
         userfile.id   = 'userfile_' + fieldcount;
         userfile.name = 'serendipity[userfile][' + fieldcount + ']';
-        
+
         targetfilename.id   = 'target_filename_' + fieldcount;
         targetfilename.name = 'serendipity[target_filename][' + fieldcount + ']';
-        
+
         targetdir.id   = 'target_directory_' + fieldcount;
         targetdir.name = 'serendipity[target_directory][' + fieldcount + ']';
-        
+
         columncount.id   = 'column_count_' + fieldcount;
         columncount.name = 'serendipity[column_count][' + fieldcount + ']';
 
@@ -638,7 +640,7 @@ switch ($serendipity['GET']['adminAction']) {
 
         document.getElementById(targetdir.id).selectedIndex = document.getElementById('target_directory_' + (fieldcount - 1)).selectedIndex;
     }
-    
+
     var inputStorage = new Array();
     function checkInputs() {
         for (i = 1; i <= fieldcount; i++) {
@@ -650,14 +652,14 @@ switch ($serendipity['GET']['adminAction']) {
         }
 
     }
-    
+
     function debugFields() {
         for (i = 1; i <= fieldcount; i++) {
             debugField('target_filename_' + i);
             debugField('userfile_' + i);
         }
     }
-    
+
     function rememberOptions() {
         td     = document.getElementById('target_directory_2');
         td_val = td.options[td.selectedIndex].value;
@@ -677,7 +679,7 @@ switch ($serendipity['GET']['adminAction']) {
             useDuplicate = true;
         } else {
             sourceval = getfilename(document.getElementById('userfile_' + source).value);
-        } 
+        }
 
         if (sourceval.length > 0) {
             document.getElementById('target_filename_' + target).value = sourceval;
@@ -687,7 +689,7 @@ switch ($serendipity['GET']['adminAction']) {
         // Display filename in duplicate form as well!
         if (useDuplicate) {
             tkey = target + 1;
-            
+
             if (!inputStorage[tkey] || inputStorage[tkey] == document.getElementById('target_filename_' + tkey).value) {
                 document.getElementById('target_filename_' + (target+1)).value = sourceval;
                 inputStorage[target + 1] = '~~~';
@@ -698,7 +700,7 @@ switch ($serendipity['GET']['adminAction']) {
 
     <form action="?" method="POST" id="uploadform" enctype="multipart/form-data" onsubmit="rememberOptions()">
         <div>
-            <?php echo serendipity_setFormToken(); ?> 
+            <?php echo serendipity_setFormToken(); ?>
             <input type="hidden" name="serendipity[action]"      value="admin" />
             <input type="hidden" name="serendipity[adminModule]" value="images" />
             <input type="hidden" name="serendipity[adminAction]" value="add" />
@@ -713,9 +715,9 @@ switch ($serendipity['GET']['adminAction']) {
             <table id="foreign_upload" class="image_add_foreign">
                 <tr>
                     <td nowrap="nowrap"><?php echo ENTER_MEDIA_URL; ?></td>
-                    <td><input type="text" id="imageurl" name="serendipity[imageurl]" 
-                             onchange="checkInputs()" 
-                              value="" 
+                    <td><input type="text" id="imageurl" name="serendipity[imageurl]"
+                             onchange="checkInputs()"
+                              value=""
                                size="40" /></td>
                 </tr>
                 <tr>
@@ -738,8 +740,8 @@ switch ($serendipity['GET']['adminAction']) {
             <table style="margin-top: 35px" id="upload_table" class="image_add_local">
                 <tr>
                     <td nowrap='nowrap'><?php echo ENTER_MEDIA_UPLOAD; ?></td>
-                    <td><input id="userfile_1" name="serendipity[userfile][1]" 
-                             onchange="checkInputs();" 
+                    <td><input id="userfile_1" name="serendipity[userfile][1]"
+                             onchange="checkInputs();"
                                type="file" /></td>
                 </tr>
 
@@ -765,7 +767,7 @@ switch ($serendipity['GET']['adminAction']) {
            </table>
            <div id="ccounter"><input type="hidden" name="serendipity[column_count][1]" id="column_count_1" value="true" /></div>
            </div>
-           
+
            <div id="debug">
            </div>
 
@@ -774,14 +776,14 @@ switch ($serendipity['GET']['adminAction']) {
                 document.write('<span id="upload_form"><' + '/span>');
                 addField();
            </script>
-           
+
             <?php serendipity_plugin_api::hook_event('backend_image_addform', $serendipity); ?>
 
             <div style="text-align: center; margin-top: 15px; margin-bottom: 15px">
                 <script type="text/javascript">
                     document.write('<input class="serendipityPrettyButton" type="button" value="<?php echo IMAGE_MORE_INPUT; ?>" onclick="hideForeign(); addField()"' + '/><br' + '/>');
                 </script>
-                <input type="checkbox" name="serendipity[all_authors]" value="true" checked="checked" id="all_authors" /><label id="all_authors_label" for="all_authors"><?php echo ALL_AUTHORS; ?></label> <input onclick="checkInputs();" type="submit" value="<?php echo GO; ?>" class="serendipityPrettyButton" />
+                <input type="hidden" name="serendipity[all_authors]" value="true" checked="checked" id="all_authors" /> <input onclick="checkInputs();" type="submit" value="<?php echo GO; ?>" class="serendipityPrettyButton" />
             </div>
         </div>
         <div class="image_add_note"><?php echo ADD_MEDIA_BLAHBLAH_NOTE; ?></div>
@@ -888,7 +890,7 @@ switch ($serendipity['GET']['adminAction']) {
         <div>
             <?php echo NEWSIZE; ?>
 
-            <?php echo serendipity_setFormToken(); ?> 
+            <?php echo serendipity_setFormToken(); ?>
             <input type="hidden" name="serendipity[adminModule]" value="images" />
             <input type="hidden" name="serendipity[adminAction]" value="scale" />
             <input type="hidden" name="serendipity[fid]"         value="<?php echo $serendipity["GET"]["fid"]; ?>" />
index eb9382d83e81ef87cdd464a283673ce256f14e22..c76a073d9803e234b92a01fc153ca5a3b4b0d78b 100644 (file)
@@ -1034,5 +1034,29 @@ if (!function_exists('microtime_float')) {
     }
 }
 
+/**
+ * Converts Array data to be used as a GET string
+ */
+function serendipity_build_query(&$array, $array_prefix = null, $comb_char = '&amp;') {
+    $ret = array();
+    if (!is_array($array)) {
+        return '';
+    }
+
+    foreach ($array as $k => $v) {
+        $newkey = urlencode($k);
+        if ($array_prefix) {
+            $newkey = $array_prefix . '[' . $newkey . ']';
+        }
+        if (is_array($v)) {
+            $ret[] = serendipity_build_query($v, $newkey, $comb_char);
+        } else {
+            $ret[] = $newkey . '=' . urlencode($v);
+        }
+    }
+
+    return implode($comb_char, $ret);
+}
+
 define("serendipity_FUNCTIONS_LOADED", true);
 /* vim: set sts=4 ts=4 expandtab : */
index 9b24023eaf4a2c5bef6afbe766434fc481c33325..5e85b98b37f676bb54100b304bc49cc8a1ab8550 100644 (file)
@@ -248,21 +248,27 @@ function serendipity_fetchImages($group = false, $start = 0, $end = 20, $images
     if ($dir = @opendir($basedir . $odir)) {
                $aTempArray = array();
                while (($file = @readdir($dir)) !== false) {
+                   if ($file == '.svn' || $file == 'CVS' || $file == '.' || $file == '..') {
+                       continue;
+                   }
                        array_push($aTempArray, $file);
                }
                @closedir($dir);
                sort($aTempArray);
                foreach($aTempArray as $f) {
-            if ($f != '.' && $f != '..' && strpos($f, $serendipity['thumbSuffix']) === false) {
-                $cdir = ($odir != '' ? $odir . '/' : '');
-                if (is_dir($basedir . $odir . '/' . $f)) {
-                    $temp = serendipity_fetchImages($group, $start, $end, $images, $cdir . $f);
-                    foreach($temp AS $tkey => $tval) {
-                        array_push($images, $tval);
-                    }
-                } else {
-                    array_push($images, $cdir . $f);
+            if (strpos($f, $serendipity['thumbSuffix']) !== false) {
+                // This is a s9y thumbnail, skip it.
+                continue;
+            }
+
+            $cdir = ($odir != '' ? $odir . '/' : '');
+            if (is_dir($basedir . $odir . '/' . $f)) {
+                $temp = serendipity_fetchImages($group, $start, $end, $images, $cdir . $f);
+                foreach($temp AS $tkey => $tval) {
+                    array_push($images, $tval);
                 }
+            } else {
+                array_push($images, $cdir . $f);
             }
         }
     }
@@ -1193,7 +1199,7 @@ function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = fa
                }
                unset($aResultSet[$sKey]);
        }
-       sort($paths);
+       //sort($paths);
        if ($debug) echo "<p>Got files: <pre>" . print_r($aFilesOnDisk, true) . "</pre></p>";
        $serendipity['current_image_hash'] = md5(serialize($aFilesOnDisk));
 
@@ -1361,7 +1367,7 @@ function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = fa
 <?php
         if ($show_upload) {
 ?>
-                <input type="button" value="<?php echo htmlspecialchars(ADD_MEDIA); ?>" onclick="location.href='<?php echo $url; ?>&amp;serendipity[adminAction]=addSelect'; return false" class="serendipityPrettyButton" />
+                <input type="button" value="<?php echo htmlspecialchars(ADD_MEDIA); ?>" onclick="location.href='<?php echo $url; ?>&amp;serendipity[adminAction]=addSelect&amp;serendipity[only_path]=<?php echo urlencode($serendipity['GET']['only_path']); ?>'; return false" class="serendipityPrettyButton" />
 <?php
         }
 ?>
index 095a1347ecf750d8223835c78ca1a7d435610e84..c5a2ed42711a4f93783cdef64bfd60adbb22f0c6 100644 (file)
@@ -24,12 +24,12 @@ if (!isset($serendipity['GET']['step'])) {
 
 function ifRemember($name, $value, $isDefault = false, $att = 'checked') {
     global $serendipity;
-    
+
     if (!is_array($serendipity['COOKIE']) && !$isDefault) {
         return false;
     }
-    
-    if ((!is_array($serendipity['COOKIE']) && $isDefault) || 
+
+    if ((!is_array($serendipity['COOKIE']) && $isDefault) ||
         (!isset($serendipity['COOKIE']['serendipity_' . $name]) && $isDefault) ||
         (isset($serendipity['COOKIE']['serendipity_' . $name]) && $serendipity['COOKIE']['serendipity_' . $name] == $value)) {
 
@@ -42,9 +42,24 @@ function ifRemember($name, $value, $isDefault = false, $att = 'checked') {
         <title><?php echo SELECT_FILE; ?></title>
         <meta http-equiv="Content-Type" content="text/html; charset=<?php echo LANG_CHARSET; ?>" />
         <link rel="stylesheet" type="text/css" href="<?php echo serendipity_rewriteURL('serendipity_admin.css'); ?>" />
+        <link rel="stylesheet" type="text/css" href="<?php echo serendipity_getTemplateFile('treeview/tree.css'); ?>" />
+        <script type="text/javascript" src="bundled-libs/YahooUI/treeview/YAHOO.js"></script>
+        <script type="text/javascript" src="bundled-libs/YahooUI/treeview/treeview.js" ></script>
     </head>
 
     <script type="text/javascript">
+        function addLoadEvent(func) {
+          var oldonload = window.onload;
+          if (typeof window.onload != 'function') {
+            window.onload = func;
+          } else {
+            window.onload = function() {
+              oldonload();
+              func();
+            }
+          }
+        }
+
         function SetCookie(name, value) {
             var today  = new Date();
             var expire = new Date();
@@ -58,7 +73,7 @@ function ifRemember($name, $value, $isDefault = false, $att = 'checked') {
                 elname = new String(el.elements[i].name);
                 elname = elname.replace(/\[/g, '_');
                 elname = elname.replace(/\]/g, '');
-                
+
                 if (el.elements[i].type == 'radio') {
                     if (el.elements[i].checked) {
                         SetCookie(elname, el.elements[i].value);
@@ -69,9 +84,28 @@ function ifRemember($name, $value, $isDefault = false, $att = 'checked') {
             }
         }
     </script>
-<body id="serendipityAdminBodyImageSelector">
+<?php
+if (empty($serendipity['GET']['step']) && $serendipity['GET']['page'] < 1) {
+    $GET_STRING = serendipity_build_query($_GET);
+?>
+<frameset id="media_frame" cols="20%,*">
+    <frame id="media_frame_tree" frameborder="0" name="tree" scrolling="auto" src="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity_admin_image_selector.php?<?php echo $GET_STRING; ?>&amp;serendipity[step]=tree" />
+    <frame id="media_frame_main" frameborder="0" name="media" src="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity_admin_image_selector.php?<?php echo $GET_STRING; ?>&amp;serendipity[step]=default" />
+</frameset>
+</html>
+<?php
+    return;
+}
+
+$body_id = 'serendipityAdminBodyImageSelector';
+if ($serendipity['GET']['step'] === 'tree') {
+    $body_id = 'serendipityAdminBodyImageSelectorTree';
+}
+?>
+<body id="<?php echo $body_id; ?>">
 
 <div class="serendipityAdminContent">
+
 <?php
 switch ($serendipity['GET']['step']) {
     case '1':
@@ -202,7 +236,7 @@ switch ($serendipity['GET']['step']) {
                 <input type="text"  name="serendipity[url]" size="30" value="<?php echo $file['path']; ?>" /><br />
                 <?php } else {
                     $aArray = array('imagelinkurl' => $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] .'.'. $file['extension']);
-                    serendipity_plugin_api::hook_event('frontend_image_selector_link_url', $aArray); 
+                    serendipity_plugin_api::hook_event('frontend_image_selector_link_url', $aArray);
                 ?>
                 <input type="text"  name="serendipity[url]" size="30" value="<?php echo $aArray['imagelinkurl']?>" /><br />
                 <?php } ?>
@@ -233,8 +267,8 @@ switch ($serendipity['GET']['step']) {
 ?>
     <script type="text/javascript">
         <?php serendipity_plugin_api::hook_event('frontend_image_add_filenameonly', $serendipity); ?>
-        self.opener.serendipity_imageSelector_addToElement('<?php echo htmlspecialchars($imgName); ?>', '<?php echo htmlspecialchars($serendipity['GET']['htmltarget']); ?>');
-        self.close();
+        parent.self.opener.serendipity_imageSelector_addToElement('<?php echo htmlspecialchars($imgName); ?>', '<?php echo htmlspecialchars($serendipity['GET']['htmltarget']); ?>');
+        parent.self.close();
     </script>
 <?php
         } else {
@@ -242,18 +276,105 @@ switch ($serendipity['GET']['step']) {
     <script type="text/javascript">
     block = '<a href="<?php echo htmlspecialchars($imgName); ?>" title="<?php echo htmlspecialchars($file['name'] . '.' . $file['extension']); ?>" target="_blank"><?php echo htmlspecialchars($file['name'] . '.' . $file['extension']); ?></a>';
     <?php serendipity_plugin_api::hook_event('frontend_image_add_unknown', $serendipity); ?>
-    if (self.opener.editorref) {
-        self.opener.editorref.surroundHTML(block, '');
+    if (parent.self.opener.editorref) {
+        parent.self.opener.editorref.surroundHTML(block, '');
     } else {
-        self.opener.serendipity_imageSelector_addToBody(block, '<?php echo $serendipity['GET']['textarea']; ?>');
+        parent.self.opener.serendipity_imageSelector_addToBody(block, '<?php echo $serendipity['GET']['textarea']; ?>');
     }
-    self.close();
+    parent.self.close();
     </script>
 <?php
         }
     }
     break;
 
+    case 'tree':
+       $aExclude = array("CVS" => true, ".svn" => true);
+       serendipity_plugin_api::hook_event('backend_media_path_exclude_directories', $aExclude);
+       $paths        = array();
+
+       $aResultSet   = serendipity_traversePath(
+           $serendipity['serendipityPath'] . $serendipity['uploadPath'],
+           '',
+           false,
+           NULL,
+           1,
+           NULL,
+           FALSE,
+           $aExclude
+       );
+
+       foreach ($aResultSet AS $sKey => $sFile) {
+               if ($sFile['directory']) {
+                       array_push($paths, $sFile);
+               }
+               unset($aResultSet[$sKey]);
+       }
+        serendipity_directoryACL($paths, 'read');
+?>
+    <script type="text/javascript">
+    var toggle_state = 'expand';
+    function treeToggleAll() {
+        if (toggle_state == 'expand') {
+            toggle_state = 'collapse';
+            tree.expandAll();
+        } else {
+            toggle_state = 'expand';
+            tree.collapseAll();
+        }
+    }
+    </script>
+
+    <div id="content">
+        <form name="mainForm" action="javscript:;">
+            <div class="newsItem">
+                <div id="expandcontractdiv">
+                    <a href="javascript:treeToggleAll()"><?php echo TOGGLE_ALL; ?></a>
+                </div>
+                <div id="treeDiv1"></div>
+            </div>
+        </form>
+    </div>
+
+    <div id="footerContainer">
+        <div id="footer">
+            <p>&nbsp;</p>
+        </div>
+    </div>
+
+    <script type="text/javascript">
+       var tree;
+       var nodes = new Array();
+       var nodeIndex;
+
+       function treeInit() {
+               tree = new YAHOO.widget.TreeView("treeDiv1");
+               var baseurl = '<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity_admin_image_selector.php?serendipity[step]=default&serendipity[only_path]=';
+        var rootNode = new YAHOO.widget.TextNode("<?php echo MEDIA; ?>", tree.getRoot(), false);
+               rootNode.href = baseurl;
+               rootNode.target = 'media';
+        rootNode.expanded = true;
+<?php
+        foreach($paths AS $item) {
+            if ($item['depth'] == 1) {
+                echo '      var tmpNode = new YAHOO.widget.TextNode("' . $item['name'] . '", rootNode, false);' . "\n";
+            } else {
+                echo '      var tmpNode = new YAHOO.widget.TextNode("' . $item['name'] . '", last_node_' . ($item['depth'] - 1) . ', false);' . "\n";
+            }
+            echo '      var last_node_' . $item['depth'] . ' = tmpNode;' . "\n";
+            echo '      tmpNode.href   = baseurl + "' . $item['relpath'] . '"' . "\n";
+            echo '      tmpNode.target = "media"' . "\n";
+        }
+?>
+               tree.draw();
+       }
+
+    addLoadEvent(treeInit);
+    </script>
+<?php
+        break;
+
+    case 'default':
     default:
         $add_url = '';
         if (!empty($serendipity['GET']['htmltarget'])) {
@@ -264,6 +385,7 @@ switch ($serendipity['GET']['step']) {
             $add_url .= '&amp;serendipity[filename_only]=' . $serendipity['GET']['filename_only'];
         }
 ?>
+
     <h1><?php echo SELECT_FILE; ?></h1>
     <h2><?php echo CLICK_FILE_TO_INSERT; ?></h2>
     <br />
@@ -282,7 +404,6 @@ switch ($serendipity['GET']['step']) {
         );
 }
 ?>
-
 </div>
 </body>
 </html>
index c7549711ca99fc2410c4b8a7254e9b3a9af69071..fa927da4ec0fc11ee802a1ed9b2ed1d4ecd1a188 100644 (file)
@@ -72,7 +72,7 @@ function wrapSelectionWithLink(txtarea) {
          document.getElementById && getMozSelection(txtarea) == "") {
         var my_desc = prompt("Enter Description", '');
     }
-    
+
     var my_title = prompt("Enter title/tooltip:", "");
 
        html_title = "";
@@ -142,7 +142,7 @@ function serendipity_insLink (area) {
         area.focus();
         return;
     }
-    
+
        html_title = "";
     if (my_title != "") {
                html_title = ' title="' + my_title + '"';
@@ -194,8 +194,8 @@ function serendipity_imageSelector_done(textarea)
     }
 
     if (f['serendipity[filename_only]'] && f['serendipity[filename_only]'].value == 'true') {
-        self.opener.serendipity_imageSelector_addToElement(img, f['serendipity[htmltarget]'].value);
-        self.close();
+        parent.self.opener.serendipity_imageSelector_addToElement(img, f['serendipity[htmltarget]'].value);
+        parent.self.close();
         return true;
     }
 
@@ -232,14 +232,14 @@ function serendipity_imageSelector_done(textarea)
         block = insert;
     }
 
-    if (self.opener.editorref) {
-        self.opener.editorref.surroundHTML(block, '');
+    if (parent.self.opener.editorref) {
+        parent.self.opener.editorref.surroundHTML(block, '');
     } else {
-       
-        self.opener.serendipity_imageSelector_addToBody(block, textarea);
+
+        parent.self.opener.serendipity_imageSelector_addToBody(block, textarea);
     }
 
-    self.close();
+    parent.self.close();
 }
 
 // -->
diff --git a/templates/default/treeview/lm.gif b/templates/default/treeview/lm.gif
new file mode 100644 (file)
index 0000000..e7d0a3c
Binary files /dev/null and b/templates/default/treeview/lm.gif differ
diff --git a/templates/default/treeview/lmh.gif b/templates/default/treeview/lmh.gif
new file mode 100644 (file)
index 0000000..3ff6302
Binary files /dev/null and b/templates/default/treeview/lmh.gif differ
diff --git a/templates/default/treeview/ln.gif b/templates/default/treeview/ln.gif
new file mode 100644 (file)
index 0000000..b7b3e55
Binary files /dev/null and b/templates/default/treeview/ln.gif differ
diff --git a/templates/default/treeview/loading.gif b/templates/default/treeview/loading.gif
new file mode 100644 (file)
index 0000000..0bbf3bc
Binary files /dev/null and b/templates/default/treeview/loading.gif differ
diff --git a/templates/default/treeview/lp.gif b/templates/default/treeview/lp.gif
new file mode 100644 (file)
index 0000000..b87f003
Binary files /dev/null and b/templates/default/treeview/lp.gif differ
diff --git a/templates/default/treeview/lph.gif b/templates/default/treeview/lph.gif
new file mode 100644 (file)
index 0000000..e3478d8
Binary files /dev/null and b/templates/default/treeview/lph.gif differ
diff --git a/templates/default/treeview/screen.css b/templates/default/treeview/screen.css
new file mode 100644 (file)
index 0000000..a709519
--- /dev/null
@@ -0,0 +1 @@
+html, body { padding: 0px 0px 10px 0px; border: 0; margin: 0; }\rbody { font: normal 11px verdana, sans-serif; color: #333; line-height: 19px; margin: 0; }\r#container { clear: both; text-align: left; padding: 0 0; margin: 0 0; }\r#containerTop { height:48px; }\r#pad {  padding: 0px 20px 0px 20px; }\ra { text-decoration: underline; color: #46546C; }\ra:hover { text-decoration: underline; color: #4d77c3; }\rh1, h2, h3, h4, h5, h6 { font-family: palatino, georgia, "Times New Roman", serif; }\rh2 { font-size:16px; font-weight: bold; margin: 0 0 11px 0; }\r.border_2px { border: 1px solid #D8D8D8; padding: 2px; background: #fff; }\r.border_5px { border: 1px solid #D8D8D8; padding: 5px; background: #fff; margin: 0 0 4px 0; }\rimg { padding: 0; margin: 0; border: 0; }\rform { padding: 0; margin: 0; }\r.input { width: 85px; font-size: 9px; }\r.submit { font-size: 9px; }\r#pageTitle { position:absolute;top:10px;left:90px; }\r#pageTitle H3 {      font-size:14pt; color:#666666 }\r#header h1 { float:left; margin-top: 19px; margin-left: 50px;  }\r#header h1 a { display: block; height: 19px; text-decoration: none; }\r#header { height:  60px; border: 0px solid #CFFB00; margin-bottom:0px; }\r#header h4 { position: relative; float: right; font-size:11px; \r             letter-spacing: 1px; top: 10px; right: 30px; \r             line-height: 15px; padding: 0 0 0 13px; margin: 0px; }\r#content { float: left; width: 500px; min-height:400px; padding:10px 0px; border: 0px solid #C13B00;\r           margin-left: 50px; top:0px; }\r#content h1 { font-size:18px; margin:0px;      }\r.newsItem { padding-bottom:25px; margin-bottom:25px; overflow: hidden; }\r.newsItem h3 { font-size:18px; margin:0px; }\r.newsItem h3 a { text-decoration:none; color:#6A7981; }\r.newsItem h3 a:hover { text-decoration:underline; color:#000; }\r.newsItemFooter, .newsItemFooter a { font-size:9px; color:#999; font-weight:normal; }\r.newsItemFooter a:hover { color:#222; }\r#footer { padding: 0px 0px 20px 0px; clear: both; color: #999; border-top:0px #CCC solid; margin:0px 26px 0px 30px }\r#footer a { color: #999; }\r#footer a:hover { color: #222; }\r#footerContainer { clear: both; }\r\r#rightbar {\r    float: right;\r    padding: 5px 5px 5px 5px;\r    width: 304px; /* for IE5-Win */\r    width: 300px;\r    border: 1px solid #333333;\r    position:relative;\r    right:48px;\r    top:0px;\r    background-color:#eeeeee;\r    }\r#rightbar h2, #rightbar h3 {\r    font-size:12px;\r    text-align:center;\r    color:#FFF;\r    \r    border-bottom:#848B8F solid 1px;\r    border-right:#949B9F solid 1px;\r    border-top:#eee solid 1px;\r    padding:1px;\r    margin:0px 0px 0px 0px;\r    background-color:#383e45;\r    width:100%;\r    }\r#rightbar h2 a, #rightbar h3 a {\r    font-size:12px;\r    color:#FFF;\r    text-decoration:none;\r    display:block;\r    }\r#rightBarPad {\r    margin:0px;\r    }\r#sidenav {\r    margin: 0px 0;\r    border-bottom: 1px solid #ddd;\r    }\r#sidenav ul {\r    margin: 0; \r    padding: 0; \r    border: 0;\r    \r    }\r#sidenav ul li {\r    list-style: none; \r    list-style-image: none !important;\r    margin: 0; \r    padding:0;\r    }\r#sidenav ul li a {\r   text-decoration: none;\r   padding: 5px 0px 5px 0px;\r   color: #4C5250;\r   display: block;\r   width: 187px;\r   font-size: 11px !important;   \r   font-weight: bold;\r   border-top: 1px solid #ddd;\r   border-bottom: 1px solid #aaa;\r   border-left: 1px solid #C7CBD0;\r   text-shadow: -2px -2px 0px #FFF;\r}\r   \r\r#sidenav ul li a:hover {\r\r/* background: url(../img/navHover2.png) top no-repeat; */\rborder-top: 1px solid #A1AAAF;\rborder-bottom: 1px solid #CCC;\rborder-right: 0px solid #C3C7CA;\rborder-left: 1px solid #C3C7CA;\rtext-shadow: 4px 4px 0px #C3C7CA;\r}\r
\ No newline at end of file
diff --git a/templates/default/treeview/tm.gif b/templates/default/treeview/tm.gif
new file mode 100644 (file)
index 0000000..e30abad
Binary files /dev/null and b/templates/default/treeview/tm.gif differ
diff --git a/templates/default/treeview/tmh.gif b/templates/default/treeview/tmh.gif
new file mode 100644 (file)
index 0000000..ad7e557
Binary files /dev/null and b/templates/default/treeview/tmh.gif differ
diff --git a/templates/default/treeview/tn.gif b/templates/default/treeview/tn.gif
new file mode 100644 (file)
index 0000000..4a28039
Binary files /dev/null and b/templates/default/treeview/tn.gif differ
diff --git a/templates/default/treeview/tp.gif b/templates/default/treeview/tp.gif
new file mode 100644 (file)
index 0000000..d6d0ed0
Binary files /dev/null and b/templates/default/treeview/tp.gif differ
diff --git a/templates/default/treeview/tph.gif b/templates/default/treeview/tph.gif
new file mode 100644 (file)
index 0000000..e4d7d99
Binary files /dev/null and b/templates/default/treeview/tph.gif differ
diff --git a/templates/default/treeview/tree.css b/templates/default/treeview/tree.css
new file mode 100644 (file)
index 0000000..835742b
--- /dev/null
@@ -0,0 +1,115 @@
+#expandcontractdiv {
+    font-size: xx-small;
+    margin-bottom: 5px;
+    text-align: center;
+}
+
+#serendipityAdminBodyImageSelectorTree {
+    background-color: #EEE;
+    background-image: none;
+    border-right: 1px dotted black;
+    height: 100%;
+}
+
+#media_frame_tree {
+    background-color: #EEE;
+}
+
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/* first or middle sibling, no children */
+.ygtvtn {
+       width:16px; height:22px;
+       background: url(tn.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, collapsable */
+.ygtvtm {
+       width:16px; height:22px;
+       cursor:pointer ;
+       background: url(tm.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, collapsable, hover */
+.ygtvtmh {
+       width:16px; height:22px;
+       cursor:pointer ;
+       background: url(tmh.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, expandable */
+.ygtvtp {
+       width:16px; height:22px;
+       cursor:pointer ;
+       background: url(tp.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, expandable, hover */
+.ygtvtph {
+       width:16px; height:22px;
+       cursor:pointer ;
+       background: url(tph.gif) 0 0 no-repeat;
+}
+
+/* last sibling, no children */
+.ygtvln {
+       width:16px; height:22px;
+       background: url(ln.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, collapsable */
+.ygtvlm {
+       width:16px; height:22px;
+       cursor:pointer ;
+       background: url(lm.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, collapsable, hover */
+.ygtvlmh {
+       width:16px; height:22px;
+       cursor:pointer ;
+       background: url(lmh.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, expandable */
+.ygtvlp {
+       width:16px; height:22px;
+       cursor:pointer ;
+       background: url(lp.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, expandable, hover */
+.ygtvlph {
+       width:17px; height:22px; cursor:pointer ;
+       background: url(lph.gif) 0 0 no-repeat;
+}
+
+/* Loading icon */
+.ygtvloading {
+       width:16px; height:22px;
+       background: url(loading.gif) 0 0 no-repeat;
+}
+
+/* the style for the empty cells that are used for rendering the depth
+ * of the node */
+.ygtvdepthcell {
+       width:16px; height:22px;
+       background: url(vline.gif) 0 0 no-repeat;
+}
+
+.ygtvblankdepthcell { width:16px; height:22px; }
+
+/* the style of the div around each node */
+.ygtvitem { }
+
+/* the style of the div around each node's collection of children */
+.ygtvchildren { }
+* html .ygtvchildren { height:2%; }
+
+/* the style of the text label in ygTextNode */
+.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover {
+       margin-left:2px;
+       text-decoration: none;
+}
+
diff --git a/templates/default/treeview/vline.gif b/templates/default/treeview/vline.gif
new file mode 100644 (file)
index 0000000..1fb0de8
Binary files /dev/null and b/templates/default/treeview/vline.gif differ