From ace21f5c6fe368d2df7c6785451431d8fc56b333 Mon Sep 17 00:00:00 2001 From: shizuki Date: Sat, 4 Nov 2006 09:22:52 +0000 Subject: [PATCH] bug fix git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@472 1ca29b6e-896d-4ea0-84a5-967f57386b96 --- trunk/NP_Dtree/dtree/dtree.php | 2 +- trunk/NP_Dtree/dtree/dtreedata.php | 344 +++++++++++++++++++------------------ 2 files changed, 178 insertions(+), 168 deletions(-) diff --git a/trunk/NP_Dtree/dtree/dtree.php b/trunk/NP_Dtree/dtree/dtree.php index 5a29915..a230716 100644 --- a/trunk/NP_Dtree/dtree/dtree.php +++ b/trunk/NP_Dtree/dtree/dtree.php @@ -1 +1 @@ -/*--------------------------------------------------| | dTree 2.05 | www.destroydrop.com/javascript/tree/ | |---------------------------------------------------| | Copyright (c) 2002-2003 Geir LandrĀE | | | | This script can be used freely as long as all | | copyright messages are intact. | | | | Updated: 17.04.2003 | |--------------------------------------------------*/ plug =& $oPluginAdmin->plugin; $imgpath = $this->plug->getAdminURL(); // $imgpath = 'nucleus/plugins/dtree/'; ?> // 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, plug->getOption('folderLinks') == 'yes') { echo 'folderLinks : true,'; } else { echo 'folderLinks : false,'; } if ($this->plug->getOption('useSelection') == 'yes') { echo 'useSelection : true,'; } else { echo 'useSelection : false,'; } if ($this->plug->getOption('useCookies') == 'yes') { echo 'useCookies : true,'; } else { echo 'useCookies : false,'; } if ($this->plug->getOption('useLines') == 'yes') { echo 'useLines : true,'; } else { echo 'useLines : false,'; } if ($this->plug->getOption('useIcons') == 'yes') { echo 'useIcons : true,'; } else { echo 'useIcons : false,'; } if ($this->plug->getOption('useStatusText') == 'yes') { echo 'useStatusText : true,'; } else { echo 'useStatusText : false,'; } if ($this->plug->getOption('closeSameLevel') == 'yes') { echo 'closeSameLevel : true,'; } else { echo 'closeSameLevel : false,'; } if ($this->plug->getOption('inOrder') == 'yes') { echo 'inOrder : true,'; } else { echo 'inOrder : false,'; } ?> // 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'; } if (node.url) { str += ''; str += node.name; if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += ''; str += ''; if (node._hc) { str += '
'; str += this.addNode(node); str += '
'; } 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 += ''; } else str += ''; } 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'; } if (node.url) { str += ''; str += node.name; if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += ''; str += ''; if (node._hc) { str += '
'; str += this.addNode(node); str += '
'; } 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 += ''; } else str += ''; } 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; ngetBlog($blogid); - $blogurl = $b->getURL(); - if (!$blogurl) { - if($blog) { - $b_tmp =& $manager->getBlog($blogid); - $blogurl = $b_tmp->getURL(); - } - if (!$blogurl) { - $blogurl = $CONF['IndexURL']; - if (!$usePathInfo) { - if ($data['type'] == 'pageparser') { - $blogurl .= 'index.php'; - } else { - $blogurl = $CONF['Self']; - } - } - } - } - if ($usePathInfo) { - if (substr($blogurl, -1) == '/') { - $blogurl = substr($blogurl, 0, -1); - } - } - - $CONF['BlogURL'] = $blogurl; - $CONF['ItemURL'] = $blogurl; - $CONF['CategoryURL'] = $blogurl; - $CONF['ArchiveURL'] = $blogurl; - $CONF['ArchiveListURL'] = $blogurl; - $CONF['SearchURL'] = $blogurl; - - echo $objectId . "=new dTree('" . htmlspecialchars($objectId) . "');\n"; - - echo $objectId . ".add(0,-1,'" . htmlspecialchars($blogname) . "');\n"; - - $resq = 'SELECT * FROM %s WHERE cblog = %d'; - $res = sql_query(sprintf($resq, sql_table('category'), $blogid)); - $n = 1; - while ($o = mysql_fetch_object($res)) { - $catid = intval($o->catid); - $nodeArray['cat'][$catid] = $n; -// $url = createBlogidLink($blogid, array('catid'=>$catid)); - $url = createCategoryLink($catid); -// $url = createBlogidLink($blogid, array("$CategoryKey"=>$catid)); - echo $objectId . ".add(" . $n . ",0,'" . htmlspecialchars($o->cname) . "','" . htmlspecialchars($url) . "','" . htmlspecialchars($o->cdesc) . "');\n"; - $catFilter[] = $catid; - $n++; - } - - global $manager; - if (!$manager->pluginInstalled('NP_MultipleCategories')) { - $mPlugin =& $manager->getPlugin('NP_MultipleCategories'); - $subrequest = $mPlugin->getRequestName(); - 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) . "').className = 'selectedNode';"; - } - return; - } - - if ($catFilter[1]) { - $catFilter = @join(', ', $catFilter); - $catFilter = ' IN (' . $catFilter . ')'; - } else { - $catFilter = '=' . $catFilter; - } - - $query = 'SELECT * FROM %s WHERE catid %s'; - $res = sql_query(sprintf($query, sql_table('plug_multiple_categories_sub'), $catFilter)); - while ($o = mysql_fetch_object($res)) { - $scatid = intval($o->scatid); - $nodeArray['subcat'][$scatid] = $n; - $n++; - } - $query = 'SELECT * FROM %s WHERE catid %s'; - $res = sql_query(sprintf($query, sql_table('plug_multiple_categories_sub'), $catFilter)); - while ($u = mysql_fetch_object($res)) { - $scatid = intval($u->scatid); - $parent_id = intval($u->parentid); - $cat_id = intval($u->catid); -// $url = createBlogidLink($blogid, array('catid'=>$u->catid, 'subcatid'=>$scatid)); - $url = createCategoryLink($u->catid, array($subrequest => $scatid)); -// $url = createBlogidLink($blogid, array("$CategoryKey"=>$u->catid, 'subcatid'=>$scatid)); - $scat_desc = $b->getCategoryDesc($catid); - $pnode = (!empty($parent_id)) ? $nodeArray['subcat'][$parent_id] : $nodeArray['cat'][$cat_id]; - echo $objectId . ".add(" . $nodeArray['subcat'][$scatid] . "," . $pnode . ",'" . htmlspecialchars($u->sname) . "','" . htmlspecialchars($url) . "','" . htmlspecialchars($u->sdesc) . "');\n"; - } - - echo "document.write(" . $objectId . ");\n"; - - - if ($sid = intRequestVar('sid')) { -// $sid = intRequestVar('sid'); - $nodeId = 's' . $objectId . $nodeArray['subcat'][$sid]; - echo "document.getElementById('" . $nodeId . "').className='urlselected';\n"; - echo $objectId . ".openTo(" . $nodeArray['subcat'][$sid] . ",true);\n"; - } elseif ($cid = intRequestVar('cid')) { -// $cid = intRequestVar('cid'); - $nodeId = 's' . $objectId . $nodeArray['cat'][$cid]; - echo "document.getElementById('" . $nodeId . "').className='urlselected';\n"; - echo $objectId . ".openTo(" . $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); -// $catid = quickQuery('SELECT icat as result FROM ' . sql_table('item') . ' WHERE inumber = ' . $itemid); - $nodeId = 's' . $objectId.$nodeArray['cat'][$catid]; - echo "document.getElementById('" . $nodeId . "').className='selectedNode';\n"; - - //multi catid - $que = 'SELECT categories as result FROM %s WHERE item_id = %d'; - $catids = quickQuery(sprintf($que, sql_table('plug_multiple_categories'), $itemid)); - if ($catids) { - $catids = explode(',', $catids); - for ($i=0;$igetBlog($blogid); + $blogurl = $b->getURL(); + if (!$blogurl) { + if($blog) { + $b_tmp =& $manager->getBlog($blogid); + $blogurl = $b_tmp->getURL(); + } + if (!$blogurl) { + $blogurl = $CONF['IndexURL']; + if (!$usePathInfo) { + if ($data['type'] == 'pageparser') { + $blogurl .= 'index.php'; + } else { + $blogurl = $CONF['Self']; + } + } + } + } + if ($usePathInfo) { + if (substr($blogurl, -1) == '/') { + $blogurl = substr($blogurl, 0, -1); + } + } + + $CONF['BlogURL'] = $blogurl; + $CONF['ItemURL'] = $blogurl; + $CONF['CategoryURL'] = $blogurl; + $CONF['ArchiveURL'] = $blogurl; + $CONF['ArchiveListURL'] = $blogurl; + $CONF['SearchURL'] = $blogurl; + + echo $objectId . "=new dTree('" . htmlspecialchars($objectId) . "');\n"; + + echo $objectId . ".add(0,-1,'" . htmlspecialchars($blogname) . "');\n"; + + $resq = 'SELECT * FROM %s WHERE cblog = %d'; + $res = sql_query(sprintf($resq, sql_table('category'), $blogid)); + $n = 1; + while ($o = mysql_fetch_object($res)) { + $catid = intval($o->catid); + $nodeArray['cat'][$catid] = $n; +// $url = createBlogidLink($blogid, array('catid'=>$catid)); + $url = createCategoryLink($catid); +// $url = createBlogidLink($blogid, array("$CategoryKey"=>$catid)); + $printData = $objectId + . ".add(" . $n + . ",0,'" + . htmlspecialchars($o->cname) . "','" + . htmlspecialchars($url) . "','" + . htmlspecialchars($o->cdesc) . "');\n"; + echo $printData; + $catFilter[] = $catid; + $n++; + } + + 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) . "').className = 'selectedNode';"; + } + return; + } + + if ($catFilter[1]) { + $catFilter = @join(', ', $catFilter); + $catFilter = ' IN (' . $catFilter . ')'; + } else { + $catFilter = '=' . $catFilter; + } + + $query = 'SELECT * FROM %s WHERE catid %s ORDER BY scatid'; + $res = sql_query(sprintf($query, sql_table('plug_multiple_categories_sub'), $catFilter)); + while ($o = mysql_fetch_object($res)) { + $scatid = intval($o->scatid); + $nodeArray['subcat'][$scatid] = $n; + $n++; + } + $query = 'SELECT * FROM %s WHERE catid %s ORDER BY scatid'; + $res = sql_query(sprintf($query, sql_table('plug_multiple_categories_sub'), $catFilter)); + $mcategories =& $manager->getPlugin('NP_MultipleCategories'); + if (method_exists($mcategories, "getRequestName")) { + $subrequest = $mcategories->getRequestName(); + } else { + $subrequest = 'subcatid'; + } + + while ($u = mysql_fetch_object($res)) { + $scatid = intval($u->scatid); + $parent_id = intval($u->parentid); + $cat_id = intval($u->catid); +// $url = createBlogidLink($blogid, array('catid'=>$u->catid, 'subcatid'=>$scatid)); + $url = createCategoryLink($cat_id, array($subrequest => $scatid)); +// $url = createBlogidLink($blogid, array("$CategoryKey"=>$u->catid, 'subcatid'=>$scatid)); + + $pnode = (!empty($parent_id)) ? $nodeArray['subcat'][$parent_id] : $nodeArray['cat'][$cat_id]; + $printData = $objectId . ".add(" . $nodeArray['subcat'][$scatid] . "," + . $pnode . ",'" + . htmlspecialchars($u->sname) . "','" + . htmlspecialchars($url) . "','" + . htmlspecialchars($u->sdesc) . "');\n"; + echo $printData; + } + + echo "document.write(" . $objectId . ");\n"; + + + if ($sid = intRequestVar('sid')) { +// $sid = intRequestVar('sid'); + $nodeId = 's' . $objectId . $nodeArray['subcat'][$sid]; + echo "document.getElementById('" . $nodeId . "').className='urlselected';\n"; + echo $objectId . ".openTo(" . $nodeArray['subcat'][$sid] . ",true);\n"; + } elseif ($cid = intRequestVar('cid')) { +// $cid = intRequestVar('cid'); + $nodeId = 's' . $objectId . $nodeArray['cat'][$cid]; + echo "document.getElementById('" . $nodeId . "').className='urlselected';\n"; + echo $objectId . ".openTo(" . $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); +// $catid = quickQuery('SELECT icat as result FROM ' . sql_table('item') . ' WHERE inumber = ' . $itemid); + $nodeId = 's' . $objectId.$nodeArray['cat'][$catid]; + echo "document.getElementById('" . $nodeId . "').className='selectedNode';\n"; + + //multi catid + $que = 'SELECT categories as result FROM %s WHERE item_id = %d'; + $catids = quickQuery(sprintf($que, sql_table('plug_multiple_categories'), $itemid)); + if ($catids) { + $catids = explode(',', $catids); + for ($i=0;$i \ No newline at end of file -- 2.11.0