OSDN Git Service

朝の分修正/未テスト
authorshizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 6 Oct 2006 05:15:59 +0000 (05:15 +0000)
committershizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 6 Oct 2006 05:15:59 +0000 (05:15 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@425 1ca29b6e-896d-4ea0-84a5-967f57386b96

trunk/NP_Dtree/NP_Dtree.php
trunk/NP_Dtree/dtree/dtreedata.php

index 7baea41..db46435 100644 (file)
@@ -65,7 +65,7 @@ class NP_Dtree extends NucleusPlugin
                if ($skinType == 'template') {
                        echo '<script type="text/javascript" src="' .
                                        htmlspecialchars($this->getAdminURL()) . 'dtreedata.php?o=' .
-                                       $randomID.'a&amp;bid=' . $blogid . '&amp;id=' . $itemid . '"></script>';
+                                       $randomID . 'a&amp;bid=' . $blogid . '&amp;id=' . $itemid . '"></script>';
                        echo '<a href="javascript: ' . $randomID . 'a.openAll();">open all</a>' .
                                        ' | <a href="javascript: ' . $randomID . 'a.closeAll();">close all</a>';
                        return;
index 31ae8a7..a69f508 100644 (file)
@@ -1,25 +1,11 @@
 <?php
-//     $strRel = '../../../';
-//     include($strRel . 'config.php');
+global $CONF;
+       $strRel = '../../../';
+       include($strRel . 'config.php');
 
        $usePathInfo = ($CONF['URLMode'] == 'pathinfo');
 
        if ($usePathInfo) {
-               if (empty($CONF['ItemKey'])) {
-                       $CONF['ItemKey'] = 'item';
-               }
-               if (empty($CONF['ArchiveKey'])) {
-                       $CONF['ArchiveKey'] = 'archive';
-               }
-               if (empty($CONF['ArchivesKey'])) {
-                       $CONF['ArchivesKey'] = 'archives';
-               }
-               if (empty($CONF['MemberKey'])) {
-                       $CONF['MemberKey'] = 'member';
-               }
-               if (empty($CONF['BlogKey'])) {
-                       $CONF['BlogKey'] = 'blog';
-               }
                if (empty($CONF['CategoryKey'])) {
                        $CONF['CategoryKey'] = 'category';
                }
 
        $CategoryKey = ($usePathInfo) ? $CONF['CategoryKey'] : 'catid';
 
-       $objectId = requestVar('o');
-       $blogid = intval(requestVar('bid'));
+//     $objectId = requestVar('o');
+       $objectId = 'tree' . intval(substr(requestVar('o'), 4));
+       $blogid = intRequestVar('bid');
+       if (empty($blogid)) $blogid = intval($CONF['DefaultBlog']);
        $blogname = getBlogNameFromID($blogid);
 
                $b =& $manager->getBlog($blogid);
                $blogurl = $b->getURL();
                if (!$blogurl) {
                        if($blog) {
-                               $b_tmp =& $manager->getBlog($CONF['DefaultBlog']);
+                               $b_tmp =& $manager->getBlog($blogid);
                                $blogurl = $b_tmp->getURL();
                        }
                        if (!$blogurl) {
                                $blogurl = $CONF['IndexURL'];
-                               if (!$usePathInfo){
+                               if (!$usePathInfo) {
                                        if ($data['type'] == 'pageparser') {
                                                $blogurl .= 'index.php';
                                        } else {
                $CONF['ArchiveListURL'] = $blogurl;
                $CONF['SearchURL'] = $blogurl;
 
-       echo $objectId . " = new dTree('" . htmlspecialchars($objectId) . "');\n";
+       echo $objectId . "=new dTree('" . htmlspecialchars($objectId) . "');\n";
        
        echo $objectId . ".add(0,-1,'" . htmlspecialchars($blogname) . "');\n";
        
-       $res = sql_query("SELECT * FROM " . sql_table('category') . " WHERE cblog = " . $blogid);
+       $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;
+               $nodeArray['cat'][$catid] = $n;
 //             $url = createBlogidLink($blogid, array('catid'=>$catid));
                $url = createCategoryLink($catid);
 //             $url = createBlogidLink($blogid, array("$CategoryKey"=>$catid));
                $mPlugin =& $manager->getPlugin('NP_MultipleCategories');
                $subrequest = $mPlugin->getRequestName();
                echo 'document.write(' . $objectId . ');';
-               if ($itemid = intval(requestVar('id'))) {
-                       $catid = quickQuery('SELECT icat as result FROM ' . sql_table('item') . ' WHERE inumber = ' . $itemid);
-                       $nodeId = 's' . $objectId . $nodeArray[cat][$catid];
+               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 = @join(', ', $catFilter);
                $catFilter = ' IN (' . $catFilter . ')';
        } else {
                $catFilter = '=' . $catFilter;
        }
        
-       $query = "SELECT * FROM " . sql_table('plug_multiple_categories_sub') . " WHERE catid" . $catFilter;
-       $res = sql_query($query);
+       $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;
+               $nodeArray['subcat'][$scatid] = $n;
                $n++;
        }
-       $query = "SELECT * FROM " . sql_table('plug_multiple_categories_sub') . " WHERE catid" . $catFilter;
-       $res = sql_query($query);
+       $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));
-               $pnode = ($u->parentid) ? $nodeArray[subcat][$u->parentid] : $nodeArray[cat][$u->catid];
-               echo $objectId . ".add(" . $nodeArray[subcat][$u->scatid] . "," . $pnode . ",'" . htmlspecialchars($u->sname) . "','" . $url . "');\n";
+               $pnode = (!empty($parent_id)) ? $nodeArray['subcat'][$parent_id] : $nodeArray['cat'][$cat_id];
+               echo $objectId . ".add(" . $nodeArray['subcat'][$scatid] . "," . $pnode . ",'" . htmlspecialchars($u->sname) . "','" . $url . "');\n";
        }
 
-       echo "document.write(".$objectId.");\n";
+       echo "document.write(" . $objectId . ");\n";
 
 
-       if (requestVar('sid')) {
-               $sid = intval(requestVar('sid'));
-               $nodeId = 's' . $objectId . $nodeArray[subcat][$sid];
-               echo "document.getElementById('" . $nodeId . "').className = 'urlselected';\n";
-               echo $objectId . ".openTo(" . $nodeArray[subcat][$sid] . ", true);\n";
-       } elseif(requestVar('cid')) {
-               $cid = intval(requestVar('cid'));
-               $nodeId = 's' . $objectId . $nodeArray[cat][$cid];
-               echo "document.getElementById('" . $nodeId . "').className = 'urlselected';\n";
-               echo $objectId . ".openTo(" . $nodeArray[cat][$cid] . ", true);\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 = requestVar('id')) {
-               $catid = quickQuery('SELECT icat as result FROM ' . sql_table('item') . ' WHERE inumber = ' . intval($itemid));
-               $nodeId = 's' . $objectId.$nodeArray[cat][$catid];
-               echo "document.getElementById('" . $nodeId . "').className = 'selectedNode';\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'), intval($itemid)));
+               $catids = quickQuery(sprintf($que, sql_table('plug_multiple_categories'), $itemid));
                if ($catids) {
                        $catids = explode(',', $catids);
                        for ($i=0;$i<count($catids);$i++) {
                                $catidTemp = intval($catids[$i]);
                                if ($catidTemp != $catid) {
-                                       $nodeId = 's' . $objectId . $nodeArray[cat][$catidTemp];
-                                       echo "document.getElementById('" . $nodeId . "').className = 'selectedCatNode';\n";
+                                       $nodeId = 's' . $objectId . $nodeArray['cat'][$catidTemp];
+                                       echo "document.getElementById('" . $nodeId . "').className='selectedCatNode';\n";
                                }
                        }
                }
                
                //(multi) subcatid
                $que = 'SELECT subcategories as result FROM %s WHERE item_id = %d';
-               $scatids = quickQuery(sprintf($que, sql_table('plug_multiple_categories'), intval($itemid)));
+               $scatids = quickQuery(sprintf($que, sql_table('plug_multiple_categories'), $itemid));
                if ($scatids) {
                        $scatids = explode(',', $scatids);
                        for ($i=0;$i<count($scatids);$i++) {
                                $scatid = intval($scatids[$i]);
-                               $nodeId = 's' . $objectId . $nodeArray[subcat][$scatid];
-                               echo "document.getElementById('" . $nodeId . "').className = 'selectedScatNode';\n";
-                               echo $objectId . ".openTo(" . $nodeArray[subcat][$scatid] . ", true);\n";
+                               $nodeId = 's' . $objectId . $nodeArray['subcat'][$scatid];
+                               echo "document.getElementById('" . $nodeId . "').className='selectedScatNode';\n";
+                               echo $objectId . ".openTo(" . $nodeArray['subcat'][$scatid] . ",true);\n";
                        }
                }
        }