OSDN Git Service

FIX: コメントの編集・削除、アクセス禁止の追加と削除が行えないバグの修正
[nucleus-jp/nucleus-next.git] / nucleus / libs / AdminActions.php
index d736d9e..ff3c888 100644 (file)
@@ -10,10 +10,6 @@ class AdminActions extends BaseActions
        // reference to the skin object for which a part is being parsed
        private $skin;
        
-       // an instance of parser class
-//     private $parser;
-       protected $parser;
-       
        private $skintype;
        
        /* NOTE: list of whole available action names for tags
@@ -94,8 +90,8 @@ class AdminActions extends BaseActions
                'iprangeinput',
                'itemnavlist',
                'jstoolbaroptions',
-               'languageselectoptions',
                'listplugplugoptionrow',
+               'localeselectoptions',
                'mediadirwarning',
                'movedistselect',
                'moveitemid',
@@ -136,12 +132,12 @@ class AdminActions extends BaseActions
         */
        static private $default_actions = array(
                'addtickettourl',
+               'adminurl',
+               'customhelplink',
                'headmessage',
-               'ticket',
-               'sprinttext',
                'helplink',
-               'customhelplink',
-               'adminurl'
+               'sprinttext',
+               'ticket'
        );
        
        /**
@@ -164,7 +160,7 @@ class AdminActions extends BaseActions
                'adminskinremovetype'   => _ADM_SKPRT_ADMINSKINREMOVETYPE,
                'admintemplatedelete'   => _ADM_SKPRT_ADMINTEMPLATEDELETE,
                'admintemplateedit'             => _ADM_SKPRT_ADMINTEMPLATEEDIT,
-               'admntemplateoverview'  => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
+               'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
                'backupoverview'                => _ADM_SKPRT_BACKUPOVERVIEW,
                'backuprestore'                 => _ADM_SKPRT_BACKUPRESTORE,
                'banlist'                               => _ADM_SKPRT_BANLIST,
@@ -177,6 +173,7 @@ class AdminActions extends BaseActions
                'batchitem'                             => _ADM_SKPRT_BATCHITEM,
                'batchmember'                   => _ADM_SKPRT_BATCHMEMBER,
                'batchmove'                             => _ADM_SKPRT_BATCHMOVE,
+               'batchmovecat'                  => _ADM_SKPRT_BATCHMOVECAT,
                'batchteam'                             => _ADM_SKPRT_BATCHTEAM,
                'blogcommentlist'               => _ADM_SKPRT_BLOGCOMMENTLIST,
                'blogselectbox'                 => _ADM_SKPRT_BLOGSELECTBOX,
@@ -229,17 +226,60 @@ class AdminActions extends BaseActions
        );
        
        /**
-        * AdminActions::getDefinedActions()
+        * AdminActions::getAvailableSkinTypes()
         * 
         * @static
-        * @param       string  $type   page type
+        * @param       void
+        * @return      array   list of friendly names for page actions
+        */
+       static public function getAvailableSkinTypes()
+       {
+               return self::$default_skin_types;
+       }
+       
+       /**
+        * AdminActions::getDefaultTypes()
+        *
+        * @static
+        * @param       void
+        * @return      array   list of friendly names for page actions
+        */
+       static public function getDefaultTypes()
+       {
+               return self::$default_skin_types;
+       }
+       
+       /**
+        * AdminActions::__construct()
+        * Constructor for a new Actions object
+        * 
+        * @param       string  $type
+        * @return      void
+        */
+       public function __construct($type)
+       {
+               // call constructor of superclass first
+               parent::__construct();
+               $this->skintype = $type;
+               if ( !class_exists('Navlist') || !class_exists('Batch') )
+               {
+                       global $DIR_LIBS;
+                       include $DIR_LIBS . 'ENCAPSULATE.php';
+               }
+               return;
+       }
+       
+       /**
+        * AdminActions::getAvailableActions()
+        * 
+        * @param       void
         * @return      array   allowed actions for the page type
         */
-       static public function getDefinedActions($type = '')
+       public function getAvailableActions()
        {
                $extra_actions = array();
                
-               switch ( $type )
+               switch ( $this->skintype )
                {
                        case 'actionlog':
                                $extra_actions = array(
@@ -313,6 +353,10 @@ class AdminActions extends BaseActions
                                        'editadminskintype',
                                );
                                break;
+                       case 'admintemplatedelete':
+                               $extra_actions = array(
+                                       'editadmintemplateinfo',
+                               );
                        case 'admintemplateedit':
                                $extra_actions = array(
                                        'editadmintemplateinfo',
@@ -427,16 +471,17 @@ class AdminActions extends BaseActions
                        case 'blogsettings':
                                $extra_actions = array(
                                        'adminbloglink',
-                                       'blogteammembers',
-                                       'requestblogid',
-                                       'blogsetting',
+                                       'blogcatlist',
                                        'blognotifysetting',
-                                       'defcatselect',
-                                       'blogtime',
+                                       'blogsetting',
                                        'blogsettingyesno',
-                                       'pluginoptions',
-                                       'blogcatlist',
+                                       'blogteammembers',
+                                       'blogtime',
+                                       'defcatselect',
+                                       'defskinselect',
                                        'pluginextras',
+                                       'pluginoptions',
+                                       'requestblogid',
                                );
                                break;
                        case 'bookmarklet':
@@ -465,6 +510,7 @@ class AdminActions extends BaseActions
                                        'requestblogid',
                                        'categorysetting',
                                        'editdesturl',
+                                       'pluginoptions'
                                );
                                break;
                        case 'commentdelete':
@@ -481,13 +527,12 @@ class AdminActions extends BaseActions
                                $extra_actions = array(
                                        'adminbloglink',
                                        'blogid',
-                                       'jsinput',
-                                       'jsbuttonbar',
                                        'contents',
                                        'categories',
                                        'currenttime',
-                                       'pluginextras',
-                                       'itemoptions'
+                                       'init',
+                                       'itemoptions',
+                                       'pluginextras'
                                );
                                break;
                        case 'createnewlog':
@@ -504,9 +549,9 @@ class AdminActions extends BaseActions
                                break;
                        case 'editmembersettings':
                                $extra_actions = array(
-                                       'editmember',
-                                       'languageselectoptions',
                                        'adminskinselectoptions',
+                                       'editmember',
+                                       'localeselectoptions',
                                        'pluginoptions',
                                );
                                break;
@@ -532,8 +577,6 @@ class AdminActions extends BaseActions
                                $extra_actions = array(
                                        'init',
                                        'contents',
-                                       'jsinput',
-                                       'jsbuttonbar',
                                        'checkedonval',
                                        'categories',
                                        'currenttime',
@@ -627,10 +670,10 @@ class AdminActions extends BaseActions
                                        'defblogselect',
                                        'defskinselect',
                                        'configsettingsedit',
-                                       'languageselectoptions',
                                        'configsettingsyesno',
                                        'outputspecialdirs',
                                        'jstoolbaroptions',
+                                       'localeselectoptions',
                                        'mediadirwarning',
                                        'pluginextras',
                                );
@@ -740,51 +783,7 @@ class AdminActions extends BaseActions
                
                $defined_actions = array_merge(self::$default_actions, $extra_actions);
                
-               return array_merge($defined_actions, parent::getDefinedActions());
-       }
-       
-       /**
-        * AdminActions::getDefaultSkinTypes()
-        * 
-        * @static
-        * @param       void
-        * @return      array   list of friendly names for page actions
-        */
-       static public function getDefaultSkinTypes()
-       {
-               return self::$default_skin_types;
-       }
-       
-       /**
-        * AdminActions::getDefaultTypes()
-        *
-        * @static
-        * @param       void
-        * @return      array   list of friendly names for page actions
-        */
-       static public function getDefaultTypes()
-       {
-               return self::$default_skin_types;
-       }
-       
-       /**
-        * AdminActions::__construct()
-        * Constructor for a new Actions object
-        * 
-        * @param       string  $type
-        * @return      void
-        */
-       public function __construct($type)
-       {
-               // call constructor of superclass first
-               parent::__construct();
-               $this->skintype = $type;
-               if ( !class_exists('Navlist') || !class_exists('Batch') )
-               {
-                       global $DIR_LIBS;
-                       include $DIR_LIBS . 'ENCAPSULATE.php';
-               }
-               return;
+               return array_merge($defined_actions, parent::getAvailableActions());
        }
        
        /**
@@ -800,19 +799,6 @@ class AdminActions extends BaseActions
        }
        
        /**
-        * AdminActions::setParser()
-        * Set the parser
-        * 
-        * @param       object  $parser an instance of Parser class
-        * @return      void
-        */
-       public function setParser(&$parser)
-       {
-               $this->parser =& $parser;
-               return;
-       }
-       
-       /**
         * AdminActions::parse_actionloglist()
         * Parse skinvar actionloglist
         * 
@@ -930,10 +916,10 @@ class AdminActions extends BaseActions
                switch ( $type )
                {
                        case 'title':
-                               echo TEMPLATE::fill($title, $aVars);
+                               echo Template::fill($title, $aVars);
                                break;
                        case 'text':
-                               echo TEMPLATE::fill($text,  $aVars);
+                               echo Template::fill($text,  $aVars);
                                break;
                        case 'ackey':
                                echo Entity::hsc($key);
@@ -1006,15 +992,13 @@ class AdminActions extends BaseActions
        {
                global $manager;
                $templates = array();
+               
                if ( !empty($templateName) )
                {
                        $templates = Template::read($templateName);
                }
-               if ( isset($templates['ADMIN_BATCHLIST']) || !empty($templates['ADMIN_BATCHLIST']) )
-               {
-                       $template = $templates['ADMIN_BATCHLIST'];
-               }
-               else
+               
+               if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
                {
                        $template = '<li><%text(_BATCH_EXECUTING)%>'
                                  . '<b><%adminbatchaction%></b>'
@@ -1023,6 +1007,10 @@ class AdminActions extends BaseActions
                                  . '<b><%batchlistmsg%></b>'
                                  . '</li>' . "\n";
                }
+               else
+               {
+                       $template = $templates['ADMIN_BATCHLIST'];
+               }
                
                $selected = requestIntArray('batch');
                $action   = requestVar('batchaction');
@@ -1067,14 +1055,15 @@ class AdminActions extends BaseActions
                // walk over all selectedids and perform action
                foreach ( $selected as $selectedid )
                {
-                       $error    = '';
+                       $error = '';
                        $selectedid = intval($selectedid);
+                       
                        switch ( $action )
                        {
                                case 'delete':
                                        if ( $this->skintype != 'batchteam' )
                                        {
-                                               $error = Admin::$deleteaction($selectedid);
+                                               $error = Admin::deleteaction($selectedid);
                                        }
                                        else
                                        {
@@ -1086,7 +1075,7 @@ class AdminActions extends BaseActions
                                        break;
                                case 'setadmin':
                                        // always succeeds
-                                       sql_query('UPDATE ' . $setadminsql . $selectedid);
+                                       sql_query("UPDATE {$setadminsql} {$selectedid};");
                                        $error = '';
                                        break;
                                case 'unsetadmin':
@@ -1098,27 +1087,29 @@ class AdminActions extends BaseActions
                                        }
                                        else
                                        {
-                                               sql_query('UPDATE ' . $unsetupsql . $selectedid);
+                                               sql_query("UPDATE {$setadminsql} {$selectedid};");
                                        }
                                        break;
                                default:
                                        $error = _BATCH_UNKNOWN . Entity::hsc($action);
                        }
+                       
                        $data = array(
                                'batchid'                       => $selectedid,
                                'batchlisttype'         => Entity::hsc($batchlisttype),
                                'adminbatchaction'      => Entity::hsc($action),
                                'batchlistmsg'          => $error ? $error : _BATCH_SUCCESS,
                        );
-                       $handler = new Actions('template', $template, new ADMIN);
-                       $parser  = new Parser($handler);
+                       
+                       $handler = new AdminActions('template');
+                       $parser = new Parser($handler);
                        
                        ob_start();
                        $parser->parse($template);
                        $template = ob_get_contents();
                        ob_end_clean();
                        
-                       echo TEMPLATE::fill($template, $data);
+                       echo Template::fill($template, $data);
                        return;
                }
        }
@@ -1142,13 +1133,13 @@ class AdminActions extends BaseActions
                        $templates = Template::read($templateName);
                }
                
-               if ( isset($templates['ADMIN_BLOGLINK']) || !empty($templates['ADMIN_BLOGLINK']) )
+               if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
                {
-                       $template = $templates['ADMIN_BLOGLINK'];
+                       $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
                }
                else
                {
-                       $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
+                       $template = $templates['ADMIN_BLOGLINK'];
                }
                
                $data = array(
@@ -1157,7 +1148,7 @@ class AdminActions extends BaseActions
                        'blogname'                              => Entity::hsc($blog->getName())
                );
                
-               echo TEMPLATE::fill($template, $data);
+               echo Template::fill($template, $data);
                return;
        }
        
@@ -1208,6 +1199,7 @@ class AdminActions extends BaseActions
                                $show  = array(
                                        'content' => 'shortblognames'
                                );
+                               Showlist($query, 'table', $show, $templateName);
                                break;
                        case 'template':
                                $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
@@ -1215,9 +1207,9 @@ class AdminActions extends BaseActions
                                $show  = array(
                                        'content' => 'shortnames'
                                );
+                               Showlist($query, 'table', $show, $templateName);
                                break;
                }
-               Showlist($query, 'table', $show, $templateName);
                return;
        }
        
@@ -1236,20 +1228,26 @@ class AdminActions extends BaseActions
                {
                        $templates = Template::read($templateName);
                }
-               if ( isset($templates['SKINIE_EXPORT_LIST']) && !empty($templates['SKINIE_EXPORT_LIST']) )
+               
+               if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
                {
-                       $template = $templates['SKINIE_EXPORT_LIST'];
+                       $template = "<td>"
+                                 . "<input type=\"checkbox\" name=\"<%typeid%>\"  id=\"<%expid%>\" />\n"
+                                 . "<label for=\"<%expid%>\"><%expname%></label>"
+                                 . "</td>\n"
+                                 . "<td><%expdesc%></td>\n"
+                                 . "</tr>\n"
+                                 . "<tr>\n";
                }
                else
                {
-                       $template = '<td><input type="checkbox" name="<%typeid%>"  id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
-                                 . "<td><%expdesc%></td>\n"
-                                 . "</tr><tr>\n";
+                       $template = $templates['SKINIE_EXPORT_LIST'];
                }
+               
                switch ( $type )
                {
                        case 'skin':
-                               $query = "SELECT * FROM %s WHERE sdincmode = 'admin';";
+                               $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
                                $query = sprintf($query, sql_table('skin_desc'));
                                $res = sql_query($query);
                                
@@ -1261,11 +1259,11 @@ class AdminActions extends BaseActions
                                                'expname'       => Entity::hsc($skinObj->sdname),
                                                'expdesc'       => Entity::hsc($skinObj->sddesc),
                                        );
-                                       echo TEMPLATE::fill($template, $data);
+                                       echo Template::fill($template, $data);
                                }
                                break;
                        case 'template':
-                               $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%'";
+                               $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
                                $query = sprintf($query, sql_table('template_desc'));
                                $res = sql_query($query);
                                while ( $templateObj = sql_fetch_object($res) )
@@ -1276,7 +1274,7 @@ class AdminActions extends BaseActions
                                                'expname'       => Entity::hsc($templateObj->tdname),
                                                'expdesc'       => Entity::hsc($templateObj->tddesc),
                                        );
-                                       echo TEMPLATE::fill($template, $data);
+                                       echo Template::fill($template, $data);
                                }
                                break;
                }
@@ -1292,12 +1290,12 @@ class AdminActions extends BaseActions
         */
        public function parse_adminskinoverview($templateName = '')
        {
-               $query = "SELECT * FROM %s WHERE sdincmode = 'admin' ORDER BY sdname;";
+               $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
                $query = sprintf($query, sql_table('skin_desc'));
                
-               $template['content']    = 'adminskinlist';
-               $template['tabindex']   = 10;
-               $template['friendly_names'] = Skin::getAvailableTypes();
+               $template['content'] = 'adminskinlist';
+               $template['tabindex'] = 10;
+               $template['friendly_names'] = $this->skin->getAvailableTypes();
                Showlist($query, 'table', $template, $templateName);
                return;
        }
@@ -1308,14 +1306,14 @@ class AdminActions extends BaseActions
         * 
         * @param       void
         * @return      void
-        */
+        */     
        public function parse_adminskinselectoptions()
        {
                global $CONF;
-               $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdincmode = 'admin';";
+               $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
                $query = sprintf($query, sql_table('skin_desc'));
                
-               $template['name']        = 'adminskin';
+               $template['name'] = 'adminskin';
                $template['selected'] = $CONF['DefaultAdminSkin'];
                $template['tabindex'] = 110;
                Showlist($query, 'select', $template, '');
@@ -1336,7 +1334,7 @@ class AdminActions extends BaseActions
                        $templates = Template::read($templateName);
                }
                
-               $nType  = Skin::getFriendlyNames('AdminActions');
+               $nType  = $this->skin->getAvailableTypes();
                $skinid = intRequestVar('skinid');
                
                $query = "SELECT stype FROM  %s WHERE stype NOT IN (%s) AND sdesc=%d;";
@@ -1345,22 +1343,16 @@ class AdminActions extends BaseActions
                $res    = sql_query($query);
                if ( $res && sql_num_rows($res) > 0 )
                {
-                       $data = array();
-                       if ( array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
-                       {
-                               $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
-                       }
-                       else
+                       /* NOTE: set templates for HEAD/BODY/FOOT */
+                       if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
                        {
                                $template['head'] = "<ul>\n";
                        }
-                       echo TEMPLATE::fill($template['head'], $data);
-                       
-                       if ( array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
+                       else
                        {
-                               $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
+                               $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
                        }
-                       else
+                       if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
                        {
                                $template['body'] = '<li>'
                                                  . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">'
@@ -1371,7 +1363,24 @@ class AdminActions extends BaseActions
                                                  . '</a>)'
                                                  . "</li>\n";
                        }
+                       else
+                       {
+                               $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
+                       }
+                       if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
+                       {
+                               $template['foot'] = "</ul>\n";
+                       }
+                       else
+                       {
+                               $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
+                       }
+                       
                        $tabstart = 120;
+                       
+                       /* NOTE: do echo */
+                       $data = array();
+                       echo $template['head'];
                        while ( $row = sql_fetch_assoc($res) )
                        {
                                $data = array(
@@ -1379,19 +1388,10 @@ class AdminActions extends BaseActions
                                        'skinid'        => $skinid,
                                        'skintype'      => Entity::hsc(strtolower($row['stype']))
                                );
-                               echo TEMPLATE::fill($template['body'], $data);
+                               echo Template::fill($template['body'], $data);
                        }
-                       
                        $data = array();
-                       if ( array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
-                       {
-                               $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
-                       }
-                       else
-                       {
-                               $template['foot'] = "</ul>\n";
-                       }
-                       echo TEMPLATE::fill($template['foot'], $data);
+                       echo $template['foot'];
                }
                return;
        }
@@ -1408,7 +1408,7 @@ class AdminActions extends BaseActions
                $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
                $query = sprintf($query, sql_table('template_desc'));
                
-               $template['content']  = 'admintemplatelist';
+               $template['content'] = 'admintemplatelist';
                $template['tabindex'] = 10;
                
                Showlist($query, 'table', $template, $templateName);
@@ -1426,11 +1426,12 @@ class AdminActions extends BaseActions
        {
                global $DIR_ADMINSKINS;
                $skinType = strtolower(trim(requestVar('type')));
-               $actions  = Skin::getAllowedActionsForType($skinType);
+               $actions  = $this->skin->getAllowedActionsForType($skinType);
                sort($actions);
                
                while ( $current = array_shift($actions) )
                {
+                       // TODO: remove this
                        // skip deprecated vars
                        if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
                        {
@@ -1438,7 +1439,6 @@ class AdminActions extends BaseActions
                        }
                        
                        echo helplink("adminskinvar-{$current}") . "$current</a>\n";
-//                     echo "<a href=\"{$DIR_ADMINSKINS}documentation/help.html#{$current}\" onclick=\"if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);\">{$current}</a>\n";
                        
                        if ( count($actions) != 0 )
                        {
@@ -1458,11 +1458,15 @@ class AdminActions extends BaseActions
        public function parse_allowedskinactions()
        {
                $skinType = strtolower(trim(requestVar('type')));
-               $actions  = SKIN::getAllowedActionsForType($skinType);
+               $skinid = intRequestVar('skinid');
+               
+               $skin = new Skin($skinid);
+               $actions = $skin->getAllowedActionsForType($skinType);
                sort($actions);
                
                while ( $current = array_shift($actions) )
                {
+                       // TODO: remove this
                        // skip deprecated vars
                        if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
                        {
@@ -1490,29 +1494,32 @@ class AdminActions extends BaseActions
        public function parse_banlistdeletedlist($templateName = '')
        {
                global $manager;
-               $templates = array();
                
+               $templates = array();
                if ( $templateName )
                {
                        $templates = Template::read($templateName);
                }
-               if ( isset($templates['BANLIST_DELETED_LIST']) && !empty($templates['BANLIST_DELETED_LIST']) )
+               
+               if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
                {
-                       $template = $templates['BANLIST_DELETED_LIST'];
+                       $template = "<li><%blogname%></li>\n";
                }
                else
                {
-                       $template = "<li><%blogname%></li>\n";
+                       $template = $templates['BANLIST_DELETED_LIST'];
                }
+               
                $deleted = requestArray('delblogs');
                foreach ( $deleted as $delblog )
                {
                        $blog =& $manager->getBlog($delblog);
                        $data =  array(
-                               Entity::hsc($blog->getName())
+                               'blogname' => Entity::hsc($blog->getName())
                        );
-                       TEMPLATE::fill($template, $data);
+                       echo Template::fill($template, $data);
                }
+               
                return;
        }
        
@@ -1648,12 +1655,25 @@ class AdminActions extends BaseActions
                $template['content']  = 'categorylist';
                $template['tabindex'] = 200;
                
-               $batch = new Batch('member');
+               $batch = new Batch('category');
                $batch->showlist($query, 'table', $template);
                return;
        }
        
        /**
+        * AdminActions::parse_blogid()
+        * Parse skinvar blogid
+        * 
+        * @param       void
+        * @return      void
+        */
+       function parse_blogid()
+       {
+               echo intRequestVar('blogid');
+               return;
+       }
+       
+       /**
         * AdminActions::parse_blognotifysetting()
         * Parse skinvar blognotifysetting
         * 
@@ -1728,7 +1748,7 @@ class AdminActions extends BaseActions
                        {
                                if ( isset($multipleBlogs) && !empty($multipleBlogs) )
                                {
-                                       echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\>\n";
+                                       echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\">\n";
                                }
                                
                                // show selection to create new category when allowed/wanted
@@ -1742,9 +1762,9 @@ class AdminActions extends BaseActions
                                }
                                
                                // 2. for each category in that blog
-                               $catQueriy  = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
+                               $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
                                $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
-                               $categories = sql_query(sprintf($catQueriy));
+                               $categories = sql_query($catQuery);
                                while ( $oCat = sql_fetch_object($categories) )
                                {
                                        if ( $oCat->catid == $selected )
@@ -1881,9 +1901,10 @@ class AdminActions extends BaseActions
                                . "FROM %s, %s "
                                . "WHERE mnumber=tmember AND tblog=%d;";
                $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
-               $res    = sql_query($query);
+               $res = sql_query($query);
                $memberNames = array();
-               while ($o = sql_fetch_object($res)) {
+               while ( $o = sql_fetch_object($res) )
+               {
                        $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
                }
                echo implode(',', $memberNames);
@@ -1909,9 +1930,9 @@ class AdminActions extends BaseActions
                }
                else
                {
-                       $bid            = intRequestVar('blogid');
-                       $b                      = $manager->getBlog($bid);
-                       $timestamp      = $b->getCorrectTime() + $offset;
+                       $bid = intRequestVar('blogid');
+                       $b = $manager->getBlog($bid);
+                       $timestamp = $b->getCorrectTime() + $offset;
                }
                
                echo i18n::formatted_datetime($format, $timestamp);
@@ -1934,6 +1955,62 @@ class AdminActions extends BaseActions
                echo Entity::hsc('javascript:' . getBookmarklet($blogid));
                return;
        }
+
+       /**
+        * AdminActions::parse_categories()
+        * Parse skinvar categories
+        * 
+        * create category dropdown box
+        * 
+        * @param       string  $type   name of setting for category
+        * @return      void
+        */
+       function parse_categories($startidx = 0)
+       {
+               global $manager;
+               
+               $item = FALSE;
+               $itemid =  intRequestVar('itemid');
+               $item   = &$manager->getItem($itemid, 1, 1);
+               
+               $blog = FALSE;
+               if ( !$item )
+               {
+                       $blogid =  intRequestVar('blogid');
+               }
+               else
+               {
+                       $blogid =  $item['blogid'];
+               }
+               $blog   = &$manager->getBlog($blogid);
+               
+               if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
+               {
+                       $item['body'] = removeBreaks($item['body']);
+                       $item['more'] = removeBreaks($item['more']);
+               }
+               
+               $contents = array();
+               if ( requestVar('action') == 'itemedit' )
+               {
+                       $contents = $item;
+               }
+               
+               if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
+               {
+                       // on add item
+                       $catid = $blog->getDefaultCategory();
+               }
+               else
+               {
+                       // on edit item
+                       $catid = $contents['catid'];
+               }
+               
+               Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
+               
+               return;
+       }
        
        /**
         * AdminActions::parse_category()
@@ -1969,7 +2046,7 @@ class AdminActions extends BaseActions
                $res    = sql_query($query);
                $obj    = sql_fetch_object($res);
                
-               if ( $type != desc )
+               if ( $type != 'name' )
                {
                        echo Entity::hsc($obj->cdesc);
                }
@@ -1985,22 +2062,62 @@ class AdminActions extends BaseActions
         * AdminActions::parse_codename()
         * Parse templatevar codename
         * 
-        * @param       void
-        * @return      void
+        * @param       $value
+        * @param       $name
         * 
-        * TODO: is this need???
         */
-       public function parse_codename()
+       function parse_checkedonval($value, $name)
        {
-               global $nucleus;
-               echo $nucleus['codename'];
-               return;
-       }
-       
-       /**
-        * AdminActions::parse_commentnavlist()
-        * Parse skinvar commentnavlist
-        * 
+               global $manager;
+               
+               $item = false;
+               $itemid = intRequestVar('itemid');
+               $item =& $manager->getItem($itemid, 1, 1);
+               
+               $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
+               
+               if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
+               {
+                       $item['body'] = removeBreaks($item['body']);
+                       $item['more'] = removeBreaks($item['more']);
+               }
+               
+               $contents = array();
+               if ( requestVar('action') == 'itemedit' )
+               {
+                       $contents = $item;
+               }
+               if ( !isset($contents[$name]) )
+               {
+                       $contents[$name] = '';
+               }
+               if ($contents[$name] == $value)
+               {
+                       echo 'checked="checked"';
+               }
+               return;
+       }
+       
+       /**
+        * AdminActions::parse_codename()
+        * Parse templatevar codename
+        * 
+        * @param       void
+        * @return      void
+        * 
+        * TODO: is this need???
+        */
+       public function parse_codename()
+       {
+               global $nucleus;
+               echo $nucleus['codename'];
+               return;
+       }
+       
+       /**
+        * AdminActions::parse_commentnavlist()
+        * Parse skinvar commentnavlist
+        * 
         * @param       void
         * @return      void
         */
@@ -2144,6 +2261,77 @@ class AdminActions extends BaseActions
        }
        
        /**
+        * AdminActions::parse_contents()
+        * Parse skinvar contents
+        * 
+        * @param       string  $which          part for item
+        * @return      void
+        */
+       function parse_contents($which)
+       {
+               global $manager;
+               
+               $item = false;
+               $contents = array();
+               
+               if ( requestVar('action') == 'itemedit' )
+               {
+                       $itemid = intRequestVar('itemid');
+                       $item =& $manager->getItem($itemid, 1, 1);
+                       
+                       $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
+                       
+                       if ( $item && $blog->convertBreaks() )
+                       {
+                               $item['body'] = removeBreaks($item['body']);
+                               $item['more'] = removeBreaks($item['more']);
+                       }
+                       $contents = $item;
+               }
+               elseif ( requestVar('action') == 'createitem' )
+               {
+                       $blogid = intRequestVar('blogid');
+                       $blog =& $manager->getBlog($blogid);
+                       $manager->notify(
+                               'PreAddItemForm',
+                               array(
+                                       'contents' => &$contents,
+                                       'blog'     => &$blog
+                               )
+                       );
+               }
+               
+               if ( !array_key_exists($which, $contents) )
+               {
+                       $contents[$which] = '';
+               }
+               echo Entity::hsc($contents[$which],ENT_QUOTES);
+       }
+       
+       /**
+        * AdminActions::parse_currenttime()
+        * Parse skinvar currenttime
+        * 
+        * @param       string  $what
+        */
+       // for future items
+       function parse_currenttime($what)
+       {
+               global $manager;
+               if ( requestVar('action') == 'itemedit' )
+               {
+                       $itemid = intRequestVar('itemid');
+                       $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
+               } 
+               elseif ( requestVar('action') == 'createitem' )
+               {
+                       $blog =& $manager->getBlog(intRequestVar('blogid'));
+               }
+               $nu = getdate($blog->getCorrectTime());
+               echo $nu[$what];
+       }
+       
+       /**
         * AdminActions::parse_customhelplink()
         * Parse skinvar customhelplink
         * 
@@ -2183,40 +2371,51 @@ class AdminActions extends BaseActions
        public function parse_defaultadminskintypes($tabindex, $templateName = '')
        {
                $templates = array();
+               
                if ( $templateName )
                {
                        $templates = Template::read($templateName);
                }
                
-               $types   = Skin::getFriendlyNames('AdminActions');
+               $types = $this->skin->getAvailableTypes();
                ksort($types);
                
-               if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
+               /* NOTE: set templates for HEAD/BODY/FOOT */
+               if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
                {
-                       $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
+                       $template['head'] = "<ul>\n";
                }
                else
                {
-                       $template['head'] = "<ul>\n";
+                       $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
                }
-               
-               echo $template['head'];
-               
-               if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
+               if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
+               {
+                       $template['body'] = "<li>"
+                                         . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&amp;skinid=<%skinid%>&amp;type=<%skintype%>\"><%name%></a> <%help%>"
+                                         . "</li>\n";
+               }
+               else
                {
                        $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
                }
+               if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
+               {
+                       $template['foot'] = "</ul>\n";
+               }
                else
                {
-                       $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">'
-                                         . "<%name%></a> <%help%></li>\n";
+                       $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
                }
-               $handler = new Actions('template', $template, new ADMIN);
-               $parser  = new PARSER(Actions::getDefinedActions(), $handler);
                
+               $handler = new AdminActions('template');
+               $parser = new PARSER($handler);
+               
+               /* NOTE: do output */
+               echo $template['head'];
                foreach ( $types as $type => $fName )
                {
-                       $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
+                       $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
                        $data = array(
                                'tabindex'      => $tabindex,
                                'skintype'      => $type,
@@ -2224,19 +2423,11 @@ class AdminActions extends BaseActions
                                'help'          => $helplink,
                                'skinid'        => intrequestVar('skinid'),
                        );
-                       $templateBody = Template::fill($template['body'], $data);
-                       $parser->parse($templateBody);
+                       $parser->parse(Template::fill($template['body'], $data));
                        $tabindex++;
                }
-               if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
-               {
-                       $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
-               }
-               else
-               {
-                       $template['foot'] = "           </ul>\n";
-               }
                echo $template['foot'];
+               
                return;
        }
        
@@ -2250,12 +2441,16 @@ class AdminActions extends BaseActions
        public function parse_defblogselect($templateName = '')
        {
                global $CONF;
-               $query  = "SELECT bname as text, bnumber as value FROM %s;";
+               
+               $query = "SELECT bname as text, bnumber as value FROM %s;";
                $query = sprintf($query, sql_table('blog'));
-               $template['name']        = 'DefaultBlog';
+               
+               $template['name'] = 'DefaultBlog';
                $template['selected'] = $CONF['DefaultBlog'];
                $template['tabindex'] = 10;
+               
                Showlist($query, 'select', $template, $templateName);
+               
                return;
        }
        
@@ -2269,14 +2464,19 @@ class AdminActions extends BaseActions
        public function parse_defcatselect($templateName = '')
        {
                global $manager;
+               
                $blogid = intRequestVar('blogid');
-               $blog   = $manager->getBlog($blogid);
-               $query  = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
+               $blog = $manager->getBlog($blogid);
+               
+               $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
                $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
+               
                $template['name']        = 'defcat';
                $template['selected'] = $blog->getDefaultCategory();
                $template['tabindex'] = 110;
+               
                Showlist($query, 'select', $template, $templateName);
+               
                return;
        }
        
@@ -2290,20 +2490,20 @@ class AdminActions extends BaseActions
         */
        public function parse_defskinselect($type = 'blog', $templateName = '')
        {
-               global $manager;
-               $query  = "SELECT sdname as text, sdnumber as value FROM %s;";
+               global $CONF, $manager;
+               
+               $query  = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
                $query = sprintf($query, sql_table('skin_desc'));
                
                $blogid = intRequestVar('blogid');
                
                if ( !$blogid )
                {
-                       global $CONF;
                        $template['selected'] = $CONF['BaseSkin'];
                }
                else
                {
-                       $blog                            = $manager->getBlog($blogid);
+                       $blog = $manager->getBlog($blogid);
                        $template['selected'] = $blog->getDefaultSkin();
                }
                
@@ -2318,7 +2518,9 @@ class AdminActions extends BaseActions
                
                $template['name']        = $nname;
                $template['tabindex'] = 50;
+               
                Showlist($query, 'select', $template, $templateName);
+               
                return;
        }
        
@@ -2366,10 +2568,14 @@ class AdminActions extends BaseActions
        public function parse_deleteitembody()
        {
                global $manager;
+               
                $itemid =  intRequestVar('itemid');
-               $item   =& $manager->getItem($itemid, 1, 1);
-               $body   =  strip_tags($item['body']);
+               $item =& $manager->getItem($itemid, 1, 1);
+               
+               $body =  strip_tags($item['body']);
+               
                echo Entity::hsc(shorten($body, 300, '...'));
+               
                return;
        }
        
@@ -2396,9 +2602,12 @@ class AdminActions extends BaseActions
        public function parse_deleteitemtitle()
        {
                global $manager;
+               
                $itemid = intRequestVar('itemid');
-               $item  =& $manager->getItem($itemid, 1, 1);
+               $item =& $manager->getItem($itemid, 1, 1);
+               
                echo Entity::hsc(strip_tags($item['title']));
+               
                return;
        }
        
@@ -2448,9 +2657,8 @@ class AdminActions extends BaseActions
        public function parse_editadminskintype($type = 'id')
        {
                global $CONF, $manager, $member;
-               $skinid = intRequestVar('skinid');
-               $skin   = new Skin($skinid);
-               $fNames = Skin::getFriendlyNames();
+               
+               $fNames = $this->skin->getAvailableTypes();
                $sType  = strtolower(trim(requestVar('type')));
                
                switch ( $type )
@@ -2459,16 +2667,16 @@ class AdminActions extends BaseActions
                                echo intRequestVar('skinid');
                                break;
                        case 'name':
-                               echo Entity::hsc($skin->getName());
+                               echo Entity::hsc($this->skin->getName());
                                break;
                        case 'desc':
-                               echo Entity::hsc($skin->getDescription());
+                               echo Entity::hsc($this->skin->getDescription());
                                break;
                        case 'type':
-                               echo Entity::hsc($skin->getContentType());
+                               echo Entity::hsc($this->skin->getContentType());
                                break;
                        case 'content':
-                               echo Entity::hsc($skin->getContent($sType));
+                               echo Entity::hsc($this->skin->getContentFromDB($sType));
                                break;
                        case 'skintype':
                                $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
@@ -2478,7 +2686,7 @@ class AdminActions extends BaseActions
                                echo Entity::hsc($sType);
                                break;
                        case 'prefix':
-                               echo Entity::hsc($skin->getIncludePrefix());
+                               echo Entity::hsc($this->skin->getIncludePrefix());
                                break;
                        case 'mode':
                                $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
@@ -2491,80 +2699,6 @@ class AdminActions extends BaseActions
        }
        
        /**
-        * AdminActions::parse_editadmintemplateinfo()
-        * Parse skinvar editadmintemplateinfo
-        * 
-        * @param       string  $type                   type of skin template
-        * @param       string  $description    description of template
-        * @param       string  $name                   name of stemplate
-        * @param       string  $tabindex               index number for tabindex attribute of input element
-        * @param       string  $big                    
-        * @param       string  $tplt                   
-        */
-       public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
-       {
-               global $manager;
-               $templateid                             =  intRequestVar('templateid');
-               $templatename                   =  Template::getNameFromId($templateid);
-               $templatedescription    =  Template::getDesc($templateid);
-               $template                               =& Template::read($templatename);
-               switch ( $type )
-               {
-                       case 'id':
-                               echo intval($templateid);
-                               break;
-                       case 'name':
-                               echo Entity::hsc($templatename);
-                               break;
-                       case 'desc':
-                               echo Entity::hsc($templatedescription);
-                               break;
-                       case 'extratemplate':
-                               $tabidx    = 600;
-                               $pluginfields = array();
-                               $manager->notify(
-                                       'AdminTemplateExtraFields',
-                                       array(
-                                               'fields' => &$pluginfields
-                                       )
-                               );
-                               $tmplt = array();
-                               if ( $description )
-                               {
-                                       $tmplt = Template::read($description);
-                               }
-                               if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
-                               {
-                                       $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
-                               }
-                               else
-                               {
-                                       $base = "</tr>\n"
-                                             . "<tr>\n"
-                                             . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
-                               }
-                               foreach ( $pluginfields as $pfkey => $pfvalue )
-                               {
-                                       $data = array(
-                                               'explugtplname' => Entity::hsc($pfkey)
-                                       );
-                                       echo TEMPLATE::fill($base, $data);
-                                       foreach ( $pfvalue as $pffield => $pfdesc )
-                                       {
-                                               $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
-                                       }
-                               }
-                               break;
-                       default:
-                               $desc = defined($description) ? constant($description) : $description;
-                               $name = defined($name) ? constant($name) : $name;
-                               $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
-                               break;
-               }
-               return;
-       }
-       
-       /**
         * AdminActions::parse_editcomment()
         * Parse skinvar editcomment
         * 
@@ -2574,6 +2708,7 @@ class AdminActions extends BaseActions
        public function parse_editcomment($type = 'id')
        {
                global $manager;
+               
                $commentid      = intRequestVar('commentid');
                $comment        = COMMENT::getComment($commentid);
                
@@ -2585,13 +2720,13 @@ class AdminActions extends BaseActions
                                echo intRequestVar('commentid');
                                break;
                        case 'user':
-                               if (array_key_exists('member', $comment) && !empty($comment['member']) )
+                               if ( !array_key_exists('member', $comment) || empty($comment['member']) )
                                {
-                                       echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
+                                       echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
                                }
                                else
                                {
-                                       echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
+                                       echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
                                }
                                break;
                        case 'date':
@@ -2601,6 +2736,13 @@ class AdminActions extends BaseActions
                                $comment['body'] = str_replace('<br />', '', $comment['body']);
                                $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
                                echo $comment['body'];
+                               break;
+                       case 'cmail':
+                               echo $comment['userid'];
+                               break;
+                       case 'url':
+                               echo $comment['userid'];
+                               break;
                        default:
                                echo $comment[$type];
                                break;
@@ -2633,7 +2775,7 @@ class AdminActions extends BaseActions
                global $manager;
                // show list of members with actions
                $query =  'SELECT * FROM '.sql_table('member');
-               $template['content']  = 'memberlist';
+               $template['content'] = 'memberlist';
                $template['tabindex'] = 10;
                
                $batch = new Batch('member');
@@ -2652,8 +2794,9 @@ class AdminActions extends BaseActions
        public function parse_editmember($type = 'id', $templateName = '')
        {
                global $CONF, $manager, $member;
-               $memberid       = intRequestVar('memberid');
-               $mem            = MEMBER::createFromID($memberid);
+               
+               $memberid = intRequestVar('memberid');
+               $mem = MEMBER::createFromID($memberid);
                
                switch ( $type )
                {
@@ -2742,7 +2885,7 @@ class AdminActions extends BaseActions
                $aOptions = array();
                $aOIDs  = array();
                
-               $query  = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
+               $query  = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
                $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
                $resource = sql_query($query);
                
@@ -2750,7 +2893,6 @@ class AdminActions extends BaseActions
                {
                        array_push($aOIDs, $o->oid);
                        $aOptions[$o->oid] = array(
-                               
                                'oid'                   => $o->oid,
                                'value'                 => $o->odef,
                                'name'                  => $o->oname,
@@ -2776,17 +2918,17 @@ class AdminActions extends BaseActions
                }
                
                // call plugins
-               $manager->notify(
-                       'PrePluginOptionsEdit',
-                       array(
-                               'context'       =>  'global',
-                               'plugid'        =>  $pid,
-                               'options'       => &$aOptions
-                       )
+               $data = array(
+                       'context'       =>  'global',
+                       'plugid'        =>  $pid,
+                       'options'       => &$aOptions
                );
+               $manager->notify('PrePluginOptionsEdit', $data);
                
                $template['content'] = 'plugoptionlist';
-               $amount                   = Showlist($aOptions, 'table', $template, $templateName);
+               
+               $amount = Showlist($aOptions, 'table', $template, $templateName);
+               
                if ( $amount == 0 )
                {
                        echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
@@ -2840,10 +2982,10 @@ class AdminActions extends BaseActions
        public function parse_editskintype($type = 'id')
        {
                global $CONF, $manager, $member;
-               $skinid = intRequestVar('skinid');
-               $skin   = new SKIN($skinid);
-               $fNames = SKIN::getFriendlyNames('Actions');
-               $sType  = strtolower(trim(requestVar('type')));
+               $skinid = intRequestVar('skinid');
+               $skin   = new SKIN($skinid);
+               $fNames = $skin->getAvailableTypes();
+               $sType  = strtolower(trim(requestVar('type')));
                
                switch ( $type )
                {
@@ -2860,7 +3002,7 @@ class AdminActions extends BaseActions
                                echo Entity::hsc($skin->getContentType());
                                break;
                        case 'content':
-                               echo Entity::hsc($skin->getContent($sType));
+                               echo Entity::hsc($skin->getContentFromDB($sType));
                                break;
                        case 'skintype':
                                $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
@@ -2907,64 +3049,139 @@ class AdminActions extends BaseActions
         * @param       string  $tabindex               index value for tabindex attribute of input element
         * @param       string  $big                    
         * @param       string  $tplt                   name of template
+        * @return      boolean 
         */
-       public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
+       public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
        {
                global $manager;
-               $templateid                             =  intRequestVar('templateid');
-               $templatename                   =  TEMPLATE::getNameFromId($templateid);
-               $templatedescription    =  TEMPLATE::getDesc($templateid);
-               $template                               =& $manager->getTemplate($templatename);
+               
+               $t_id           =  intRequestVar('templateid');
+               $t_name         =  Template::getNameFromId($t_id);
+               $t_desc         =  Template::getDesc($t_id);
+               $template       = &Template::read($t_name);
+               
                switch ( $type )
                {
                        case 'id':
-                               echo intval($templateid);
+                               echo intval($t_id);
                                break;
                        case 'name':
-                               echo Entity::hsc($templatename);
+                               echo Entity::hsc($t_name);
                                break;
                        case 'desc':
-                               echo Entity::hsc($templatedescription);
+                               echo Entity::hsc($t_desc);
                                break;
                        case 'extratemplate':
-                               $tabidx    = 600;
+                               $tabidx = 600;
                                $pluginfields = array();
-                               $manager->notify(
-                                       'TemplateExtraFields',
-                                       array(
-                                               'fields' => &$pluginfields
-                                       )
-                               );
+                               $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
+                               
                                $tmplt = array();
-                               if ( $description )
+                               if ( $desc )
+                               {
+                                       $tmplt = Template::read($desc);
+                               }
+                               if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
                                {
-                                       $tmplt = Template::read($description);
+                                       $base = "</tr>\n"
+                                             . "<tr>\n"
+                                             . '<th colspan="2"><%explugtplname%>' . "</th>\n";
                                }
-                               if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
+                               else
                                {
                                        $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
                                }
+                               
+                               foreach ( $pluginfields as $pfkey => $pfvalue )
+                               {
+                                       $data = array('explugtplname' => Entity::hsc($pfkey));
+                                       
+                                       echo Template::fill($base, $data);
+                                       
+                                       foreach ( $pfvalue as $pffield => $pfdesc )
+                                       {
+                                               $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
+                                       }
+                               }
+                               break;
+                       default:
+                               $desc = defined($desc) ? constant($desc) : $desc;
+                               $name = defined($name) ? constant($name) : $name;
+                               $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
+                               break;
+               }
+               
+               return;
+       }
+       
+       /**
+        * AdminActions::parse_editadmintemplateinfo()
+        * Parse skinvar editadmintemplateinfo
+        * 
+        * @param       string  $type                   type of skin template
+        * @param       string  $description    description of template
+        * @param       string  $name                   name of stemplate
+        * @param       string  $tabindex               index number for tabindex attribute of input element
+        * @param       string  $big                    
+        * @param       string  $tplt                   
+        */
+       public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
+       {
+               global $manager;
+               
+               $t_id           =  intRequestVar('templateid');
+               $t_name         =  Template::getNameFromId($t_id);
+               $t_desc         =  Template::getDesc($t_id);
+               $template       = &Template::read($t_name);
+               
+               switch ( $type )
+               {
+                       case 'id':
+                               echo intval($t_id);
+                               break;
+                       case 'name':
+                               echo Entity::hsc($t_name);
+                               break;
+                       case 'desc':
+                               echo Entity::hsc($t_desc);
+                               break;
+                       case 'extratemplate':
+                               $tabidx = 600;
+                               $pluginfields = array();
+                               $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
+                               
+                               $tmplt = array();
+                               if ( $desc )
+                               {
+                                       $tmplt = Template::read($desc);
+                               }
+                               if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
+                               {
+                                       $base = "</tr>\n"
+                                             . "<tr>\n"
+                                             . '<th colspan="2"><%explugtplname%>' . "</th>\n";
+                               }
                                else
                                {
-                                       $base = "</tr><tr>\n"
-                                                 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
+                                       $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
                                }
+                               
                                foreach ( $pluginfields as $pfkey => $pfvalue )
                                {
-                                       $data = array(
-                                               'explugtplname' => Entity::hsc($pfkey)
-                                       );
-                                       echo TEMPLATE::fill($base, $data);
+                                       $data = array('explugtplname' => Entity::hsc($pfkey));
+                                       
+                                       echo Template::fill($base, $data);
+                                       
                                        foreach ( $pfvalue as $pffield => $pfdesc )
                                        {
-                                               $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
+                                               $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
                                        }
                                }
                                break;
                        default:
-                               $desc = defined($description) ? constant($description) : $description;
+                               $desc = defined($desc) ? constant($desc) : $desc;
                                $name = defined($name) ? constant($name) : $name;
-                               $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
+                               $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
                                break;
                }
                return;
@@ -2980,6 +3197,9 @@ class AdminActions extends BaseActions
        public function parse_eventformextra($type = 'activation')
        {
                global $manager;
+               
+               $data = array();
+               
                switch ( $type )
                {
                        case 'activation':
@@ -2999,14 +3219,12 @@ class AdminActions extends BaseActions
                                        Admin::error(_ERROR_ACTIVATE);
                                }
                                $data = array(
-                                       'type'   => 'activation',
-                                       'member' => $mem
+                                       'type'          => 'activation',
+                                       'member'        => $mem
                                );
                                break;
                        case 'membermailform-notloggedin':
-                               $data = array(
-                                       'type' => 'membermailform-notloggedin',
-                               );
+                               $data = array('type' => 'membermailform-notloggedin',);
                                break;
                }
                $manager->notify('FormExtra', $data);
@@ -3020,19 +3238,19 @@ class AdminActions extends BaseActions
        public function parse_extrahead()
        {
                global $manager;
+               
                $extrahead = Admin::getAdminextrahead();
-               $manager->notify(
-                       'AdminPrePageHead',
-                       array(
-                               'extrahead'     => &$extrahead,
-                               'action'        => Admin::getAdminAction()
-                       )
+               
+               $data = array(
+                       'extrahead'     => &$extrahead,
+                       'action'        => Admin::getAdminAction()
                );
+               
+               $manager->notify('AdminPrePageHead', $data);
                echo $extrahead;
                return;
        }
        
-       
        /**
         * AdminActions::parse_member()
         * Parse skinvar member
@@ -3095,10 +3313,14 @@ class AdminActions extends BaseActions
                                        echo $member->getID();
                                        break;
                                case 'yourprofileurl':
-                                       if ($CONF['URLMode'] == 'pathinfo')
+                                       if ( $CONF['URLMode'] == 'pathinfo' )
+                                       {
                                                echo Link::create_member_link($member->getID());
+                                       }
                                        else
+                                       {
                                                echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
+                                       }
                                        break;
                        }
                }
@@ -3167,7 +3389,7 @@ class AdminActions extends BaseActions
         */
        public function parse_getblogsetting($which)
        {
-               global $blog;
+               global $blog, $manager;
                
                if ( $blog )
                {
@@ -3175,7 +3397,6 @@ class AdminActions extends BaseActions
                }
                elseif ( $bid = intRequestVar('blogid') )
                {
-                       global $manager;
                        $b = $manager->getBlog($bid);
                }
                else
@@ -3327,11 +3548,10 @@ class AdminActions extends BaseActions
         */
        public function parse_helplink($topic = '')
        {
-               if ( empty($topic) )
+               if ( !empty($topic) )
                {
-                       return;
+                       help($topic);
                }
-               help($topic);
                return;
        }
        
@@ -3410,6 +3630,44 @@ class AdminActions extends BaseActions
         * AdminActions::parse_inputyesno()
         * Parse skinvar inputyesno
         * 
+        * some init stuff for all forms
+        * 
+        * @param       void
+        * @return      void
+        */
+       function parse_init()
+       {
+               global $manager;
+               
+               $item = false;
+               if ( requestVar('action') == 'itemedit' )
+               {
+                       $itemid = intRequestVar('itemid');
+                       $item =& $manager->getItem($itemid, 1, 1);
+                       
+                       $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
+                       if ( $item && $blog->convertBreaks() )
+                       {
+                               $item['body'] = removeBreaks($item['body']);
+                               $item['more'] = removeBreaks($item['more']);
+                       }
+                       $contents = $item;
+                       $authorid = $contents['authorid'];
+               }
+               elseif ( requestVar('action') == 'createitem' )
+               {
+                       $blogid = intRequestVar('blogid');
+                       $blog =& $manager->getBlog($blogid);
+                       $authorid = '';
+               }
+               $blog->insertJavaScriptInfo($authorid);
+               return;
+       }
+       
+       /**
+        * AdminActions::parse_inputyesno()
+        * Parse skinvar inputyesno
+        * 
         * @param       string  $name                   
         * @param       string  $checkedval             
         * @param       string  $tabindex               
@@ -3463,36 +3721,45 @@ class AdminActions extends BaseActions
                {
                        $templates = Template::read($templateName);
                }
-               if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
+               if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
                {
-                       $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
+                       $template['title'] = "<tr>"
+                                          . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
+                                          . "</tr>\n";
                }
                else
                {
-                       $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
+                       $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
                }
-               if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
+               if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
                {
-                       $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
+                       $template['body'] = "<tr>"
+                                         . "<%listplugplugoptionrow%>"
+                                         . "</tr>\n";
                }
                else
                {
-                       $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
+                       $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 )
                {
-                       $handler = new Actions($this->skintype, $template, $option);
-                       $parser  = new PARSER(Actions::getDefinedActions(), $handler);
+                       
                        // 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']);
@@ -3512,8 +3779,8 @@ class AdminActions extends BaseActions
        {
                $option = Admin::$aOption;
                
-               $meta   = NucleusPlugin::getOptionMeta($option['typeinfo']);
-               if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
+               $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
+               if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
                {
                        echo '<tr>';
                        listplug_plugOptionRow($option);
@@ -3534,11 +3801,11 @@ class AdminActions extends BaseActions
                if ( requestVar('ip') )
                {
                        $iprangeVal = Entity::hsc(requestVar('ip'));
-                       echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
-                       echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
+                       echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
+                       echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
                        echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
                        echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
-                       echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
+                       echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
                }
                else
                {
@@ -3558,33 +3825,7 @@ class AdminActions extends BaseActions
        public function parse_itemnavlist()
        {
                global $CONF, $manager, $member;
-               if ( $this->skintype == 'itemlist' )
-               {
-                       $blogid =  intRequestVar('blogid');
-                       $blog   =& $manager->getBlog($blogid);
-               }
-               if ( postVar('start') )
-               {
-                       $start = intPostVar('start');
-               }
-               else
-               {
-                       $start = 0;
-               }
                
-               // amount of items to show
-               if ( postVar('amount') )
-               {
-                       $amount = intPostVar('amount');
-               }
-               else
-               {
-                       $amount = intval($CONF['DefaultListSize']);
-                       if ( $amount < 1 )
-                       {
-                               $amount = 10;
-                       }
-               }
                $query  = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
                        . " FROM %s, %s, %s, %s"
                        . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
@@ -3593,7 +3834,20 @@ class AdminActions extends BaseActions
                
                if ( $this->skintype == 'itemlist' )
                {
-                       $query .= ' AND iblog   = ' . $blogid;
+                       $blog = FALSE;
+                       if ( array_key_exists('blogid', $_REQUEST) )
+                       {
+                               $blogid = intRequestVar('blogid');
+                       }
+                       else if ( array_key_exists('itemid', $_REQUEST) )
+                       {
+                               $itemid =  intRequestVar('itemid');
+                               $item   = &$manager->getItem($itemid, 1, 1);
+                               $blogid =  (integer) $item['blogid'];
+                       }
+                       $blog =& $manager->getBlog($blogid);
+                       
+                       $query .= " AND iblog={$blogid}";
                        $template['now'] = $blog->getCorrectTime(time());
                        
                        // non-blog-admins can only edit/delete their own items
@@ -3618,13 +3872,92 @@ class AdminActions extends BaseActions
                                . '  OR  (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
                                . '  OR  (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
                }
+               
+               if ( postVar('start') )
+               {
+                       $start = intPostVar('start');
+               }
+               else
+               {
+                       $start = 0;
+               }
+               
+               // amount of items to show
+               if ( postVar('amount') )
+               {
+                       $amount = intPostVar('amount');
+               }
+               else
+               {
+                       $amount = (integer) $CONF['DefaultListSize'];
+                       if ( $amount < 1 )
+                       {
+                               $amount = 10;
+                       }
+               }
+               
                $query .= ' ORDER BY itime DESC'
                        . " LIMIT {$start},{$amount}";
                
                $template['content'] = 'itemlist';
                
-               $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
-               $navList->showBatchList('item', $query, 'table', $template);
+               $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
+               $navList->showBatchList('item', $query, 'table', $template);
+               return;
+       }
+       
+       /**
+        * AdminActions::parse_itemoptions()
+        * Parse skinvar itemoptions
+        * Adds the itemOptions of a plugin to a page
+        * @author TeRanEX
+        */
+       function parse_itemoptions()
+       {
+               $this->parse_pluginoptions('item');
+               return;
+       }
+       
+       /**
+        * AdminActions::parse_itemoptions()
+        * 
+        * date change on edit item
+        * 
+        * Parse skinvar itemoptions
+        * Adds the itemOptions of a plugin to a page
+        * @author TeRanEX
+        */
+       function parse_itemtime($what)
+       {
+               global $manager;
+               
+               $item = false;
+               $itemid = intRequestVar('itemid');
+               $item =& $manager->getItem($itemid, 1, 1);
+               
+               $blog   =& $manager->getBlog(getBlogIDFromItemID($itemid));
+               
+               if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
+               {
+                       $item['body'] = removeBreaks($item['body']);
+                       $item['more'] = removeBreaks($item['more']);
+               }
+               
+               $contents = array();
+               if ( requestVar('action') == 'itemedit' )
+               {
+                       $contents = $item;
+               } 
+               elseif ( requestVar('action') == 'createitem' )
+               {
+                       $data = array(
+                               'contents' => &$contents,
+                               'blog'     => &$this->blog
+                       );
+                       $manager->notify('PreAddItemForm', $data);
+               }
+               $itemtime = getdate($contents['timestamp']);
+               echo $itemtime[$what];
                return;
        }
        
@@ -3643,6 +3976,7 @@ class AdminActions extends BaseActions
                        _SETTINGS_JSTOOLBAR_SIMPLE,
                        _SETTINGS_JSTOOLBAR_FULL
                );
+               
                $i = 1;
                foreach ( $options as $option )
                {
@@ -3654,59 +3988,6 @@ class AdminActions extends BaseActions
                return;
        }
        /**
-        * Parse skinvar languageselectoptions
-        */
-       function parse_languageselectoptions()
-       {
-               $locales = i18n::get_available_locale_list();
-               $memid   = intRequestVar('memberid');
-               if ($memid)
-               {
-                       $mem = MEMBER::createFromID($memid);
-                       if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
-                       {
-                               echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
-                       }
-                       else
-                       {
-                               echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
-                       }
-               }
-               else
-               {
-                       if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
-                       {
-                               echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
-                       }
-               }
-               foreach ( $locales as $locale )
-               {
-                       if ($memid)
-                       {
-                               if ( $locale == $mem->getLocale() )
-                               {
-                                       echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
-                               }
-                               else
-                               {
-                                       echo "<option value=\"{$locale}\">{$locale}</option>\n";
-                               }
-                       }
-                       else
-                       {
-                               if ( $locale == i18n::get_current_locale() )
-                               {
-                                       echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
-                               }
-                               else
-                               {
-                                       echo "<option value=\"{$locale}\">{$locale}</option>\n";
-                               }
-                       }
-               }
-       }
-       
-       /**
         * AdminActions::parse_localeselectoptions()
         * Parse skinvar localeselectoptions
         * 
@@ -3716,7 +3997,8 @@ class AdminActions extends BaseActions
        public function parse_localeselectoptions()
        {
                $locales = i18n::get_available_locale_list();
-               $memid   = intRequestVar('memberid');
+               
+               $memid = intRequestVar('memberid');
                if ( $memid )
                {
                        $mem = MEMBER::createFromID($memid);
@@ -3735,10 +4017,18 @@ class AdminActions extends BaseActions
                        {
                                echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
                        }
+                       else
+                       {
+                               echo "<option value=\"\">en_Latn_US</option>\n";
+                       }
                }
                foreach ( $locales as $locale )
                {
-                       if ($memid)
+                       if ( $locale == 'en_Latn_US' )
+                       {
+                               continue;
+                       }
+                       else if ($memid)
                        {
                                if ( $locale == $mem->getLocale() )
                                {
@@ -3821,7 +4111,7 @@ class AdminActions extends BaseActions
                                if ( $this->skintype == 'itemmove' )
                                {
                                        $query  = "SELECT icat as result FROM %s WHERE inumber=%d;";
-                                       $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
+                                       $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
                                        $catid  = quickQuery(sprintf($query, intRequestVar('itemid')));
                                        Admin::selectBlogCategory('catid', $catid, 10, 1);
                                }
@@ -3853,9 +4143,11 @@ class AdminActions extends BaseActions
        public function parse_newestcompare()
        {
                global $nucleus;
+               
                $newestVersion  = getLatestVersion();
                $newestCompare  = str_replace('/', '.', $newestVersion);
                $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
+               
                if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
                {
                        echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
@@ -3875,7 +4167,7 @@ class AdminActions extends BaseActions
        {
                $blogid = intRequestVar('blogid');
                
-               $query  = "SELECT tmember FROM %s WHERE tblog=%d;";
+               $query = "SELECT tmember FROM %s WHERE tblog=%d;";
                $query = sprintf($query, sql_table('team'), (integer) $blogid);
                $res = sql_query($query);
                
@@ -3920,14 +4212,14 @@ class AdminActions extends BaseActions
         */
        public function parse_outputspecialdirs($type)
        {
+               global $DIR_MEDIA, $DIR_NUCLEUS;
+               
                switch ( $type )
                {
                        case 'nucleusdir':
-                               global $DIR_NUCLEUS;
                                echo Entity::hsc($DIR_NUCLEUS);
                                break;
                        case 'mediadir':
-                               global $DIR_MEDIA;
                                echo Entity::hsc($DIR_MEDIA);
                                break;
                }
@@ -3943,10 +4235,12 @@ class AdminActions extends BaseActions
         */
        public function parse_passrequestvars()
        {
+               $passvar   = Admin::getAdminpassvar();
                $oldaction = postVar('oldaction');
+               
                if ( ($oldaction != 'logout')
                  && ($oldaction != 'login')
-                 && Admin::passvar
+                 && $passvar
                  && !postVar('customaction') )
                {
                        passRequestVars();
@@ -3969,22 +4263,12 @@ class AdminActions extends BaseActions
                        case 'member':
                                $id  = intRequestVar('memberid');
                                $mem = MEMBER::createFromID($id);
-                               $manager->notify(
-                                       'MemberSettingsFormExtras',
-                                       array(
-                                               'member' => &$mem
-                                       )
-                               );
+                               $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
                                break;
                        case 'blog':
                                $id  = intRequestVar('blogid');
                                $blg = $manager->getBlog($id);
-                               $manager->notify(
-                                       'BlogSettingsFormExtras',
-                                       array(
-                                               'member' => &$blg
-                                       )
-                               );
+                               $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
                                break;
                        default:
                                $manager->notify(
@@ -4007,6 +4291,7 @@ class AdminActions extends BaseActions
        public function parse_pluginhelp()
        {
                global $manager, $DIR_PLUGINS;
+               
                $plugid = intGetVar('plugid');
                $plugName =  getPluginNameFromPid($plugid);
                $plug =& $manager->getPlugin($plugName);
@@ -4039,11 +4324,14 @@ class AdminActions extends BaseActions
         */
        public function parse_pluginlistlist($templateName = '')
        {
-               $query  = "SELECT * FROM %s ORDER BY porder ASC;";
+               $query = "SELECT * FROM %s ORDER BY porder ASC;";
                $query = sprintf($query, sql_table('plugin'));
+               
                $template['content']  = 'pluginlist';
                $template['tabindex'] = 10;
+               
                Showlist($query, 'table', $template, $templateName);
+               
                return;
        }
        
@@ -4056,6 +4344,8 @@ class AdminActions extends BaseActions
         */
        public function parse_pluginoptions($type = 'global')
        {
+               global $itemid;
+               
                switch ( $type )
                {
                        case 'member':
@@ -4067,6 +4357,9 @@ class AdminActions extends BaseActions
                        case 'category':
                                $id = intRequestVar('catid');
                                break;
+                       case 'item':
+                               $id = $itemid;
+                               break;
                }
                Admin::insertPluginOptions($type, $id);
                return;
@@ -4097,14 +4390,17 @@ class AdminActions extends BaseActions
                               . ' WHERE tblog=bnumber and tmember=' . $member->getID()
                               . ' ORDER BY bname';
                }
-               $template['name']          = 'blogid';
-               $template['tabindex']   = 15000;
-               $template['extra']        = _QMENU_ADD_SELECT;
-               $template['selected']   = -1;
+               
+               $template['name']               = 'blogid';
+               $template['tabindex']   = 15000;
+               $template['extra']              = _QMENU_ADD_SELECT;
+               $template['selected']   = -1;
                $template['shorten']    = 10;
-               $template['shortenel']  = '';
-               $template['javascript'] = 'onchange="return form.submit()"';
+               $template['shortenel']  = '';
+               $template['javascript'] = 'onchange="return form.submit()"';
+               
                Showlist($query, 'select', $template, $templateName);
+               
                return;
        }
 
@@ -4133,38 +4429,44 @@ class AdminActions extends BaseActions
                );
                if ( count($pluginExtras) > 0 )
                {
-                       if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
+                       if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
                        {
-                               $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
+                               $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
                        }
                        else
                        {
-                               $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
+                               $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
                        }
-                       $handler = new Actions($this->skintype, $template, $this->objAdmin);
-                       $parser  = new PARSER(Actions::getDefinedActions(), $handler);
-                       $parser->parse($template['title']);
-                       
-                       if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
+                       if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
                        {
-                               $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
+                               $template['head'] = "<ul>\n";
                        }
                        else
                        {
-                               $template['head'] = '<ul>';
+                               $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
                        }
-                       
-                       echo $template['head'];
-                       
-                       if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
+                       if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
+                       {
+                               $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
+                       }
+                       else
                        {
                                $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
                        }
+                       if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
+                       {
+                               $template['foot'] = "</ul>\n";
+                       }
                        else
                        {
-                               $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
+                               $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
                        }
                        
+                       $handler = new Actions($this->skintype);
+                       $parser = new PARSER($handler);
+                       
+                       $parser->parse($template['title']);
+                       echo $template['head'];
                        foreach ( $pluginExtras as $aInfo )
                        {
                                $data = array(
@@ -4172,15 +4474,7 @@ class AdminActions extends BaseActions
                                        'plugadmintooltip'      => Entity::hsc($aInfo['tooltip']),
                                        'plugadmintitle'        => Entity::hsc($aInfo['title']),
                                );
-                               echo TEMPLATE::fill($template['body'], $data);
-                       }
-                       if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
-                       {
-                               $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
-                       }
-                       else
-                       {
-                               $template['foot'] = '</ul>';
+                               echo Template::fill($template['body'], $data);
                        }
                        echo $template['foot'];
                }
@@ -4229,15 +4523,17 @@ class AdminActions extends BaseActions
         */
        public function parse_selectlocaladminskinfiles()
        {
-               echo 'UUU';
                global $DIR_SKINS, $manager;
+               
                $adminskindir = $DIR_SKINS . 'admin/';
                $candidates = SkinImport::searchForCandidates($adminskindir);
+               
                foreach ( $candidates as $skinname => $skinfile )
                {
                        $html = Entity::hsc($skinfile);
                        echo '<option value="' . $html . '">' . $skinname . "</option>\n";
                }
+               
                return;
        }
        
@@ -4251,12 +4547,15 @@ class AdminActions extends BaseActions
        public function parse_selectlocalskinfiles()
        {
                global $DIR_SKINS;
+               
                $candidates = SkinImport::searchForCandidates($DIR_SKINS);
+               
                foreach ( $candidates as $skinname => $skinfile )
                {
                        $html = Entity::hsc($skinfile);
                        echo '<option value="' . $html . '">' . $skinname . "</option>\n";
                }
+               
                return;
        }
        
@@ -4273,7 +4572,7 @@ class AdminActions extends BaseActions
                switch ( $type )
                {
                        case 'blog':
-                               $query = "SELECT bshortname, bname FROM %s";
+                               $query = "SELECT bshortname, bname FROM %s;";
                                $show  = array(
                                        'content' => 'shortblognames'
                                );
@@ -4281,7 +4580,7 @@ class AdminActions extends BaseActions
                                Showlist($query, 'table', $show, $templateName);
                                break;
                        case 'template':
-                               $query = "SELECT tdname as name, tddesc as description WHERE tdname NOT LIKE 'admin/%%' FROM %s";
+                               $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
                                $show  = array(
                                        'content' => 'shortnames'
                                );
@@ -4313,9 +4612,13 @@ class AdminActions extends BaseActions
                }
                else
                {
-                       $template = '<td><input type="checkbox" name="<%typeid%>"  id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
-                                         . "<td><%expdesc%></td>\n"
-                                         . "</tr><tr>\n";
+                       $template = "<td>"
+                                 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
+                                 . "<label for=\"<%expid%>\"><%expname%></label>\n"
+                                 . "</td>\n"
+                                 . "<td><%expdesc%></td>\n"
+                                 . "</tr>\n"
+                                 . "<tr>\n";
                }
                switch ( $type )
                {
@@ -4329,11 +4632,11 @@ class AdminActions extends BaseActions
                                                'expname'       => Entity::hsc($skinObj->sdname),
                                                'expdesc'       => Entity::hsc($skinObj->sddesc),
                                        );
-                                       echo TEMPLATE::fill($template, $data);
+                                       echo Template::fill($template, $data);
                                }
                                break;
                        case 'template':
-                               $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%'");
+                               $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
                                while ($templateObj = sql_fetch_object($res)) {
                                        $data = array(
                                                'typeid'        => 'template[' . $templateObj->tdnumber . ']',
@@ -4341,7 +4644,7 @@ class AdminActions extends BaseActions
                                                'expname'       => Entity::hsc($templateObj->tdname),
                                                'expdesc'       => Entity::hsc($templateObj->tddesc),
                                        );
-                                       echo TEMPLATE::fill($template, $data);
+                                       echo Template::fill($template, $data);
                                }
                                break;
                }
@@ -4358,14 +4661,11 @@ class AdminActions extends BaseActions
        public function parse_skinoverview($templateName = '')
        {
                global $CONF;
-               $query = "SELECT * FROM %s ORDER BY sdname";
+               $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
                $query = sprintf($query, sql_table('skin_desc'));
                
                $template['content']  = 'skinlist';
                $template['tabindex'] = 10;
-//             $template['friendly_names'] = Skin::getFriendlyNames('Actions');
-               $skin = new Skin($CONF['BaseSkin']);
-               $template['friendly_names'] = $skin->getDefaultTypes();
                
                Showlist($query, 'table', $template, $templateName);
                return;
@@ -4381,6 +4681,8 @@ class AdminActions extends BaseActions
        public function parse_skintypehelp()
        {
                $nowSkinType = strtolower(trim(requestVar('type')));
+               
+               /* TODO: use Skin class */
                $regularType = array(
                        'index',
                        'item',
@@ -4417,6 +4719,8 @@ class AdminActions extends BaseActions
                {
                        $templates = Template::read($templateName);
                }
+               
+               /* TODO: use Skin class */
                $nType  = array(
                        'index',
                        'item',
@@ -4443,26 +4747,27 @@ class AdminActions extends BaseActions
                        {
                                $template['head'] = "<ul>\n";
                        }
-                       echo TEMPLATE::fill($template['head'], $data);
-                       if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
-                       {
-                               $template['body'] = $templates['SPECIALSKINLIST_BODY'];
-                       }
-                       else
+                       echo Template::fill($template['head'], $data);
+                       if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
                        {
                                $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&amp;skinid=<%skinid%>'
                                                                  . '&amp;type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
                                                                  . 'action=skinremovetype&amp;skinid=<%skinid%>&amp;type=<%skintype%>">remove</a>)</li>';
                        }
+                       else
+                       {
+                               $template['body'] = $templates['SPECIALSKINLIST_BODY'];
+                       }
+                       
                        $tabstart = 75;
                        while ( $row = sql_fetch_assoc($res) )
                        {
                                $data = array(
-                                       'tabindex' => $tabstart++,
-                                       'skinid'   => $skinid,
-                                       'skintype' => Entity::hsc(strtolower($row['stype']))
+                                       'tabindex'      => $tabstart++,
+                                       'skinid'        => $skinid,
+                                       'skintype'      => Entity::hsc(strtolower($row['stype']))
                                );
-                               echo TEMPLATE::fill($template['body'], $data);
+                               echo Template::fill($template['body'], $data);
                        }
                        $data = array();
                        if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
@@ -4473,7 +4778,7 @@ class AdminActions extends BaseActions
                        {
                                $template['foot'] = "</ul>\n";
                        }
-                       echo TEMPLATE::fill($template['foot'], $data);
+                       echo Template::fill($template['foot'], $data);
                        return;
                }
        }
@@ -4566,13 +4871,16 @@ class AdminActions extends BaseActions
                                {
                                        $templates = Template::read($templateName);
                                }
-                               if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
+                               if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
                                {
-                                       $template = $templates['SYSTEMINFO_GDSETTINGS'];
+                                       $template = "<tr>\n"
+                                                 . "<td><%key%></td>\n"
+                                                 . "<td><%value%></td>\n"
+                                                 . "</tr>\n";
                                }
                                else
                                {
-                                       $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
+                                       $template = $templates['SYSTEMINFO_GDSETTINGS'];
                                }
                                
                                $gdinfo = gd_info();
@@ -4591,7 +4899,7 @@ class AdminActions extends BaseActions
                                                'key'   => $key,
                                                'value' => $value,
                                        );
-                                       echo TEMPLATE::fill($template, $data);
+                                       echo Template::fill($template, $data);
                                }
                                break;
                        case 'modrewrite':
@@ -4640,9 +4948,12 @@ class AdminActions extends BaseActions
        {
                $query  = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
                $query = sprintf($query, sql_table('template_desc'));
+               
                $template['content']  = 'templatelist';
                $template['tabindex'] = 10;
+               
                Showlist($query, 'table', $template, $templateName);
+               
                return;
        }
        
@@ -4690,7 +5001,7 @@ class AdminActions extends BaseActions
                        // Super-Admins have access to all blogs! (no add item support though)
                        $query =  "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
                                . " FROM %s"
-                               . " ORDER BY bnumber";
+                               . " ORDER BY bnumber;";
                        $query = sprintf($query, sql_table('blog'));
                }
                else
@@ -4698,7 +5009,7 @@ class AdminActions extends BaseActions
                        $query =  "SELECT bnumber, bname, tadmin, burl, bshortname"
                                . " FROM %s,%s"
                                . " WHERE tblog=bnumber and tmember=%d"
-                               . " ORDER BY bnumber";
+                               . " ORDER BY bnumber;";
                        $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
                }
                
@@ -4728,7 +5039,7 @@ class AdminActions extends BaseActions
                        
                        $query =  "SELECT ititle, inumber, bshortname"
                               . " FROM %s,%s"
-                              . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
+                              . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
                        $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
                        
                        $template['content'] = 'draftlist';
@@ -4914,6 +5225,7 @@ class AdminActions extends BaseActions
         * 
         * @param       void
         * @return      void
+        * @return      boolean
         */
        private function ifSkincandidates()
        {
@@ -4925,6 +5237,11 @@ class AdminActions extends BaseActions
        /**
         * Actions::ifPlugin()
         * Checks if a plugin exists and call its doIf function
+        * 
+        * @param       string  $name   name of plugin
+        * @param       string  $key    
+        * @param       string  $value  
+        * @return      callback
         */
        private function ifPlugin($name, $key = '', $value = '')
        {
@@ -4935,28 +5252,33 @@ class AdminActions extends BaseActions
                {
                        return;
                }
-
+               
                $params = func_get_args();
                array_shift($params);
-
+               
                return call_user_func_array(array(&$plugin, 'doIf'), $params);
        }
 
        /**
+        * AdminActions::ifCategory()
         *  Different checks for a category
+        * 
+        * @param       string  $key    key for information of category
+        * @param       string  $value  value for information of category
+        * @return      boolean
         */
-       private function ifCategory($name = '', $value='')
+       private function ifCategory($key = '', $value='')
        {
                global $blog, $catid;
-
+               
                // when no parameter is defined, just check if a category is selected
-               if (($name != 'catname' && $name != 'catid') || ($value == ''))
+               if (($key != 'catname' && $key != 'catid') || ($value == ''))
                {
                        return $blog->isValidCategory($catid);
                }
-
+               
                // check category name
-               if ( $name == 'catname' )
+               if ( $key == 'catname' )
                {
                        $value = $blog->getCategoryIdFromName($value);
                        if ($value == $catid)
@@ -4964,23 +5286,27 @@ class AdminActions extends BaseActions
                                return $blog->isValidCategory($catid);
                        }
                }
-
+               
                // check category id
-               if (($name == 'catid') && ($value == $catid))
+               if (($key == 'catid') && ($value == $catid))
                {
                        return $blog->isValidCategory($catid);
                }
-
+               
                return FALSE;
        }
-
+       
        /**
-        *  Checks if a member is on the team of a blog and return his rights
+        * AdminActions::ifOnTeam()
+        * Checks if a member is on the team of a blog and return his rights
+        * 
+        * @param       string  $blogName       name of weblog
+        * @return      boolean
         */
        private function ifOnTeam($blogName = '')
        {
                global $blog, $member, $manager;
-
+               
                // when no blog found
                if ( ($blogName == '') && !is_object($blog) )
                {
@@ -4992,7 +5318,7 @@ class AdminActions extends BaseActions
                {
                        $blogid = getBlogIDFromName($blogName);
                }
-
+               
                if (($blogName == '') || !$manager->existsBlogID($blogid))
                {
                        // use current blog
@@ -5000,37 +5326,45 @@ class AdminActions extends BaseActions
                }
                return $member->teamRights($blogid);
        }
-
+       
        /**
-        *  Checks if a member is admin of a blog
+        * AdminActions::ifAdmin()
+        * Checks if a member is admin of a blog
+        * 
+        * @param       string  $blogName       name of weblog
+        * @return      boolean
         */
        private function ifAdmin($blogName = '')
        {
                global $blog, $member, $manager;
-
+               
                // when no blog found
                if (($blogName == '') && (!is_object($blog)))
                {
                        return 0;
                }
-
+               
                // explicit blog selection
                if ($blogName != '')
                {
                        $blogid = getBlogIDFromName($blogName);
                }
-
+               
                if (($blogName == '') || !$manager->existsBlogID($blogid))
                {
                        // use current blog
                        $blogid = $blog->getID();
                }
-
+               
                return $member->isBlogAdmin($blogid);
        }
-
+       
        /**
+        * AdminActions::ifAddresscange()
         * Check e-Mail address is changed
+        * 
+        * @param       void
+        * @return      boolean
         */
        private function ifAddresscange()
        {
@@ -5057,6 +5391,77 @@ class AdminActions extends BaseActions
        }
        
        /**
+        * AdminActions::templateEditRow()
+        * Template edit box
+        * 
+        * @param       array   $template       
+        * @param       string  $desc           
+        * @param       string  $name           
+        * @param       string  $help           
+        * @param       integer $tabindex       
+        * @param       boolean $big            
+        * @param       array   $tmplt          
+        * @return      void
+        */
+       private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
+       {
+               static $count = 1;
+               
+               if ( !array_key_exists($name, $template) )
+               {
+                       $template[$name] = '';
+               }
+               
+               $tmplt = array();
+               $base  = array();
+               
+               if ( $tplt )
+               {
+                       $tmplt = skinableTEMPLATE::read($tplt);
+               }
+               
+               $data = array(
+                       'description'   => $desc,
+                       'help'                  => empty($help) ? '' : helpHtml('template' . $help),
+                       'count'                 => $count,
+                       'name'                  => $name,
+                       'tabindex'              => $tabindex,
+                       'rows'                  => $big ? 10 : 5,
+               );
+               
+               if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
+               {
+                       $base['head'] = "</tr>"
+                                     . "<tr>\n"
+                                     . "<td><%description%><%help%></td>\n"
+                                     . "<td id=\"td<%count%>\">\n"
+                                     . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
+               }
+               else
+               {
+                       $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
+               }
+               
+               if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
+               {
+                       $base['tail'] = "</textarea>\n"
+                                     . "</td>\n";
+               }
+               else
+               {
+                       $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
+               }
+               
+               echo TEMPLATE::fill($base['head'], $data);
+               echo ENTITY::hsc($template[$name]);
+               echo TEMPLATE::fill($base['tail'], $data);
+               
+               $count++;
+               
+               return;
+       }
+       
+       /**
         * AdminActions::customHelp()
         * shows a link to custom help file
         * 
@@ -5089,33 +5494,49 @@ class AdminActions extends BaseActions
         */
        static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
        {
+               global $CONF;
+               
                $templates = array();
-               if ($tplName) {
-                       $templates = skinableTEMPLATE::read($tplName);
+               
+               if ( $tplName )
+               {
+                       $templates = Template::read($tplName);
+               }
+               
+               if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
+               {
+                       $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
                }
-               if (isset($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) && !empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR'])) {
+               else
+               {
                        $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
-               } else {
-                       $template = '<a href="<%helpurl%>#<%helptarget%>" title="<%title%>" <%onclick%>>';
                }
-               if (empty($url)) {
-                       global $CONF;
-                       $url    = $CONF['AdminURL'] . 'documentation/customHelp.html';
+               
+               if ( empty($url) )
+               {
+                       $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
                }
-               if (empty($onclick)) {
+               
+               if ( empty($onclick) )
+               {
                        $onclick = 'onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);"';
-               } elseif (preg_match('/^onclick/', $onclick)) {
+               }
+               elseif ( preg_match('#^onclick#', $onclick) )
+               {
                        $onclick = $onclick;
-               } else {
+               }
+               else
+               {
                        $onclick = 'onclick="' . $onclick . '"';
                }
+               
                $data = array(
-                               'helpurl'    => $url,
-                               'helptarget' => $id,
-                               'onclick'    => $onclick,
-                               'title'      => (isset($title) && !empty($title)) ? $title : _HELP_TT,
+                       'helpurl'               => $url,
+                       'helptarget'    => $id,
+                       'onclick'               => $onclick,
+                       'title'                 => (isset($title) && !empty($title)) ? $title : _HELP_TT,
                );
-               return TEMPLATE::fill($template, $data);
+               return Template::fill($template, $data);
        }
        
        /**
@@ -5132,31 +5553,35 @@ class AdminActions extends BaseActions
         */
        private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
        {
+               global $CONF;
+               
                $templates = array();
+               
                if ( $tplName )
                {
                        $templates = Template::read($tplName);
                }
-               if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
+               if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
                {
-                       $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
+                       $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
                }
                else
                {
-                       $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
+                       $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
                }
                
                if ( empty($iconURL) )
                {
-                       global $CONF;
                        $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
                }
+               
                if ( function_exists('getimagesize') )
                {
                        $size   = getimagesize($iconURL);
                        $width  = 'width="'  . $size[0] . '" ';
                        $height = 'height="' . $size[1] . '" ';
                }
+               
                $data = array(
                        'iconurl'       => $iconURL,
                        'width'         => $width,
@@ -5164,8 +5589,10 @@ class AdminActions extends BaseActions
                        'alt'           => (isset($alt) && !empty($alt))         ? $alt   : _HELP_TT,
                        'title'         => (isset($title) && !empty($title)) ? $title : _HELP_TT,
                );
-               $icon = TEMPLATE::fill($template, $data);
+               
+               $icon = Template::fill($template, $data);
                $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
+               
                return $help . $icon;
        }
        
@@ -5202,17 +5629,17 @@ class AdminActions extends BaseActions
                
                if ( $name == 'admin' )
                {
-                       if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
-                       {
-                               $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
-                       }
-                       else
+                       if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
                        {
                                $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
                                          . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
                                          . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
                                          . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
                        }
+                       else
+                       {
+                               $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
+                       }
                }
                else
                {
@@ -5261,33 +5688,40 @@ class AdminActions extends BaseActions
                }
                else
                {
-                       echo TEMPLATE::fill($template, $dat);
+                       echo Template::fill($template, $dat);
                }
                return;
        }
-
+       
        /**
+        * AdminActions::existsNewPlugin()
         * Check exists new plugin
+        * 
+        * @param       void
+        * @return      boolean exists or not
         */
        private function existsNewPlugin()
        {
                global $DIR_PLUGINS;
+               
                $candidates = array();
-               $files      = scandir($DIR_PLUGINS);
-               foreach ($files as $file) {
-                       if (preg_match("/^NP_(.*)\.php$/", $file, $matches)) {
+               $files = scandir($DIR_PLUGINS);
+               
+               foreach ( $files as $file )
+               {
+                       if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
+                       {
                                $name = $matches[1];
-                               $que  = 'SELECT '
-                                               . '    * '
-                                               . 'FROM '
-                                               .      sql_table('plugin') . ' '
-                                               . 'WHERE '
-                                               . '    pfile = "NP_' . sql_real_escape_string($name) . '"';
-                               $res  = sql_query($que);
-                               if (sql_num_rows($res) == 0) {
+                               $query = "SELECT * FROM %s WHERE pfile='%s';";
+                               $query = sprintf($query, sql_table('plugin'), sql_real_escape_string("{NP_{$name}"));
+                               $res  = sql_query($query);
+                               
+                               if ( sql_num_rows($res) == 0 )
+                               {
                                        $candidates[] = $name;
                                }
                        }
+                       continue;
                }
                $this->newPlugCandidates = $candidates;
                return (count($candidates) > 0);