From 7709233bdc52fb125781702bc03a465cd10906b5 Mon Sep 17 00:00:00 2001 From: shizuki Date: Tue, 16 Jan 2007 14:11:50 +0000 Subject: [PATCH] =?utf8?q?=E6=B8=85=E6=9B=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@522 1ca29b6e-896d-4ea0-84a5-967f57386b96 --- trunk/NP_Dtree/NP_Dtree.php | 21 +- trunk/NP_Dtree/dtree/dtree.php | 723 ++++++++++++++++++++++++++++++++++++- trunk/NP_Dtree/dtree/dtreedata.php | 128 ++++--- 3 files changed, 807 insertions(+), 65 deletions(-) diff --git a/trunk/NP_Dtree/NP_Dtree.php b/trunk/NP_Dtree/NP_Dtree.php index 8edeb45..3746954 100644 --- a/trunk/NP_Dtree/NP_Dtree.php +++ b/trunk/NP_Dtree/NP_Dtree.php @@ -49,14 +49,14 @@ class NP_Dtree extends NucleusPlugin function install() { - $this->createOption('folderLinks', _DTREE_DIR_LINK, 'yesno', 'yes'); - $this->createOption('useSelection', _DTREE_SELECTION, 'yesno', 'no'); - $this->createOption('useCookies', _DTREE_COOKIE, 'yesno', 'no'); - $this->createOption('useLines', _DTREE_LINE, 'yesno', 'yes'); - $this->createOption('useIcons', _DTREE_ICON, 'yesno', 'yes'); - $this->createOption('useStatusText', _DTREE_ST_TEXT, 'yesno', 'no'); - $this->createOption('closeSameLevel', _DTREE_CL_SLEVEL, 'yesno', 'no'); - $this->createOption('inOrder', _DTREE_IN_ORDER, 'yesno', 'no'); + $this->createOption('folderLinks', _DTREE_DIR_LINK, 'yesno', 'yes'); + $this->createOption('useSelection', _DTREE_SELECTION, 'yesno', 'no'); + $this->createOption('useCookies', _DTREE_COOKIE, 'yesno', 'no'); + $this->createOption('useLines', _DTREE_LINE, 'yesno', 'yes'); + $this->createOption('useIcons', _DTREE_ICON, 'yesno', 'yes'); + $this->createOption('useStatusText', _DTREE_ST_TEXT, 'yesno', 'no'); + $this->createOption('closeSameLevel', _DTREE_CL_SLEVEL, 'yesno', 'no'); + $this->createOption('inOrder', _DTREE_IN_ORDER, 'yesno', 'no'); } function init() @@ -124,6 +124,9 @@ class NP_Dtree extends NucleusPlugin . ' | ' . "\n" . '' . _DTREE_CLOSEALL . '' . "\n"; echo $data; +/* if (!(intRequestVar('page') > 0) !$catid && !$subcatid) { + echo ''; + }*/ } @@ -133,4 +136,4 @@ class NP_Dtree extends NucleusPlugin } } -?> +?> \ No newline at end of file diff --git a/trunk/NP_Dtree/dtree/dtree.php b/trunk/NP_Dtree/dtree/dtree.php index fb2d742..1946ce5 100644 --- a/trunk/NP_Dtree/dtree/dtree.php +++ b/trunk/NP_Dtree/dtree/dtree.php @@ -1 +1,722 @@ -/*--------------------------------------------------| | dTree 2.05 | www.destroydrop.com/javascript/tree/ | |---------------------------------------------------| | Copyright (c) 2002-2003 Geir Landr・ | | | | This script can be used freely as long as all | | copyright messages are intact. | | | | Updated: 17.04.2003 | |--------------------------------------------------*/ plugin; $imgpath = $plug->getAdminURL(); // $imgpath = 'nucleus/plugins/dtree/'; if ($plug->getOption('folderLinks') == 'yes') { $folderLinks = 'true,'; } else { $folderLinks = 'false,'; } if ($plug->getOption('useSelection') == 'yes') { $useSelection = 'true,'; } else { $useSelection = 'false,'; } if ($plug->getOption('useCookies') == 'yes') { $useCookies = 'true,'; } else { $useCookies = 'false,'; } if ($plug->getOption('useLines') == 'yes') { $useLines = 'true,'; } else { $useLines = 'false,'; } if ($plug->getOption('useIcons') == 'yes') { $useIcons = 'true,'; } else { $useIcons = 'false,'; } if ($plug->getOption('useStatusText') == 'yes') { $useStatusText = 'true,'; } else { $useStatusText = 'false,'; } if ($plug->getOption('closeSameLevel') == 'yes') { $closeSameLevel = 'true,'; } else { $closeSameLevel = 'false,'; } if ($plug->getOption('inOrder') == 'yes') { $inOrder = 'true'; } else { $inOrder = 'false'; } ?> // Node object var imgpath = ""; function Node(id, pid, name, url, title, target, icon, iconOpen, open) { this.id = id; this.pid = pid; this.name = name; this.url = url; this.title = title; this.target = target; this.icon = icon; this.iconOpen = iconOpen; this._io = open || false; this._is = false; this._ls = false; this._hc = false; this._ai = 0; this._p; }; // Tree object function dTree(objName) { this.config = { target : null, folderLinks : useSelection : useCookies : useLines : useIcons : useStatusText : closeSameLevel : inOrder : // folderLinks : true, // useSelection : false, // useCookies : false, // useLines : false, // useIcons : false, // useStatusText : true, // closeSameLevel : true, // inOrder : false } this.icon = { root : imgpath + 'img/base.gif', folder : imgpath + 'img/folder.gif', folderOpen : imgpath + 'img/folderopen.gif', // node : imgpath + 'img/page.gif', node : imgpath + 'img/folder.gif', empty : imgpath + 'img/empty.gif', line : imgpath + 'img/line.gif', join : imgpath + 'img/join.gif', joinBottom : imgpath + 'img/joinbottom.gif', plus : imgpath + 'img/plus.gif', plusBottom : imgpath + 'img/plusbottom.gif', minus : imgpath + 'img/minus.gif', minusBottom : imgpath + 'img/minusbottom.gif', nlPlus : imgpath + 'img/nolines_plus.gif', nlMinus : imgpath + 'img/nolines_minus.gif' }; this.obj = objName; this.aNodes = []; this.aIndent = []; this.root = new Node(-1); this.selectedNode = null; this.selectedFound = false; this.completed = false; }; // Adds a new node to the node array dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open); }; // Open/close all nodes dTree.prototype.openAll = function() { this.oAll(true); }; dTree.prototype.closeAll = function() { this.oAll(false); }; // Outputs the tree to the page dTree.prototype.toString = function() { var str = '
\n'; if (document.getElementById) { if (this.config.useCookies) this.selectedNode = this.getSelected(); str += this.addNode(this.root); } else str += 'Browser not supported.'; str += '
'; if (!this.selectedFound) this.selectedNode = null; this.completed = true; return str; }; // Creates the tree structure dTree.prototype.addNode = function(pNode) { var str = ''; var n=0; if (this.config.inOrder) n = pNode._ai; for (n; n\n'; } if (node.url) { str += ''; str += node.name; if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '\n'; str += '\n'; if (node._hc) { str += '
\n'; str += this.addNode(node); str += '
\n'; } this.aIndent.pop(); return str; }; // Adds the empty and line icons dTree.prototype.indent = function(node, nodeId) { var str = ''; if (this.root.id != node.pid) { for (var n=0; n'; (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); if (node._hc) { str += '\n'; } else str += '\n'; } return str; }; // Checks if a node has any children and if it is the last sibling dTree.prototype.setCS = function(node) { var lastId; for (var n=0; nplugin; + $imgpath = $plug->getAdminURL(); +// $imgpath = 'nucleus/plugins/dtree/'; + + if ($plug->getOption('folderLinks') == 'yes') { + $folderLinks = 'true,'; + } else { + $folderLinks = 'false,'; + } + if ($plug->getOption('useSelection') == 'yes') { + $useSelection = 'true,'; + } else { + $useSelection = 'false,'; + } + if ($plug->getOption('useCookies') == 'yes') { + $useCookies = 'true,'; + } else { + $useCookies = 'false,'; + } + if ($plug->getOption('useLines') == 'yes') { + $useLines = 'true,'; + } else { + $useLines = 'false,'; + } + if ($plug->getOption('useIcons') == 'yes') { + $useIcons = 'true,'; + } else { + $useIcons = 'false,'; + } + if ($plug->getOption('useStatusText') == 'yes') { + $useStatusText = 'true,'; + } else { + $useStatusText = 'false,'; + } + if ($plug->getOption('closeSameLevel') == 'yes') { + $closeSameLevel = 'true,'; + } else { + $closeSameLevel = 'false,'; + } + if ($plug->getOption('inOrder') == 'yes') { + $inOrder = 'true'; + } else { + $inOrder = 'false'; + } + +?> +// Node object + +var imgpath = ""; + +function Node(id, pid, name, url, title, target, icon, iconOpen, open) { + + this.id = id; + + this.pid = pid; + + this.name = name; + + this.url = url; + + this.title = title; + + this.target = target; + + this.icon = icon; + + this.iconOpen = iconOpen; + + this._io = open || false; + + this._is = false; + + this._ls = false; + + this._hc = false; + + this._ai = 0; + + this._p; + +}; + +// Tree object + +function dTree(objName) { + + this.config = { + target : null, + + folderLinks : + useSelection : + useCookies : + useLines : + useIcons : + useStatusText : + closeSameLevel : + inOrder : + +// folderLinks : true, +// useSelection : false, +// useCookies : false, +// useLines : false, +// useIcons : false, +// useStatusText : true, +// closeSameLevel : true, +// inOrder : false + } + + this.icon = { + + root : imgpath + 'img/base.gif', + folder : imgpath + 'img/folder.gif', + folderOpen : imgpath + 'img/folderopen.gif', +// node : imgpath + 'img/page.gif', + node : imgpath + 'img/folder.gif', + empty : imgpath + 'img/empty.gif', + line : imgpath + 'img/line.gif', + join : imgpath + 'img/join.gif', + joinBottom : imgpath + 'img/joinbottom.gif', + plus : imgpath + 'img/plus.gif', + plusBottom : imgpath + 'img/plusbottom.gif', + minus : imgpath + 'img/minus.gif', + minusBottom : imgpath + 'img/minusbottom.gif', + nlPlus : imgpath + 'img/nolines_plus.gif', + nlMinus : imgpath + 'img/nolines_minus.gif' + + }; + + this.obj = objName; + + this.aNodes = []; + + this.aIndent = []; + + this.root = new Node(-1); + + this.selectedNode = null; + + this.selectedFound = false; + + this.completed = false; + +}; + + + +// Adds a new node to the node array + +dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { + + this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open); + +}; + + + +// Open/close all nodes + +dTree.prototype.openAll = function() { + + this.oAll(true); + +}; + +dTree.prototype.closeAll = function() { + + this.oAll(false); + +}; + + + +// Outputs the tree to the page + +dTree.prototype.toString = function() { + + var str = '
\n'; + + if (document.getElementById) { + + if (this.config.useCookies) this.selectedNode = this.getSelected(); + + str += this.addNode(this.root); + + } else str += 'Browser not supported.'; + + str += '
'; + + if (!this.selectedFound) this.selectedNode = null; + + this.completed = true; + + return str; + +}; + + + +// Creates the tree structure + +dTree.prototype.addNode = function(pNode) { + + var str = ''; + + var n=0; + + if (this.config.inOrder) n = pNode._ai; + + for (n; n\n'; + + } + + if (node.url) { + + str += ''; + + str += node.name; + + if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '\n'; + + str += '\n'; + + if (node._hc) { + + str += '
\n'; + + str += this.addNode(node); + + str += '
\n'; + + } + + this.aIndent.pop(); + + return str; + +}; + + + +// Adds the empty and line icons + +dTree.prototype.indent = function(node, nodeId) { + + var str = ''; + + if (this.root.id != node.pid) { + + for (var n=0; n'; + + (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); + + if (node._hc) { + + str += '\n'; + + } else str += '\n'; + + } + + return str; + +}; + + + +// Checks if a node has any children and if it is the last sibling + +dTree.prototype.setCS = function(node) { + + var lastId; + + for (var n=0; ncatid); + $catid = intval($o->catid); $nodeArray['cat'][$catid] = $n; - $url = createCategoryLink($catid); - $printData = $objectId - . ".add(" . $n - . ",0,'" - . htmlspecialchars($o->cname, ENT_QUOTES, _CHARSET) . "','" - . htmlspecialchars($url, ENT_QUOTES, _CHARSET) . "','" - . htmlspecialchars($o->cdesc, ENT_QUOTES, _CHARSET) . "');\n"; + $url = createCategoryLink($catid); + $printData = $objectId + . ".add" + . "(" + . $n . "," + . "0," + . "'" . htmlspecialchars($o->cname, ENT_QUOTES, _CHARSET) . "'," +// . "'" . htmlspecialchars($url, ENT_QUOTES, _CHARSET) . "'," + . "'" . $url . "'," + . "'" . htmlspecialchars($o->cdesc, ENT_QUOTES, _CHARSET). "'" + . ");\n"; echo $printData; $catFilter[] = $catid; $n++; @@ -75,13 +78,15 @@ global $CONF, $manager; if (!$manager->pluginInstalled('NP_MultipleCategories')) { echo 'document.write(' . $objectId . ');'; if ($itemid = intRequestVar('id')) { - $que = 'SELECT icat as result FROM %s WHERE inumber = %d'; - $catid = quickQuery(sprintf($que, sql_table('item'), $itemid)); - $catid = intval($catid); - $nodeId = 's' . $objectId . $nodeArray['cat'][$catid]; - echo "document.getElementById('" - . htmlspecialchars($nodeId, ENT_QUOTES, _CHARSET) - . "').className = 'selectedNode';"; + $que = 'SELECT icat as result FROM %s WHERE inumber = %d'; + $catid = quickQuery(sprintf($que, sql_table('item'), $itemid)); + $catid = intval($catid); + $nodeId = 's' . $objectId . $nodeArray['cat'][$catid]; + $printData = "document.getElementById('" + . htmlspecialchars($nodeId, ENT_QUOTES, _CHARSET) + . "').className = 'selectedNode';"; + echo $printData; + unset($printData); } return; } @@ -110,7 +115,6 @@ global $CONF, $manager; $subrequest = 'subcatid'; } // $query = 'SELECT * FROM %s WHERE catid%s'; -// $query = 'SELECT * FROM %s WHERE catid%s ORDER BY ordid ASC'; $query = 'SELECT * FROM %s WHERE catid%s ORDER BY parentid, catid, ordid'; $query = sprintf($query, $scatTable, $catFilter); $res = sql_query($query); @@ -134,56 +138,67 @@ global $CONF, $manager; $url = createCategoryLink($cat_id, $linkParam); if (!empty($parent_id)) { - $pnode = $nodeArray['subcat'][$parent_id]; + $pnode = intval($nodeArray['subcat'][$parent_id]); } else { - $pnode = $nodeArray['cat'][$cat_id]; + $pnode = intval($nodeArray['cat'][$cat_id]); } $printData = $objectId . ".add" - . "(" . $nodeArray['subcat'][$scatid] . "," + . "(" + . intval($nodeArray['subcat'][$scatid]) . "," . $pnode . "," . "'" . htmlspecialchars($o->sname, ENT_QUOTES, _CHARSET) . "'," - . "'" . htmlspecialchars($url, ENT_QUOTES, _CHARSET) . "'," +// . "'" . htmlspecialchars($url, ENT_QUOTES, _CHARSET) . "'," + . "'" . $url . "'," . "'" . htmlspecialchars($o->sdesc, ENT_QUOTES, _CHARSET) . "'" . ");\n"; echo $printData; + unset($printData); } -// ksort($printData); -// foreach($printData as $parentNode => $scatNode) { -// foreach($scatNode as $showData) { -// echo $showData; -// } -// } echo "document.write(" . $objectId . ");\n"; if ($sid = intRequestVar('sid')) { - $nodeId = 's' . $objectId . $nodeArray['subcat'][$sid]; - echo "document.getElementById('" . $nodeId . "').className='urlselected';\n"; - echo $objectId . ".openTo(" . $nodeArray['subcat'][$sid] . ",true);\n"; + $nodeId = 's' . $objectId . intval($nodeArray['subcat'][$sid]); + $printData = "document.getElementById('" . $nodeId . "')" + . ".className='urlselected';\n" + . $objectId + . ".openTo(" . intval($nodeArray['subcat'][$sid]) . ",true);\n"; + echo $printData; + unset($printData); } elseif ($cid = intRequestVar('cid')) { - $nodeId = 's' . $objectId . $nodeArray['cat'][$cid]; - echo "document.getElementById('" . $nodeId . "').className='urlselected';\n"; - echo $objectId . ".openTo(" . $nodeArray['cat'][$cid] . ",true);\n"; + $nodeId = 's' . $objectId . intval($nodeArray['cat'][$cid]); + $printData = "document.getElementById('" . $nodeId . "')." + . "className='urlselected';\n" + . $objectId + . ".openTo(" . intval($nodeArray['cat'][$cid]) . ",true);\n"; } if ($itemid = intRequestVar('id')) { - $que = 'SELECT icat as result FROM %s WHERE inumber = %d'; - $catid = quickQuery($que, sql_table('item'), $itemid); - $catid = intva($catid); - $nodeId = 's' . $objectId.$nodeArray['cat'][$catid]; - echo "document.getElementById('" . $nodeId . "').className='selectedNode';\n"; + $que = 'SELECT icat as result FROM %s WHERE inumber = %d'; + $catid = quickQuery($que, sql_table('item'), $itemid); + $catid = intval($catid); + $nodeId = 's' . $objectId . intval($nodeArray['cat'][$catid]); + $printData = "document.getElementById('" . $nodeId . "')" + . ".className='selectedNode';\n"; + echo $printData; + unset($printData); //multi catid - $que = 'SELECT categories as result FROM %s WHERE item_id = %d'; - $catids = quickQuery(sprintf($que, sql_table('plug_multiple_categories'), $itemid)); + $que = 'SELECT categories as result FROM %s WHERE item_id = %d'; + $que = sprintf($que, sql_table('plug_multiple_categories'), $itemid); + $catids = quickQuery($que); if ($catids) { $catids = explode(',', $catids); - for ($i=0;$i \ No newline at end of file -- 2.11.0