OSDN Git Service

(none)
authorsatona <satona@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 3 Oct 2006 12:19:35 +0000 (12:19 +0000)
committersatona <satona@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 3 Oct 2006 12:19:35 +0000 (12:19 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@407 1ca29b6e-896d-4ea0-84a5-967f57386b96

19 files changed:
trunk/NP_MultipleCategories/multiplecategories/class.php [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/bdelete.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/bedit.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/down.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/empty.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/folder.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/folder_open.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/folderopen.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/join.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/joinbottom.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/line.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/minus.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/minusbottom.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/images/up.gif [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/index.php [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/language/english.php [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/language/japanese-euc.php [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/language/japanese-utf8.php [new file with mode: 0644]
trunk/NP_MultipleCategories/multiplecategories/orderlist.js [new file with mode: 0644]

diff --git a/trunk/NP_MultipleCategories/multiplecategories/class.php b/trunk/NP_MultipleCategories/multiplecategories/class.php
new file mode 100644 (file)
index 0000000..4f8b4e9
--- /dev/null
@@ -0,0 +1,293 @@
+<?php
+
+/* 
+  Class for Plugin Admin Area 
+  Taka http://vivian.stripper.jp/ 2004-04-13
+
+     Copied / Arranged => nucleus/libs/ADMIN.php, TEMPLATE.php
+     And a few was added...
+*/
+       
+       // class PULUG_ADMIN
+       // class PLUG_TEMPLATE_MANAGER
+
+class PLUG_ADMIN {
+       
+       function action($action) {
+               $methodName = 'action_' . $action;
+               if (method_exists($this, $methodName)) {
+                       call_user_func(array(&$this, $methodName));
+               } else {
+                       $this->error(_BADACTION . " ($action)");
+               }
+       }
+
+       function disallow() {
+               global $HTTP_SERVER_VARS;
+               
+               ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . $HTTP_SERVER_VARS['REQUEST_URI']);
+               
+               $this->error(_ERROR_DISALLOWED);
+       }
+
+       function error($msg) {
+               global $oPluginAdmin;
+               
+               $oPluginAdmin->start();
+               $dir=$oPluginAdmin->plugin->getAdminURL();
+               ?>
+               <h2>Error!</h2>
+               <?php           echo $msg;
+               echo "<br />";
+               echo "<a href='".$dir."index.php' onclick='history.back()'>"._BACK."</a>";
+               
+               $oPluginAdmin->end();
+               exit;
+       }
+
+       function requestEx($name) {
+               if(phpversion()<"4.1.0") {
+                       global $HTTP_POST_VARS, $HTTP_GET_VARS;
+                       $data = $HTTP_POST_VARS[$name] ? $HTTP_POST_VARS[$name] : $HTTP_GET_VARS[$name];
+               } else {
+                       $data = $_REQUEST[$name];
+               }
+               if (is_array($data) && get_magic_quotes_gpc()) {
+                               return array_map("stripslashes",$data);
+               } else {
+                               return get_magic_quotes_gpc() ? stripslashes($data) : $data;
+               }
+       }
+
+       function help($name) {
+               echo $this->helpHtml($name);
+       }
+
+       function helpHtml($name) {
+               return $this->helplink($name) . '<img src="documentation/icon-help.gif" width="15" height="15" alt="'._HELP_TT.'" /></a>';
+       }
+
+       function helplink($name) {
+               global $oPluginAdmin;
+               
+               $dir=$oPluginAdmin->plugin->getAdminURL();
+               return '<a href="'.$dir.'help.html#'. $name . '" onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);">';
+       }
+
+       function showRadioButton($name, $radio_array, $checked, $tabindex=0) {
+   /*
+      $name : The name of the radiobutton element.
+      $radio_array :An associative array of option element data.
+        [Format] $radio_array = array('radiobutton value' => 'radiobutton title')
+      $checked : The value of the checked element.
+   */
+               foreach ($radio_array as $k => $v) {
+                       echo '<input type="radio" name="'.$name.'" id="'.$name.$k.'" value="'.$k.'"';
+                       if ($k == $checked) echo ' checked="checked"';
+                       echo ' tabindex="'.$tabindex.'" />';
+                       echo '<label for="'.$name.$k.'">'.$v.'</label>';
+               }
+       }
+
+       function showBlogCheckbox($name, $checked_array=array(), $tabindex=0) {
+   /*
+      $name : The name of the input(checkbox) element.
+           !!! Checked blogID data is returned as array. !!!
+      $checked_array : Array containing blogID which should be checked beforehand.
+   */
+
+               $query = 'SELECT bnumber, bname FROM '.sql_table('blog').' ORDER BY bnumber';
+               $res = sql_query($query);
+               
+               while ($data = mysql_fetch_assoc($res)) {
+                       $data['bname'] = htmlspecialchars(shorten($data['bname'],16,'..'));
+                       
+                       echo '<span style="white-space:nowrap"><input type="checkbox" name="'.$name.'[]" value="'.$data['bnumber'].'"';
+                       
+                       if(in_array($data['bnumber'],$checked_array)) {
+                               echo ' checked="checked"';
+                       }
+                       echo ' tabindex="'.$tabindex.'" id="blog_checkbox'.$data['bnumber'].'" />';
+                       echo '<label for="blog_checkbox'.$data['bnumber'].'">';
+                       echo $data['bnumber'].":".$data['bname'].'</label></span>';
+               }
+       }
+
+       function showCategoryCheckbox($name, $blogid, $checked_array=array(), $tabindex=0) {
+   /*
+      $name : The name of the input(checkbox) element.
+           !!! Checked catID data is returned as array. !!!
+      $blogid : blogID to which a category belongs
+      $checked_array : Array containing catID which should be checked beforehand.
+   */
+
+               $query = 'SELECT catid, cname FROM '.sql_table('category').'WHERE cblog='.$blogid.' ORDER BY catid';
+               $res = sql_query($query);
+               
+               while ($data = mysql_fetch_assoc($res)) {
+                       $data['cname'] = htmlspecialchars(shorten($data['cname'],16,'..'));
+                       
+                       echo '<span style="white-space:nowrap"><input type="checkbox" name="'.$name.'[]" value="'.$data['catid'].'"';
+                       
+                       if(in_array($data['catid'],$checked_array)) {
+                               echo ' checked="checked"';
+                       }
+                       echo ' tabindex="'.$tabindex.'" id="category_checkbox'.$data['catid'].'" />';
+                       echo '<label for="category_checkbox'.$data['catid'].'">';
+                       echo $data['catid'].":".$data['cname'].'</label></span>';
+               }
+       }
+
+       function showSelectMenu($name, $option_array, $selected, $tabindex=0) {
+   /*
+      $name : The name of the select element.
+      $option_array :An associative array of option element data.
+        [Format] $option_array = array('option value' => 'option title')
+      $selected : The value of the selected option element.
+   */
+
+               echo '<select name="'.$name.'" tabindex="'.$tabindex.'">';
+               foreach ($option_array as $k => $v) {
+                       echo '<option value="'.$k.'"';
+                       if ($k == $selected) echo ' selected="selected"';
+                       echo '>'.$v.'</option>';
+               }
+               echo '</select>';
+       }
+
+       function showRankSelectMenu($name, $selected=20, $maxvalue=50, $tabindex=0) {
+               echo '<select name="'.$name.'" tabindex="'.$tabindex.'">';
+               for ($i=1; $i<=$maxvalue; $i++) {
+                       echo '<option value="'.$i.'"';
+                       if ($i == $selected)  echo ' selected="selected"';
+                       echo '>'.$i.'</option>';
+               }
+               echo '</select>';
+       }
+
+       function showAllCategorySelectMenu($name, $selected = '', $tabindex = 0) {
+               
+               echo '<select name="',$name,'" tabindex="',$tabindex,'">';
+               if (!$selected) {
+                       echo '<option value="" selected="selected"> --- </option>';
+               }
+
+               // 1. select blogs (we'll create optiongroups)
+               $queryBlogs =  'SELECT bnumber, bname FROM '.sql_table('blog').' ORDER BY bnumber';
+               $blogs = sql_query($queryBlogs);
+               if (mysql_num_rows($blogs) > 1) {
+                       $multipleBlogs = 1;
+               }
+
+               while ($oBlog = mysql_fetch_object($blogs)) {
+                       if ($multipleBlogs) {
+                               echo '<optgroup label="',htmlspecialchars($oBlog->bname),'">';
+                       }
+               
+                       // 2. for each category in that blog
+                       $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
+                       while ($oCat = mysql_fetch_object($categories)) {
+                               if ($oCat->catid == $selected)
+                                       $selectText = ' selected="selected" ';
+                               else
+                                       $selectText = '';
+                               echo '<option value="',$oCat->catid,'" ', $selectText,'>',htmlspecialchars($oCat->cname),'</option>';
+                       }
+
+                       if ($multipleBlogs) {
+                               echo '</optgroup>';
+                       }
+               
+               }
+               echo '</select>';
+               
+       }
+
+       function templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
+   /*
+      $template : An associative array of current template.
+         [Format] $template = array( 'template part name' => 'template part value')
+      $description : Description of current template part.
+      $name : The name of the current template part.
+   */
+       ?>
+               </tr><tr>       
+                       <td><?php echo $description ?> <?php if ($help) $this->help($help); ?></td>
+                       <td><textarea name="<?php echo $name?>" tabindex="<?php echo $tabindex?>" cols="50" rows="<?php echo $big ? '10' : '5'; ?>"><?php echo  htmlspecialchars($template[$name]); ?></textarea></td>
+       <?php
+       }
+
+}
+
+
+class PLUG_TEMPLATE_MANAGER {
+       
+       function PLUG_TEMPLATE_MANAGER($table,$primarykey,$namecolumn) {
+               $this->table = $table;
+               $this->idkey = $primarykey;
+               $this->namekey = $namecolumn;
+               // !!! $this->idkey must be set as "auto_increment." !!!
+       }
+
+       function getIdFromName($name) {
+               return quickQuery('SELECT '.$this->idkey.' as result FROM '.$this->table.' WHERE '.$this->namekey.'="'.addslashes($name).'"');
+       }
+
+       function getNameFromID($id) {
+               return quickQuery('SELECT '.$this->namekey.' as result FROM '.$this->table.' WHERE '.$this->idkey.'='.intval($id));
+       }
+       
+       function getDataFromID($dataname,$id) {
+               return quickQuery('SELECT '.$dataname.' as result FROM '.$this->table.' WHERE '.$this->idkey.'='.intval($id));
+       }
+       
+       function exists($name) {
+               $res = sql_query('SELECT * FROM '.$this->table.' WHERE '.$this->namekey.'="'.addslashes($name).'"');
+               return (mysql_num_rows($res) != 0);
+       }
+       
+       function existsID($id) {
+               $res = sql_query('select * FROM '.$this->table.' WHERE '.$this->idkey.'='.intval($id));
+               return (mysql_num_rows($res) != 0);
+       }
+       
+       function getNameList($w='') {
+               $where = '';
+               if ($w != '') $where = ' WHERE '.$w;
+               $res = sql_query('SELECT '.$this->idkey.' as id, '.$this->namekey.' as name FROM '.$this->table. $where .' ORDER BY '.$this->namekey);
+               while ($obj = mysql_fetch_object($res)) {
+                       $templates[intval($obj->id)] = $obj->name;
+               }
+               return $templates;
+       }
+       
+       function read($name) {
+               $query = 'SELECT * FROM '.$this->table.' WHERE '.$this->namekey.'="'.addslashes($name).'"';
+               $res = sql_query($query);
+               return mysql_fetch_assoc($res);
+       }
+
+       function createTemplate($name) {
+               sql_query('INSERT INTO '.$this->table.' SET '.$this->namekey.'="'. addslashes($name) .'"');
+               $newid = mysql_insert_id();
+               return $newid;
+       }
+
+       function updateTemplate($id, $template) {
+               $query = 'UPDATE '.$this->table.' SET ';
+               foreach ($template as $k => $v) {
+                       $query .= $k.'="'.addslashes($v).'",';
+               }
+               $query = substr($query,0,-1);
+               $query .= ' WHERE '.$this->idkey.'='.$id;
+               sql_query($query);
+       }
+
+       function deleteTemplate($id) {
+               sql_query('DELETE FROM '.$this->table.' WHERE '.$this->idkey.'=' . $id);
+       }
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/bdelete.gif b/trunk/NP_MultipleCategories/multiplecategories/images/bdelete.gif
new file mode 100644 (file)
index 0000000..241e2da
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/bdelete.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/bedit.gif b/trunk/NP_MultipleCategories/multiplecategories/images/bedit.gif
new file mode 100644 (file)
index 0000000..bfdd342
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/bedit.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/down.gif b/trunk/NP_MultipleCategories/multiplecategories/images/down.gif
new file mode 100644 (file)
index 0000000..039bca9
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/down.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/empty.gif b/trunk/NP_MultipleCategories/multiplecategories/images/empty.gif
new file mode 100644 (file)
index 0000000..1993c8b
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/empty.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/folder.gif b/trunk/NP_MultipleCategories/multiplecategories/images/folder.gif
new file mode 100644 (file)
index 0000000..01b64b0
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/folder.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/folder_open.gif b/trunk/NP_MultipleCategories/multiplecategories/images/folder_open.gif
new file mode 100644 (file)
index 0000000..f75a9cf
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/folder_open.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/folderopen.gif b/trunk/NP_MultipleCategories/multiplecategories/images/folderopen.gif
new file mode 100644 (file)
index 0000000..cc9521d
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/folderopen.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/join.gif b/trunk/NP_MultipleCategories/multiplecategories/images/join.gif
new file mode 100644 (file)
index 0000000..18b9569
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/join.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/joinbottom.gif b/trunk/NP_MultipleCategories/multiplecategories/images/joinbottom.gif
new file mode 100644 (file)
index 0000000..4e6d2e2
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/joinbottom.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/line.gif b/trunk/NP_MultipleCategories/multiplecategories/images/line.gif
new file mode 100644 (file)
index 0000000..efe7e67
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/line.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/minus.gif b/trunk/NP_MultipleCategories/multiplecategories/images/minus.gif
new file mode 100644 (file)
index 0000000..d4222da
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/minus.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/minusbottom.gif b/trunk/NP_MultipleCategories/multiplecategories/images/minusbottom.gif
new file mode 100644 (file)
index 0000000..c6b53e1
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/minusbottom.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/images/up.gif b/trunk/NP_MultipleCategories/multiplecategories/images/up.gif
new file mode 100644 (file)
index 0000000..6a91583
Binary files /dev/null and b/trunk/NP_MultipleCategories/multiplecategories/images/up.gif differ
diff --git a/trunk/NP_MultipleCategories/multiplecategories/index.php b/trunk/NP_MultipleCategories/multiplecategories/index.php
new file mode 100644 (file)
index 0000000..bd11d02
--- /dev/null
@@ -0,0 +1,882 @@
+<?php
+/**
+  * NP_MultipleCategories Admin Page Script 
+  *     Taka ( http://reverb.jp/vivian/) 2004-12-01
+  *   + nakahara21 ( http://nakahara21.com/) 2005-07-20
+  *   + sato(na) ( http://wa.otesei.com/) 2006-05-01
+  */
+
+       // if your 'plugin' directory is not in the default location,
+       // edit this variable to point to your site directory
+       // (where config.php is)
+       $strRel = '../../../';
+
+       include($strRel . 'config.php');
+       if (!$member->isLoggedIn())
+               doError('You\'re not logged in.');
+
+       include($DIR_LIBS . 'PLUGINADMIN.php');
+
+       // create the admin area page
+       $oPluginAdmin = new PluginAdmin('MultipleCategories');
+       
+// ------------------------------------------------------------------
+
+class NpMCategories_ADMIN {
+
+       function NpMCategories_ADMIN() {
+               global $oPluginAdmin;
+               
+               $this->plug =& $oPluginAdmin->plugin;
+               $this->plugname = $this->plug->getName();
+               $this->url = $this->plug->getAdminURL();
+               $this->table = sql_table('plug_multiple_categories_sub');
+
+//modify start+++++++++
+               $this->version = $this->plug->checkMSCVersion();
+
+               // include language file for this plugin 
+               $language = ereg_replace( '[\\|/]', '', getLanguageName()); 
+               if (file_exists($this->plug->getDirectory().'language/'.$language.'.php')) 
+                       include_once($this->plug->getDirectory().'language/'.$language.'.php'); 
+               else 
+                       include_once($this->plug->getDirectory().'language/'.'english.php');
+//modify end+++++++++
+
+       }
+
+//-------------------
+
+       function action_overview($msg='') {
+               global $member, $oPluginAdmin;
+               
+               $member->isAdmin() or $this->disallow();
+
+               $oPluginAdmin->start();
+               
+               echo '<p><a href="index.php?action=pluginlist">('._PLUGS_BACK.')</a></p>';
+               echo '<h2>' .$this->plugname. '</h2>'."\n";
+               if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
+               echo '<p>[<a href="index.php?action=pluginoptions&amp;plugid='.$this->plug->getID().'">'._MC_EDIT_PLUGIN_OPTIONS.'</a>]</p>';
+               
+//modify start+++++++++
+               if($this->version == 2){
+                       echo '<blockquote style="color: red;border:1px solid red;padding:0.5em;"><b>Upgarde Information:</b><br />';
+                       echo _MC_SCAT_TABLE_UPDATE_INFO;
+?>
+                       <form method="post" action="<?php echo $this->url ?>index.php"><div>
+                               <input type="hidden" name="action" value="tableUpgrade" />
+                               <input type="submit" tabindex="10" value="upgrade table" />
+                       </div></form>
+<?php
+                       echo '</blockquote>';
+               }
+               
+               $res = sql_query('SELECT bnumber, bname FROM '.sql_table('blog'));
+               while ($o = mysql_fetch_object($res)) {
+?>
+<?php
+               echo '<h3 style="padding-left: 0px">' . htmlspecialchars($o->bname) . '</h3>';
+?>
+<table>
+       <thead>
+               <tr><th><?php echo _LISTS_NAME ?></th><th><?php echo _LISTS_DESC ?></th><th><?php echo _MC_SUB_CATEGORIES ?></th><th><?php echo _LISTS_ACTIONS ?></th></tr>
+       </thead>
+       <tbody>
+<?php
+                       $cats = $this->plug->_getCategories($o->bnumber);
+                       foreach ($cats as $cat) {
+                               $snum = quickQuery("SELECT count(*) as result FROM ".$this->table." WHERE catid=".$cat['catid']);
+                               $snum = intval($snum);
+?>
+               <tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'>
+                       <td>
+                               <?php echo htmlspecialchars($cat['name']) ?></td>
+                       <td><?php echo htmlspecialchars($cat['cdesc']) ?></td>
+                       <td><?php echo $snum ?></td>
+                       <td><a href="<?php echo $this->url ?>index.php?action=scatoverview&amp;catid=<?php echo $cat['catid'] ?>" tabindex="50"><?php echo _MC_EDIT_SUB_CATEGORIES ?></a></td>
+               </tr>
+<?php
+                       }
+?>
+       </tbody>
+</table>
+<?php
+               }
+               
+               $oPluginAdmin->end();
+       
+       }
+
+//-----
+
+       function action_scatoverview($msg = '') {
+               global $member, $oPluginAdmin;
+               
+               $member->isAdmin() or $this->disallow();
+               
+               $catid = intRequestVar('catid');
+               $catname = $this->plug->_getCatNameFromID($catid);
+               
+               $oPluginAdmin->start();
+
+?>
+<p><a href="<?php echo $this->url ?>index.php?action=overview">(Go Back)</a></p>
+
+<h2><?php 
+               echo _MC_EDIT_SUB_CATEGORIES_OF." '".htmlspecialchars($catname)."'</h2>\n";
+
+               if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
+
+               $defines = $this->plug->_getDefinedScats($catid);
+               if (count($defines) > 0) {
+
+//modify start+++++++++
+                       if($this->version > 2){
+                               echo $this->listupSubcategories($catid, $subcatid);
+                               echo $this->showOrderMenu($catid, $subcatid);
+                       }else{
+//modify end+++++++++
+
+?>
+
+       <table>
+       <thead>
+               <tr><th><?php echo _LISTS_NAME ?></th><th><?php echo _LISTS_DESC ?></th><th colspan='2'><?php echo _LISTS_ACTIONS ?></th></tr>
+       </thead>
+       <tbody>
+<?php
+                       foreach ($defines as $scat) {
+?>
+               <tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'>
+                       <td><?php echo htmlspecialchars($scat['sname']) ?></td>
+                       <td><?php echo htmlspecialchars($scat['sdesc']) ?></td>
+                       <td><a href="<?php echo $this->url ?>index.php?action=scatedit&amp;catid=<?php echo $catid ?>&amp;scatid=<?php echo $scat['scatid'] ?>" tabindex="50"><?php echo _LISTS_EDIT ?></a></td>
+                       <td><a href="<?php echo $this->url ?>index.php?action=scatdelete&amp;catid=<?php echo $catid ?>&amp;scatid=<?php echo $scat['scatid'] ?>" tabindex="50"><?php echo _LISTS_DELETE ?></a></td>
+               </tr>
+<?php
+                       }
+?>
+       </tbody>
+       </table>
+<?php
+//modify start+++++++++
+                       }
+//modify end+++++++++
+               } //end of if(count($defines) > 0)
+               
+               echo "\n\n".'<h3>'._MC_CREATE_NEW_SUB_CATEGORY.'</h3>'."\n\n";
+               
+?>
+       <form method="post" action="<?php echo $this->url ?>index.php"><div>
+       
+               <input name="action" value="scatnew" type="hidden" />
+               <input name="catid" value="<?php echo $catid ?>" type="hidden" />
+               <table><tr>
+                       <td><?php echo _MC_SCAT_NAME ?></td>
+                       <td><input name="sname" tabindex="10010" maxlength="20" size="20" /></td>
+               </tr><tr>
+                       <td><?php echo _MC_SCAT_DESC ?></td>
+                       <td><input name="sdesc" tabindex="10020" size="60" maxlength="200" /></td>
+               </tr><tr>
+<?php
+                       if($this->version > 2){
+?>
+                       <td><?php echo _MC_SCAT_PARENT_NAME ?></td>
+                       <td>
+<?php
+                               $subcategoryList = $this->getCategoryList($catid);
+                               echo $this->printCategoryList($catid, $subcategoryList, 1, 0);
+?>
+       </td>
+               </tr><tr>
+<?php
+                       }
+?>
+                       <td><?php echo _MC_SCAT_CREATE ?></td>
+                       <td><input type="submit" tabindex="10030" value="<?php echo _MC_SCAT_CREATE ?>" onclick="return checkSubmit();" /></td>
+               </tr></table>
+               
+       </div></form>
+<?php
+               
+               $oPluginAdmin->end();
+       
+       }
+       
+       function action_scatedit($msg = '') {//-----
+               global $member, $oPluginAdmin;
+               
+               $member->isAdmin() or $this->disallow();
+
+               $scatid = intRequestVar('scatid');
+               $catid = intRequestVar('catid');
+               
+               $res = sql_query("SELECT * FROM ".$this->table." WHERE scatid=$scatid and catid=$catid");
+               if ($o = mysql_fetch_object($res)) {
+
+                       $oPluginAdmin->start();
+
+?>
+<p><a href="<?php echo $this->url ?>index.php?action=scatoverview&amp;catid=<?php echo $catid ?>">(Go Back to OVERVIEW)</a></p>
+
+<h2><?php 
+                       echo _MC_SCAT_EDIT;
+                       echo  " '".htmlspecialchars($o->sname)."'</h2>\n";
+
+                       if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
+
+?>
+<script language=javascript src=<?php echo $this->url ?>orderlist.js></script>
+<form method="post" action="<?php echo $this->url ?>index.php?action=scatedit&catid=<?php echo $catid; ?>&scatid=<?php echo $scatid; ?>">
+       <input type="hidden" name="action" value="scatupdate" />
+       <input type="hidden" name="scatid" value="<?php echo $scatid; ?>" />
+       <input type="hidden" name="catid" value="<?php echo $catid; ?>" />
+
+       <div>
+               
+       <table><tr>
+               <td><?php echo _MC_SCAT_NAME ?></td>
+               <td><input name="sname" tabindex="10010" maxlength="20" size="20" value="<?php echo htmlspecialchars($o->sname) ?>" /></td>
+       </tr><tr>
+               <td><?php echo _MC_SCAT_DESC ?></td>
+               <td><input name="sdesc" tabindex="10020" size="60" maxlength="200" value="<?php echo htmlspecialchars($o->sdesc) ?>" /></td>
+       </tr><tr>
+<?php
+                       if($this->version > 2){
+?>
+                       <td><?php echo _MC_SCAT_PARENT_NAME . '<br />' . _MC_SCAT_PARENT_NAME_DESC ?></td><!-- <sato(na)0.402j /> -->
+                       <td>
+<?php
+                               $pid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$scatid);
+                               //<sato(na)0.402j>
+                               //$subcategoryList = $this->getCategoryList($catid, $pid);
+                               //echo $this->printCategoryList($catid, $subcategoryList, 1);
+                               echo $this->printCategoryListUD($catid, $pid);
+                               //</sato(na)0.402j>
+?>
+       </td>
+               </tr><tr>
+<?php
+                       }
+?>
+               <td><?php echo _MC_SCAT_UPDATE ?></td>
+               <td><input type="submit" tabindex="10030" value="<?php echo _MC_SCAT_UPDATE ?>" onclick="return checkSubmit();" /></td>
+       </tr></table>
+               
+       </div>
+</form>
+<?php
+                       if($this->version > 2) echo $this->showOrderMenu($catid, $scatid);
+
+                       $oPluginAdmin->end();
+
+               } else $this->error(_MC_SCAT_MISSING);
+       }//-----
+
+       function action_scatnew() {
+               global $member;
+               
+               $member->isAdmin() or $this->disallow();
+               
+               $sname = postVar('sname');
+               if (!trim($sname)){
+                       $this->action_scatoverview(_MC_SCAT_ERROR_NAME);
+               } else{
+                       $newid = $this->createSubcat($sname);
+
+                       $array = array(
+                               'catid'=>postVar('catid'),
+                               'sdesc'=>postVar('sdesc')
+                       );
+                       if($this->version > 2)
+                               $array['parentid'] = postVar('parentid');
+                       
+                       $this->updateSubcat($newid,$array);
+
+                       $this->action_scatoverview();
+               }
+       }
+       
+       function action_scatupdate() {
+               global $member;
+               
+               $scatid = intRequestVar('scatid');
+
+               $member->isAdmin() or $this->disallow();
+               
+               $sname = postVar('sname');
+               if (!trim($sname)) {
+                       $this->action_scatoverview("Error! Input a name.");
+               } else {
+               
+                       $this->addToScat($scatid);
+               
+                       $this->action_scatedit(_MC_SCAT_DATA_UPDATE);
+               }
+       
+       }       
+
+//modify start+++++++++
+       function action_tableUpgrade() {
+               if($this->version == 2){
+                       $q = "ALTER TABLE `".$this->table."` ADD `parentid` INT( 11 ) DEFAULT '0' NOT NULL AFTER `scatid` , ADD `ordid` INT( 11 ) DEFAULT '100' NOT NULL AFTER `parentid` ;";
+               }elseif($this->version == 3){
+                       $q = "ALTER TABLE `".$this->table."` ADD `ordid` INT( 11 ) DEFAULT '100' NOT NULL AFTER `parentid` ;";
+               }
+               if($q)  sql_query($q);
+               
+               $this->version = 4;
+
+               $this->action_overview('<blockquote style="color: red;border:1px solid red;padding:0.5em;"><b>'._MC_SCAT_TABLE_UPDATE.'</b></blockquote>');
+       }
+
+       function action_scatOrder() {
+               global $member;
+               
+               $scatid = intRequestVar('scatid');
+
+               $member->isAdmin() or $this->disallow();
+               
+               $order = array();
+               $order = explode(",", requestVar('orderList'));
+
+               $x=1;
+               foreach($order as $o){
+                       $o = trim(rtrim($o));
+                       $query = 'UPDATE '.$this->table.' SET ordid='.$x.' WHERE scatid='.$o;
+                       sql_query($query);
+                       $x++;
+               }
+
+               if(requestVar('redirect') == 'scatoverview'){
+                       $this->action_scatoverview(_MC_SCAT_ORDER_UPDATE);
+               }else{
+                       $this->action_scatedit(_MC_SCAT_ORDER_UPDATE);
+               }
+       
+       }       
+//modify end+++++++++
+
+       function action_scatdelete() {
+               global $member, $oPluginAdmin;
+               
+               $member->isAdmin() or $this->disallow();
+               
+               $scatid = intRequestVar('scatid');
+               $catid = intRequestVar('catid');
+//modify start+++++++++
+               if($this->version > 2){
+                       $sname = $this->plug->_getScatNameFromID($scatid);
+                       $sdesc = $this->plug->_getScatDescFromID($scatid);
+                       if($sdesc) $sdesc = ' ('.$sdesc.')';
+
+               
+                       $modChildren = $this->_getDefinedScatsFromScat($scatid);
+                       $pid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$scatid);
+                       $pname = ($pid)? 
+                               $this->plug->_getScatNameFromID($pid).' ('._MC_SUB_CATEGORIES.')':
+                               quickQuery('SELECT cname as result FROM '.sql_table('category').' WHERE catid='.intval($catid)).' (' . _EBLOG_CAT_TITLE . ')';
+               }
+//modify end+++++++++
+               
+               $oPluginAdmin->start();
+               ?>
+                       <h2><?php echo _DELETE_CONFIRM?></h2>
+                       
+                       <p><?php echo _MC_CONFIRMTXT_SCAT ?><b><?php echo $sname.$sdesc ?></b></p>
+                       
+       <?php
+               if($modChildren){
+                       $modList = $pid.'-';
+                       echo '<blockquote style="color: red;border:1px solid red;padding:1em;"><b>Note:</b><br />';
+                       echo _MC_SCAT_DELETE_NOTE_LIST;
+                       echo '<ul>';
+                       for($i=0;$i<count($modChildren);$i++){
+                               echo '<li>'.$modChildren[$i]['sname']."</li>\n";
+                               $modList .= $modChildren[$i]['scatid'].'/';
+                       }
+                       echo '</ul>';
+                       echo _MC_SCAT_DELETE_NOTE_PARENT.'<ul><li>'.$pname.'</li></ul>';
+                       echo '</blockquote>';
+                       $extraInput = '<input type="hidden" name="modlist" value="'.substr($modList, 0, -1).'" />'."\n";
+               }
+       ?>
+       
+                       
+                       <form method="post" action="<?php echo $this->url ?>index.php"><div>
+                               <input type="hidden" name="action" value="scatdeleteconfirm" />
+                               <input type="hidden" name="scatid" value="<?php echo $scatid ?>" />
+                               <input type="hidden" name="catid" value="<?php echo $catid ?>" />
+                               <?php echo $extraInput ?>
+                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
+                       </div></form>
+               <?php
+               
+               $oPluginAdmin->end();
+       }       
+       
+       function action_scatdeleteconfirm() {
+               global $member, $manager;
+               
+               $scatid = intRequestVar('scatid');
+               $catid  = intRequestVar('catid');
+               
+               $member->isAdmin() or $this->disallow();
+               
+//modify start+++++++++
+               $modList = requestVar('modlist');
+               if($modList){
+                       list($parent, $children) = explode("-", $modList);
+                       $children = explode("/", $children);
+                       for($i=0;$i<count($children);$i++){
+                               $c = trim(rtrim($children[$i]));
+                               $query = 'UPDATE '.$this->table.' SET parentid='.intval($parent).' WHERE scatid='.$c;
+                               sql_query($query);
+                       }
+               }
+//modify end+++++++++
+
+               $this->deleteSubcat($scatid);
+               
+               $this->action_scatoverview("Sub category has been deleted.");
+       }
+       
+       function addToScat($nowid) {
+               if($this->version >= 3)
+                       $datanames = array('catid','sname','sdesc','parentid');
+               else
+                       $datanames = array('catid','sname','sdesc');
+               foreach ($datanames as $val) {
+                       $scat[$val] = postVar($val);
+               }
+               $this->updateSubcat($nowid,$scat);
+       }
+
+       function createSubcat($name) {
+               sql_query('INSERT INTO '.$this->table.' SET sname="'. addslashes($name) .'"');
+               $newid = mysql_insert_id();
+               return $newid;
+       }
+
+       //<sato(na)0.402j>
+       //printCategoryList for update
+       function printCategoryListUD($catid, $parentid) {
+               $catName = quickQuery('SELECT cname as result FROM '.sql_table('category').' WHERE catid='.intval($catid));
+               $text .= "<select size='10' name='parentid'>\n";
+               $text    .= "<option value='0'>&nbsp;$catName&nbsp;</option>\n";
+               foreach ($this->plug->_setSubOrder() as $val) {
+                       $query = 'SELECT * FROM '.$this->table.' WHERE scatid=' . intval($val);
+                       $res   = sql_query($query);
+                       $row   = mysql_fetch_array($res);
+                       if ($row['catid'] == $catid){
+                               $levelstr = '';
+                               for ($i=0; $i<$this->getDepth($val, 0); $i++) $levelstr .= "&hellip;&hellip;";
+                               $selected = ($parentid == $val) ? " selected='selected'" : '';
+                               $text    .= "<option value='".$val."'".$selected.">&nbsp;".$levelstr."&hellip;&nbsp;".
+                                           $row['sname']." <sup>".$row['sdesc']."</sup>&nbsp;</option>\n";
+                       }
+               }
+               $text .= "</select>\n";
+               return $text;
+       }
+       function getDepth($scatid, $level) {
+               $parentid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$scatid);
+               return ($parentid == 0) ? $level : $this->getDepth($parentid, $level + 1);
+       }
+       function descendantCheck($parentid, $checkid){
+               $res = sql_query("SELECT scatid FROM ".$this->table." WHERE parentid=".$parentid);
+               while ($o = mysql_fetch_object($res)) {
+                       if ($o->scatid == $checkid) {
+                               return TRUE;
+                       } else {
+                               if ($this->descendantCheck($o->scatid, $checkid)) return TRUE;
+                       }
+               }
+               return FALSE;
+       }
+       //</sato(na)0.402j>
+
+       function updateSubcat($id, $scat) {
+               
+               //<sato(na)0.402j>
+               $old_parentid = quickQuery('SELECT parentid as result FROM '.$this->table.' WHERE scatid='.$id);
+               if ($id == $scat['parentid']) $branch = 'Self'; else $branch = ($this->descendantCheck($id, $scat['parentid']) ? 'Descendant' : 'Other');
+               
+               switch ($branch){
+                       case 'Self':
+                               //cancel
+                               $scat['parentid'] = $old_parentid;
+                               //echo '----------------------------------------Self';
+                       break;
+                       case 'Descendant':
+                               //Succession
+                               //echo '----------------------------------------Descendant';
+                               $query = 'UPDATE '.$this->table.' SET parentid='.$old_parentid.' WHERE parentid='.$id;
+                               sql_query($query);
+                       break;
+                       case 'Other':
+                               //Nothing is done.
+                               //echo '----------------------------------------Other';
+               }
+               //</sato(na)0.402j>
+               
+               $query = 'UPDATE '.$this->table.' SET ';
+               foreach ($scat as $k => $v) {
+                       $query .= $k.'="'.addslashes($v).'",';
+               }
+               $query = substr($query,0,-1);
+               $query .= ' WHERE scatid='.$id;
+               sql_query($query);
+       }
+       
+       function deleteSubcat($id) {
+               sql_query('DELETE FROM '.$this->table.' WHERE scatid=' . $id);
+
+               $res = sql_query("SELECT categories, subcategories, item_id FROM ". sql_table("plug_multiple_categories") ." WHERE subcategories REGEXP '(^|,)$id(,|$)'");
+               $dell = array();
+               $up = array();
+
+               while ($o = mysql_fetch_object($res)) {
+                       $o->subcategories = preg_replace("/^(?:(.*),)?$catid(?:,(.*))?$/","$1,$2",$o->subcategories);
+                       if (!$o->categories && (!$o->subcategories || $o->subcategories == ',')) {
+                               $del[] = $o->item_id;
+                       } else {
+                               $o->subcategories = preg_replace("/(^,+|(?<=,),+|,+$)/","",$o->subcategories);
+                               $up[] = "UPDATE ". sql_table("plug_multiple_categories") ." SET categories='".addslashes($o->categories)."', subcategories='".addslashes($o->subcategories)."' WHERE item_id=".$o->item_id;
+                       }
+               }
+               
+               if (count($del) > 0) {
+                       sql_query("DELETE FROM ". sql_table("plug_multiple_categories") . " WHERE item_id in (".implode(",",$del).")");
+               }
+               if (count($up) > 0) {
+                       foreach ($up as $v) {
+                               sql_query($v);
+                       }
+               }
+       }
+       
+
+       function action($action) {
+               $methodName = 'action_' . $action;
+               if (method_exists($this, $methodName)) {
+                       call_user_func(array(&$this, $methodName));
+               } else {
+                       $this->error(_BADACTION . " ($action)");
+               }
+       }
+
+       function disallow() {
+               global $HTTP_SERVER_VARS;
+               
+               ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . $HTTP_SERVER_VARS['REQUEST_URI']);
+               
+               $this->error(_ERROR_DISALLOWED);
+       }
+
+       function error($msg) {
+               global $oPluginAdmin;
+               
+               $oPluginAdmin->start();
+               $dir=$oPluginAdmin->plugin->getAdminURL();
+               ?>
+               <h2>Error!</h2>
+               <?php           echo $msg;
+               echo "<br />";
+               echo "<a href='".$dir."index.php' onclick='history.back()'>"._BACK."</a>";
+               
+               $oPluginAdmin->end();
+               exit;
+       }
+
+//modify start+++++++++
+    /* START OF UNLIMITED DEPTH SUBCATEGORY HELPER FUNCTIONS */
+    
+    function listupSubcategories($catid, $subcatid){
+        $cat .= "<table style='width:auto;'><tr><td>\n";
+        $cat .= "<table border='0' cellpadding='0' cellspacing='0' style='width:auto;'>\n";
+
+               $subcategoryList = $this->getCategoryList($catid);
+//             print_r($subcategoryList);
+        $subcategories   = $this->printCategoryList($catid, $subcategoryList, 2, 0);
+        if ($subcategories == "") {
+            $cat .= "No subcategories currently exist in this category.\n";
+        } else {
+            $cat .= $subcategories;
+        }
+        $cat .= "</table></td></tr></table>\n";
+        $cat .= "<br />\n";
+        return $cat;
+
+    }
+    
+       function showOrderMenu($catid, $subcatid=0){//<sato(na)0.402j />
+               $text = "<h3>"._MC_MODIFY_CHILDREN_ORDER."</h3>\n";
+               if ($sorder = $this->subcatOrd($catid, $subcatid)){
+                       $text .= "<table style='width:auto;'>\n";
+                       $text .= "<script language=javascript src={$this->url}orderlist.js></script>\n";
+                       $text .= "<form method='post' name='ordform' onsubmit=\"submitCatOrder();\">\n";
+                       $text .= "<input type='hidden' name='action' value='scatOrder'>\n";
+                       $text .= "<input type='hidden' name='redirect' value='".getVar('action')."'>\n";
+                       $text .= "<input type=hidden name=orderList value=''>\n";
+                       //<sato(na)0.402j>
+                               global $CONF;
+                               $actionUrl = $CONF['ActionURL'].'?action=plugin&amp;name=MultipleCategories&amp;catid='.$catid.'&amp;subcatid='.$subcatid;
+                               echo '<script language="javascript" src="'.$actionUrl.'"></script>';
+                               $text .= '
+<tr><td class="main" style="border:0px;padding:0px;">
+<table style="width:auto; margin:0; padding:0;">
+       <tr><td style="border:0px;padding:0px;" colspan="6">'._MC_SHOW_ORDER_MENU_KEY.'</td>
+       <tr><td style="border:0px;padding:0px;">
+               <table>
+                       <tr>
+                               <td style="border:0px; padding:0px 3px;">ID</td>
+                               <td style="border:0px; padding:0px 3px;">
+                                       <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'id\', \'ASC\')"><br />
+                                       <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'id\', \'DESC\')">
+                               </td>
+                               <td style="border:0px; padding:0px 3px;">[ '._MC_SHOW_ORDER_MENU_SNAME.' ]</td>
+                               <td style="border:0px; padding:0px 3px;">
+                                       <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'sname\', \'ASC\')"><br />
+                                       <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'sname\', \'DESC\')">
+                               </td>
+                               <td style="border:0px; padding:0px 3px;">'._MC_SHOW_ORDER_MENU_SDESC.'</td>
+                               <td style="border:0px; padding:0px 3px;">
+                                       <img src=plugins/multiplecategories/images/up.gif alt="Move Up" onClick="orderKey(\'sdesc\', \'ASC\')"><br />
+                                       <img src=plugins/multiplecategories/images/down.gif alt="Move Down" onClick="orderKey(\'sdesc\', \'DESC\')">
+                               </td>
+                       </tr>
+               </table>
+       </td></tr>
+</table>
+</td></tr>';
+                       //</sato(na)0.402j>
+                       $text .= $sorder;
+                       $text .= "<tr><td class='main' style='border:0px;padding:0px;'><input type='submit' value='"._MC_SUBMIT_CHILDREN_ORDER."'></td></form></tr>\n";
+                       $text .= "</table>\n";
+               } else {
+                       $text .= _MC_NO_CHILDREN_ORDER;
+               }
+               return $text;
+       }
+    function getCategoryList($catid, $selected = 0) {//$selected : parentid
+        /** Returns a list of the gallery categories **/
+        $queryString  = "SELECT * FROM ".$this->table;
+        $queryString .= " WHERE catid=".$catid;
+        $queryString .= ($this->version >= 4)? " ORDER BY parentid ASC, ordid ASC, scatid ASC" : " ORDER BY scatid ASC";
+        $resultSet    = sql_query($queryString);
+
+        $categoryArray = array();
+        $flatList      = array();
+        if (!mysql_num_rows($resultSet)) return $categoryArray;
+        
+        while ($row = mysql_fetch_array($resultSet)) {
+            $isSelected = ($row["scatid"] == $selected)?1:0;
+            $flatList[] = array(
+                            "id"          => $row["scatid"],
+                            "title"       => $row["sname"],
+                            "description" => $row["sdesc"],
+                            "children"    => array(),
+                            "parent"      => $row["parentid"],
+                            "selected"    => $isSelected
+                        );
+        }
+
+        while (count($flatList)) {
+            // Check the first one in the list
+            $temp = array_shift($flatList);
+            // Is it a top level category?
+            if ($temp["parent"] == 0 || $temp["id"] == $selected) {
+                // No parent, so just push it to the end of the big array
+                $categoryArray[] = $temp;
+            } else {
+                // Has a parent, so search for parent, and push it to the end of the parent's child array
+                if (!$this->appendChildCategory($categoryArray, $temp)) {
+                    // Failed, so push category back onto the end of the array
+                    $flatList[] = $temp;
+                }
+            }
+        }
+        return $categoryArray;
+    }
+
+    function appendChildCategory(&$categoryArray, $child) {
+        if (empty($categoryArray)) return false;
+        
+        for($i=0; $i<count($categoryArray); $i++) {
+            $category =& $categoryArray[$i];
+            if ($category["id"] == $child["parent"]) {
+                // Found it, push to category's child list
+                $category["children"][] = $child;
+                return true;
+            } else {
+                if ($this->appendChildCategory($category["children"], $child)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    function printCategoryList($catid, $categoryList, $type=1, $selectedCategory=0, $def='') {
+        $text = "";
+        $catName = quickQuery('SELECT cname as result FROM '.sql_table('category').' WHERE catid='.intval($catid));
+        if ($type == 1) {
+            // Select box
+            $text .= "<select size='10' name='parentid'>\n";
+            if ($def != 1){
+                $selected = ($selectedCategory == 0) ? " selected='selected'" : '';
+                $text    .= "<option value='0'$selected>&nbsp;$catName&nbsp;</option>\n";
+            }
+            $text .= $this->walkCategoryList($categoryList, $catid, $type, $selectedCategory);
+            $text .= "</select>\n";
+        } elseif ($type == 2) {
+            // Table: with action cell
+            $text .= "<tr><td class='mainbold' style='border:0px;padding:0px;'><img src='./plugins/multiplecategories/images/folderopen.gif' alt='' /> $catName </td><td class='mainbold' style='border:0px;padding:0px;'>"._LISTS_ACTIONS."</td></tr>\n";
+            $text .= $this->walkCategoryList($categoryList, $catid, $type, $selectedCategory);
+        } elseif ($type == 3) {
+            //
+            $selected = ($selectedCategory == 0) ? " selected='selected'" : '';
+            $text    .= "<option value='0'$selected> $catName </option>\n";
+            $text    .= $this->walkCategoryList($categoryList, $catid, $type, $selectedCategory);
+        }
+        return $text;
+    }
+
+    function walkCategoryList(&$categoryList, $catid, $type = 1, $selectedCategory = 0, $level = 0, $childrenLevel = array()) {
+        $text = "";
+        if ($type == 1) {
+            // Select box
+            foreach ($categoryList as $category) {
+                if ($category["selected"] == 1) {
+                    $text .= "<option value='{$category['id']}' selected='selected'>&nbsp;\n";
+                } else {
+                    $text .= "<option value='{$category['id']}'>&nbsp;\n";
+                }
+                for ($i=0;$i<$level;$i++) {
+                    $text .= "&hellip;&hellip;";
+                }
+                $text .= "&hellip;&nbsp;".$category["title"]." <sup>".$category["description"]."</sup>&nbsp;</option>\n";
+                $text .= $this->walkCategoryList($category["children"], $catid, $type, $selectedCategory, $level+1);
+            }
+        } elseif ($type == 2) {
+            // Table
+            for ($j=0; $j < count($categoryList); $j++) {
+                $category              = $categoryList[$j];
+                $hasSiblings           = (($j < (count($categoryList)-1))?1:0); // are there more categories on the same level as this category?
+                $childrenLevel[$level] = $hasSiblings;
+                $children = $this->walkCategoryList($category["children"], $catid, $type, $selectedCategory, $level+1, $childrenLevel);
+
+                if ($selectedCategory == $category["id"]) {
+                    $text .= "<tr bgcolor=\"#B5C1DC\">\n";
+                } else {
+                    $text .= "<tr onmouseover='focusRow(this);' onmouseout='blurRow(this);' style='border:0px;padding:0px;'>\n";
+                }
+                $text .= "<td class='hover' style='border:0px;padding:0px;'>\n";
+                if ($level == 0) {
+                    if ($hasSiblings) {
+                        $text .= "<img src='./plugins/multiplecategories/images/minusbottom.gif' alt='' /><img src='./plugins/multiplecategories/images/folder.gif' alt='' /> \n";
+                    } else {
+                        $text .= "<img src='./plugins/multiplecategories/images/minus.gif' alt='' /><img src='./plugins/multiplecategories/images/folder.gif' alt='' /> \n";
+                    }
+                } else {
+                    for ($i=0;$i<$level;$i++) {
+                        if ($childrenLevel[$i]) {
+                            $text .= "<img src='./plugins/multiplecategories/images/line.gif' alt='' /> \n";
+                        } else {
+                            $text .= "<img src='./plugins/multiplecategories/images/empty.gif' alt='' />";
+                        }
+                    }
+                    if ($hasSiblings) {
+                        if ($children != "") {
+                            $text .= "<img src='./plugins/multiplecategories/images/minusbottom.gif' alt='' /><img src='./plugins/multiplecategories/images/folder.gif' alt='' /> \n";
+                        } else {
+                            $text .= "<img src='./plugins/multiplecategories/images/joinbottom.gif' alt='' /><img src='./plugins/multiplecategories/images/folder.gif' alt='' /> \n";
+                        }
+                    } else {
+                        if ($children != "") {
+                            $text .= "<img src='./plugins/multiplecategories/images/minus.gif' alt='' /><img src='./plugins/multiplecategories/images/folder.gif' alt='' /> \n";
+                        } else {
+                            $text .= "<img src='./plugins/multiplecategories/images/join.gif' alt='' /><img src='./plugins/multiplecategories/images/folder.gif' alt='' /> \n";
+                        }
+                    }
+                }
+                if ($row[group] != 0){ $group = "(Private)"; }
+                else { $group = ''; }
+                if ($selectedCategory == $category["id"]) {
+                    $text .= "<strong>".$category["title"]." <sup>".$category["description"]."</sup>"."</strong> $group</td>\n";
+                } else {
+                    $text .= $category["title"]." <sup>".$category["description"]."</sup>"." $group</td>\n";
+                }
+                $subcatid = $category["id"];
+                if ($type == 2) {
+                    // ALL ACTIONS //
+                    $text .= "<td class='hover' align='center' style='border:0px;padding:0px 0px 0px 15px;'><a href={$this->url}index.php?action=scatedit&catid=$catid&amp;scatid=$subcatid><img src=plugins/multiplecategories/images/bedit.gif alt='"._LISTS_EDIT."' border=0></a> \n<a href={$this->url}index.php?action=scatdelete&catid=$catid&amp;scatid=$subcatid><img src=plugins/multiplecategories/images/bdelete.gif alt='"._LISTS_DELETE."' border=0></a></td>\n";
+                }
+                $text .= "</tr>\n";
+                $text .= $children;
+            }
+        } elseif ($type == 3) {
+            // Select box
+            foreach ($categoryList as $category) {
+                if ($category["id"] == $selectedCategory) {
+                    $text .= "<option value='{$category['id']}' selected='selected'>\n";
+                } else {
+                    $text .= "<option value='{$category['id']}'>\n";
+                }
+                for ($i=0;$i<$level;$i++) {
+                    $text .= "&nbsp;&nbsp;";
+                }
+                $text .= $category["title"]."</option>\n";
+                $text .= $this->walkCategoryList($category["children"], $catid, $type, $selectedCategory, $level+1);
+            }
+        }
+        return $text;
+    }
+
+
+    function subcatOrd($catid, $subcatid=0){
+        $q = "select scatid, sname, sdesc from ".$this->table." where parentid = '$subcatid' and catid=$catid";//<sato(na)0.402j />
+        $q .= ($this->version >= 4) ? ' order by ordid, scatid ASC': ' order by scatid ASC';
+        $result = sql_query($q);
+        if(mysql_num_rows($result) < 2){
+               return FALSE;
+        }
+        $text .= "<tr><td class=main style='border:0px;padding:0px;'><select name=order multiple size=15>";
+        //<sato(na)0.402j>
+        while($row = mysql_fetch_array($result)){
+            $text .= "<option value=".$row['scatid'].">".$row['scatid']."&nbsp;[&nbsp;".$row['sname']."&nbsp;]&nbsp;".$row['sdesc']."</option>";
+        }
+        $text .= "</select>"._MC_SHOW_ORDER_MENU_INDIVIDUAL."&nbsp;";
+        //</sato(na)0.402j>
+        $text .= "<img src=plugins/multiplecategories/images/up.gif alt='Move Up' onClick=\"moveOptionUp(document.ordform.order)\">&nbsp;";
+        $text .= "<img src=plugins/multiplecategories/images/down.gif alt='Move Down' onClick=\"moveOptionDown(document.ordform.order)\"></td></tr>";
+        return $text;
+    }
+
+       function _getDefinedScatsFromScat($id){
+               $aResult = array();     
+               $query = 'SELECT * FROM '.sql_table('plug_multiple_categories_sub').' WHERE parentid=' . intval($id);
+               $res = sql_query($query);       
+               while ($a = mysql_fetch_assoc($res)){
+                       array_push($aResult,$a);
+               } 
+               return $aResult;
+       }
+//modify end+++++++++
+
+
+} // NpMCategories_ADMIN end
+       
+// ------------------------------------------------------------------
+
+$myAdmin = new NpMCategories_ADMIN();
+if (requestVar('action')) {
+       $myAdmin->action(requestVar('action'));
+} else {
+       $myAdmin->action('overview');
+}
+
+?>
+
diff --git a/trunk/NP_MultipleCategories/multiplecategories/language/english.php b/trunk/NP_MultipleCategories/multiplecategories/language/english.php
new file mode 100644 (file)
index 0000000..3d93fa4
--- /dev/null
@@ -0,0 +1,33 @@
+<?php 
+define('_MC_EDIT_PLUGIN_OPTIONS',                      'Edit Plugin Options'); 
+define('_MC_SUB_CATEGORIES',                           'Sub Categories'); 
+define('_MC_EDIT_SUB_CATEGORIES',                      'Edit sub categories'); 
+define('_MC_EDIT_SUB_CATEGORIES_OF',           'Edit sub categories of'); 
+define('_MC_CREATE_NEW_SUB_CATEGORY',          'Create New Sub Category'); 
+define('_MC_SCAT_NAME',                                                'Name');
+define('_MC_SCAT_DESC',                                                'Description');
+define('_MC_SCAT_CREATE',                                      'Create Sub Category');
+define('_MC_SCAT_UPDATE',                                      'UPDATE Sub Category');
+define('_MC_SCAT_EDIT',                                                'Edit');
+define('_MC_SCAT_DATA_UPDATE',                         'Sub category data has been saved.');
+define('_MC_SCAT_MISSING',                                     'Sub category is missing...');
+define('_MC_SCAT_ERROR_NAME',                                  'Error! Input a name.');
+define('_MC_CONFIRMTXT_SCAT',                  'The sub category you are going to delete is: ');
+
+define('_MC_SCAT_PARENT_NAME',                         'Parent');
+define('_MC_SCAT_ORDER_UPDATE',                                'Sub category order has been updated.');
+define('_MC_MODIFY_CHILDREN_ORDER',                            'Modify Children Order');
+define('_MC_SUBMIT_CHILDREN_ORDER',                            'Submit Children Order');
+define('_MC_NO_CHILDREN_ORDER',                                '( No child categories are here )');
+define('_MC_SCAT_DELETE_NOTE_LIST',                            'This subcategory you\'re going to delete has child(ren) listed below.');
+define('_MC_SCAT_DELETE_NOTE_PARENT',                          'If delete, these subcategoris will be automatically belong to');
+define('_MC_SCAT_TABLE_UPDATE_INFO',                           'If you want to use UNLIMITED DEPTH SUBCATEGORY, table upgrade is required.');
+define('_MC_SCAT_TABLE_UPDATE',                                'upgrade successed.');
+
+define('_MC_SCAT_PARENT_NAME_DESC',                            "\81iWhen oneself is specified, it doesn't change.\81j");
+define('_MC_SHOW_ORDER_MENU_KEY',                              'sort key');
+define('_MC_SHOW_ORDER_MENU_SNAME',                            'sname');
+define('_MC_SHOW_ORDER_MENU_SDESC',                            'sdesc');
+define('_MC_SHOW_ORDER_MENU_INDIVIDUAL',                               'individual');
+
+?>
\ No newline at end of file
diff --git a/trunk/NP_MultipleCategories/multiplecategories/language/japanese-euc.php b/trunk/NP_MultipleCategories/multiplecategories/language/japanese-euc.php
new file mode 100644 (file)
index 0000000..aac6039
--- /dev/null
@@ -0,0 +1,33 @@
+<?php 
+define('_MC_EDIT_PLUGIN_OPTIONS',                      '¤³¤Î¥×¥é¥°¥¤¥ó¤Î¥ª¥×¥·¥ç¥óÊÔ½¸²èÌ̤Ø'); 
+define('_MC_SUB_CATEGORIES',                           '¥µ¥Ö¥«¥Æ¥´¥ê'); 
+define('_MC_EDIT_SUB_CATEGORIES',                      '¥µ¥Ö¥«¥Æ¥´¥ê¤ÎÊÔ½¸²èÌ̤Ø'); 
+define('_MC_EDIT_SUB_CATEGORIES_OF',           '¥µ¥Ö¥«¥Æ¥´¥ê¤ÎÊÔ½¸ - ¥«¥Æ¥´¥ê̾'); 
+define('_MC_CREATE_NEW_SUB_CATEGORY',          '¥µ¥Ö¥«¥Æ¥´¥ê¤Î¿·µ¬ºîÀ®'); 
+define('_MC_SCAT_NAME',                                                '¥µ¥Ö¥«¥Æ¥´¥ê̾');
+define('_MC_SCAT_DESC',                                                '¥µ¥Ö¥«¥Æ¥´¥ê¤ÎÀâÌÀ');
+define('_MC_SCAT_CREATE',                                      '¿·¤·¤¤¥µ¥Ö¥«¥Æ¥´¥ê¤òºîÀ®');
+define('_MC_SCAT_UPDATE',                                      '¥µ¥Ö¥«¥Æ¥´¥ê¤Î¹¹¿·');
+define('_MC_SCAT_EDIT',                                                '¥µ¥Ö¥«¥Æ¥´¥ê¤ÎÊÔ½¸ - ¥µ¥Ö¥«¥Æ¥´¥ê̾ ');
+define('_MC_SCAT_DATA_UPDATE',                         '¥µ¥Ö¥«¥Æ¥´¥ê¤Î¥Ç¡¼¥¿¤ò¹¹¿·¤·¤Þ¤·¤¿¡£');
+define('_MC_SCAT_MISSING',                                     '¥µ¥Ö¥«¥Æ¥´¥ê¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£');
+define('_MC_SCAT_ERROR_NAME',                          '¥¨¥é¡¼¤Ç¤¹¡£¥µ¥Ö¥«¥Æ¥´¥ê̾¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£');
+define('_MC_CONFIRMTXT_SCAT',                  '°Ê²¼¤Î¥µ¥Ö¥«¥Æ¥´¥ê¤òºï½ü¤·¤è¤¦¤È¤·¤Æ¤¤¤Þ¤¹: ');
+
+define('_MC_SCAT_PARENT_NAME',                         '¿Æ¤È¤Ê¤ë(¥µ¥Ö)¥«¥Æ¥´¥ê');
+define('_MC_SCAT_ORDER_UPDATE',                                '¥µ¥Ö¥«¥Æ¥´¥ê¤Îʤӽç¤ò¹¹¿·¤·¤Þ¤·¤¿¡£');
+define('_MC_MODIFY_CHILDREN_ORDER',                            '»Ò¥µ¥Ö¥«¥Æ¥´¥ê¤Îʤӽç¤ÎÊѹ¹');
+define('_MC_SUBMIT_CHILDREN_ORDER',                            'ʤӽç¤òÈ¿±Ç');
+define('_MC_NO_CHILDREN_ORDER',                                '( »Ò¤È¤Ê¤ë¥µ¥Ö¥«¥Æ¥´¥ê¤ÏÊ£¿ô¤¢¤ê¤Þ¤»¤ó )');
+define('_MC_SCAT_DELETE_NOTE_LIST',                            'ºï½ü¤·¤è¤¦¤È¤¹¤ë¥µ¥Ö¥«¥Æ¥´¥ê¤Ë¤Ï¡¢Ä¾²¼¤Ë°Ê²¼¤Î»Ò¥µ¥Ö¥«¥Æ¥´¥ê¤¬Â¸ºß¤·¤Þ¤¹');
+define('_MC_SCAT_DELETE_NOTE_PARENT',                          '¤â¤·ºï½ü¤ò¼Â¹Ô¤·¤¿¾ì¹ç¡¢»Ò¥«¥Æ¥´¥ê¤Ï³¬Áؤ¬·«¤ê¾å¤¬¤ê¼¡¤Î(¥µ¥Ö)¥«¥Æ¥´¥ê¤Ë¼«Æ°Åª¤Ë°¤·¤Þ¤¹');
+define('_MC_SCAT_TABLE_UPDATE_INFO',                           '¥µ¥Ö¥«¥Æ¥´¥ê¤ò̵¸Â³¬ÁØ´ÉÍý¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥Æ¡¼¥Ö¥ë¤Î¥¢¥Ã¥×¥°¥ì¡¼¥É¤¬É¬ÍפǤ¹');
+define('_MC_SCAT_TABLE_UPDATE',                                '¥µ¥Ö¥«¥Æ¥´¥ê´ÉÍýÍѥơ¼¥Ö¥ë¤Î¥¢¥Ã¥×¥°¥ì¡¼¥É¤Ï´°Î»¤·¤Þ¤·¤¿');
+
+define('_MC_SCAT_PARENT_NAME_DESC',                            '¡Ê¼«Ê¬¼«¿È¤ò»ØÄꤷ¤¿¾ì¹ç¡¢Êѹ¹¤·¤Þ¤»¤ó¡£¡Ë');
+define('_MC_SHOW_ORDER_MENU_KEY',                              'ʤÓÂؤ¨´ð½à');
+define('_MC_SHOW_ORDER_MENU_SNAME',                            '̾Á°');
+define('_MC_SHOW_ORDER_MENU_SDESC',                            'ÀâÌÀ');
+define('_MC_SHOW_ORDER_MENU_INDIVIDUAL',                               '¸ÄÊÌ»ØÄê');
+
+?>
\ No newline at end of file
diff --git a/trunk/NP_MultipleCategories/multiplecategories/language/japanese-utf8.php b/trunk/NP_MultipleCategories/multiplecategories/language/japanese-utf8.php
new file mode 100644 (file)
index 0000000..dd53027
--- /dev/null
@@ -0,0 +1,33 @@
+<?php 
+define('_MC_EDIT_PLUGIN_OPTIONS',                      'このプラグインのオプション編集画面へ'); 
+define('_MC_SUB_CATEGORIES',                           'サブカテゴリ'); 
+define('_MC_EDIT_SUB_CATEGORIES',                      'サブカテゴリの編集画面へ'); 
+define('_MC_EDIT_SUB_CATEGORIES_OF',           'サブカテゴリの編集 - カテゴリ名'); 
+define('_MC_CREATE_NEW_SUB_CATEGORY',          'サブカテゴリの新規作成'); 
+define('_MC_SCAT_NAME',                                                'サブカテゴリ名');
+define('_MC_SCAT_DESC',                                                'サブカテゴリの説明');
+define('_MC_SCAT_CREATE',                                      '新しいサブカテゴリを作成');
+define('_MC_SCAT_UPDATE',                                      'サブカテゴリの更新');
+define('_MC_SCAT_EDIT',                                                'サブカテゴリの編集 - サブカテゴリ名 ');
+define('_MC_SCAT_DATA_UPDATE',                         'サブカテゴリのデータを更新しました。');
+define('_MC_SCAT_MISSING',                                     'サブカテゴリが見つかりません。');
+define('_MC_SCAT_ERROR_NAME',                          'エラーです。サブカテゴリ名を入力してください。');
+define('_MC_CONFIRMTXT_SCAT',                  '以下のサブカテゴリを削除しようとしています: ');
+
+define('_MC_SCAT_PARENT_NAME',                         '親となる(サブ)カテゴリ');
+define('_MC_SCAT_ORDER_UPDATE',                                'サブカテゴリの並び順を更新しました。');
+define('_MC_MODIFY_CHILDREN_ORDER',                            '子サブカテゴリの並び順の変更');
+define('_MC_SUBMIT_CHILDREN_ORDER',                            '並び順を反映');
+define('_MC_NO_CHILDREN_ORDER',                                '( 子となるサブカテゴリは複数ありません )');
+define('_MC_SCAT_DELETE_NOTE_LIST',                            '削除しようとするサブカテゴリには、直下に以下の子サブカテゴリが存在します');
+define('_MC_SCAT_DELETE_NOTE_PARENT',                          'もし削除を実行した場合、子カテゴリは階層が繰り上がり次の(サブ)カテゴリに自動的に属します');
+define('_MC_SCAT_TABLE_UPDATE_INFO',                           'サブカテゴリを無限階層管理したい場合は、テーブルのアップグレードが必要です');
+define('_MC_SCAT_TABLE_UPDATE',                                'サブカテゴリ管理用テーブルのアップグレードは完了しました');
+
+define('_MC_SCAT_PARENT_NAME_DESC',                            '(自分自身を指定した場合、変更しません。)');
+define('_MC_SHOW_ORDER_MENU_KEY',                              '並び替え基準');
+define('_MC_SHOW_ORDER_MENU_SNAME',                            '名前');
+define('_MC_SHOW_ORDER_MENU_SDESC',                            '説明');
+define('_MC_SHOW_ORDER_MENU_INDIVIDUAL',                               '個別指定');
+
+?>
\ No newline at end of file
diff --git a/trunk/NP_MultipleCategories/multiplecategories/orderlist.js b/trunk/NP_MultipleCategories/multiplecategories/orderlist.js
new file mode 100644 (file)
index 0000000..4e76964
--- /dev/null
@@ -0,0 +1,116 @@
+function getSelectedValues (select) {
+  var r = new Array();
+  for (var i = 0; i < select.options.length; i++)
+    if (select.options[i].selected)
+      r[r.length] = select.options[i].value;
+  return r;
+}
+
+
+function submitCatOrder(){
+    selectAllOptions(document.ordform.order);
+    document.ordform.orderList.value = getSelectedValues(document.ordform.order);
+    document.ordform.order.value = '';
+
+}
+
+
+function selectAllOptions(obj) {
+       for (var i=0; i<obj.options.length; i++) {
+               obj.options[i].selected = true;
+               }
+       }
+
+function swapOptions(obj,i,j) {
+       var o = obj.options;
+       var i_selected = o[i].selected;
+       var j_selected = o[j].selected;
+       var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
+       var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
+       o[i] = temp2;
+       o[j] = temp;
+       o[i].selected = j_selected;
+       o[j].selected = i_selected;
+       }
+
+function moveOptionUp(obj) {
+       // If > 1 option selected, do nothing
+       var selectedCount=0;
+       for (i=0; i<obj.options.length; i++) {
+               if (obj.options[i].selected) {
+                       selectedCount++;
+                       }
+               }
+       if (selectedCount > 1) {
+               return;
+               }
+       // If this is the first item in the list, do nothing
+       var i = obj.selectedIndex;
+       if (i == 0) {
+               return;
+               }
+       swapOptions(obj,i,i-1);
+       obj.options[i-1].selected = true;
+       }
+
+function moveOptionDown(obj) {
+       // If > 1 option selected, do nothing
+       var selectedCount=0;
+       for (i=0; i<obj.options.length; i++) {
+               if (obj.options[i].selected) {
+                       selectedCount++;
+                       }
+               }
+       if (selectedCount > 1) {
+               return;
+               }
+       // If this is the last item in the list, do nothing
+       var i = obj.selectedIndex;
+       if (i == (obj.options.length-1)) {
+               return;
+               }
+       swapOptions(obj,i,i+1);
+       obj.options[i+1].selected = true;
+       }
+
+//<sato(na)0.402j>
+function setScatDat(id, sname, sdesc) {
+       this.id     = id;
+       this.sname  = sname;
+       this.sdesc  = sdesc;
+}
+function scatListRefresh(scatDat){
+       //del
+       optionsLength = document.ordform.order.options.length;
+       for (i=0; i<=optionsLength; i++) document.ordform.order.options[0] = null;
+       //add
+       for(var i = 0; i < scatDat.length; i++) {
+               label = scatDat[i].id + " [ " + scatDat[i].sname + " ] " + scatDat[i].sdesc;
+               document.ordform.order.options[i] = new Option(label, scatDat[i].id);
+       }
+}
+function sortidASC(a, b) {
+       if (b.id == a.id) return 0;
+       return a.id - b.id;
+}
+function sortidDESC(a, b) {
+       if (b.id == a.id) return 0;
+       return b.id - a.id;
+}
+function sortsnameASC(a, b) {
+       if (b.sname == a.sname) return 0;
+       return (a.sname > b.sname) ? 1 : -1;
+}
+function sortsnameDESC(a, b) {
+       if (b.sname == a.sname) return 0;
+       return (b.sname > a.sname) ? 1 : -1;
+}
+function sortsdescASC(a, b) {
+       if (b.sdesc == a.sdesc) return 0;
+       return (a.sdesc > b.sdesc) ? 1 : -1;
+}
+function sortsdescDESC(a, b) {
+       if (b.sdesc == a.sdesc) return 0;
+       return (b.sdesc > a.sdesc) ? 1 : -1;
+}
+//</sato(na)0.402j>
\ No newline at end of file