OSDN Git Service

Merge commit 'b65daabb9967c28543ca406c4de1d2a903c3ac2c' into skinnable-master
[nucleus-jp/nucleus-next.git] / nucleus / libs / AdminActions.php
index 0faf855..1182503 100644 (file)
@@ -35,7 +35,6 @@ class AdminActions extends BaseActions
                'batchmovetype',
                'blogcatlist',
                'blognotifysetting',
-               'blogselectbox',
                'blogsetting',
                'blogsettingyesno',
                'blogteamlist',
@@ -82,7 +81,6 @@ class AdminActions extends BaseActions
                'importskininfo',
                'inputyesno',
                'insertpluginfo',
-               'insertpluginoptions',
                'insplugoptcontent',
                'iprangeinput',
                'itemnavlist',
@@ -169,7 +167,7 @@ class AdminActions extends BaseActions
                'adminskinremovetype'   => _ADM_SKPRT_ADMINSKINREMOVETYPE,
                'admintemplatedelete'   => _ADM_SKPRT_ADMINTEMPLATEDELETE,
                'admintemplateedit'             => _ADM_SKPRT_ADMINTEMPLATEEDIT,
-               'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
+               'admntemplateoverview'  => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
                'backupoverview'                => _ADM_SKPRT_BACKUPOVERVIEW,
                'backuprestore'                 => _ADM_SKPRT_BACKUPRESTORE,
                'banlist'                               => _ADM_SKPRT_BANLIST,
@@ -185,7 +183,6 @@ class AdminActions extends BaseActions
                'batchmovecat'                  => _ADM_SKPRT_BATCHMOVECAT,
                'batchteam'                             => _ADM_SKPRT_BATCHTEAM,
                'blogcommentlist'               => _ADM_SKPRT_BLOGCOMMENTLIST,
-               'blogselectbox'                 => _ADM_SKPRT_BLOGSELECTBOX,
                'blogsettings'                  => _ADM_SKPRT_BLOGSETTINGS,
                'bookmarklet'                   => _ADM_SKPRT_BOOKMARKLET,
                'browseowncomments'             => _ADM_SKPRT_BROWSEOWNCOMMENTS,
@@ -198,7 +195,6 @@ class AdminActions extends BaseActions
                'createnewlog'                  => _ADM_SKPRT_CREATENEWLOG,
                'deleteblog'                    => _ADM_SKPRT_DELETEBLOG,
                'editmembersettings'    => _ADM_SKPRT_EDITMEMBERSETTINGS,
-               'insertpluginoptions'   => _ADM_SKPRT_INSERTPLUGINO,
                'itemcommentlist'               => _ADM_SKPRT_ITEMCOMMENTLIST,
                'itemdelete'                    => _ADM_SKPRT_ITEMDELETE,
                'itemedit'                              => _ADM_SKPRT_ITEMEDIT,
@@ -472,11 +468,6 @@ class AdminActions extends BaseActions
                                        'adminbatchlist',
                                );
                                break;
-                       case 'blogselectbox':
-                               $extra_actions = array(
-                                       'blogselectbox',
-                               );
-                               break;
                        case 'blogsettings':
                                $extra_actions = array(
                                        'adminbloglink',
@@ -564,11 +555,6 @@ class AdminActions extends BaseActions
                                        'pluginoptions',
                                );
                                break;
-                       case 'insertpluginoptions':
-                               $extra_actions = array(
-                                       'insertpluginoptions',
-                               );
-                               break;
                        case 'itemcommentlist':
                                $extra_actions = array(
                                        'requestblogid',
@@ -976,10 +962,10 @@ class AdminActions extends BaseActions
                
                if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
                {
-                       $template = '<li><%text(_BATCH_EXECUTING)%>'
-                                 . '<b><%adminbatchaction%></b>'
-                                 . '<%batchlisttype%>'
-                                 . '<b><%batchid%></b>...'
+                       $template = '<li><%text(_BATCH_EXECUTING)%>&nbsp;'
+                                 . '<b><%adminbatchaction%></b>&nbsp;'
+                                 . '<%batchlisttype%>&nbsp;'
+                                 . '<b><%batchid%></b>...&nbsp;'
                                  . '<b><%batchlistmsg%></b>'
                                  . '</li>' . "\n";
                }
@@ -1062,7 +1048,7 @@ class AdminActions extends BaseActions
                                        }
                                        else
                                        {
-                                               DB::execute("UPDATE {$setadminsql} {$selectedid};");
+                                               DB::execute("UPDATE {$unsetupsql} {$selectedid};");
                                        }
                                        break;
                                default:
@@ -1079,11 +1065,12 @@ class AdminActions extends BaseActions
                        $handler = new AdminActions('template');
                        $parser = new Parser($handler);
                        
+                       $output = Template::fill($template, $data);
                        ob_start();
-                       $parser->parse($template);
-                       $template = ob_get_contents();
+                       $parser->parse($output);
+                       $output = ob_get_contents();
                        ob_end_clean();
-                       echo Template::fill($template, $data);
+                       echo "{$output}<br />";
                }
                return;
        }
@@ -1281,7 +1268,7 @@ class AdminActions extends BaseActions
         * @param       void
         * @return      void
         */     
-       public function parse_adminskinselectoptions()
+       public function parse_adminskinselectoptions($templateName = '')
        {
                global $CONF;
                $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
@@ -1290,7 +1277,7 @@ class AdminActions extends BaseActions
                $template['name'] = 'adminskin';
                $template['selected'] = $CONF['AdminSkin'];
                $template['tabindex'] = 110;
-               Showlist($query, 'select', $template, '');
+               Showlist($query, 'select', $template, $templateName);
                return;
        }
        
@@ -1688,99 +1675,6 @@ class AdminActions extends BaseActions
        }
        
        /**
-        * AdminActions::parse_blogselectbox()
-        * Parse skinvar blogselectbox
-        * 
-        * @param       void
-        * @return      void
-        */
-       public function parse_blogselectbox()
-       {
-               global $member;
-               
-               $selectData     = requestVar('selectData');
-               $mode           = $selectData['mode'];
-               $name           = Entity::hsc($selectData['name']);
-               $tabindex       = Entity::hsc($selectData['tabindex']);
-               $aBlogIds       = array_map('intval', $selectData['aBlogIds']);
-               $showNewCat     = intval($selectData['showNewCat']);
-               $selected       = intval($selectData['selected']);
-               
-               echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
-               
-               // 1. select blogs (we'll create optiongroups)
-               // (only select those blogs that have the user on the team)
-               $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
-               $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
-               $blogs = DB::getResult($queryBlogs);
-               
-               if ( $mode == 'category' )
-               {
-                       if ( $blogs->rowCount() > 1 )
-                       {
-                               $multipleBlogs = 1;
-                       }
-                       foreach ( $blogs as $rBlog )
-                       {
-                               if ( isset($multipleBlogs) && !empty($multipleBlogs) )
-                               {
-                                       echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
-                               }
-                               
-                               // show selection to create new category when allowed/wanted
-                               if ( $showNewCat )
-                               {
-                                       // check if allowed to do so
-                                       if ( $member->blogAdminRights($rBlog['bnumber']) )
-                                       {
-                                               echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
-                                       }
-                               }
-                               
-                               // 2. for each category in that blog
-                               $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
-                               $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
-                               $categories = DB::getResult($catQuery);
-                               foreach ( $categories as $rCat )
-                               {
-                                       if ( $rCat['catid'] == $selected )
-                                       {
-                                               $selectText = ' selected="selected" ';
-                                       }
-                                       else
-                                       {
-                                               $selectText = '';
-                                       }
-                                       echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
-                               }
-                               
-                               if ( isset($multipleBlogs) && !empty($multipleBlogs) )
-                               {
-                                       echo '</optgroup>';
-                               }
-                       }
-               }
-               else
-               {
-                       // blog mode
-                       foreach ( $blogs as $rBlog )
-                       {
-                               echo '<option value="' . $rBlog['bnumber'] . '"';
-                               if ( $rBlog['bnumber'] == $selected )
-                               {
-                                       echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
-                               }
-                               else
-                               {
-                                       echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";
-                               }
-                       }
-               }
-               echo "</select>\n";
-               return;
-       }
-       
-       /**
         * AdminActions::parse_blogsetting()
         * Parse skinvar blogsetting
         * 
@@ -1983,7 +1877,7 @@ class AdminActions extends BaseActions
                        $catid = $contents['catid'];
                }
                
-               Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
+               $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
                
                return;
        }
@@ -2832,6 +2726,8 @@ class AdminActions extends BaseActions
         */
        public function parse_editpluginfo($type)
        {
+               global $manager;
+               
                $pid = intRequestVar('plugid');
                switch ( $type )
                {
@@ -2839,7 +2735,7 @@ class AdminActions extends BaseActions
                                echo $pid;
                                break;
                        case 'name':
-                               echo Entity::hsc(getPluginNameFromPid($pid));
+                               echo Entity::hsc($manager->getPluginNameFromPid($pid));
                                break;
                }
                return;
@@ -3421,6 +3317,7 @@ class AdminActions extends BaseActions
         */
        public function parse_geteditpluginfo($type)
        {
+               global $manager;
                $pid = intRequestVar('plugid');
                switch ( $type )
                {
@@ -3428,7 +3325,7 @@ class AdminActions extends BaseActions
                                return $pid;
                                break;
                        case 'name':
-                               return Entity::hsc(getPluginNameFromPid($pid));
+                               return Entity::hsc($manager->getPluginNameFromPid($pid));
                                break;
                }
                return;
@@ -3540,7 +3437,7 @@ class AdminActions extends BaseActions
        public function parse_helpplugname()
        {
                $plugid = intGetVar('plugid');
-               Entity::hsc(getPluginNameFromPid($plugid));
+               Entity::hsc($manager->getPluginNameFromPid($plugid));
                return;
        }
        
@@ -3680,72 +3577,6 @@ class AdminActions extends BaseActions
        }
        
        /**
-        * AdminActions::parse_insertpluginoptions()
-        * Parse skinvar insertpluginoptions
-        * 
-        * @param       string  $templateName   name of template
-        * @return      void
-        */
-       public function parse_insertpluginoptions($templateName = '')
-       {
-               $options        = Admin::getAdminaOption();
-               $template       = array();
-               $templats       = array();
-               
-               if ( $templateName )
-               {
-                       $templates = Template::read($templateName);
-               }
-               
-               if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
-               {
-                       $template['title'] = "<tr>"
-                                          . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
-                                          . "</tr>\n";
-               }
-               else
-               {
-                       $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
-               }
-               
-               if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
-               {
-                       $template['body'] = "<tr>"
-                                         . "<%listplugplugoptionrow%>"
-                                         . "</tr>\n";
-               }
-               else
-               {
-                       $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
-               }
-               
-               $prevPid = -1;
-               
-               include_libs('ACTIONS.php');
-               $handler = new Actions($this->skintype);
-               $parser = new PARSER($handler);
-                       
-               foreach ( $options as $option )
-               {
-                       
-                       // new plugin?
-                       if ( $prevPid != $option['pid'] )
-                       {
-                               $prevPid  = $option['pid'];
-                               $parser->parse($template['title']);
-                       }
-                       
-                       $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
-                       
-                       if ( @$meta['access'] != 'hidden' )
-                       {
-                               $parsed = $parser->parse($template['body']);
-                       }
-               }
-               return;
-       }
-       
-       /**
         * AdminActions::parse_insplugoptcontent()
         * Parse skinvar insplugoptcontent
         * 
@@ -4065,10 +3896,10 @@ class AdminActions extends BaseActions
                switch ( $actionType )
                {
                        case 'batchitem':
-                               Admin::selectBlogCategory('destcatid');
+                               $this->selectBlog('destcatid', 'category');
                                break;
                        case 'batchcategory':
-                               Admin::selectBlog('destblogid');
+                               $this->selectBlog('destblogid');
                                break;
                        default:
                                if ( $this->skintype == 'itemmove' )
@@ -4076,7 +3907,7 @@ class AdminActions extends BaseActions
                                        $query  = "SELECT icat as result FROM %s WHERE inumber=%d;";
                                        $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
                                        $catid  = DB::getValue(sprintf($query, intRequestVar('itemid')));
-                                       Admin::selectBlogCategory('catid', $catid, 10, 1);
+                                       $this->selectBlog('catid', 'category', $catid, 10, 1);
                                }
                                break;
                }
@@ -4143,8 +3974,11 @@ class AdminActions extends BaseActions
                $query  = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
                $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
                
-               $template['name']        = 'memberid';
-               $template['tabindex'] = 10000;
+               $template = array(
+                                       'name'          => 'memberid',
+                                       'tabindex'      => 10000,
+                                       'selected'      => 0
+                               );
                Showlist($query, 'select', $template, $templateName);
                return;
        }
@@ -4256,7 +4090,7 @@ class AdminActions extends BaseActions
                global $manager, $DIR_PLUGINS;
                
                $plugid = intGetVar('plugid');
-               $plugName =  getPluginNameFromPid($plugid);
+               $plugName = $manager->getPluginNameFromPid($plugid);
                $plug =& $manager->getPlugin($plugName);
                
                if ( $plug->supportsFeature('HelpPage') > 0 )
@@ -4305,7 +4139,7 @@ class AdminActions extends BaseActions
         * @param       string  $type   type of plugin option
         * @return      void
         */
-       public function parse_pluginoptions($context='global')
+       public function parse_pluginoptions($context='global', $templateName='')
        {
                global $itemid, $manager;
                
@@ -4369,12 +4203,59 @@ class AdminActions extends BaseActions
                $data = array(
                        'context'       =>  $context,
                        'contextid'     =>  $contextid,
-                       'options'       => &$opt4ions
+                       'options'       => &$options
                );
                $manager->notify('PrePluginOptionsEdit', $data);
                
-               $content = $this->parser->skin->getContentFromDB('insertpluginoptions');
-               $this->parser->parse($content);
+               $template = array();
+               if ( $templateName )
+               {
+                       $templates = Template::read($templateName);
+                       if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
+                       {
+                               $template['title'] = "<tr>"
+                                                  . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
+                                                  . "</tr>\n";
+                       }
+                       else
+                       {
+                               $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
+                       }
+                       
+                       if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
+                       {
+                               $template['body'] = "<tr>"
+                                                 . "<%listplugplugoptionrow%>"
+                                                 . "</tr>\n";
+                       }
+                       else
+                       {
+                               $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
+                       }
+               }
+               
+               $prevPid = -1;
+               
+               include_libs('ACTIONS.php');
+               $handler = new Actions($this->skintype);
+               $parser = new PARSER($handler);
+                       
+               foreach ( $options as $option )
+               {
+                       // new plugin?
+                       if ( $prevPid != $option['pid'] )
+                       {
+                               $prevPid  = $option['pid'];
+                               $parser->parse($template['title']);
+                       }
+                       
+                       $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
+                       
+                       if ( @$meta['access'] != 'hidden' )
+                       {
+                               $parsed = $parser->parse($template['body']);
+                       }
+               }
                
                return;
        }
@@ -4637,7 +4518,7 @@ class AdminActions extends BaseActions
                switch ( $type )
                {
                        case 'skin':
-                               $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'));
+                               $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
                                foreach ( $res as $row )
                                {
                                        $data = array(
@@ -5719,24 +5600,28 @@ class AdminActions extends BaseActions
        {
                global $DIR_PLUGINS;
                
-               $candidates = array();
+               $query = "SELECT * FROM %s;";
+               $query = sprintf($query, sql_table('plugin'));
+               $res  = DB::getResult($query);
+               
+               $installed = array();
+               foreach( $res as $row )
+               {
+                       $installed[] = $row['pfile'];
+               }
+               
                $files = scandir($DIR_PLUGINS);
                
+               $candidates = array();
                foreach ( $files as $file )
                {
-                       if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
+                       if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
                        {
-                               $name = $matches[1];
-                               $query = "SELECT * FROM %s WHERE pfile=%s;";
-                               $query = sprintf($query, sql_table('plugin'), DB::quoteValue("{NP_{$name}"));
-                               $res  = DB::getResult($query);
-                               
-                               if ( $res->rowCount() == 0 )
+                               if ( !in_array($matches[1], $installed) )
                                {
-                                       $candidates[] = $name;
+                                       $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
                                }
                        }
-                       continue;
                }
                $this->newPlugCandidates = $candidates;
                return (count($candidates) > 0);
@@ -5753,16 +5638,16 @@ class AdminActions extends BaseActions
        {
                global $member, $nucleus, $CONF, $manager;
                
+               $extrahead = Admin::getAdminextrahead();
+               $data = array(
+                       'extrahead'     => &$extrahead,
+                       'action'        =>  Admin::getAdminAction()
+               );
+               $manager->notify('AdminPrePageHead', $data);
+
                $content = $this->parser->skin->getContentFromDB('pagehead');
                if ( !$content )
                {
-                       $extrahead = Admin::$extrahead;
-                       $data = array(
-                               'extrahead'     => &$extrahead,
-                               'action'        =>  Admin::$action
-                       );
-                       $manager->notify('AdminPrePageHead', $data);
-                       
                        $baseUrl = Entity::hsc($CONF['SkinsURL']);
                        
                        /*
@@ -5875,14 +5760,14 @@ class AdminActions extends BaseActions
        {
                global $action, $member, $manager;
                
+               $data = array(
+                       'action' => Admin::getAdminAction()
+               );
+               $manager->notify('AdminPrePageFoot', $data);
+
                $content = $this->parser->skin->getContentFromDB('pagefoot');
                if ( !$content )
                {
-                       $data = array(
-                               'action' => self::$action
-                       );
-                       $manager->notify('AdminPrePageFoot', $data);
-                       
                        if ( $member->isLoggedIn() && ($action != 'showlogin') )
                        {
                                echo '<h2>' . _LOGOUT . "</h2>\n";
@@ -6012,4 +5897,129 @@ class AdminActions extends BaseActions
                
                return;
        }
+       /**
+        * AdminActions::selectBlog()
+        * Inserts a HTML select element with choices for all blogs to which the user has access
+        *      mode = 'blog' => shows blognames and values are blogids
+        *      mode = 'category' => show category names and values are catids
+        *
+        * @param       string  $name                           
+        * @param       string  $mode                           
+        * @param       integer $selected                       
+        * @param       integer $tabindex                       
+        * @param       integer $showNewCat                     
+        * @param       integer $iForcedBlogInclude     ID for weblog always included
+        * @param $iForcedBlogInclude
+        *      ID of a blog that always needs to be included, without checking if the
+        *      member is on the blog team (-1 = none)
+        * @return      void
+        */
+       private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
+       {
+               global $member, $CONF;
+               
+               // 0. get IDs of blogs to which member can post items (+ forced blog)
+               $aBlogIds = array();
+               if ( $iForcedBlogInclude != -1 )
+               {
+                       $aBlogIds[] = intval($iForcedBlogInclude);
+               }
+               
+               if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
+               {
+                       $query =  "SELECT bnumber FROM %s ORDER BY bname;";
+                       $query = sprintf($query, sql_table('blog'));
+               }
+               else
+               {
+                       $query =  "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
+                       $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
+               }
+               
+               $rblogids = DB::getResult($query);
+               foreach ( $rblogids as $row )
+               {
+                       if ( $row['bnumber'] != $iForcedBlogInclude )
+                       {
+                               $aBlogIds[] = intval($row['bnumber']);
+                       }
+               }
+               
+               if ( count($aBlogIds) == 0 )
+               {
+                       return;
+               }
+               
+               echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
+               
+               // 1. select blogs (we'll create optiongroups)
+               // (only select those blogs that have the user on the team)
+               $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
+               $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
+               $blogs = DB::getResult($queryBlogs);
+               
+               if ( $mode == 'category' )
+               {
+                       if ( $blogs->rowCount() > 1 )
+                       {
+                               $multipleBlogs = 1;
+                       }
+                       foreach ( $blogs as $rBlog )
+                       {
+                               if ( isset($multipleBlogs) && !empty($multipleBlogs) )
+                               {
+                                       echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
+                               }
+                               
+                               // show selection to create new category when allowed/wanted
+                               if ( $showNewCat )
+                               {
+                                       // check if allowed to do so
+                                       if ( $member->blogAdminRights($rBlog['bnumber']) )
+                                       {
+                                               echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
+                                       }
+                               }
+                               
+                               // 2. for each category in that blog
+                               $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
+                               $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
+                               $categories = DB::getResult($catQuery);
+                               foreach ( $categories as $rCat )
+                               {
+                                       if ( $rCat['catid'] == $selected )
+                                       {
+                                               $selectText = ' selected="selected" ';
+                                       }
+                                       else
+                                       {
+                                               $selectText = '';
+                                       }
+                                       echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
+                               }
+                               
+                               if ( isset($multipleBlogs) && !empty($multipleBlogs) )
+                               {
+                                       echo '</optgroup>';
+                               }
+                       }
+               }
+               else
+               {
+                       foreach ( $blogs as $rBlog )
+                       {
+                               echo '<option value="' . $rBlog['bnumber'] . '"';
+                               if ( $rBlog['bnumber'] == $selected )
+                               {
+                                       echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
+                               }
+                               else
+                               {
+                                       echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";
+                               }
+                       }
+               }
+               echo "</select>\n";
+               return;
+       }
 }