OSDN Git Service

Merge branch 'skinnable-master'
[nucleus-jp/nucleus-next.git] / nucleus / libs / ADMIN.php
index dd1ef75..2bbcc40 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-/*
+/**
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
  * Copyright (C) 2002-2009 The Nucleus Group
  *
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: ADMIN.php 1626 2012-01-09 15:46:54Z sakamocchi $
-
+ * @version $Id: ADMIN.php 1661 2012-02-12 11:55:39Z sakamocchi $
  */
 
 if ( !function_exists('requestVar') ) exit;
 require_once dirname(__FILE__) . '/showlist.php';
 
-/**
- * Builds the admin area and executes admin actions
- */
-class ADMIN {
-
+class Admin
+{
+<<<<<<< HEAD
+       private $xml_version_info = '1.0';
+       private $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
+       private $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
+       private $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
+       
     /**
      * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
      */
@@ -115,7 +117,7 @@ class ADMIN {
         );
 /*
         // the rest of the actions needs to be checked
-        $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
+        $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
 */
         if (!in_array($this->action, $aActionsNotToCheck))
         {
@@ -126,7 +128,7 @@ class ADMIN {
         if (method_exists($this, $methodName))
             call_user_func(array(&$this, $methodName));
         else
-            $this->error(_BADACTION . i18n::hsc(" ($action)"));
+            $this->error(_BADACTION . Entity::hsc(" ($action)"));
 
     }
 
@@ -153,7 +155,7 @@ class ADMIN {
         $this->pagehead();
 
         echo '<h2>', _LOGIN ,'</h2>';
-        if ($msg) echo _MESSAGE , ': ', i18n::hsc($msg);
+        if ($msg) echo _MESSAGE , ': ', Entity::hsc($msg);
         ?>
 
         <form action="index.php" method="post"><p>
@@ -163,11 +165,11 @@ class ADMIN {
         <br />
         <input name="action" value="login" type="hidden" />
         <br />
-        <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
+        <input type="submit" value="<?php echo _LOGIN ?>" tabindex="30" />
         <br />
         <small>
-            <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
-            <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
+            <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED ?></label>
+            <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT ?></a>
         </small>
         <?php           // pass through vars
 
@@ -216,7 +218,7 @@ class ADMIN {
         $amount = showlist($query,'table',$template);
 
         if (($showAll != 'yes') && ($member->isAdmin())) {
-            $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
+            $total = DB::getValue('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
             if ($total > $amount)
                 echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
         }
@@ -285,7 +287,7 @@ class ADMIN {
      * @param object BLOG
      */
     function bloglink(&$blog) {
-        return '<a href="'.i18n::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. i18n::hsc( $blog->getName() ) .'</a>';
+        return '<a href="'.Entity::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. Entity::hsc( $blog->getName() ) .'</a>';
     }
 
     /**
@@ -329,68 +331,438 @@ class ADMIN {
         $this->pagefoot();
     }
 
-    /**
-     * @todo document this
-     */
-    function action_itemlist($blogid = '') {
-        global $member, $manager, $CONF;
-
-        if ($blogid == '')
-            $blogid = intRequestVar('blogid');
-
-        $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
-        $this->pagehead();
-        $blog =& $manager->getBlog($blogid);
-
-        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-        echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
-
-        // start index
-        if (postVar('start'))
-            $start = intPostVar('start');
-        else
-            $start = 0;
-
-        if ($start == 0)
-            echo '<p><a href="index.php?action=createitem&amp;blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
-
-        // amount of items to show
-        if (postVar('amount'))
-            $amount = intPostVar('amount');
-        else {
-            $amount = intval($CONF['DefaultListSize']);
-            if ($amount < 1)
-                $amount = 10;
-        }
-
-        $search = postVar('search');    // search through items
-
-        $query =  'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
-               . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
-               . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
-
-        if ($search)
-            $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
-
-        // non-blog-admins can only edit/delete their own items
-        if (!$member->blogAdminRights($blogid))
-            $query .= ' and iauthor=' . $member->getID();
-
-
-        $query .= ' ORDER BY itime DESC'
-                . " LIMIT $start,$amount";
-
-        $template['content'] = 'itemlist';
-        $template['now'] = $blog->getCorrectTime(time());
-
-        $manager->loadClass("ENCAPSULATE");
-        $navList = new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
-        $navList->showBatchList('item',$query,'table',$template);
-
-
-        $this->pagefoot();
-    }
+       /**
+        * Admin::action_itemlist()
+        * 
+        * @param       integer $blogid ID for weblog
+        * @return      void
+        */
+       public function action_itemlist($blogid = '')
+=======
+       static private $skin;
+       
+       static public $action;
+       static public $aOptions;
+       static public $blog;
+       static public $contents;
+       static public $extrahead;
+       static public $headMess;
+       static public $passvar;
+       
+       static private $skinless_actions = array(
+               'plugindeleteconfirm',
+               'pluginoptionsupdate',
+               'blogsettingsupdate',
+               'settingsupdate',
+               'addnewlog2',
+               'additem',
+               'banlistnewfromitem',
+               'itemdeleteconfirm',
+               'itemupdate',
+               'changemembersettings',
+               'clearactionlog',
+               'memberedit',
+               'login',
+               
+               'skinremovetypeconfirm',
+               'skinclone',
+               'skindeleteconfirm',
+               'skinnew',
+               'skineditgeneral',
+               'skinupdate',
+               
+               'skinieexport',
+               
+               'templateupdate',
+               'templatedeleteconfirm',
+               'templatenew',
+               'templateclone',
+               
+               'adminskinremovetypeconfirm',
+               'adminskinclone',
+               'adminskindeleteconfirm',
+               'adminskinnew',
+               'adminskineditgeneral',
+               'adminskinupdate',
+               
+               'adminskinieexport',
+               
+               'admintemplateupdate',
+               'admintemplatedeleteconfirm',
+               'admintemplatenew',
+               'admintemplateclone'
+       );
+       
+       static private $ticketless_actions = array(
+               'showlogin',
+               'login',
+               'overview',
+               'itemlist',
+               'blogcommentlist',
+               'bookmarklet',
+               'blogsettings',
+               'banlist',
+               'createaccount',
+               'deleteblog',
+               'editmembersettings',
+               'createaccount',
+               'forgotpassword',
+               'browseowncomments',
+               'createitem',
+               'browseownitems',
+               'itemedit',
+               'itemmove',
+               'categoryedit',
+               'categorydelete',
+               'manage',
+               'actionlog',
+               'settingsedit',
+               'backupoverview',
+               'pluginlist',
+               'createnewlog',
+               'usermanagement',
+               'itemcommentlist',
+               'commentedit',
+               'commentdelete',
+               'banlistnewfromitem',
+               'banlistdelete',
+               'itemdelete',
+               'manageteam',
+               'teamdelete',
+               'banlistnew',
+               'memberedit',
+               'memberdelete',
+               'pluginhelp',
+               'pluginoptions',
+               'plugindelete',
+               
+               'activate',
+               'systemoverview',
+               'activatesetpwd',
+               
+               'skinoverview',
+               'skinclone',
+               'skindelete',
+               'skinedit',
+               'skinedittype',
+               'skinnew',
+               'skinremovetype',
+               
+               'skinieoverview',
+               
+               'templateoverview',
+               'templateclone',
+               'templateedit',
+               'templatedelete',
+               
+               'adminskinoverview',
+               'adminskinclone',
+               'adminskindelete',
+               'adminskinedit',
+               'adminskinedittype',
+               'adminskinnew',
+               'adminskinremovetype',
+               
+               'adminskinieoverview',
+               
+               'admintemplateoverview',
+               'admintemplateclone',
+               'admintemplateedit',
+               'admintemplatedelete'
+       );
+       
+       /**
+        * NOTE: This is for condition of admin/normal skin actions
+        */
+       static public $adminskin_actions = array(
+               /* ticketless */
+               'adminskinoverview',
+               'adminskinclone',
+               'adminskindelete',
+               'adminskinedit',
+               'adminskinedittype',
+               'adminskinnew',
+               'adminskinremovetype',
+               
+               'adminskinieoverview',
+               
+               'admintemplateoverview',
+               'admintemplateclone',
+               'admintemplateedit',
+               'admintemplatedelete',
+               
+               /* ticket needed */
+               'adminskineditgeneral',
+               'adminskinupdate',
+               'adminskindeleteconfirm',
+               'adminskinremovetypeconfirm',
+               
+               'adminskinieoverview',
+               'adminskiniedoimport',
+               'adminskinieexport',
+               'adminskinieimport',
+               
+               'admintemplatenew',
+               'admintemplatedeleteconfirm',
+               'admintemplateupdate'
+       );
+       
+       static public function initialize()
+       {
+               global $CONF, $manager, $member;
+               
+               /* NOTE: 1. decide which skinid to use */
+               $skinid = $CONF['AdminSkin'];
+               if ( $member->isLoggedIn() )
+               {
+                       $memskin = $member->getAdminSkin();
+                       if ( $memskin && Skin::existsID($memskin))
+                       {
+                               $skinid = $memskin;
+                       }
+               }
+               
+               /* NOTE: 2. make an instance of skin object */
+               if ( !Skin::existsID($skinid) )
+               {
+                       return FALSE;
+               }
+               
+               /* NOTE: 3. initializing each members */
+               self::$skin                     =& $manager->getSkin($skinid, 'AdminActions', 'AdminSkin');
+               self::$action           = '';
+               self::$extrahead        = '';
+               self::$passvar          = '';
+               self::$headMess         = '';
+               self::$aOptions         = '';
+               return TRUE;
+       }
+       
+       /**
+        * Admin::action()
+        * Executes an action
+        *
+        * @param       string  $action action to be performed
+        * @return      void
+        */
+       static public function action($action)
+       {
+               global $CONF, $manager, $member;
+               
+               /* 1. decide action name */
+               $customAction = postvar('customaction');
+               if ( empty($customAction) )
+               {
+                       $alias = array(
+                               'login' => 'overview',
+                               ''              => 'overview',
+                       );
+               }
+               else
+               {
+                       $alias = array(
+                               'login' => $customAction,
+                               ''              => $customAction
+                       );
+               }
+               if ( array_key_exists($action, $alias) && isset($alias[$action]) )
+               {
+                       $action = $alias[$action];
+               }
+               $method_name = "action_{$action}";
+               self::$action = strtolower($action);
+               
+               /* 2. check ticket-needed action */
+               if ( !in_array(self::$action, self::$ticketless_actions) && !$manager->checkTicket() )
+               {
+                       self::error(_ERROR_BADTICKET);
+                       return;
+               }
+               
+               /* 3. parse according to the action */
+               else if ( method_exists('Admin', $method_name) )
+               {
+                       call_user_func(array(__CLASS__, $method_name));
+                       return;
+               }
+               /* 4. parse special admin skin */
+               elseif ( in_array(self::$action, self::$skinless_actions) )
+               {
+                       /* TODO: need to be implemented or not?
+                       self::action_parseSpecialskin();
+                       */
+               }
+               else
+               {
+                       self::error(_BADACTION . ENTITY::hsc($action));
+                       return;
+               }
+               
+               return;
+       }
+       
+       /**
+        * Action::action_showlogin()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_showlogin()
+       {
+               global $error;
+               self::action_login($error);
+               return;
+       }
+       
+       /**
+        * Action::action_login()
+        * 
+        * @param       string  $msg            message for pageheader
+        * @param       integer $passvars       ???
+        */
+       static private function action_login($msg = '', $passvars = 1)
+       {
+               global $member;
+               
+               // skip to overview when allowed
+               if ( $member->isLoggedIn() && $member->canLogin() )
+               {
+                       self::action_overview();
+                       return;
+               }
+               
+               /* TODO: needless variable??? */
+               self::$passvar = $passvars;
+               if ( $msg )
+               {
+                       self::$headMess = $msg;
+               }
+               
+               self::$skin->parse('showlogin');
+       }
+       
+       /**
+        * Action::action_overview()
+        * provides a screen with the overview of the actions available
+        * 
+        * @param       string  $msg    message for pageheader
+        * @return      void
+        */
+       static private function action_overview($msg = '')
+       {
+               if ( $msg )
+               {
+                       self::$headMess = $msg;
+               }
+               
+               self::$skin->parse('overview');
+               return;
+       }
+       
+       /**
+        * Admin::action_manage()
+        * 
+        * @param       string  $msg    message for pageheader
+        * @retrn       void
+        */
+       static private function action_manage($msg = '')
+       {
+               global $member;
+               
+               if ( $msg )
+               {
+                       self::$headMess = $msg;
+               }
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('manage');
+               return;
+       }
+       
+       /**
+        * Action::action_itemlist()
+        * 
+        * @param       integer id for weblod
+        * @return      void
+        */
+       static private function action_itemlist($blogid = '')
+>>>>>>> skinnable-master
+       {
+               global $member, $manager, $CONF;
+               
+               if ( $blogid == '' )
+               {
+                       $blogid = intRequestVar('blogid');
+               }
+               
+<<<<<<< HEAD
+               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
+               
+               $this->pagehead();
+               $blog =& $manager->getBlog($blogid);
+               
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+               echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
+               
+               // start index
+               if ( postVar('start') )
+               {
+                       $start = intPostVar('start');
+               }
+               else
+               {
+                       $start = 0;
+               }
+               
+               if ( $start == 0 )
+               {
+                       echo '<p><a href="index.php?action=createitem&amp;blogid='.$blogid.'">' . _ITEMLIST_ADDNEW . "</a></p>\n";
+               }
+               
+               // amount of items to show
+               if ( postVar('amount') )
+               {
+                       $amount = intPostVar('amount');
+               }
+               else
+               {
+                       $amount = intval($CONF['DefaultListSize']);
+                       if ( $amount < 1 )
+                       {
+                               $amount = 10;
+                       }
+               }
+               
+               $search = postVar('search');    // search through items
+               
+               $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
+                      . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
+                      . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
+               
+               if ( $search )
+               {
+                       $query .= " AND ((ititle LIKE " . DB::quoteValue('%'.$search.'%') . ") OR (ibody LIKE " . DB::quoteValue('%'.$search.'%') . ") OR (imore LIKE " . DB::quoteValue('%'.$search.'%') . "))";
+               }
+               
+               // non-blog-admins can only edit/delete their own items
+               if ( !$member->blogAdminRights($blogid) )
+               {
+                       $query .= ' and iauthor=' . $member->getID();
+               }
+               
+               $query .= ' ORDER BY itime DESC'
+                       . " LIMIT $start, $amount";
+               
+               $template['content'] = 'itemlist';
+               $template['now'] = $blog->getCorrectTime(time());
+               
+               $manager->loadClass("ENCAPSULATE");
+               $navList = new NavList('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
+               $navList->showBatchList('item',$query,'table',$template);
+               
+               $this->pagefoot();
+               return;
+       }
 
     /**
      * @todo document this
@@ -424,14 +796,14 @@ class ADMIN {
 
         echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
         echo '<h2>',_BATCH_ITEMS,'</h2>';
-        echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
         echo '<ul>';
 
 
         // walk over all itemids and perform action
         foreach ($selected as $itemid) {
             $itemid = intval($itemid);
-            echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
+            echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
 
             // perform action, display errors if needed
             switch($action) {
@@ -442,7 +814,7 @@ class ADMIN {
                     $error = $this->moveOneItem($itemid, $destCatid);
                     break;
                 default:
-                    $error = _BATCH_UNKNOWN . i18n::hsc($action);
+                    $error = _BATCH_UNKNOWN . Entity::hsc($action);
             }
 
             echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
@@ -484,13 +856,13 @@ class ADMIN {
 
         echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
         echo '<h2>',_BATCH_COMMENTS,'</h2>';
-        echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
         echo '<ul>';
 
         // walk over all itemids and perform action
         foreach ($selected as $commentid) {
             $commentid = intval($commentid);
-            echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
+            echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
 
             // perform action, display errors if needed
             switch($action) {
@@ -498,7 +870,7 @@ class ADMIN {
                     $error = $this->deleteOneComment($commentid);
                     break;
                 default:
-                    $error = _BATCH_UNKNOWN . i18n::hsc($action);
+                    $error = _BATCH_UNKNOWN . Entity::hsc($action);
             }
 
             echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
@@ -538,13 +910,13 @@ class ADMIN {
 
         echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
         echo '<h2>',_BATCH_MEMBERS,'</h2>';
-        echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
         echo '<ul>';
 
         // walk over all itemids and perform action
         foreach ($selected as $memberid) {
             $memberid = intval($memberid);
-            echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
+            echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
 
             // perform action, display errors if needed
             switch($action) {
@@ -553,19 +925,19 @@ class ADMIN {
                     break;
                 case 'setadmin':
                     // always succeeds
-                    sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
+                    DB::execute('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
                     $error = '';
                     break;
                 case 'unsetadmin':
                     // there should always remain at least one super-admin
-                    $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
-                    if (sql_num_rows($r) < 2)
+                    $r = DB::getResult('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
+                    if ($r->rowCount() < 2)
                         $error = _ERROR_ATLEASTONEADMIN;
                     else
-                        sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
+                        DB::execute('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
                     break;
                 default:
-                    $error = _BATCH_UNKNOWN . i18n::hsc($action);
+                    $error = _BATCH_UNKNOWN . Entity::hsc($action);
             }
 
             echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
@@ -608,13 +980,13 @@ class ADMIN {
         echo '<p><a href="index.php?action=manageteam&amp;blogid=',$blogid,'">(',_BACK,')</a></p>';
 
         echo '<h2>',_BATCH_TEAM,'</h2>';
-        echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
         echo '<ul>';
 
         // walk over all itemids and perform action
         foreach ($selected as $memberid) {
             $memberid = intval($memberid);
-            echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
+            echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
 
             // perform action, display errors if needed
             switch($action) {
@@ -623,19 +995,19 @@ class ADMIN {
                     break;
                 case 'setadmin':
                     // always succeeds
-                    sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
+                    DB::execute('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
                     $error = '';
                     break;
                 case 'unsetadmin':
                     // there should always remain at least one admin
-                    $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
-                    if (sql_num_rows($r) < 2)
+                    $r = DB::getResult('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
+                    if ($r->rowCount() < 2)
                         $error = _ERROR_ATLEASTONEBLOGADMIN;
                     else
-                        sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
+                        DB::execute('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
                     break;
                 default:
-                    $error = _BATCH_UNKNOWN . i18n::hsc($action);
+                    $error = _BATCH_UNKNOWN . Entity::hsc($action);
             }
 
             echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
@@ -682,13 +1054,13 @@ class ADMIN {
 
         echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
         echo '<h2>',BATCH_CATEGORIES,'</h2>';
-        echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
         echo '<ul>';
 
         // walk over all itemids and perform action
         foreach ($selected as $catid) {
             $catid = intval($catid);
-            echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
+            echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
 
             // perform action, display errors if needed
             switch($action) {
@@ -699,7 +1071,7 @@ class ADMIN {
                     $error = $this->moveOneCategory($catid, $destBlogId);
                     break;
                 default:
-                    $error = _BATCH_UNKNOWN . i18n::hsc($action);
+                    $error = _BATCH_UNKNOWN . Entity::hsc($action);
             }
 
             echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
@@ -720,10 +1092,10 @@ class ADMIN {
         global $manager;
         $this->pagehead();
         ?>
-        <h2><?php echo _MOVE_TITLE?></h2>
+        <h2><?php echo _MOVE_TITLE ?></h2>
         <form method="post" action="index.php"><div>
 
-            <input type="hidden" name="action" value="batch<?php echo $type?>" />
+            <input type="hidden" name="action" value="batch<?php echo $type ?>" />
             <input type="hidden" name="batchaction" value="move" />
             <?php
                 $manager->addTicketHidden();
@@ -739,7 +1111,7 @@ class ADMIN {
             ?>
 
 
-            <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
+            <input type="submit" value="<?php echo _MOVE_BTN ?>" onclick="return checkSubmit();" />
 
         </div></form>
         <?php       $this->pagefoot();
@@ -753,10 +1125,10 @@ class ADMIN {
         global $manager;
         $this->pagehead();
         ?>
-        <h2><?php echo _MOVECAT_TITLE?></h2>
+        <h2><?php echo _MOVECAT_TITLE ?></h2>
         <form method="post" action="index.php"><div>
 
-            <input type="hidden" name="action" value="batch<?php echo $type?>" />
+            <input type="hidden" name="action" value="batch<?php echo $type ?>" />
             <input type="hidden" name="batchaction" value="move" />
             <?php
                 $manager->addTicketHidden();
@@ -772,7 +1144,7 @@ class ADMIN {
             ?>
 
 
-            <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
+            <input type="submit" value="<?php echo _MOVECAT_BTN ?>" onclick="return checkSubmit();" />
 
         </div></form>
         <?php       $this->pagefoot();
@@ -787,10 +1159,10 @@ class ADMIN {
 
         $this->pagehead();
         ?>
-        <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
+        <h2><?php echo _BATCH_DELETE_CONFIRM ?></h2>
         <form method="post" action="index.php"><div>
 
-            <input type="hidden" name="action" value="batch<?php echo $type?>" />
+            <input type="hidden" name="action" value="batch<?php echo $type ?>" />
             <?php $manager->addTicketHidden() ?>
             <input type="hidden" name="batchaction" value="delete" />
             <input type="hidden" name="confirmation" value="yes" />
@@ -811,7 +1183,7 @@ class ADMIN {
 
             ?>
 
-            <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
+            <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN ?>" onclick="return checkSubmit();" />
 
         </div></form>
         <?php       $this->pagefoot();
@@ -825,351 +1197,2956 @@ class ADMIN {
      * @see function selectBlog
      */
     function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
-        ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
-    }
-
-    /**
-     * Inserts a HTML select element with choices for all blogs to which the user has access
-     *      mode = 'blog' => shows blognames and values are blogids
-     *      mode = 'category' => show category names and values are catids
-     *
-     * @param $iForcedBlogInclude
-     *      ID of a blog that always needs to be included, without checking if the
-     *      member is on the blog team (-1 = none)
-     * @todo document parameters
-     */
-    function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
-        global $member, $CONF;
-
-        // 0. get IDs of blogs to which member can post items (+ forced blog)
-        $aBlogIds = array();
-        if ($iForcedBlogInclude != -1)
-            $aBlogIds[] = intval($iForcedBlogInclude);
-
-        if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
-            $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
-        else
-            $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
-        $rblogids = sql_query($queryBlogs);
-        while ($o = sql_fetch_object($rblogids))
-            if ($o->bnumber != $iForcedBlogInclude)
-                $aBlogIds[] = intval($o->bnumber);
-
-        if (count($aBlogIds) == 0)
-            return;
-
-        echo '<select name="',$name,'" tabindex="',$tabindex,'">';
-
-        // 1. select blogs (we'll create optiongroups)
-        // (only select those blogs that have the user on the team)
-        $queryBlogs =  'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
-        $blogs = sql_query($queryBlogs);
-        if ($mode == 'category') {
-            if (sql_num_rows($blogs) > 1)
-                $multipleBlogs = 1;
-
-            while ($oBlog = sql_fetch_object($blogs)) {
-                if ($multipleBlogs)
-                    echo '<optgroup label="',i18n::hsc($oBlog->bname),'">';
-
-                // show selection to create new category when allowed/wanted
-                if ($showNewCat) {
-                    // check if allowed to do so
-                    if ($member->blogAdminRights($oBlog->bnumber))
-                        echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
-                }
-
-                // 2. for each category in that blog
-                $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
-                while ($oCat = sql_fetch_object($categories)) {
-                    if ($oCat->catid == $selected)
-                        $selectText = ' selected="selected" ';
-                    else
-                        $selectText = '';
-                    echo '<option value="',$oCat->catid,'" ', $selectText,'>',i18n::hsc($oCat->cname),'</option>';
-                }
-
-                if ($multipleBlogs)
-                    echo '</optgroup>';
-            }
-        } else {
-            // blog mode
-            while ($oBlog = sql_fetch_object($blogs)) {
-                echo '<option value="',$oBlog->bnumber,'"';
-                if ($oBlog->bnumber == $selected)
-                    echo ' selected="selected"';
-                echo'>',i18n::hsc($oBlog->bname),'</option>';
-            }
-        }
-        echo '</select>';
-
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_browseownitems() {
-        global $member, $manager, $CONF;
-
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-        echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
-
-        // start index
-        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;
-        }
-
-        $search = postVar('search');    // search through items
-
-        $query =  'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
-               . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
-               . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
-
-        if ($search)
-            $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
-
-        $query .= ' ORDER BY itime DESC'
-                . " LIMIT $start,$amount";
-
-        $template['content'] = 'itemlist';
-        $template['now'] = time();
-
-        $manager->loadClass("ENCAPSULATE");
-        $navList = new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
-        $navList->showBatchList('item',$query,'table',$template);
-
-        $this->pagefoot();
-
-    }
-
-    /**
-     * Show all the comments for a given item
-     * @param int $itemid
-     */
-    function action_itemcommentlist($itemid = '') {
-        global $member, $manager, $CONF;
-
-        if ($itemid == '')
-            $itemid = intRequestVar('itemid');
-
-        // only allow if user is allowed to alter item
-        $member->canAlterItem($itemid) or $this->disallow();
-
-        $blogid = getBlogIdFromItemId($itemid);
-
-        $this->pagehead();
-
-        // start index
-        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;
-        }
-
-        $search = postVar('search');
-
-        echo '<p>(<a href="index.php?action=itemlist&amp;blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
-        echo '<h2>',_COMMENTS,'</h2>';
-
-        $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
-
-        if ($search)
-            $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
-
-        $query .= ' ORDER BY ctime ASC'
-                . " LIMIT $start,$amount";
-
-        $template['content'] = 'commentlist';
-        $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
-
-        $manager->loadClass("ENCAPSULATE");
-        $navList = new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
-        $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
-
-        $this->pagefoot();
+        Admin::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
     }
 
-    /**
-     * Browse own comments
-     */
-    function action_browseowncomments() {
-        global $member, $manager, $CONF;
-
-        // start index
-        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;
-        }
-
-        $search = postVar('search');
-
-
-        $query =  'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
-
-        if ($search)
-            $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
-
-        $query .= ' ORDER BY ctime DESC'
-                . " LIMIT $start,$amount";
-
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-        echo '<h2>', _COMMENTS_YOUR ,'</h2>';
-
-        $template['content'] = 'commentlist';
-        $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
-
-        $manager->loadClass("ENCAPSULATE");
-        $navList = new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
-        $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
-
-        $this->pagefoot();
-    }
-
-    /**
-     * Browse all comments for a weblog
-     * @param int $blogid
-     */
-    function action_blogcommentlist($blogid = '')
-    {
-        global $member, $manager, $CONF;
-
-        if ($blogid == '')
-            $blogid = intRequestVar('blogid');
-        else
-            $blogid = intval($blogid);
-
-        $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
-        // start index
-        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;
-        }
-
-        $search = postVar('search');        // search through comments
-
-
-        $query =  'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
-
-        if ($search != '')
-            $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
-
-
-        $query .= ' ORDER BY ctime DESC'
-                . " LIMIT $start,$amount";
-
-
-        $blog =& $manager->getBlog($blogid);
-
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-        echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
-
-        $template['content'] = 'commentlist';
-        $template['canAddBan'] = $member->blogAdminRights($blogid);
-
-        $manager->loadClass("ENCAPSULATE");
-        $navList = new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
-        $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
-
-        $this->pagefoot();
-    }
-
-    /**
-     * Provide a page to item a new item to the given blog
-     */
-    function action_createitem() {
-        global $member, $manager;
-
-        $blogid = intRequestVar('blogid');
-
-        // check if allowed
-        $member->teamRights($blogid) or $this->disallow();
-
-        $memberid = $member->getID();
-
-        $blog =& $manager->getBlog($blogid);
-
-        $this->pagehead();
+       /**
+        * Admin::selectBlog()
+        * Inserts a HTML select element with choices for all blogs to which the user has access
+        *  mode = 'blog' => shows blognames and values are blogids
+        *  mode = 'category' => show category names and values are catids
+        * 
+        * @param       string  $name                           name of 
+        * @param       string  $mode                           blog/category
+        * @param       integer $selected                       category ID to be selected
+        * @param       integer $tabindex                       tab index value
+        * @param       integer $showNewCat                     show category to newly be created
+        * @param       integer $iForcedBlogInclude     ID of a blog that always needs to be included,
+        *                                              without checking if the member is on the blog team (-1 = none)
+        * @return      void
+        */
+       public function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
+       {
+               global $member, $CONF;
+               
+               // 0. get IDs of blogs to which member can post items (+ forced blog)
+               $aBlogIds = array();
+               if ( $iForcedBlogInclude != -1 )
+               {
+                       $aBlogIds[] = intval($iForcedBlogInclude);
+               }
+               
+               if ( !$member->isAdmin() || !array_key_exists('ShowAllBlogs', $CONF) || !$CONF['ShowAllBlogs'] )
+               {
+                       $query = "SELECT bnumber FROM %s,%s WHERE tblog=bnumber and tmember=%d;";
+                       $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
+               }
+               else
+               {
+                       $query = "SELECT bnumber FROM %s ORDER BY bname;";
+                       $query = sprintf($query, sql_table('blog'));
+               }
+               
+               $rblogids = DB::getResult($query);
+               foreach ( $rblogids as $row )
+               {
+                       if ( $row['bnumber'] != $iForcedBlogInclude )
+                       {
+                               $aBlogIds[] = (integer) $row['bnumber'];
+                       }
+               }
+               if ( count($aBlogIds) == 0 )
+               {
+                       return;
+               }
+               
+               echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
+               
+               // 1. select blogs (we'll create optiongroups)
+               // (only select those blogs that have the user on the team)
+               $query = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
+               $query = sprintf($query, sql_table('blog'), implode(',',$aBlogIds));
+               $blogs = DB::getResult($query);
+               
+               if ( $mode == 'category' )
+               {
+                       $multipleBlogs = ($blogs->rowCount() > 1);
+                       
+                       foreach ( $blogs as $row )
+                       {
+                               if ( $multipleBlogs )
+                               {
+                                       echo '<optgroup label="' . Entity::hsc($row['bname']) . '">' . "\n";
+                               }
+                               
+                               // show selection to create new category when allowed/wanted
+                               if ( $showNewCat )
+                               {
+                                       // check if allowed to do so
+                                       if ( $member->blogAdminRights($row['bnumber']) )
+                                       {
+                                               echo "<option value=\"newcat-{$row['bnumber']}\">" . _ADD_NEWCAT . "</option>\n";
+                                       }
+                               }
+                               
+                               // 2. for each category in that blog
+                               $query = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
+                               $query = sprintf($query, sql_table('category'), (integer) $row['bnumber']);
+                               $categories = DB::getResult($query);
+                               foreach ( $categories as $cat )
+                               {
+                                       if ( $cat['catid'] != $selected )
+                                       {
+                                       echo "<option value=\"{$cat['catid']}\" {$selectText} >" . Entity::hsc($cat['cname']) . "</option>\n";
+                                       }
+                                       else
+                                       {
+                                       echo "<option value=\"{$cat['catid']}\" selected=\"selected\" >" . Entity::hsc($cat['cname']) . "</option>\n";
+                                       }
+                               }
+                               
+                               if ( $multipleBlogs )
+                               {
+                                       echo "</optgroup>\n";
+                               }
+                       }
+               }
+               else
+               {
+                       // blog mode
+                       foreach ( $blogs as $row )
+                       {
+                               if ( $row['bnumber'] != $selected )
+                               {
+                                       echo "<option value=\"{$row['bnumber']}\">" . Entity::hsc($row['bname']) . "</option>\n";
+                               }
+                               else
+                               {
+                                       echo "<option value=\"{$row['bnumber']}\" selected=\"selected\">" . Entity::hsc($row['bname']) . "</option>\n";
+                               }
+                       }
+               }
+               echo "</select>\n";
+=======
+               $member->teamRights($blogid) or $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('itemlist');
+               return;
+       }
+       
+       /**
+        * Action::action_batchitem()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_batchitem()
+       {
+               global $member, $manager;
+               
+               $member->isLoggedIn() or self::disallow();
+               
+               $selected       = requestIntArray('batch');
+               $action         = requestVar('batchaction');
+               
+               if ( !is_array($selected) || sizeof($selected) == 0 )
+               {
+                       self::error(_BATCH_NOSELECTION);
+                       return;
+               }
+               
+               // On move: when no destination blog/category chosen, show choice now
+               $destCatid = intRequestVar('destcatid');
+               if ( ($action == 'move') && (!$manager->existsCategory($destCatid)) )
+               {
+                       self::batchMoveSelectDestination('item', $selected);
+               }
+               
+               // On delete: check if confirmation has been given
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
+               {
+                       self::batchAskDeleteConfirmation('item', $selected);
+               }
+               
+               self::$skin->parse('batchitem');
+               return;
+       }
+       
+       /**
+        * Action::action_batchcomment()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_batchcomment()
+       {
+               global $member;
+               
+               $member->isLoggedIn() or self::disallow();
+               
+               $selected       = requestIntArray('batch');
+               $action         = requestVar('batchaction');
+               
+               // Show error when no items were selected
+               if ( !is_array($selected) || sizeof($selected) == 0 )
+               {
+                       self::error(_BATCH_NOSELECTION);
+                       return;
+               }
+               
+               // On delete: check if confirmation has been given
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
+               {
+                       self::batchAskDeleteConfirmation('comment', $selected);
+               }
+               
+               self::$skin->parse('batchcomment');
+               return;
+       }
+       
+       /**
+        * Admin::action_batchmember()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_batchmember()
+       {
+               global $member;
+               
+               ($member->isLoggedIn() && $member->isAdmin()) or self::disallow();
+               
+               $selected       = requestIntArray('batch');
+               $action         = requestVar('batchaction');
+               
+               // Show error when no members selected
+               if ( !is_array($selected) || sizeof($selected) == 0 )
+               {
+                       self::error(_BATCH_NOSELECTION);
+                       return;
+               }
+               
+               // On delete: check if confirmation has been given
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
+               {
+                       self::batchAskDeleteConfirmation('member',$selected);
+               }
+               
+               self::$skin->parse('batchmember');
+               return;
+       }
+       
+       /**
+        * Admin::action_batchteam()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_batchteam()
+       {
+               global $member;
+               
+               $blogid = intRequestVar('blogid');
+               
+               ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or self::disallow();
+               
+               $selected       = requestIntArray('batch');
+               $action         = requestVar('batchaction');
+               
+               if ( !is_array($selected) || sizeof($selected) == 0 )
+               {
+                       self::error(_BATCH_NOSELECTION);
+                       return;
+               }
+               
+               // On delete: check if confirmation has been given
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
+               {
+                       self::batchAskDeleteConfirmation('team',$selected);
+               }
+               
+               self::$skin->parse('batchteam');
+               return;
+       }
+       
+       /**
+        * Admin::action_batchcategory()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_batchcategory()
+       {
+               global $member, $manager;
+               
+               $member->isLoggedIn() or self::disallow();
+               
+               $selected       = requestIntArray('batch');
+               $action         = requestVar('batchaction');
+               
+               if ( !is_array($selected) || sizeof($selected) == 0 )
+               {
+                       self::error(_BATCH_NOSELECTION);
+                       return;
+               }
+               
+               // On move: when no destination blog chosen, show choice now
+               $destBlogId = intRequestVar('destblogid');
+               if ( ($action == 'move') && (!$manager->existsBlogID($destBlogId)) )
+               {
+                       self::batchMoveCategorySelectDestination('category', $selected);
+               }
+               
+               // On delete: check if confirmation has been given
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
+               {
+                       self::batchAskDeleteConfirmation('category', $selected);
+               }
+               
+               self::$skin->parse('batchcategory');
+               return;
+       }
+       
+       /**
+        * Admin::batchMoveSelectDestination()
+        * 
+        * @param       string  $type   type of batch action
+        * @param       integer $ids    needless???
+        * @return      void
+        * 
+        * TODO: remove needless argument
+        */
+       static private function batchMoveSelectDestination($type, $ids)
+       {
+               $_POST['batchmove'] = $type;
+               self::$skin->parse('batchmove');
+               return;
+       }
+       
+       /**
+        * Admin::batchMoveCategorySelectDestination()
+        * 
+        * @param       string  $type   type of batch action
+        * @param       integer $ids    needless???
+        * @return      void
+        * 
+        * TODO: remove needless argument
+        */
+       static private function batchMoveCategorySelectDestination($type, $ids)
+       {
+               $_POST['batchmove'] = $type;
+               global $manager;
+               self::$skin->parse('batchmovecat');
+               return;
+       }
+       
+       /**
+        * Admin::batchAskDeleteConfirmation()
+        * 
+        * @param       string  $type   type of batch action
+        * @param       integer $ids    needless???
+        * @return      void
+        * 
+        * TODO: remove needless argument
+        */
+       static private function batchAskDeleteConfirmation($type, $ids)
+       {
+               self::$skin->parse('batchdelete');
+               return;
+       }
+       
+       /**
+        * Admin::action_browseownitems()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_browseownitems()
+       {
+               global $member, $manager, $CONF;
+               
+               self::$skin->parse('browseownitems');
+               return;
+       }
+       
+       /**
+        * Admin::action_itemcommentlist()
+        * Show all the comments for a given item
+        * 
+        * @param       integer $itemid ID for item
+        * @return      void
+        */
+       static private function action_itemcommentlist($itemid = '')
+       {
+               global $member, $manager, $CONF;
+               
+               if ( $itemid == '' )
+               {
+                       $itemid = intRequestVar('itemid');
+               }
+               
+               // only allow if user is allowed to alter item
+               $member->canAlterItem($itemid) or self::disallow();
+               
+               $item =& $manager->getItem($itemid, 1, 1);
+               $_REQUEST['itemid'] = $item['itemid'];
+               $_REQUEST['blogid'] = $item['blogid'];
+               
+               self::$skin->parse('itemcommentlist');
+               return;
+       }
+       
+       /**
+        * Admin::action_browseowncomments()
+        * Browse own comments
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_browseowncomments()
+       {
+               self::$skin->parse('browseowncomments');
+               return;
+       }
+       
+       /**
+        * Admin::action_blogcommentlist()
+        * Browse all comments for a weblog
+        * 
+        * @param       integer $blogid ID for weblog
+        * @return      void
+        */
+       static private function action_blogcommentlist($blogid = '')
+       {
+               global $member, $manager, $CONF;
+               
+               if ( $blogid == '' )
+               {
+                       $blogid = intRequestVar('blogid');
+               }
+               else
+               {
+                       $blogid = intval($blogid);
+               }
+               
+               $member->teamRights($blogid) or $member->isAdmin() or self::disallow();
+               
+               /* TODO: we consider to use the other way insterad of this */
+               $_REQUEST['blogid'] = $blogid;
+               
+               self::$skin->parse('blogcommentlist');
+               return;
+       }
+       
+       /**
+        * Admin::action_createaccount()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_createaccount()
+       {
+               global $CONF;
+               
+               if ( $CONF['AllowMemberCreate'] != 1 )
+               {
+                       self::$skin->parse('createaccountdisable');
+                       return;
+               }
+               
+               $name = '';
+               $realname ='';
+               $email = '';
+               $url = '';
+               
+               $contents = array(
+                       'name'          => '',
+                       'realname'      => '',
+                       'email'         => '',
+                       'url'           => ''
+               );
+               
+               if ( array_key_exists('showform', $_POST) && $_POST['showform'] == 1 )
+               {
+                       $action = new Action();
+                       $message = $action->createAccount();
+                       if ( $message === 1 )
+                       {
+                               self::$headMess = $message;
+                               self::$skin->parse('createaccountsuccess');
+                               return;
+                       }
+                       
+                       /* TODO: validation */
+                       if ( array_key_exists('name', $_POST) )
+                       {
+                               $contents['name'] = $_POST['name'];
+                       }
+                       if ( array_key_exists('realname', $_POST) )
+                       {
+                               $contents['realname'] = $_POST['realname'];
+                       }
+                       if ( array_key_exists('email', $_POST) )
+                       {
+                               $contents['email'] = $_POST['email'];
+                       }
+                       if ( array_key_exists('url', $_POST) )
+                       {
+                               $contents['url'] = $_POST['url'];
+                       }
+                       
+                       self::$contents = $contents;
+                       
+               }
+               
+               self::$skin->parse('createaccountinput');
+               return;
+       }
+       
+       /**
+        * Admin::action_createitem()
+        * Provide a page to item a new item to the given blog
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_createitem()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               // check if allowed
+               $member->teamRights($blogid) or self::disallow();
+               
+               $blog =& $manager->getBlog($blogid);
+               $contents = array();
+               
+               $data = array(
+                       'blog'          => &$blog,
+                       'contents'      => &$contents
+               );
+               $manager->notify('PreAddItemForm', $data);
+               
+               if ( $blog->convertBreaks() )
+               {
+                       if ( array_key_exists('body', $contents) && !empty($contents['body']) )
+                       {
+                               $contents['body'] = removeBreaks($contents['body']);
+                       }
+                       if ( array_key_exists('more', $contents) && !empty($contents['more']) )
+                       {
+                               $contents['more'] = removeBreaks($contents['more']);
+                       }
+               }
+               
+               self::$blog = &$blog;
+               self::$contents = &$contents;
+               
+               self::$skin->parse('createitem');
+               return;
+       }
+       
+       /**
+        * Admin::action_itemedit()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_itemedit()
+       {
+               global $member, $manager;
+               
+               $itemid = intRequestVar('itemid');
+               
+               // only allow if user is allowed to alter item
+               $member->canAlterItem($itemid) or self::disallow();
+               
+               $item =& $manager->getItem($itemid, 1, 1);
+               $blog =& $manager->getBlog($item['blogid']);
+               $data = array('blog'=> &$blog, 'item' => &$item);
+               $manager->notify('PrepareItemForEdit', $data);
+               
+               if ( $blog->convertBreaks() )
+               {
+                       if ( array_key_exists('body', $item) && !empty($item['body']) )
+                       {
+                               $item['body'] = removeBreaks($item['body']);
+                       }
+                       if ( array_key_exists('more', $item) && !empty($item['more']) )
+                       {
+                               $item['more'] = removeBreaks($item['more']);
+                       }
+               }
+               
+               self::$blog = &$blog;
+               self::$contents = &$item;
+               
+               self::$skin->parse('itemedit');
+               return;
+       }
+       
+       /**
+        * Admin::action_itemupdate()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_itemupdate()
+       {
+               global $member, $manager, $CONF;
+               
+               $itemid = intRequestVar('itemid');
+               $catid  = postVar('catid');
+               
+               // only allow if user is allowed to alter item
+               $member->canUpdateItem($itemid, $catid) or self::disallow();
+               
+               $actiontype = postVar('actiontype');
+               
+               // delete actions are handled by itemdelete (which has confirmation)
+               if ( $actiontype == 'delete' )
+               {
+                       self::action_itemdelete();
+                       return;
+               }
+               
+               $body           = postVar('body');
+               $title          = postVar('title');
+               $more           = postVar('more');
+               $closed         = intPostVar('closed');
+               $draftid        = intPostVar('draftid');
+               
+               // default action = add now
+               if ( !$actiontype )
+               {
+                       $actiontype='addnow';
+               }
+               
+               // create new category if needed
+               if ( i18n::strpos($catid,'newcat') === 0 )
+               {
+                       // get blogid
+                       list($blogid) = sscanf($catid,"newcat-%d");
+                       
+                       // create
+                       $blog =& $manager->getBlog($blogid);
+                       $catid = $blog->createNewCategory();
+                       
+                       // show error when sth goes wrong
+                       if ( !$catid )
+                       {
+                               self::doError(_ERROR_CATCREATEFAIL);
+                       }
+               }
+               
+               /**
+                * set some variables based on actiontype
+                * 
+                * actiontypes:
+                *      draft items -> addnow, addfuture, adddraft, delete
+                *      non-draft items -> edit, changedate, delete
+                * 
+                * variables set:
+                *      $timestamp: set to a nonzero value for future dates or date changes
+                *      $wasdraft: set to 1 when the item used to be a draft item
+                *      $publish: set to 1 when the edited item is not a draft
+                */
+               $blogid =  getBlogIDFromItemID($itemid);
+               $blog =& $manager->getBlog($blogid);
+               
+               $wasdrafts = array('adddraft', 'addfuture', 'addnow');
+               $wasdraft  = in_array($actiontype, $wasdrafts) ? 1 : 0;
+               $publish   = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
+               if ( $actiontype == 'addfuture' || $actiontype == 'changedate' )
+               {
+                       $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
+               }
+               else
+               {
+                       $timestamp =0;
+               }
+               
+               // edit the item for real
+               Item::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
+               
+               self::updateFuturePosted($blogid);
+               
+               if ( $draftid > 0 )
+               {
+                       // delete permission is checked inside Item::delete()
+                       Item::delete($draftid);
+               }
+               
+               if ( $catid != intPostVar('catid') )
+               {
+                       self::action_categoryedit(
+                               $catid,
+                               $blog->getID(),
+                               $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
+                       );
+               }
+               else
+               {
+                       // TODO: set start item correctly for itemlist
+                       $item =& $manager->getitem($itemid, 1, 1);
+                       $query = "SELECT COUNT(*) FROM %s WHERE unix_timestamp(itime) <= '%s';";
+                       $query = sprintf($query, sql_table('item'), $item['timestamp']);
+                       $cnt  = DB::getValue($query);
+                       $_REQUEST['start'] = $cnt + 1;
+                       self::action_itemlist(getBlogIDFromItemID($itemid));
+               }
+               return;
+       }
+       
+       /**
+        * Admin::action_itemdelete()
+        * Delete item
+        * 
+        * @param       Void
+        * @return      Void
+        */
+       static private function action_itemdelete()
+       {
+               global $member, $manager;
+               
+               $itemid = intRequestVar('itemid');
+               
+               // only allow if user is allowed to alter item
+               $member->canAlterItem($itemid) or self::disallow();
+               
+               if ( !$manager->existsItem($itemid,1,1) )
+               {
+                       self::error(_ERROR_NOSUCHITEM);
+                       return;
+               }
+               
+               self::$skin->parse('itemdelete');
+               return;
+       }
+       
+       /**
+        * Admin::action_itemdeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_itemdeleteconfirm()
+       {
+               global $member, $manager;
+               
+               $itemid = intRequestVar('itemid');
+               
+               // only allow if user is allowed to alter item
+               $member->canAlterItem($itemid) or self::disallow();
+               
+               // get item first
+               $item =& $manager->getItem($itemid, 1, 1);
+               
+               // delete item (note: some checks will be performed twice)
+               self::deleteOneItem($item['itemid']);
+               
+               self::action_itemlist($item['blogid']);
+               return;
+       }
+       
+       /**
+        * Admin::deleteOneItem()
+        * Deletes one item and returns error if something goes wrong
+        * 
+        * @param       integer $itemid ID for item
+        * @return      void
+        */
+       static public function deleteOneItem($itemid)
+       {
+               global $member, $manager;
+               
+               // only allow if user is allowed to alter item (also checks if itemid exists)
+               if ( !$member->canAlterItem($itemid) )
+               {
+                       return _ERROR_DISALLOWED;
+               }
+               
+               // need to get blogid before the item is deleted
+               $item =& $manager->getItem($itemid, 1, 1);
+               
+               $manager->loadClass('ITEM');
+               Item::delete($item['itemid']);
+               
+               // update blog's futureposted
+               self::updateFuturePosted($item['itemid']);
+               return;
+       }
+       
+       /**
+        * Admin::updateFuturePosted()
+        * Update a blog's future posted flag
+        * 
+        * @param integer $blogid
+        * @return      void
+        */
+       static private function updateFuturePosted($blogid)
+       {
+               global $manager;
+               
+               $blogid                 =  intval($blogid);
+               $blog                   =& $manager->getBlog($blogid);
+               $currenttime    =  $blog->getCorrectTime(time());
+               
+               $query = "SELECT * FROM %s WHERE iblog=%d AND iposted=0 AND itime>'%s'";
+               $query = sprintf($query, sql_table('item'), (integer) $blogid, i18n::formatted_datetime('mysql', $currenttime));
+               $result = DB::getResult($query);
+               
+               if ( $result->rowCount() > 0 )
+               {
+                               $blog->setFuturePost();
+               }
+               else
+               {
+                               $blog->clearFuturePost();
+               }
+               return;
+       }
 
-        // generate the add-item form
-        $formfactory = new PAGEFACTORY($blogid);
-        $formfactory->createAddForm('admin');
+       /**
+        * Admin::action_itemmove()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_itemmove()
+       {
+               global $member, $manager;
+               
+               $itemid = intRequestVar('itemid');
+               
+               $member->canAlterItem($itemid) or self::disallow();
+               
+               self::$skin->parse('itemmove');
+               return;
+       }
+       
+       /**
+        * Admin::action_itemmoveto()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_itemmoveto()
+       {
+               global $member, $manager;
+               
+               $itemid = intRequestVar('itemid');
+               $catid = requestVar('catid');
+               
+               // create new category if needed
+               if ( i18n::strpos($catid,'newcat') === 0 )
+               {
+                       // get blogid
+                       list($blogid) = sscanf($catid,'newcat-%d');
+                       
+                       // create
+                       $blog =& $manager->getBlog($blogid);
+                       $catid = $blog->createNewCategory();
+                       
+                       // show error when sth goes wrong
+                       if ( !$catid )
+                       {
+                               self::doError(_ERROR_CATCREATEFAIL);
+                       }
+               }
+               
+               // only allow if user is allowed to alter item
+               $member->canUpdateItem($itemid, $catid) or self::disallow();
+               
+               $old_blogid = getBlogIDFromItemId($itemid);
+               
+               Item::move($itemid, $catid);
+               
+               // set the futurePosted flag on the blog
+               self::updateFuturePosted(getBlogIDFromItemId($itemid));
+               
+               // reset the futurePosted in case the item is moved from one blog to another
+               self::updateFuturePosted($old_blogid);
+               
+               if ( $catid != intRequestVar('catid') )
+               {
+                       self::action_categoryedit($catid, $blog->getID());
+               }
+               else
+               {
+                       self::action_itemlist(getBlogIDFromCatID($catid));
+               }
+               return;
+       }
+       
+       /**
+        * Admin::moveOneItem()
+        * Moves one item to a given category (category existance should be checked by caller)
+        * errors are returned
+        * 
+        * @param       integer $itemid         ID for item
+        * @param       integer $destCatid      ID for category to which the item will be moved
+        * @return      void
+        */
+       static public function moveOneItem($itemid, $destCatid)
+       {
+               global $member;
+               
+               // only allow if user is allowed to move item
+               if ( !$member->canUpdateItem($itemid, $destCatid) )
+               {
+                       return _ERROR_DISALLOWED;
+               }
+               
+               Item::move($itemid, $destCatid);
+               return;
+       }
+       
+       /**
+        * Admin::action_additem()
+        * Adds a item to the chosen blog
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_additem()
+       {
+               global $manager, $CONF;
+               
+               $manager->loadClass('ITEM');
+               
+               $result = Item::createFromRequest();
+               
+               if ( $result['status'] == 'error' )
+               {
+                       self::error($result['message']);
+                       return;
+               }
+               
+               $item =& $manager->getItem($result['itemid'], 0, 0);
+               
+               if ( $result['status'] == 'newcategory' )
+               {
+                       $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . $item['blogid']);
+                       self::action_categoryedit($result['catid'], $item['blogid'], $distURI);
+               }
+               else
+               {
+                       $methodName = 'action_itemlist';
+                       self::action_itemlist($item['blogid']);
+               }
+               return;
+       }
+       
+       /**
+        * Admin::action_commentedit()
+        * Allows to edit previously made comments
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_commentedit()
+       {
+               global $member, $manager;
+               
+               $commentid = intRequestVar('commentid');
+               
+               $member->canAlterComment($commentid) or self::disallow();
+               
+               $comment = Comment::getComment($commentid);
+               $data = array('comment' => &$comment);
+               $manager->notify('PrepareCommentForEdit', $data);
+               
+               self::$contents = $comment;
+               self::$skin->parse('commentedit');
+               return;
+       }
+       
+       /**
+        * Admin::action_commentupdate()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_commentupdate()
+       {
+               global $member, $manager;
+               
+               $commentid = intRequestVar('commentid');
+               
+               $member->canAlterComment($commentid) or self::disallow();
+               
+               $url    = postVar('url');
+               $email  = postVar('email');
+               $body   = postVar('body');
+               
+               // intercept words that are too long
+               if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
+               {
+                       self::error(_ERROR_COMMENT_LONGWORD);
+                       return;
+               }
+               
+               // check length
+               if ( i18n::strlen($body) < 3 )
+               {
+                       self::error(_ERROR_COMMENT_NOCOMMENT);
+                       return;
+               }
+               
+               if ( i18n::strlen($body) > 5000 )
+               {
+                       self::error(_ERROR_COMMENT_TOOLONG);
+                       return;
+               }
+               
+               // prepare body
+               $body = Comment::prepareBody($body);
+               
+               // call plugins
+               $data = array(
+                       'body' => &$body
+               );
+               $manager->notify('PreUpdateComment', $data);
+               
+               $query = "UPDATE %s SET cmail=%s, cemail=%s, cbody=%s WHERE cnumber=%d;";
+               $query = sprintf($query, sql_table('comment'), DB::quoteValue($url), DB::quoteValue($email), DB::quoteValue($body), (integer) $commentid);
+               DB::execute($query);
+               
+               // get itemid
+               $query = "SELECT citem FROM %s WHERE cnumber=%d;";
+               $query = sprintf($query, sql_table('comment'), (integer) $commentid);
+               
+               $itemid = DB::getValue($query);
+               
+               if ( $member->canAlterItem($itemid) )
+               {
+                       self::action_itemcommentlist($itemid);
+               }
+               else
+               {
+                       self::action_browseowncomments();
+               }
+               return;
+       }
+       
+       /**
+        * Admin::action_commentdelete()
+        * Update comment
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_commentdelete()
+       {
+               global $member, $manager;
+               
+               $commentid = intRequestVar('commentid');
+               $member->canAlterComment($commentid) or self::disallow();
+               
+               self::$skin->parse('commentdelete');
+               return;
+       }
+       
+       /**
+        * Admin::action_commentdeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_commentdeleteconfirm()
+       {
+               global $member;
+               
+               $commentid = intRequestVar('commentid');
+               
+               // get item id first
+               $query = "SELECT citem FROM %s WHERE cnumber=%d;";
+               $query = sprintf($query, sql_table('comment'), (integer) $commentid);
+               
+               $itemid = DB::getValue($query);
+               
+               $error = self::deleteOneComment($commentid);
+               if ( $error )
+               {
+                       self::doError($error);
+               }
+               
+               if ( $member->canAlterItem($itemid) )
+               {
+                       self::action_itemcommentlist($itemid);
+               }
+               else
+               {
+                       self::action_browseowncomments();
+               }
+               return;
+       }
+       
+       /**
+        * Admin::deleteOneComment()
+        * 
+        * @param       integer $commentid      ID for comment
+        * @return      void
+        */
+       static public function deleteOneComment($commentid)
+       {
+               global $member, $manager;
+               
+               $commentid = (integer) $commentid;
+               
+               if ( !$member->canAlterComment($commentid) )
+               {
+                       return _ERROR_DISALLOWED;
+               }
+               
+               $data = array(
+                       'commentid' => $commentid
+               );
+               
+               $manager->notify('PreDeleteComment', $data);
+               
+               // delete the comments associated with the item
+               $query = "DELETE FROM %s WHERE cnumber=%d;";
+               $query = sprintf($query, sql_table('comment'), (integer) $commentid);
+               DB::execute($query);
+               
+               $data = array(
+                       'commentid' => $commentid
+               );
+               
+               $manager->notify('PostDeleteComment', $data);
+               
+               return '';
+       }
+       
+       /**
+        * Admin::action_usermanagement()
+        * Usermanagement main
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_usermanagement()
+       {
+               global $member, $manager;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('usermanagement');
+               return;
+       }
+       
+       /**
+        * Admin::action_memberedit()
+        * Edit member settings
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_memberedit()
+       {
+               self::action_editmembersettings(intRequestVar('memberid'));
+               return;
+       }
+       
+       /**
+        * Admin::action_editmembersettings()
+        * 
+        * @param       integer $memberid       ID for member
+        * @return      void
+        * 
+        */
+       static private function action_editmembersettings($memberid = '')
+       {
+               global $member, $manager, $CONF;
+               
+               if ( $memberid == '' )
+               {
+                       $memberid = $member->getID();
+               }
+               
+               /* TODO: we should consider to use the other way insterad of this */
+               $_REQUEST['memberid'] = $memberid;
+               
+               // check if allowed
+               ($member->getID() == $memberid) or $member->isAdmin() or self::disallow();
+               
+               self::$extrahead .= "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/numbercheck.js)%>\"></script>\n";
+               
+               self::$skin->parse('editmembersettings');
+               return;
+       }
+       
+       /**
+        * Admin::action_changemembersettings()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_changemembersettings()
+       {
+               global $member, $CONF, $manager;
+               
+               $memberid = intRequestVar('memberid');
+               
+               // check if allowed
+               ($member->getID() == $memberid) or $member->isAdmin() or self::disallow();
+               
+               $name                   = trim(strip_tags(postVar('name')));
+               $realname               = trim(strip_tags(postVar('realname')));
+               $password               = postVar('password');
+               $repeatpassword = postVar('repeatpassword');
+               $email                  = strip_tags(postVar('email'));
+               $url                    = strip_tags(postVar('url'));
+               $adminskin              = intPostVar('adminskin');
+               $bookmarklet    = intPostVar('bookmarklet');
+               
+               // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
+               if ( !preg_match('#^https?://#', $url) )
+               {
+                       $url = 'http://' . $url;
+               }
+               
+               $admin          = postVar('admin');
+               $canlogin       = postVar('canlogin');
+               $notes          = strip_tags(postVar('notes'));
+               $locale         = postVar('locale');
+               
+               $mem =& $manager->getMember($memberid);
+               
+               if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
+               {
+                       if ( !isValidDisplayName($name) )
+                       {
+                               self::error(_ERROR_BADNAME);
+                               return;
+                       }
+                       
+                       if ( ($name != $mem->getDisplayName()) && Member::exists($name) )
+                       {
+                               self::error(_ERROR_NICKNAMEINUSE);
+                               return;
+                       }
+                       
+                       if ( $password != $repeatpassword )
+                       {
+                               self::error(_ERROR_PASSWORDMISMATCH);
+                               return;
+                       }
+                       
+                       if ( $password && (i18n::strlen($password) < 6) )
+                       {
+                               self::error(_ERROR_PASSWORDTOOSHORT);
+                               return;
+                       }
+                               
+                       if ( $password )
+                       {
+                               $pwdvalid = true;
+                               $pwderror = '';
+                               
+                               $data = array(
+                                       'password'     => $password,
+                                       'errormessage' => &$pwderror,
+                                       'valid'        => &$pwdvalid
+                               );
+                               $manager->notify('PrePasswordSet', $data);
+                               
+                               if ( !$pwdvalid )
+                               {
+                                       self::error($pwderror);
+                                       return;
+                               }
+                       }
+               }
+               
+               if ( !NOTIFICATION::address_validation($email) )
+               {
+                       self::error(_ERROR_BADMAILADDRESS);
+                       return;
+               }
+               if ( !$realname )
+               {
+                       self::error(_ERROR_REALNAMEMISSING);
+                       return;
+               }
+               if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
+               {
+                       self::error(_ERROR_NOSUCHTRANSLATION);
+                       return;
+               }
+               
+               // check if there will remain at least one site member with both the logon and admin rights
+               // (check occurs when taking away one of these rights from such a member)
+               if (    (!$admin && $mem->isAdmin() && $mem->canLogin())
+                       ||      (!$canlogin && $mem->isAdmin() && $mem->canLogin())
+                       )
+               {
+                       $r = DB::getResult('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
+                       if ( $r->rowCount() < 2 )
+                       {
+                               self::error(_ERROR_ATLEASTONEADMIN);
+                               return;
+                       }
+               }
+               
+               if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
+               {
+                       $mem->setDisplayName($name);
+                       if ( $password )
+                       {
+                               $mem->setPassword($password);
+                       }
+               }
+               
+               $oldEmail = $mem->getEmail();
+               
+               $mem->setRealName($realname);
+               $mem->setEmail($email);
+               $mem->setURL($url);
+               $mem->setNotes($notes);
+               $mem->setLocale($locale);
+               $mem->setAdminSkin($adminskin);
+               $mem->setBookmarklet($bookmarklet);
+
+               // only allow super-admins to make changes to the admin status
+               if ( $member->isAdmin() )
+               {
+                       $mem->setAdmin($admin);
+                       $mem->setCanLogin($canlogin);
+               }
+               
+               $autosave = postVar('autosave');
+               $mem->setAutosave($autosave);
+               
+               $mem->write();
+               
+               // store plugin options
+               $aOptions = requestArray('plugoption');
+               NucleusPlugin::apply_plugin_options($aOptions);
+               $data = array(
+                       'context'  => 'member',
+                       'memberid' => $memberid,
+                       'member'   => &$mem
+               );
+               $manager->notify('PostPluginOptionsUpdate', $data);
+               
+               // if email changed, generate new password
+               if ( $oldEmail != $mem->getEmail() )
+               {
+                       $mem->sendActivationLink('addresschange', $oldEmail);
+                       // logout member
+                       $mem->newCookieKey();
+                       
+                       // only log out if the member being edited is the current member.
+                       if ( $member->getID() == $memberid )
+                       {
+                               $member->logout();
+                       }
+                       self::action_login(_MSG_ACTIVATION_SENT, 0);
+                       return;
+               }
+               
+               if ( ($mem->getID() == $member->getID())
+                       && ($mem->getDisplayName() != $member->getDisplayName()) )
+               {
+                       $mem->newCookieKey();
+                       $member->logout();
+                       self::action_login(_MSG_LOGINAGAIN, 0);
+               }
+               else
+               {
+                       self::action_overview(_MSG_SETTINGSCHANGED);
+               }
+               return;
+       }
 
-        $this->pagefoot();
-    }
+       /**
+        * Admin::action_memberadd()
+        * 
+        * @param       void
+        * @return      void
+        * 
+        */
+       static private function action_memberadd()
+       {
+               global $member, $manager;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               if ( postVar('password') != postVar('repeatpassword') )
+               {
+                       self::error(_ERROR_PASSWORDMISMATCH);
+                       return;
+               }
+               
+               if ( i18n::strlen(postVar('password')) < 6 )
+               {
+                       self::error(_ERROR_PASSWORDTOOSHORT);
+                       return;
+               }
+               
+               $res = Member::create(
+                       postVar('name'),
+                       postVar('realname'),
+                       postVar('password'),
+                       postVar('email'),
+                       postVar('url'),
+                       postVar('admin'),
+                       postVar('canlogin'),
+                       postVar('notes')
+               );
+               
+               if ( $res != 1 )
+               {
+                       self::error($res);
+                       return;
+               }
+               
+               // fire PostRegister event
+               $newmem = new Member();
+               $newmem->readFromName(postVar('name'));
+               $data = array(
+                       'member' => &$newmem
+               );
+               $manager->notify('PostRegister', $data);
+               
+               self::action_usermanagement();
+               return;
+       }
+       
+       /**
+        * Admin::action_forgotpassword()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_forgotpassword()
+       {
+               self::$skin->parse('forgotpassword');
+               return;
+       }
+       
+       /**
+        * Admin::action_activate()
+        * Account activation
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_activate()
+       {
+               $key = getVar('key');
+               self::showActivationPage($key);
+               return;
+       }
+       
+       /**
+        * Admin::showActivationPage()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function showActivationPage($key, $message = '')
+       {
+               global $manager;
+               
+               // clean up old activation keys
+               Member::cleanupActivationTable();
+               
+               // get activation info
+               $info = Member::getActivationInfo($key);
+               
+               if ( !$info )
+               {
+                       self::error(_ERROR_ACTIVATE);
+                       return;
+               }
+               
+               $mem =& $manager->getMember($info->vmember);
+               
+               if ( !$mem )
+               {
+                       self::error(_ERROR_ACTIVATE);
+                       return;
+               }
+               
+               /* TODO: we should consider to use the other way insterad of this */
+               $_POST['ackey']                                 = $key;
+               $_POST['bNeedsPasswordChange']  = TRUE;
+               
+               self::$headMess = $message;
+               self::$skin->parse('activate');
+               return;
+       }
+       
+       /**
+        * Admin::action_activatesetpwd()
+        * Account activation - set password part
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_activatesetpwd()
+       {
+               global $manager;
+               $key = postVar('key');
+               
+               // clean up old activation keys
+               Member::cleanupActivationTable();
+               
+               // get activation info
+               $info = Member::getActivationInfo($key);
+               
+               if ( !$info || ($info->type == 'addresschange') )
+               {
+                       return self::showActivationPage($key, _ERROR_ACTIVATE);
+               }
+               
+               $mem =& $manager->getMember($info->vmember);
+               
+               if ( !$mem )
+               {
+                       return self::showActivationPage($key, _ERROR_ACTIVATE);
+               }
+               
+               $password               = postVar('password');
+               $repeatpassword = postVar('repeatpassword');
+               
+               if ( $password != $repeatpassword )
+               {
+                       return self::showActivationPage($key, _ERROR_PASSWORDMISMATCH);
+               }
+               
+               if ( $password && (i18n::strlen($password) < 6) )
+               {
+                       return self::showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
+               }
+                       
+               if ( $password )
+               {
+                       $pwdvalid = true;
+                       $pwderror = '';
+                       
+                       $data = array(
+                               'password'              => $password,
+                               'errormessage'  => &$pwderror,
+                               'valid'                 => &$pwdvalid
+                       );
+                       $manager->notify('PrePasswordSet', $data);
+                       if ( !$pwdvalid )
+                       {
+                               return self::showActivationPage($key,$pwderror);
+                       }
+               }
+               
+               $error = '';
+               
+               $data = array(
+                       'type'   => 'activation',
+                       'member' => $mem,
+                       'error'  => &$error
+               );
+               $manager->notify('ValidateForm', $data);
+               if ( $error != '' )
+               {
+                       return self::showActivationPage($key, $error);
+               }
+               
+               // set password
+               $mem->setPassword($password);
+               $mem->write();
+               
+               // do the activation
+               Member::activate($key);
+               
+               self::$skin->parse('activatesetpwd');
+               return;
+       }
+       
+       /**
+        * Admin::action_manageteam()
+        * Manage team
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_manageteam()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               // check if allowed
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               self::$skin->parse('manageteam');
+               return;
+       }
+       
+       /**
+        * Admin::action_teamaddmember()
+        * Add member to team
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_teamaddmember()
+       {
+               global $member, $manager;
+               
+               $memberid       = intPostVar('memberid');
+               $blogid         = intPostVar('blogid');
+               $admin          = intPostVar('admin');
+               
+               // check if allowed
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $blog =& $manager->getBlog($blogid);
+               if ( !$blog->addTeamMember($memberid, $admin) )
+               {
+                       self::error(_ERROR_ALREADYONTEAM);
+                       return;
+               }
+               
+               self::action_manageteam();
+               return;
+       }
+       
+       /**
+        * Admin::action_teamdelete()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_teamdelete()
+       {
+               global $member, $manager;
+               
+               $memberid       = intRequestVar('memberid');
+               $blogid         = intRequestVar('blogid');
+               
+               // check if allowed
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $teammem =& $manager->getMember($memberid);
+               $blog =& $manager->getBlog($blogid);
+               
+               self::$skin->parse('teamdelete');
+               return;
+       }
+       
+       /**
+        * Admin::action_teamdeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_teamdeleteconfirm()
+       {
+               global $member;
+               
+               $memberid = intRequestVar('memberid');
+               $blogid = intRequestVar('blogid');
+               
+               $error = self::deleteOneTeamMember($blogid, $memberid);
+               if ( $error )
+               {
+                       self::error($error);
+                       return;
+               }
+               self::action_manageteam();
+               return;
+       }
+       
+       /**
+        * Admin::deleteOneTeamMember()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static public function deleteOneTeamMember($blogid, $memberid)
+       {
+               global $member, $manager;
+               
+               $blogid   = intval($blogid);
+               $memberid = intval($memberid);
+               
+               // check if allowed
+               if ( !$member->blogAdminRights($blogid) )
+               {
+                       return _ERROR_DISALLOWED;
+               }
+               
+               // check if: - there remains at least one blog admin
+               //           - (there remains at least one team member)
+               $tmem =& $manager->getMember($memberid);
+               
+               
+               $data = array(
+                       'member' => &$tmem,
+                       'blogid' => $blogid
+               );
+               $manager->notify('PreDeleteTeamMember', $data);
+               
+               if ( $tmem->isBlogAdmin($blogid) )
+               {
+                       /* TODO: why we did double check? */
+                       // check if there are more blog members left and at least one admin
+                       // (check for at least two admins before deletion)
+                       $query = "SELECT * FROM %s WHERE tblog=%d and tadmin=1;";
+                       $query = sprintf($query, sql_table('team'), (integer) $blogid);
+                       $r     = DB::getResult($query);
+                       if ( $r->rowCount() < 2 )
+                       {
+                               return _ERROR_ATLEASTONEBLOGADMIN;
+                       }
+               }
+               
+               $query = "DELETE FROM %s WHERE tblog=%d AND tmember=%d;";
+               $query = sprintf($query, sql_table('team'), (integer) $blogid, (integer) $memberid);
+               DB::execute($query);
+               
+               $data = array(
+                       'member' => &$tmem,
+                       'blogid' => $blogid
+               );
+               $manager->notify('PostDeleteTeamMember', $data);
+               
+               return '';
+       }
+       
+       /**
+        * Admin::action_teamchangeadmin()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_teamchangeadmin()
+       {
+               global $manager, $member;
+               
+               $blogid         = intRequestVar('blogid');
+               $memberid       = intRequestVar('memberid');
+               
+               // check if allowed
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $mem =& $manager->getMember($memberid);
+               
+               // don't allow when there is only one admin at this moment
+               if ( $mem->isBlogAdmin($blogid) )
+               {
+                       $query = "SELECT * FROM %s WHERE tblog=%d AND tadmin=1;";
+                       $query = sprintf($query, sql_table('team'), (integer) $blogid);
+                       $r = DB::getResult($query);
+                       if ( $r->rowCount() == 1 )
+                       {
+                               self::error(_ERROR_ATLEASTONEBLOGADMIN);
+                               return;
+                       }
+               }
+               
+               if ( $mem->isBlogAdmin($blogid) )
+               {
+                       $newval = 0;
+               }
+               else
+               {
+                       $newval = 1;
+               }
+               
+               $query = "UPDATE %s SET tadmin=%d WHERE tblog=%d and tmember=%d;";
+               $query = sprintf($query, (integer) $blogid, (integer) $newval, (integer) $blogid, (integer) $memberid);
+               DB::execute($query);
+               
+               // only show manageteam if member did not change its own admin privileges
+               if ( $member->isBlogAdmin($blogid) )
+               {
+                       self::action_manageteam();
+               }
+               else
+               {
+                       self::action_overview(_MSG_ADMINCHANGED);
+               }
+               return;
+       }
+       
+       /**
+        * Admin::action_blogsettings()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_blogsettings()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               // check if allowed
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $blog =& $manager->getBlog($blogid);
+               
+               self::$extrahead .= "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/numbercheck.js)%>\"></script>\n";
+               
+               self::$skin->parse('blogsettings');
+               return;
+       }
+       
+       /**
+        * Admin::action_categorynew()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_categorynew()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $cname = postVar('cname');
+               $cdesc = postVar('cdesc');
+               
+               if ( !isValidCategoryName($cname) )
+               {
+                       self::error(_ERROR_BADCATEGORYNAME);
+                       return;
+               }
+               
+               $query = "SELECT * FROM %s WHERE cname=%s AND cblog=%d;";
+               $query = sprintf($query, sql_table('category'), DB::quoteValue($cname), (integer) $blogid);
+               $res = DB::getResult($query);
+               if ( $res->rowCount() > 0 )
+               {
+                       self::error(_ERROR_DUPCATEGORYNAME);
+                       return;
+               }
+               
+               $blog           =& $manager->getBlog($blogid);
+               $newCatID       =  $blog->createNewCategory($cname, $cdesc);
+               
+               self::action_blogsettings();
+               return;
+       }
+       
+       /**
+        * Admin::action_categoryedit()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_categoryedit($catid = '', $blogid = '', $desturl = '')
+       {
+               global $member, $manager;
+               
+               if ( $blogid == '' )
+               {
+                       $blogid = intGetVar('blogid');
+               }
+               else
+               {
+                       $blogid = intval($blogid);
+               }
+               if ( $catid == '' )
+               {
+                       $catid = intGetVar('catid');
+               }
+               else
+               {
+                       $catid = intval($catid);
+               }
+               
+               /* TODO: we should consider to use the other way insterad of this */
+               $_REQUEST['blogid']             = $blogid;
+               $_REQUEST['catid']              = $catid;
+               $_REQUEST['desturl']    = $desturl;
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               self::$extrahead .= "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/numbercheck.js)%>\"></script>\n";
+               
+               self::$skin->parse('categoryedit');
+               return;
+       }
+       
+       /**
+        * Admin::action_categoryupdate()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_categoryupdate()
+       {
+               global $member, $manager;
+               
+               $blogid         = intPostVar('blogid');
+               $catid          = intPostVar('catid');
+               $cname          = postVar('cname');
+               $cdesc          = postVar('cdesc');
+               $desturl        = postVar('desturl');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               if ( !isValidCategoryName($cname) )
+               {
+                       self::error(_ERROR_BADCATEGORYNAME);
+                       return;
+               }
+               
+               $query  = "SELECT * FROM %s WHERE cname=%s AND cblog=%d AND not(catid=%d);";
+               $query  = sprintf($query, sql_table('category'), DB::quoteValue($cname), (integer) $blogid, (integer) $catid);
+               $res    = DB::getResult($query);
+               if ( $res->rowCount() > 0 )
+               {
+                       self::error(_ERROR_DUPCATEGORYNAME);
+                       return;
+               }
+               
+               $query =  "UPDATE %s SET cname=%s, cdesc=%s WHERE catid=%d;";
+               $query = sprintf($query, sql_table('category'), DB::quoteValue($cname), DB::quoteValue($cdesc), (integer) $catid);
+               DB::execute($query);
+               
+               // store plugin options
+               $aOptions = requestArray('plugoption');
+               NucleusPlugin::apply_plugin_options($aOptions);
+               $data = array(
+                       'context'       => 'category',
+                       'catid'         => $catid
+               );
+               $manager->notify('PostPluginOptionsUpdate', $data);
+               
+               if ( $desturl )
+               {
+                       redirect($desturl);
+                       return;
+               }
+               
+               self::action_blogsettings();
+               
+               return;
+       }
+       
+       /**
+        * Admin::action_categorydelete()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_categorydelete()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               $catid  = intRequestVar('catid');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $blog =& $manager->getBlog($blogid);
+               
+               // check if the category is valid
+               if ( !$blog->isValidCategory($catid) )
+               {
+                       self::error(_ERROR_NOSUCHCATEGORY);
+                       return;
+               }
+               
+               // don't allow deletion of default category
+               if ( $blog->getDefaultCategory() == $catid )
+               {
+                       self::error(_ERROR_DELETEDEFCATEGORY);
+                       return;
+               }
+               
+               // check if catid is the only category left for blogid
+               $query = "SELECT catid FROM %s WHERE cblog=%d;";
+               $query = sprintf($query, sql_table('category'), $blogid);
+               $res = DB::getResult($query);
+               if ( $res->rowCount() == 1 )
+               {
+                       self::error(_ERROR_DELETELASTCATEGORY);
+                       return;
+               }
+               
+               self::$skin->parse('categorydelete');
+>>>>>>> skinnable-master
+               return;
+       }
+       
+       /**
+<<<<<<< HEAD
+        * Admin::action_browseownitems()
+=======
+        * Admin::action_categorydeleteconfirm()
+>>>>>>> skinnable-master
+        * 
+        * @param       void
+        * @return      void
+        */
+<<<<<<< HEAD
+       public function action_browseownitems()
+       {
+               global $member, $manager, $CONF;
+               
+               $this->pagehead();
+               
+               echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
+               echo '<h2>' . _ITEMLIST_YOUR . "</h2>\n";
+               
+               // start index
+               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;
+                       }
+               }
+               
+               $search = postVar('search');    // search through items
+               
+               $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
+                      . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
+                      . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
+               
+               if ( $search )
+               {
+                       $query .= " and ((ititle LIKE " . DB::quoteValue('%'.$search.'%') . ") or (ibody LIKE " . DB::quoteValue('%'.$search.'%') . ") or (imore LIKE " . DB::quoteValue('%'.$search.'%') . "))";
+               }
+               
+               $query .= ' ORDER BY itime DESC'
+                       . " LIMIT $start, $amount";
+               
+               $template['content'] = 'itemlist';
+               $template['now'] = time();
+               
+               $manager->loadClass("ENCAPSULATE");
+               $navList = new NavList('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
+               $navList->showBatchList('item',$query,'table',$template);
+               
+               $this->pagefoot();
+=======
+       static private function action_categorydeleteconfirm()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               $catid  = intRequestVar('catid');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $error = self::deleteOneCategory($catid);
+               if ( $error )
+               {
+                       self::error($error);
+                       return;
+               }
+               
+               self::action_blogsettings();
+               return;
+       }
+       
+       /**
+        * Admin::deleteOneCategory()
+        * Delete a category by its id
+        * 
+        * @param       String  $catid  category id for deleting
+        * @return      Void
+        */
+       static public function deleteOneCategory($catid)
+       {
+               global $manager, $member;
+               
+               $catid  = intval($catid);
+               $blogid = getBlogIDFromCatID($catid);
+               
+               if ( !$member->blogAdminRights($blogid) )
+               {
+                       return ERROR_DISALLOWED;
+               }
+               
+               // get blog
+               $blog =& $manager->getBlog($blogid);
+               
+               // check if the category is valid
+               if ( !$blog || !$blog->isValidCategory($catid) )
+               {
+                       return _ERROR_NOSUCHCATEGORY;
+               }
+               
+               $destcatid = $blog->getDefaultCategory();
+               
+               // don't allow deletion of default category
+               if ( $blog->getDefaultCategory() == $catid )
+               {
+                       return _ERROR_DELETEDEFCATEGORY;
+               }
+               
+               // check if catid is the only category left for blogid
+               $query = "SELECT catid FROM %s WHERE cblog=%d;";
+               $query = sprintf($query, sql_table('category'), (integer) $blogid);
+               
+               $res = DB::getResult($query);
+               if ( $res->rowCount() == 1 )
+               {
+                       return _ERROR_DELETELASTCATEGORY;
+               }
+               
+               $data = array('catid' => $catid);
+               $manager->notify('PreDeleteCategory', $data);
+               
+               // change category for all items to the default category
+               $query = "UPDATE %s SET icat=%d WHERE icat=%d;";
+               $query =sprintf($query, sql_table('item'), (integer) $destcatid, (integer) $catid);
+               DB::execute($query);
+               
+               // delete all associated plugin options
+               NucleusPlugin::delete_option_values('category', (integer) $catid);
+               
+               // delete category
+               $query = "DELETE FROM %s WHERE catid=%d;";
+               $query = sprintf($query, sql_table('category'), (integer) $catid);
+               DB::execute($query);
+               
+               $data = array('catid' => $catid);
+               $manager->notify('PostDeleteCategory', $data);
+>>>>>>> skinnable-master
+               return;
+       }
+       
+       /**
+<<<<<<< HEAD
+        * Admin::action_itemcommentlist()
+        * 
+        * Show all the comments for a given item
+        * @param       integer $itemid ID for item
+        * @return      void
+        */
+       public function action_itemcommentlist($itemid = '')
+       {
+               global $member, $manager, $CONF;
+               
+               if ( $itemid == '' )
+               {
+                       $itemid = intRequestVar('itemid');
+               }
+               
+               // only allow if user is allowed to alter item
+               $member->canAlterItem($itemid) or $this->disallow();
+               
+               $blogid = getBlogIdFromItemId($itemid);
+               
+               $this->pagehead();
+               
+               // start index
+               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;
+                       }
+               }
+               
+               $search = postVar('search');
+               
+               echo '<p>(<a href="index.php?action=itemlist&amp;blogid=' . $blogid . '">' . _BACKTOOVERVIEW . "</a>)</p>\n";
+               echo '<h2>',_COMMENTS,'</h2>';
+               
+               $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
+               
+               if ( $search )
+               {
+                       $query .= " and cbody LIKE " . DB::quoteValue('%'.$search.'%');
+               }
+               
+               $query .= ' ORDER BY ctime ASC'
+                       . " LIMIT $start,$amount";
+               
+               $template['content'] = 'commentlist';
+               $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
+               
+               $manager->loadClass("ENCAPSULATE");
+               $navList = new NavList('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
+               $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
+               
+               $this->pagefoot();
+=======
+        * Admin::moveOneCategory()
+        * Delete a category by its id
+        * 
+        * @param       int     $catid          category id for move
+        * @param       int     $destblogid     blog id for destination
+        * @return      void
+        */
+       static public function moveOneCategory($catid, $destblogid)
+       {
+               global $manager, $member;
+               $catid      = intval($catid);
+               $destblogid = intval($destblogid);
+               $blogid     = getBlogIDFromCatID($catid);
+               // mover should have admin rights on both blogs
+               if (!$member->blogAdminRights($blogid)) {
+                       return _ERROR_DISALLOWED;
+               }
+               if (!$member->blogAdminRights($destblogid)) {
+                       return _ERROR_DISALLOWED;
+               }
+               // cannot move to self
+               if ($blogid == $destblogid) {
+                       return _ERROR_MOVETOSELF;
+               }
+               // get blogs
+               $blog     =& $manager->getBlog($blogid);
+               $destblog =& $manager->getBlog($destblogid);
+               // check if the category is valid
+               if (!$blog || !$blog->isValidCategory($catid)) {
+                       return _ERROR_NOSUCHCATEGORY;
+               }
+               // don't allow default category to be moved
+               if ($blog->getDefaultCategory() == $catid) {
+                       return _ERROR_MOVEDEFCATEGORY;
+               }
+               $data = array(
+                       'catid'                 => &$catid,
+                       'sourceblog'    => &$blog,
+                       'destblog'              => &$destblog
+               );
+               $manager->notify('PreMoveCategory', $data);
+               // update comments table (cblog)
+               $query = 'SELECT '
+               . '    inumber '
+               . 'FROM '
+               .      sql_table('item') . ' '
+               . 'WHERE '
+               . '    icat = %d';
+               $items = sql_query(sprintf($query, $catid));
+               while ($oItem = sql_fetch_object($items)) {
+                       $query = 'UPDATE '
+                       .      sql_table('comment') . ' '
+                       . 'SET '
+                       . '    cblog = %d' . ' '
+                       . 'WHERE '
+                       . '    citem = %d';
+                       sql_query(sprintf($query, $destblogid, $oItem->inumber));
+               }
+       
+               // update items (iblog)
+               $query = 'UPDATE '
+               .      sql_table('item') . ' '
+               . 'SET '
+               . '    iblog = %d '
+               . 'WHERE '
+               . '    icat = %d';
+               sql_query(sprintf($query, $destblogid, $catid));
+       
+               // move category
+               $query = 'UPDATE '
+               .      sql_table('category') . ' '
+               . 'SET '
+               . '    cblog = %d' . ' '
+               . 'WHERE '
+               . '    catid = %d';
+               sql_query(sprintf($query, $destblogid, $catid));
+               
+               $data = array(
+                       'catid'                 => &$catid,
+                       'sourceblog'    => &$blog,
+                       'destblog'              =>  $destblog
+               );
+               $manager->notify('PostMoveCategory', $data);
+               return;
+       }
 
-    /**
-     * @todo document this
-     */
-    function action_itemedit()
+       /**
+        * Admin::action_blogsettingsupdate
+        * Updating blog settings
+        * 
+        * @param       Void
+        * @return      Void
+        */
+       static private function action_blogsettingsupdate()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $blog =& $manager->getBlog($blogid);
+               
+               $notify_address = trim(postVar('notify'));
+               $shortname              = trim(postVar('shortname'));
+               $updatefile             = trim(postVar('update'));
+               
+               $notifyComment  = intPostVar('notifyComment');
+               $notifyVote             = intPostVar('notifyVote');
+               $notifyNewItem  = intPostVar('notifyNewItem');
+               
+               if ( $notifyComment == 0 )
+               {
+                       $notifyComment = 1;
+               }
+               if ( $notifyVote == 0 )
+               {
+                       $notifyVote = 1;
+               }
+               if ( $notifyNewItem == 0 )
+               {
+                       $notifyNewItem = 1;
+               }
+               $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
+               
+               if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )
+               {
+                       self::error(_ERROR_BADNOTIFY);
+                       return;
+               }
+               
+               if ( !isValidShortName($shortname) )
+               {
+                       self::error(_ERROR_BADSHORTBLOGNAME);
+                       return;
+               }
+               
+               if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )
+               {
+                       self::error(_ERROR_DUPSHORTBLOGNAME);
+                       return;
+               }
+               // check if update file is writable
+               if ( $updatefile && !is_writeable($updatefile) )
+               {
+                       self::error(_ERROR_UPDATEFILE);
+                       return;
+               }
+               
+               $blog->setName(trim(postVar('name')));
+               $blog->setShortName($shortname);
+               $blog->setNotifyAddress($notify_address);
+               $blog->setNotifyType($notifyType);
+               $blog->setMaxComments(postVar('maxcomments'));
+               $blog->setCommentsEnabled(postVar('comments'));
+               $blog->setTimeOffset(postVar('timeoffset'));
+               $blog->setUpdateFile($updatefile);
+               $blog->setURL(trim(postVar('url')));
+               $blog->setDefaultSkin(intPostVar('defskin'));
+               $blog->setDescription(trim(postVar('desc')));
+               $blog->setPublic(postVar('public'));
+               $blog->setConvertBreaks(intPostVar('convertbreaks'));
+               $blog->setAllowPastPosting(intPostVar('allowpastposting'));
+               $blog->setDefaultCategory(intPostVar('defcat'));
+               $blog->setSearchable(intPostVar('searchable'));
+               $blog->setEmailRequired(intPostVar('reqemail'));
+               $blog->writeSettings();
+               
+               // store plugin options
+               $aOptions = requestArray('plugoption');
+               NucleusPlugin::apply_plugin_options($aOptions);
+               
+               $data = array(
+                       'context' => 'blog',
+                       'blogid'  => $blogid,
+                       'blog'    => &$blog
+               );
+               $manager->notify('PostPluginOptionsUpdate', $data);
+               
+               self::action_overview(_MSG_SETTINGSCHANGED);
+>>>>>>> skinnable-master
+               return;
+       }
+       
+       /**
+<<<<<<< HEAD
+        * Admin::action_browseowncomments()
+        * Browse own comments
+=======
+        * Admin::action_deleteblog()
+>>>>>>> skinnable-master
+        * 
+        * @param       void
+        * @return      void
+        */
+<<<<<<< HEAD
+       public function action_browseowncomments()
+       {
+               global $member, $manager, $CONF;
+               
+               // start index
+               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;
+                       }
+               }
+               
+               $search = postVar('search');
+               
+               $query =  'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
+               
+               if ( $search )
+               {
+                       $query .= " and cbody LIKE " . DB::quoteValue('%'.$search.'%');
+               }
+               
+               $query .= ' ORDER BY ctime DESC'
+                       . " LIMIT $start,$amount";
+               
+               $this->pagehead();
+               
+               echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
+               echo '<h2>' . _COMMENTS_YOUR . "</h2>\n";
+               
+               $template['content'] = 'commentlist';
+               $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
+               
+               $manager->loadClass("ENCAPSULATE");
+               $navList = new NavList('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
+               $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
+               
+               $this->pagefoot();
+=======
+       static private function action_deleteblog()
+       {
+               global $member, $CONF, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               // check if blog is default blog
+               if ( $CONF['DefaultBlog'] == $blogid )
+               {
+                       self::error(_ERROR_DELDEFBLOG);
+                       return;
+               }
+               
+               $blog =& $manager->getBlog($blogid);
+               
+               self::$skin->parse('deleteblog');
+               return;
+       }
+       
+       /**
+        * Admin::action_deleteblogconfirm()
+        * Delete Blog
+        * 
+        * @param       Void
+        * @return      Void
+        */
+       static private function action_deleteblogconfirm()
+       {
+               global $member, $CONF, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               $data = array('blogid' => $blogid);
+               $manager->notify('PreDeleteBlog', $data);
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               // check if blog is default blog
+               if ( $CONF['DefaultBlog'] == $blogid )
+               {
+                       self::error(_ERROR_DELDEFBLOG);
+                       return;
+               }
+               
+               // delete all comments
+               $query = 'DELETE FROM ' . sql_table('comment') . ' WHERE cblog='.$blogid;
+               DB::execute($query);
+               
+               // delete all items
+               $query = 'DELETE FROM ' . sql_table('item') . ' WHERE iblog=' . $blogid;
+               DB::execute($query);
+               
+               // delete all team members
+               $query = 'DELETE FROM ' . sql_table('team') . ' WHERE tblog=' . $blogid;
+               DB::execute($query);
+               
+               // delete all bans
+               $query = 'DELETE FROM ' . sql_table('ban') . ' WHERE blogid=' . $blogid;
+               DB::execute($query);
+               
+               // delete all categories
+               $query = 'DELETE FROM ' . sql_table('category') . ' WHERE cblog=' . $blogid;
+               DB::execute($query);
+               
+               // delete all associated plugin options
+               NucleusPlugin::delete_option_values('blog', $blogid);
+               
+               // delete the blog itself
+               $query = 'DELETE FROM ' . sql_table('blog') . ' WHERE bnumber=' . $blogid;
+               DB::execute($query);
+               
+               $data = array('blogid' => $blogid);
+               $manager->notify('PostDeleteBlog', $data);
+               
+               self::action_overview(_DELETED_BLOG);
+>>>>>>> skinnable-master
+               return;
+       }
+       
+       /**
+<<<<<<< HEAD
+        * Admin::action_blogcommentlist()
+        * 
+        * Browse all comments for a weblog
+        * @param       integer $blogid ID for weblog
+        * @return      void
+        */
+       function action_blogcommentlist($blogid = '')
+       {
+               global $member, $manager, $CONF;
+               
+               if ( $blogid == '' )
+               {
+                       $blogid = intRequestVar('blogid');
+               }
+               else
+               {
+                       $blogid = intval($blogid);
+               }
+               
+               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
+               
+               // start index
+               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;
+                       }
+               }
+               
+               $search = postVar('search');            // search through comments
+               
+               $query =  'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
+               
+               if ( $search != '' )
+               {
+                       $query .= " and cbody LIKE " . DB::quoteValue('%'.$search.'%');
+               }
+               
+               $query .= ' ORDER BY ctime DESC'
+                       . " LIMIT $start,$amount";
+               
+               $blog =& $manager->getBlog($blogid);
+               
+               $this->pagehead();
+               
+               echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
+               echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
+               
+               $template['content'] = 'commentlist';
+               $template['canAddBan'] = $member->blogAdminRights($blogid);
+               
+               $manager->loadClass("ENCAPSULATE");
+               $navList = new NavList('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
+               $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
+               
+               $this->pagefoot();
+=======
+        * Admin::action_memberdelete()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_memberdelete()
+       {
+               global $member, $manager;
+               
+               $memberid = intRequestVar('memberid');
+               
+               ($member->getID() == $memberid) or $member->isAdmin() or self::disallow();
+               
+               $mem =& $manager->getMember($memberid);
+               
+               self::$skin->parse('memberdelete');
+               return;
+       }
+       
+       /**
+        * Admin::action_memberdeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_memberdeleteconfirm()
+       {
+               global $member;
+               
+               $memberid = intRequestVar('memberid');
+               
+               ($member->getID() == $memberid) or $member->isAdmin() or self::disallow();
+               
+               $error = self::deleteOneMember($memberid);
+               if ( $error )
+               {
+                       self::error($error);
+                       return;
+               }
+               
+               if ( $member->isAdmin() )
+               {
+                       self::action_usermanagement();
+                       return;
+               }
+               else
+               {
+                       self::action_overview(_DELETED_MEMBER);
+                       return;
+               }
+               return;
+       }
+       
+       /**
+        * Admin::deleteOneMember()
+        * Delete a member by id
+        * 
+        * @static
+        * @params      Integer $memberid       member id
+        * @return      String  null string or error messages
+        */
+       static public function deleteOneMember($memberid)
+       {
+               global $manager;
+               
+               $memberid = intval($memberid);
+               $mem =& $manager->getMember($memberid);
+               
+               if ( !$mem->canBeDeleted() )
+               {
+                       return _ERROR_DELETEMEMBER;
+               }
+               
+               $data = array('member' => &$mem);
+               $manager->notify('PreDeleteMember', $data);
+               
+               /* unlink comments from memberid */
+               if ( $memberid )
+               {
+                       $query = "UPDATE %s SET cmember=0, cuser=%s WHERE cmember=%d;";
+                       $query = sprintf($query, sql_table('comment'), DB::quoteValue($mem->getDisplayName()), $memberid);
+                       DB::execute($query);
+               }
+               
+               $query = 'DELETE FROM ' . sql_table('member') . ' WHERE mnumber=' . $memberid;
+               DB::execute($query);
+               
+               $query = 'DELETE FROM ' . sql_table('team') . ' WHERE tmember=' . $memberid;
+               DB::execute($query);
+               
+               $query = 'DELETE FROM ' . sql_table('activation') . ' WHERE vmember=' . $memberid;
+               DB::execute($query);
+               
+               // delete all associated plugin options
+               NucleusPlugin::delete_option_values('member', $memberid);
+               
+               $data = array('member' => &$mem);
+               $manager->notify('PostDeleteMember', $data);
+               
+               return '';
+       }
+       
+       /**
+        * Admin::action_createnewlog()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_createnewlog()
+       {
+               global $member, $CONF, $manager;
+               
+               // Only Super-Admins can do this
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('createnewlog');
+               return;
+       }
+       
+       /**
+        * Admin::action_addnewlog()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_addnewlog()
+       {
+               global $member, $manager, $CONF;
+               
+               // Only Super-Admins can do this
+               $member->isAdmin() or self::disallow();
+               
+               $bname                  = trim(postVar('name'));
+               $bshortname             = trim(postVar('shortname'));
+               $btimeoffset    = postVar('timeoffset');
+               $bdesc                  = trim(postVar('desc'));
+               $bdefskin               = postVar('defskin');
+               
+               if ( !isValidShortName($bshortname) )
+               {
+                       self::error(_ERROR_BADSHORTBLOGNAME);
+                       return;
+               }
+               
+               if ( $manager->existsBlog($bshortname) )
+               {
+                       self::error(_ERROR_DUPSHORTBLOGNAME);
+                       return;
+               }
+               
+               $data = array(
+                       'name'        => &$bname,
+                       'shortname'   => &$bshortname,
+                       'timeoffset'  => &$btimeoffset,
+                       'description' => &$bdesc,
+                       'defaultskin' => &$bdefskin
+               );
+               $manager->notify('PreAddBlog', $data);
+               
+               // add slashes for sql queries
+               $bname                  = DB::quoteValue($bname);
+               $bshortname             = DB::quoteValue($bshortname);
+               $btimeoffset    = DB::quoteValue($btimeoffset);
+               $bdesc                  = DB::quoteValue($bdesc);
+               $bdefskin               = DB::quoteValue($bdefskin);
+               
+               // create blog
+               $query = "INSERT INTO %s (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES (%s, %s, %s, %s, %s);";
+               $query = sprintf($query, sql_table('blog'), $bname, $bshortname, $bdesc, $btimeoffset, $bdefskin);
+               DB::execute($query);
+               
+               $blogid = DB::getInsertId();
+               $blog   =& $manager->getBlog($blogid);
+               
+               // create new category
+               $catdefname = (!defined('_EBLOGDEFAULTCATEGORY_NAME') ? 'General' : _EBLOGDEFAULTCATEGORY_NAME);
+               $catdefdesc = (!defined('_EBLOGDEFAULTCATEGORY_DESC') ? 'Items that do not fit in other categories' : _EBLOGDEFAULTCATEGORY_DESC);
+               
+               $query = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, %s, %s)';
+               DB::execute(sprintf($query, sql_table('category'), (integer) $blogid, DB::quoteValue($catdefname), DB::quoteValue($catdefdesc)));
+               $catid = DB::getInsertId();
+               
+               // set as default category
+               $blog->setDefaultCategory($catid);
+               $blog->writeSettings();
+               
+               // create team member
+               $query = "INSERT INTO %s (tmember, tblog, tadmin) VALUES (%d, %d, 1);";
+               $query = sprintf($query, sql_table('team'), (integer) $member->getID(), (integer) $blogid);
+               DB::execute($query);
+               
+               $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
+               $itemdefbody  = (defined('_EBLOG_FIRSTITEM_BODY')  ? _EBLOG_FIRSTITEM_BODY  : 'This is the first item in your weblog. Feel free to delete it.');
+               
+               $blog->additem(
+                       $blog->getDefaultCategory(),
+                       $itemdeftitle,$itemdefbody,
+                       '',
+                       $blogid,
+                       $member->getID(),
+                       $blog->getCorrectTime(),
+                       0,
+                       0,
+                       0
+               );
+               
+               $data = array('blog' => &$blog);
+               $manager->notify('PostAddBlog', $data);
+               
+               $data = array(
+                       'blog'                  => &$blog,
+                       'name'                  => _EBLOGDEFAULTCATEGORY_NAME,
+                       'description'   => _EBLOGDEFAULTCATEGORY_DESC,
+                       'catid'                 => $catid
+               );
+               $manager->notify('PostAddCategory', $data);
+               
+               /* TODO: we should consider to use the other way insterad of this */
+               $_REQUEST['blogid'] = $blogid;
+               $_REQUEST['catid']  = $catid;
+               self::$skin->parse('addnewlog');
+>>>>>>> skinnable-master
+               return;
+       }
+       
+       /**
+<<<<<<< HEAD
+        * Admin::action_createitem()
+        * Provide a page to item a new item to the given blog
+=======
+        * Admin::action_addnewlog2()
+>>>>>>> skinnable-master
+        * 
+        * @param       void
+        * @return      void
+        */
+<<<<<<< HEAD
+       public function action_createitem()
        {
                global $member, $manager;
-
+               
+               $blogid = intRequestVar('blogid');
+               
+               // check if allowed
+               $member->teamRights($blogid) or $this->disallow();
+               
+               $memberid = $member->getID();
+               
+               $blog =& $manager->getBlog($blogid);
+               
+               // generate the add-item form
+               $handler = new PageFactory($blog);
+               
+               $contents = $handler->getTemplateFor('admin', 'add');
+               $manager->notify('PreAddItemForm', array('contents' => &$contents, 'blog' => &$blog));
+               
+               $parser = new Parser($handler);
+               
+               $this->pagehead();
+               $parser->parse($contents);
+               $this->pagefoot();
+               
+=======
+       static private function action_addnewlog2()
+       {
+               global $member, $manager;
+               $blogid = intRequestVar('blogid');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $burl = requestVar('url');
+               
+               $blog =& $manager->getBlog($blogid);
+               $blog->setURL(trim($burl));
+               $blog->writeSettings();
+               
+               self::action_overview(_MSG_NEWBLOG);
+               return;
+       }
+       
+       /**
+        * Admin::action_skinieoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinieoverview()
+       {
+               global $member, $DIR_LIBS, $manager;
+               
+               $member->isAdmin() or self::disallow();
+               
+               include_once($DIR_LIBS . 'skinie.php');
+               
+               self::$skin->parse('skinieoverview');
+>>>>>>> skinnable-master
+               return;
+       }
+       
+       /**
+<<<<<<< HEAD
+        * Admin::action_itemedit()
+=======
+        * Admin::action_skinieimport()
+>>>>>>> skinnable-master
+        * 
+        * @param       void
+        * @return      void
+        */
+<<<<<<< HEAD
+       public function action_itemedit()
+       {
+               global $member, $manager;
+               
                $itemid = intRequestVar('itemid');
-
+               
                // only allow if user is allowed to alter item
                $member->canAlterItem($itemid) or $this->disallow();
-
-               $item =& $manager->getItem($itemid, 1, 1);
+               
+               $variables =& $manager->getItem($itemid, 1, 1);
                $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
-
-               $manager->notify('PrepareItemForEdit', array('item' => &$item));
-
-               if ($blog->convertBreaks())
+               
+               $manager->notify('PrepareItemForEdit', array('item' => &$variables));
+               
+               if ( $blog->convertBreaks() )
                {
-                       $item['body'] = removeBreaks($item['body']);
-                       $item['more'] = removeBreaks($item['more']);
+                       $variables['body'] = removeBreaks($variables['body']);
+                       $variables['more'] = removeBreaks($variables['more']);
                }
-
+               
                // form to edit blog items
+               $handler = new PageFactory($blog);
+               $handler->setVariables($variables);
+               
+               $content = $handler->getTemplateFor('admin', 'edit');
+               
+               $parser = new Parser($handler);
+               
                $this->pagehead();
-               $formfactory = new PAGEFACTORY($blog->getID());
-               $formfactory->createEditForm('admin', $item);
+               $parser->parse($content);
                $this->pagefoot();
-    }
-
+               return;
+       }
+       
     /**
      * @todo document this
      */
@@ -1201,7 +4178,7 @@ class ADMIN {
             $actiontype='addnow';
 
         // create new category if needed
-        if (strstr($catid,'newcat')) {
+        if ( i18n::strpos($catid,'newcat') === 0 ) {
             // get blogid
             list($blogid) = sscanf($catid,"newcat-%d");
 
@@ -1239,13 +4216,13 @@ class ADMIN {
         }
 
         // edit the item for real
-        ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
+        Item::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
 
         $this->updateFuturePosted($blogid);
 
         if ($draftid > 0) {
-            // delete permission is checked inside ITEM::delete()
-            ITEM::delete($draftid);
+            // delete permission is checked inside Item::delete()
+            Item::delete($draftid);
         }
 
         // show category edit window when we created a new category
@@ -1261,107 +4238,327 @@ class ADMIN {
             $this->action_itemlist(getBlogIDFromItemID($itemid));
         }
     }
-
-    /**
-     * @todo document this
-     */
-    function action_itemdelete() {
-        global $member, $manager;
-
-        $itemid = intRequestVar('itemid');
-
-        // only allow if user is allowed to alter item
-        $member->canAlterItem($itemid) or $this->disallow();
-
-        if (!$manager->existsItem($itemid,1,1))
-            $this->error(_ERROR_NOSUCHITEM);
-
-        $item =& $manager->getItem($itemid,1,1);
-        $title = i18n::hsc(strip_tags($item['title']));
-        $body = strip_tags($item['body']);
-        $body = i18n::hsc(shorten($body,300,'...'));
-
-        $this->pagehead();
-        ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
-
-            <p><?php echo _CONFIRMTXT_ITEM?></p>
-
-            <div class="note">
-                <b>"<?php echo  $title ?>"</b>
-                <br />
-                <?php echo $body?>
-            </div>
-
-            <form method="post" action="index.php"><div>
-                <input type="hidden" name="action" value="itemdeleteconfirm" />
-                <?php $manager->addTicketHidden() ?>
-                <input type="hidden" name="itemid" value="<?php echo  $itemid; ?>" />
-                <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>"  tabindex="10" />
-            </div></form>
-        <?php
-        $this->pagefoot();
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_itemdeleteconfirm() {
-        global $member;
-
-        $itemid = intRequestVar('itemid');
-
-        // only allow if user is allowed to alter item
-        $member->canAlterItem($itemid) or $this->disallow();
-
-        // get blogid first
-        $blogid = getBlogIdFromItemId($itemid);
-
-        // delete item (note: some checks will be performed twice)
-        $this->deleteOneItem($itemid);
-
-        $this->action_itemlist($blogid);
-    }
-
-    /**
-     * Deletes one item and returns error if something goes wrong
-     * @param int $itemid
-     */
-    function deleteOneItem($itemid) {
-        global $member, $manager;
-
-        // only allow if user is allowed to alter item (also checks if itemid exists)
-        if (!$member->canAlterItem($itemid))
-            return _ERROR_DISALLOWED;
-
-        // need to get blogid before the item is deleted
-        $blogid = getBlogIDFromItemId($itemid);
-
-        $manager->loadClass('ITEM');
-        ITEM::delete($itemid);
-
-        // update blog's futureposted
-        $this->updateFuturePosted($blogid);
-    }
-
-    /**
-     * Update a blog's future posted flag
-     * @param int $blogid
-     */
-    function updateFuturePosted($blogid) {
-        global $manager;
-
-        $blog =& $manager->getBlog($blogid);
-        $currenttime = $blog->getCorrectTime(time());
-        $result = sql_query("SELECT * FROM ".sql_table('item').
-            " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
-        if (sql_num_rows($result) > 0) {
-                $blog->setFuturePost();
-        }
-        else {
-                $blog->clearFuturePost();
-        }
-    }
+=======
+       static private function action_skinieimport()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skinFileRaw = postVar('skinfile');
+               $mode = postVar('mode');
+               
+               $error = self::skinieimport($mode, $skinFileRaw);
+               if ( $error )
+               {
+                       self::error($error);
+                       return;
+               }
+               
+               self::$skin->parse('skinieimport');
+               return;
+       }
+       
+       /**
+        * Admin::action_skiniedoimport()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skiniedoimport()
+       {
+               global $member, $DIR_LIBS, $DIR_SKINS;
+               
+               $member->isAdmin() or self::disallow();
+               
+               // load skinie class
+               include_once($DIR_LIBS . 'skinie.php');
+               
+               $mode = postVar('mode');
+               $skinFileRaw = postVar('skinfile');
+               $allowOverwrite = intPostVar('overwrite');
+               
+               $error = self::skiniedoimport($mode, $skinFileRaw, $allowOverwrite);
+               if ( $error )
+               {
+                       self::error($msg);
+                       return;
+               }
+               
+               self::$skin->parse('skiniedoimport');
+               return;
+       }
+       
+       /**
+        * Admin::action_skinieexport()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinieexport()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $aSkins = requestIntArray('skin');
+               $aTemplates = requestIntArray('template');
+               $info = postVar('info');
+               
+               self::skinieexport($aSkins, $aTemplates, $info);
+               
+               return;
+       }
+       
+       /**
+        * Admin::action_templateoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_templateoverview()
+       {
+               global $member, $manager;
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('templateoverview');
+               return;
+       }
+       
+       /**
+        * Admin::action_templateedit()
+        * 
+        * @param       string  $msg    message for pageheader
+        * @return      void
+        */
+       static private function action_templateedit($msg = '')
+       {
+               global $member, $manager;
+               if ( $msg )
+               {
+                       self::$headMess = $msg;
+               }
+               
+               $templateid = intRequestVar('templateid');
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$extrahead .= "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/templateEdit.js)%>\"></script>\n";
+               self::$extrahead .= "<script type=\"text/javascript\">setTemplateEditText('" . Entity::hsc(_EDITTEMPLATE_EMPTY) . "');</script>\n";
+               
+               self::$skin->parse('templateedit');
+               return;
+       }
+       
+       /**
+        * Admin::action_templateupdate()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_templateupdate()
+       {
+               global $member,$manager;
+               
+               $templateid = intRequestVar('templateid');
+               
+               $member->isAdmin() or self::disallow();
+               
+               $name = postVar('tname');
+               $desc = postVar('tdesc');
+               
+               if ( !isValidTemplateName($name) )
+               {
+                       self::error(_ERROR_BADTEMPLATENAME);
+                       return;
+               }
+               
+               if ( (Template::getNameFromId($templateid) != $name) && Template::exists($name) )
+               {
+                       self::error(_ERROR_DUPTEMPLATENAME);
+                       return;
+               }
+               
+               // 1. Remove all template parts
+               $query = "DELETE FROM %s WHERE tdesc=%d;";
+               $query = sprintf($query, sql_table('template'), (integer) $templateid);
+               DB::execute($query);
+               
+               // 2. Update description
+               $query = "UPDATE %s SET tdname=%s, tddesc=%s WHERE tdnumber=%d;";
+               $query = sprintf($query, sql_table('template_desc'), DB::quoteValue($name), DB::quoteValue($desc), (integer) $templateid);
+               DB::execute($query);
+               
+               // 3. Add non-empty template parts
+               self::addToTemplate($templateid, 'ITEM_HEADER',                 postVar('ITEM_HEADER'));
+               self::addToTemplate($templateid, 'ITEM',                                postVar('ITEM'));
+               self::addToTemplate($templateid, 'ITEM_FOOTER',                 postVar('ITEM_FOOTER'));
+               self::addToTemplate($templateid, 'MORELINK',                    postVar('MORELINK'));
+               self::addToTemplate($templateid, 'EDITLINK',                    postVar('EDITLINK'));
+               self::addToTemplate($templateid, 'NEW',                                 postVar('NEW'));
+               self::addToTemplate($templateid, 'COMMENTS_HEADER',             postVar('COMMENTS_HEADER'));
+               self::addToTemplate($templateid, 'COMMENTS_BODY',               postVar('COMMENTS_BODY'));
+               self::addToTemplate($templateid, 'COMMENTS_FOOTER',             postVar('COMMENTS_FOOTER'));
+               self::addToTemplate($templateid, 'COMMENTS_CONTINUED',  postVar('COMMENTS_CONTINUED'));
+               self::addToTemplate($templateid, 'COMMENTS_TOOMUCH',    postVar('COMMENTS_TOOMUCH'));
+               self::addToTemplate($templateid, 'COMMENTS_AUTH',               postVar('COMMENTS_AUTH'));
+               self::addToTemplate($templateid, 'COMMENTS_ONE',                postVar('COMMENTS_ONE'));
+               self::addToTemplate($templateid, 'COMMENTS_MANY',               postVar('COMMENTS_MANY'));
+               self::addToTemplate($templateid, 'COMMENTS_NONE',               postVar('COMMENTS_NONE'));
+               self::addToTemplate($templateid, 'ARCHIVELIST_HEADER',  postVar('ARCHIVELIST_HEADER'));
+               self::addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
+               self::addToTemplate($templateid, 'ARCHIVELIST_FOOTER',  postVar('ARCHIVELIST_FOOTER'));
+               self::addToTemplate($templateid, 'BLOGLIST_HEADER',             postVar('BLOGLIST_HEADER'));
+               self::addToTemplate($templateid, 'BLOGLIST_LISTITEM',   postVar('BLOGLIST_LISTITEM'));
+               self::addToTemplate($templateid, 'BLOGLIST_FOOTER',             postVar('BLOGLIST_FOOTER'));
+               self::addToTemplate($templateid, 'CATLIST_HEADER',              postVar('CATLIST_HEADER'));
+               self::addToTemplate($templateid, 'CATLIST_LISTITEM',    postVar('CATLIST_LISTITEM'));
+               self::addToTemplate($templateid, 'CATLIST_FOOTER',              postVar('CATLIST_FOOTER'));
+               self::addToTemplate($templateid, 'DATE_HEADER',                 postVar('DATE_HEADER'));
+               self::addToTemplate($templateid, 'DATE_FOOTER',                 postVar('DATE_FOOTER'));
+               self::addToTemplate($templateid, 'FORMAT_DATE',                 postVar('FORMAT_DATE'));
+               self::addToTemplate($templateid, 'FORMAT_TIME',                 postVar('FORMAT_TIME'));
+               self::addToTemplate($templateid, 'SEARCH_HIGHLIGHT',    postVar('SEARCH_HIGHLIGHT'));
+               self::addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
+               self::addToTemplate($templateid, 'POPUP_CODE',                  postVar('POPUP_CODE'));
+               self::addToTemplate($templateid, 'MEDIA_CODE',                  postVar('MEDIA_CODE'));
+               self::addToTemplate($templateid, 'IMAGE_CODE',                  postVar('IMAGE_CODE'));
+               
+               $data = array('fields' => array());
+               $manager->notify('TemplateExtraFields', $data);
+               foreach ( $data['fields'] as $pfkey=>$pfvalue )
+               {
+                       foreach ( $pfvalue as $pffield => $pfdesc )
+                       {
+                               self::addToTemplate($templateid, $pffield, postVar($pffield));
+                       }
+               }
+               
+               // jump back to template edit
+               self::action_templateedit(_TEMPLATE_UPDATED);
+               return;
+       }
+       
+       /**
+        * Admin::addToTemplate()
+        * 
+        * @param       Integer $id     ID for template
+        * @param       String  $partname       parts name
+        * @param       String  $content        template contents
+        * @return      Integer record index
+        * 
+        */
+       static private function addToTemplate($id, $partname, $content)
+       {
+               // don't add empty parts:
+               if ( !trim($content) )
+               {
+                       return -1;
+               }
+               
+               $query = "INSERT INTO %s (tdesc, tpartname, tcontent) VALUES (%d, %s, %s);";
+               $query = sprintf($query, sql_table('template'), (integer) $id, DB::quoteValue($partname), DB::quoteValue($content));
+               if ( DB::execute($query) === FALSE )
+               {
+                       $err = DB::getError();
+                       exit(_ADMIN_SQLDIE_QUERYERROR . $err[2]);
+               }
+               return DB::getInsertId();
+       }
+       
+       /**
+        * Admin::action_templatedelete()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_templatedelete()
+       {
+               global $member, $manager;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $templateid = intRequestVar('templateid');
+               // TODO: check if template can be deleted
+               
+               self::$skin->parse('templatedelete');
+               return;
+       }
+>>>>>>> skinnable-master
+       
+       /**
+        * Admin::action_templatedeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_templatedeleteconfirm()
+       {
+               global $member, $manager;
+               
+               $templateid = intRequestVar('templateid');
+               
+               $member->isAdmin() or self::disallow();
+               
+               $data = array('templateid' => $templateid);
+               $manager->notify('PreDeleteTemplate', $data);
+               
+               // 1. delete description
+               DB::execute('DELETE FROM ' . sql_table('template_desc') . ' WHERE tdnumber=' . $templateid);
+               
+               // 2. delete parts
+               DB::execute('DELETE FROM ' . sql_table('template') . ' WHERE tdesc=' . $templateid);
+               
+               
+               $data = array('templateid' => $templateid);
+               $manager->notify('PostDeleteTemplate', $data);
+               
+               self::action_templateoverview();
+               return;
+       }
+       
+       /**
+        * Admin::action_templatenew()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_templatenew()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+<<<<<<< HEAD
+               $query = "SELECT * FROM %s WHERE iblog=%d AND iposted=0 AND itime>%s";
+               $query = sprintf($query, sql_table('item'), (integer) $blogid, DB::formatDateTime($currenttime));
+               $result = DB::getResult($query);
+               
+               if ( $result->rowCount() > 0 )
+=======
+               $name = postVar('name');
+               $desc = postVar('desc');
+               
+               if ( !isValidTemplateName($name) )
+>>>>>>> skinnable-master
+               {
+                       self::error(_ERROR_BADTEMPLATENAME);
+                       return;
+               }
+               
+               if ( Template::exists($name) )
+               {
+                       self::error(_ERROR_DUPTEMPLATENAME);
+                       return;
+               }
+               
+               $newTemplateId = Template::createNew($name, $desc);
+               
+               self::action_templateoverview();
+               return;
+       }
+<<<<<<< HEAD
 
     /**
      * @todo document this
@@ -1378,7 +4575,7 @@ class ADMIN {
 
         $this->pagehead();
         ?>
-            <h2><?php echo _MOVE_TITLE?></h2>
+            <h2><?php echo _MOVE_TITLE ?></h2>
             <form method="post" action="index.php"><div>
                 <input type="hidden" name="action" value="itemmoveto" />
                 <input type="hidden" name="itemid" value="<?php echo  $itemid; ?>" />
@@ -1389,7 +4586,7 @@ class ADMIN {
                     $this->selectBlogCategory('catid',$item['catid'],10,1);
                 ?>
 
-                <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
+                <input type="submit" value="<?php echo _MOVE_BTN ?>" tabindex="10000" onclick="return checkSubmit();" />
             </div></form>
         <?php
         $this->pagefoot();
@@ -1405,7 +4602,7 @@ class ADMIN {
         $catid = requestVar('catid');
 
         // create new category if needed
-        if (strstr($catid,'newcat')) {
+        if ( i18n::strpos($catid,'newcat') === 0 ) {
             // get blogid
             list($blogid) = sscanf($catid,'newcat-%d');
 
@@ -1423,7 +4620,7 @@ class ADMIN {
 
         $old_blogid = getBlogIDFromItemId($itemid);
 
-        ITEM::move($itemid, $catid);
+        Item::move($itemid, $catid);
 
         // set the futurePosted flag on the blog
         $this->updateFuturePosted(getBlogIDFromItemId($itemid));
@@ -1450,7 +4647,7 @@ class ADMIN {
         if (!$member->canUpdateItem($itemid, $destCatid))
             return _ERROR_DISALLOWED;
 
-        ITEM::move($itemid, $destCatid);
+        Item::move($itemid, $destCatid);
     }
 
     /**
@@ -1461,7 +4658,7 @@ class ADMIN {
 
         $manager->loadClass('ITEM');
 
-        $result = ITEM::createFromRequest();
+        $result = Item::createFromRequest();
 
         if ($result['status'] == 'error')
             $this->error($result['message']);
@@ -1491,7 +4688,7 @@ class ADMIN {
 
                $member->canAlterComment($commentid) or $this->disallow();
 
-               $comment = COMMENT::getComment($commentid);
+               $comment = Comment::getComment($commentid);
 
                $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
 
@@ -1499,14 +4696,14 @@ class ADMIN {
                $comment['body'] = str_replace('<br />', '', $comment['body']);
 
                // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
-               /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
+               /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\") ?>[^<]*</a>", "\\1", $comment['body']) */
 
-        $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
+        $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\") ?>[^<]*</a>#i", "\\1", $comment['body']);
 
         $this->pagehead();
 
         ?>
-        <h2><?php echo _EDITC_TITLE?></h2>
+        <h2><?php echo _EDITC_TITLE ?></h2>
 
         <form action="index.php" method="post"><div>
 
@@ -1514,9 +4711,9 @@ class ADMIN {
         <?php $manager->addTicketHidden(); ?>
         <input type="hidden" name="commentid" value="<?php echo  $commentid; ?>" />
         <table><tr>
-            <th colspan="2"><?php echo _EDITC_TITLE?></th>
+            <th colspan="2"><?php echo _EDITC_TITLE ?></th>
         </tr><tr>
-            <td><?php echo _EDITC_WHO?></td>
+            <td><?php echo _EDITC_WHO ?></td>
             <td>
             <?php               if ($comment['member'])
                     echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
@@ -1525,10 +4722,10 @@ class ADMIN {
             ?>
             </td>
         </tr><tr>
-            <td><?php echo _EDITC_WHEN?></td>
+            <td><?php echo _EDITC_WHEN ?></td>
             <td><?php echo  date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
         </tr><tr>
-            <td><?php echo _EDITC_HOST?></td>
+            <td><?php echo _EDITC_HOST ?></td>
             <td><?php echo  $comment['host']; ?></td>
         </tr>
         <tr>
@@ -1540,15 +4737,15 @@ class ADMIN {
             <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
         </tr>
         <tr>
-            <td><?php echo _EDITC_TEXT?></td>
+            <td><?php echo _EDITC_TEXT ?></td>
             <td>
                 <textarea name="body" tabindex="10" rows="10" cols="50"><?php                   // htmlspecialchars not needed (things should be escaped already)
                     echo $comment['body'];
                 ?></textarea>
             </td>
         </tr><tr>
-            <td><?php echo _EDITC_EDIT?></td>
-            <td><input type="submit"  tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
+            <td><?php echo _EDITC_EDIT ?></td>
+            <td><input type="submit"  tabindex="20" value="<?php echo _EDITC_EDIT ?>" onclick="return checkSubmit();" /></td>
         </tr></table>
 
         </div></form>
@@ -1576,87 +4773,295 @@ class ADMIN {
 
                // intercept words that are too long
                if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
+=======
+       
+       /**
+        * Admin::action_templateclone()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_templateclone()
+       {
+               global $member;
+               
+               $templateid = intRequestVar('templateid');
+               
+               $member->isAdmin() or self::disallow();
+               
+               // 1. read old template
+               $name = Template::getNameFromId($templateid);
+               $desc = Template::getDesc($templateid);
+               
+               // 2. create desc thing
+               $name = "cloned" . $name;
+               
+               // if a template with that name already exists:
+               if ( Template::exists($name) )
+>>>>>>> skinnable-master
                {
-                       $this->error(_ERROR_COMMENT_LONGWORD);
+                       $i = 1;
+                       while (Template::exists($name . $i))
+                       {
+                               $i++;
+                       }
+                       $name .= $i;
                }
-
-               // check length
-               if (i18n::strlen($body) < 3)
+               
+               $newid = Template::createNew($name, $desc);
+               
+               // 3. create clone
+               // go through parts of old template and add them to the new one
+               $query = "SELECT tpartname, tcontent FROM %s WHERE tdesc=%d;";
+               $query = sprintf($query, sql_table('template'), (integer) $templateid);
+               
+               $res = DB::getResult($query);
+               foreach ( $res as $row)
                {
-                       $this->error(_ERROR_COMMENT_NOCOMMENT);
+                       self::addToTemplate($newid, $row['tpartname'], $row['tcontent']);
                }
-
-               if (i18n::strlen($body) > 5000)
+               
+               self::action_templateoverview();
+               return;
+       }
+       
+       /**
+        * Admin::action_admintemplateoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_admintemplateoverview()
+       {
+               global $member;
+               $member->isAdmin() or self::disallow();
+               self::$skin->parse('admntemplateoverview');
+               return;
+       }
+       
+       /**
+        * Admin::action_admintemplateedit()
+        * 
+        * @param       string  $msg    message for pageheader
+        * @return      void
+        */
+       static private function action_admintemplateedit($msg = '')
+       {
+               global $member, $manager;
+               if ( $msg )
                {
-                       $this->error(_ERROR_COMMENT_TOOLONG);
+                       self::$headMess = $msg;
                }
+<<<<<<< HEAD
 
-        // prepare body
-        $body = COMMENT::prepareBody($body);
-
-        // call plugins
-        $manager->notify('PreUpdateComment',array('body' => &$body));
-
-        $query = 'UPDATE ' . sql_table('comment')
-               . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
-               . " WHERE cnumber = " . $commentid;
-        sql_query($query);
-
-        // get itemid
-        $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
-        $o = sql_fetch_object($res);
-        $itemid = $o->citem;
-
-        if ($member->canAlterItem($itemid))
-            $this->action_itemcommentlist($itemid);
-        else
-            $this->action_browseowncomments();
-
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_commentdelete() {
-        global $member, $manager;
-
-        $commentid = intRequestVar('commentid');
-
-        $member->canAlterComment($commentid) or $this->disallow();
-
-        $comment = COMMENT::getComment($commentid);
-
-        $body = strip_tags($comment['body']);
-        $body = i18n::hsc(shorten($body, 300, '...'));
-
-        if ($comment['member'])
-            $author = $comment['member'];
-        else
-            $author = $comment['user'];
+               // prepare body
+               $body = Comment::prepareBody($body);
 
-        $this->pagehead();
-        ?>
+               // call plugins
+               $manager->notify('PreUpdateComment',array('body' => &$body));
 
-            <h2><?php echo _DELETE_CONFIRM?></h2>
+               $query = 'UPDATE ' . sql_table('comment')
+                       . ' SET cmail = ' . DB::quoteValue($url) . ', cemail = ' . DB::quoteValue($email) . ', cbody = ' . DB::quoteValue($body)
+                       . ' WHERE cnumber = ' . $commentid;
+               DB::execute($query);
 
-            <p><?php echo _CONFIRMTXT_COMMENT?></p>
+               // get itemid
+               $res = DB::getValue('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
+               $itemid = $res;
 
-            <div class="note">
-            <b><?php echo _EDITC_WHO?>:</b> <?php echo  $author ?>
-            <br />
-            <b><?php echo _EDITC_TEXT?>:</b> <?php echo  $body ?>
-            </div>
+               if ($member->canAlterItem($itemid))
+                       $this->action_itemcommentlist($itemid);
+               else
+                       $this->action_browseowncomments();
 
-            <form method="post" action="index.php"><div>
-                <input type="hidden" name="action" value="commentdeleteconfirm" />
-                <?php $manager->addTicketHidden() ?>
-                <input type="hidden" name="commentid" value="<?php echo  $commentid; ?>" />
-                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-            </div></form>
-        <?php
-        $this->pagefoot();
     }
-
+=======
+               $member->isAdmin() or self::disallow();
+               
+               self::$extrahead .= "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/templateEdit.js)%>\"></script>\n";
+               self::$extrahead .= '<script type="text/javascript">setTemplateEditText("' . Entity::hsc(_EDITTEMPLATE_EMPTY) . '");</script>' . "\n";
+               
+               self::$skin->parse('admintemplateedit');
+               return;
+       }
+>>>>>>> skinnable-master
+       
+       /**
+        * Admin::action_admintemplateupdate()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_admintemplateupdate()
+       {
+               global $member, $manager;
+               $templateid = intRequestVar('templateid');
+               $member->isAdmin() or self::disallow();
+               $name = postVar('tname');
+               $desc = postVar('tdesc');
+               
+               if ( !isValidTemplateName($name) )
+               {
+                       self::error(_ERROR_BADTEMPLATENAME);
+                       return;
+               }
+               
+               if ( (Template::getNameFromId($templateid) != $name) && Template::exists($name) )
+               {
+                       self::error(_ERROR_DUPTEMPLATENAME);
+                       return;
+               }
+               
+               // 1. Remove all template parts
+               $query = "DELETE FROM %s WHERE tdesc=%d;";
+               $query = sprintf($query, sql_table('template'), (integer) $templateid);
+               DB::execute($query);
+               
+               // 2. Update description
+               $query = "UPDATE %s SET tdname=%s, tddesc=%s WHERE tdnumber=%d;";
+               $query = sprintf($query, sql_table('template_desc'), DB::quoteValue($name), DB::quoteValue($desc), (integer) $templateid);
+               DB::execute($query);
+               
+               // 3. Add non-empty template parts
+               self::addToTemplate($templateid, 'NORMALSKINLIST_HEAD',                                         postVar('NORMALSKINLIST_HEAD'));
+               self::addToTemplate($templateid, 'NORMALSKINLIST_BODY',                                         postVar('NORMALSKINLIST_BODY'));
+               self::addToTemplate($templateid, 'NORMALSKINLIST_FOOT',                                         postVar('NORMALSKINLIST_FOOT'));
+               self::addToTemplate($templateid, 'ADMIN_CUSTOMHELPLINK_ICON',                           postVar('ADMIN_CUSTOMHELPLINK_ICON'));
+               self::addToTemplate($templateid, 'ADMIN_CUSTOMHELPLINK_ANCHOR',                         postVar('ADMIN_CUSTOMHELPLINK_ANCHOR'));
+               self::addToTemplate($templateid, 'ADMIN_BLOGLINK',                                                      postVar('ADMIN_BLOGLINK'));
+               self::addToTemplate($templateid, 'ADMIN_BATCHLIST',                                                     postVar('ADMIN_BATCHLIST'));
+               self::addToTemplate($templateid, 'ACTIVATE_FORGOT_TITLE',                                       postVar('ACTIVATE_FORGOT_TITLE'));
+               self::addToTemplate($templateid, 'ACTIVATE_FORGOT_TEXT',                                        postVar('ACTIVATE_FORGOT_TEXT'));
+               self::addToTemplate($templateid, 'ACTIVATE_REGISTER_TITLE',                                     postVar('ACTIVATE_REGISTER_TITLE'));
+               self::addToTemplate($templateid, 'ACTIVATE_REGISTER_TEXT',                                      postVar('ACTIVATE_REGISTER_TEXT'));
+               self::addToTemplate($templateid, 'ACTIVATE_CHANGE_TITLE',                                       postVar('ACTIVATE_CHANGE_TITLE'));
+               self::addToTemplate($templateid, 'ACTIVATE_CHANGE_TEXT',                                        postVar('ACTIVATE_CHANGE_TEXT'));
+               self::addToTemplate($templateid, 'TEMPLATE_EDIT_EXPLUGNAME',                            postVar('TEMPLATE_EDIT_EXPLUGNAME'));
+               self::addToTemplate($templateid, 'TEMPLATE_EDIT_ROW_HEAD',                                      postVar('TEMPLATE_EDIT_ROW_HEAD'));
+               self::addToTemplate($templateid, 'TEMPLATE_EDIT_ROW_TAIL',                                      postVar('TEMPLATE_EDIT_ROW_TAIL'));
+               self::addToTemplate($templateid, 'SPECIALSKINLIST_HEAD',                                        postVar('SPECIALSKINLIST_HEAD'));
+               self::addToTemplate($templateid, 'SPECIALSKINLIST_BODY',                                        postVar('SPECIALSKINLIST_BODY'));
+               self::addToTemplate($templateid, 'SPECIALSKINLIST_FOOT',                                        postVar('SPECIALSKINLIST_FOOT'));
+               self::addToTemplate($templateid, 'SYSTEMINFO_GDSETTINGS',                                       postVar('SYSTEMINFO_GDSETTINGS'));
+               self::addToTemplate($templateid, 'BANLIST_DELETED_LIST',                                        postVar('BANLIST_DELETED_LIST'));
+               self::addToTemplate($templateid, 'INSERT_PLUGOPTION_TITLE',                                     postVar('INSERT_PLUGOPTION_TITLE'));
+               self::addToTemplate($templateid, 'INSERT_PLUGOPTION_BODY',                                      postVar('INSERT_PLUGOPTION_BODY'));
+               self::addToTemplate($templateid, 'INPUTYESNO_TEMPLATE_ADMIN',                           postVar('INPUTYESNO_TEMPLATE_ADMIN'));
+               self::addToTemplate($templateid, 'INPUTYESNO_TEMPLATE_NORMAL',                          postVar('INPUTYESNO_TEMPLATE_NORMAL'));
+               self::addToTemplate($templateid, 'ADMIN_SPECIALSKINLIST_HEAD',                          postVar('ADMIN_SPECIALSKINLIST_HEAD'));
+               self::addToTemplate($templateid, 'ADMIN_SPECIALSKINLIST_BODY',                          postVar('ADMIN_SPECIALSKINLIST_BODY'));
+               self::addToTemplate($templateid, 'ADMIN_SPECIALSKINLIST_FOOT',                          postVar('ADMIN_SPECIALSKINLIST_FOOT'));
+               self::addToTemplate($templateid, 'SKINIE_EXPORT_LIST',                                          postVar('SKINIE_EXPORT_LIST'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_SELECT_HEAD',                       postVar('SHOWLIST_LISTPLUG_SELECT_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_SELECT_BODY',                       postVar('SHOWLIST_LISTPLUG_SELECT_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_SELECT_FOOT',                       postVar('SHOWLIST_LISTPLUG_SELECT_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_HEAD',                        postVar('SHOWLIST_LISTPLUG_TABLE_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BODY',                        postVar('SHOWLIST_LISTPLUG_TABLE_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_FOOT',                        postVar('SHOWLIST_LISTPLUG_TABLE_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO',       postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD',       postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP',       postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO',       postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC',       postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA',       postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT',       postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN',       postVar('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM',       postVar('SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLIST_BD_SADM',       postVar('SHOWLIST_LISTPLUG_TABLE_BLIST_BD_SADM'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD',       postVar('SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY',       postVar('SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT',       postVar('SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT'));
+               self::addToTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_NAVILIST',            postVar('SHOWLIST_LISTPLUG_TABLE_NAVILIST'));
+               self::addToTemplate($templateid, 'PLUGIN_QUICKMENU_TITLE',                                      postVar('PLUGIN_QUICKMENU_TITLE'));
+               self::addToTemplate($templateid, 'PLUGIN_QUICKMENU_HEAD',                                       postVar('PLUGIN_QUICKMENU_HEAD'));
+               self::addToTemplate($templateid, 'PLUGIN_QUICKMENU_BODY',                                       postVar('PLUGIN_QUICKMENU_BODY'));
+               self::addToTemplate($templateid, 'PLUGIN_QUICKMENU_FOOT',                                       postVar('PLUGIN_QUICKMENU_FOOT'));
+               
+               $data = array('fields' => array());
+               $manager->notify('AdminTemplateExtraFields', $data);
+               foreach ( $data['fields'] as $pfkey => $pfvalue )
+               {
+                       foreach ( $pfvalue as $pffield => $pfdesc )
+                       {
+                               self::addToTemplate($templateid, $pffield, postVar($pffield));
+                       }
+               }
+               
+               // jump back to template edit
+               self::action_admintemplateedit(_TEMPLATE_UPDATED);
+               return;
+       }
+       
+       /**
+        * Admin::action_admintemplatedelete()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_admintemplatedelete()
+       {
+               global $member, $manager;
+               $member->isAdmin() or self::disallow();
+               
+               // TODO: check if template can be deleted
+               self::$skin->parse('admintemplatedelete');
+               return;
+       }
+       
+<<<<<<< HEAD
     /**
      * @todo document this
      */
@@ -1666,9 +5071,8 @@ class ADMIN {
         $commentid = intRequestVar('commentid');
 
         // get item id first
-        $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
-        $o = sql_fetch_object($res);
-        $itemid = $o->citem;
+        $res = DB::getValue('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
+        $itemid = $res;
 
         $error = $this->deleteOneComment($commentid);
         if ($error)
@@ -1695,89 +5099,113 @@ class ADMIN {
 
         // delete the comments associated with the item
         $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
-        sql_query($query);
+        DB::execute($query);
 
         $manager->notify('PostDeleteComment', array('commentid' => $commentid));
 
         return '';
     }
 
-    /**
-     * Usermanagement main
-     */
-    function action_usermanagement() {
-        global $member, $manager;
-
-        // check if allowed
-        $member->isAdmin() or $this->disallow();
-
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-        echo '<h2>' . _MEMBERS_TITLE .'</h2>';
-
-        echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
-
-        // show list of members with actions
-        $query =  'SELECT *'
-               . ' FROM '.sql_table('member');
-        $template['content'] = 'memberlist';
-        $template['tabindex'] = 10;
-
-        $manager->loadClass("ENCAPSULATE");
-        $batch = new BATCH('member');
-        $batch->showlist($query,'table',$template);
-
-        echo '<h3>' . _MEMBERS_NEW .'</h3>';
-        ?>
-            <form method="post" action="index.php" name="memberedit"><div>
-
-            <input type="hidden" name="action" value="memberadd" />
-            <?php $manager->addTicketHidden() ?>
-
-            <table>
-            <tr>
-                <th colspan="2"><?php echo _MEMBERS_NEW?></th>
-            </tr><tr>
-                <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
-                <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
-                </td>
-                <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_REALNAME?></td>
-                <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_PWD?></td>
-                <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_REPPWD?></td>
-                <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_EMAIL?></td>
-                <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_URL?></td>
-                <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
-                <td><?php $this->input_yesno('admin',0,10060); ?> </td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
-                <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_NOTES?></td>
-                <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
-            </tr><tr>
-                <td><?php echo _MEMBERS_NEW?></td>
-                <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
-            </tr></table>
-
-            </div></form>
-        <?php
-        $this->pagefoot();
-    }
-
+       /**
+        * Admin::action_usermanagement()
+        * 
+        * Usermanagement main
+        * @param       void
+        * @return      void
+        */
+       public function action_usermanagement()
+       {
+               global $member, $manager;
+               
+               // check if allowed
+               $member->isAdmin() or $this->disallow();
+               
+               $this->pagehead();
+               
+               echo '<p><a href="index.php?action=manage">(' . _BACKTOMANAGE . ")</a></p>\n";
+               
+               echo '<h2>' . _MEMBERS_TITLE . "</h2>\n";
+               
+               echo '<h3>' . _MEMBERS_CURRENT . "</h3>\n";
+               
+               // show list of members with actions
+               $query =  'SELECT * FROM '.sql_table('member');
+               $template['content'] = 'memberlist';
+               $template['tabindex'] = 10;
+               
+               $manager->loadClass("ENCAPSULATE");
+               $batch = new Batch('member');
+               $batch->showlist($query,'table',$template);
+               
+               echo '<h3>' . _MEMBERS_NEW .'</h3>';
+               echo "<form method=\"post\" action=\"index.php\" name=\"memberedit\">\n";
+               echo "<div>\n";
+               echo "<input type=\"hidden\" name=\"action\" value=\"memberadd\" />\n";
+               $manager->addTicketHidden();
+               
+               echo '<table frame="box" rules="rules" summary="' . _MEMBERS_NEW . '">' ."\n";
+               echo "<tr>\n";
+               echo '<th colspan="2">' . _MEMBERS_NEW . "</th>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_DISPLAY;
+               help('shortnames');
+               echo '<br />';
+               echo '<small>' . _MEMBERS_DISPLAY_INFO . '</small>';
+               echo "</td>\n";
+               echo "<td><input tabindex=\"10010\" name=\"name\" size=\"32\" maxlength=\"32\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_REALNAME . "</td>\n";
+               echo "<td><input name=\"realname\" tabindex=\"10020\" size=\"40\" maxlength=\"60\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_PWD . "</td>\n";
+               echo "<td><input name=\"password\" tabindex=\"10030\" size=\"16\" maxlength=\"40\" type=\"password\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_REPPWD . "</td>\n";
+               echo "<td><input name=\"repeatpassword\" tabindex=\"10035\" size=\"16\" maxlength=\"40\" type=\"password\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_EMAIL . "</td>\n";
+               echo "<td><input name=\"email\" tabindex=\"10040\" size=\"40\" maxlength=\"60\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_URL . "</td>\n";
+               echo "<td><input name=\"url\" tabindex=\"10050\" size=\"40\" maxlength=\"100\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_SUPERADMIN;
+               help('superadmin');
+               echo "</td>\n";
+               echo '<td>';
+               $this->input_yesno('admin',0,10060);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_CANLOGIN;
+               help('canlogin');
+               echo "</td>\n";
+               echo '<td>';
+               $this->input_yesno('canlogin',1,10070);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_NOTES . "</td>\n";
+               echo "<td><input name=\"notes\" maxlength=\"100\" size=\"40\" tabindex=\"10080\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _MEMBERS_NEW . "</td>\n";
+               echo '<td><input type="submit" value="' . _MEMBERS_NEW_BTN . '" tabindex="10090" onclick="return checkSubmit();" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "</table>\n";
+               echo "</div>\n";
+               echo "</form>\n";
+               $this->pagefoot();
+               return;
+       }
+       
     /**
      * Edit member settings
      */
@@ -1785,23 +5213,30 @@ class ADMIN {
         $this->action_editmembersettings(intRequestVar('memberid'));
     }
 
+=======
+>>>>>>> skinnable-master
        /**
-        * @todo document this
+        * Admin::action_admintemplatedeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
         */
-       function action_editmembersettings($memberid = '') {
-               global $member, $manager, $CONF;
+       static private function action_admintemplatedeleteconfirm()
+       {
+               global $member, $manager;
                
-               if ($memberid == '')
-               {
-                       $memberid = $member->getID();
-               }
+               $templateid = intRequestVar('templateid');
+               $member->isAdmin() or self::disallow();
                
-               // check if allowed
-               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
+               $data = array('templateid' => $templateid);
+               $manager->notify('PreDeleteAdminTemplate', $data);
                
-               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-               $this->pagehead($extrahead);
+               // 1. delete description
+               $query = "DELETE FROM %s WHERE tdnumber=%s;";
+               $query = sprintf($query, sql_table('template_desc'), (integer) $templateid);
+               DB::execute($query);
                
+<<<<<<< HEAD
                // show message to go back to member overview (only for admins)
                if ($member->isAdmin())
                {
@@ -1813,7 +5248,7 @@ class ADMIN {
                }
                echo '<h2>' . _MEMBERS_EDIT . '</h2>';
                
-               $mem = MEMBER::createFromID($memberid);
+               $mem =& $manager->getMember($memberid);
                ?>
                <form method="post" action="index.php" name="memberedit"><div>
                
@@ -1822,67 +5257,67 @@ class ADMIN {
                <?php $manager->addTicketHidden() ?>
                
                <table><tr>
-                       <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
+                       <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
                </tr><tr>
-                       <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
-                               <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
+                       <td><?php echo _MEMBERS_DISPLAY ?> <?php help('shortnames'); ?>
+                               <br /><small><?php echo _MEMBERS_DISPLAY_INFO ?></small>
                        </td>
                        <td>
                        <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
-                               <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo  i18n::hsc($mem->getDisplayName()); ?>" />
+                               <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo  Entity::hsc($mem->getDisplayName()); ?>" />
                        <?php } else {
-                               echo i18n::hsc($member->getDisplayName());
+                               echo Entity::hsc($member->getDisplayName());
                           }
                        ?>
                        </td>
                </tr><tr>
-                       <td><?php echo _MEMBERS_REALNAME?></td>
-                       <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo  i18n::hsc($mem->getRealName()); ?>" /></td>
+                       <td><?php echo _MEMBERS_REALNAME ?></td>
+                       <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo  Entity::hsc($mem->getRealName()); ?>" /></td>
                </tr><tr>
                <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
-                       <td><?php echo _MEMBERS_PWD?></td>
+                       <td><?php echo _MEMBERS_PWD ?></td>
                        <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
                </tr><tr>
-                       <td><?php echo _MEMBERS_REPPWD?></td>
+                       <td><?php echo _MEMBERS_REPPWD ?></td>
                        <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
                <?php } ?>
                </tr><tr>
-                       <td><?php echo _MEMBERS_EMAIL?>
-                               <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
+                       <td><?php echo _MEMBERS_EMAIL ?>
+                               <br /><small><?php echo _MEMBERS_EMAIL_EDIT ?></small>
                        </td>
-                       <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo  i18n::hsc($mem->getEmail()); ?>" /></td>
+                       <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo  Entity::hsc($mem->getEmail()); ?>" /></td>
                </tr><tr>
-                       <td><?php echo _MEMBERS_URL?></td>
-                       <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo  i18n::hsc($mem->getURL()); ?>" /></td>
+                       <td><?php echo _MEMBERS_URL ?></td>
+                       <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo  Entity::hsc($mem->getURL()); ?>" /></td>
                <?php // only allow to change this by super-admins
                   // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
                   if ($member->isAdmin()) {
                ?>
                        </tr><tr>
-                               <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
+                               <td><?php echo _MEMBERS_SUPERADMIN ?> <?php help('superadmin'); ?></td>
                                <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
                        </tr><tr>
-                               <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
+                               <td><?php echo _MEMBERS_CANLOGIN ?> <?php help('canlogin'); ?></td>
                                <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
                <?php } ?>
                </tr><tr>
-                       <td><?php echo _MEMBERS_NOTES?></td>
-                       <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo  i18n::hsc($mem->getNotes()); ?>" /></td>
+                       <td><?php echo _MEMBERS_NOTES ?></td>
+                       <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo  Entity::hsc($mem->getNotes()); ?>" /></td>
                </tr><tr>
-                       <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
+                       <td><?php echo _MEMBERS_LOCALE ?> <?php help('locale'); ?>
                        </td>
                        <td>
                        
-                               <select name="deflang" tabindex="85">
+                               <select name="locale" tabindex="85">
                                <?php
                                $locales = i18n::get_available_locale_list();
                                if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
                                {
-                                       echo "<option value=\"\" selected=\"selected\">" . i18n::hsc(_MEMBERS_USESITELANG) . "</option>\n";
+                                       echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
                                }
                                else
                                {
-                                       echo "<option value=\"\">" . i18n::hsc(_MEMBERS_USESITELANG) . "</option>\n";
+                                       echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
                                }
                                
                                foreach( $locales as $locale )
@@ -1902,7 +5337,7 @@ class ADMIN {
                        </td>
                </tr>
                <tr>
-                       <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
+                       <td><?php echo _MEMBERS_USEAUTOSAVE ?> <?php help('autosave'); ?></td>
                        <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
                </tr>
                <?php
@@ -1912,8 +5347,8 @@ class ADMIN {
                <tr>
                        <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
                </tr><tr>
-                       <td><?php echo _MEMBERS_EDIT?></td>
-                       <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
+                       <td><?php echo _MEMBERS_EDIT ?></td>
+                       <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN ?>" onclick="return checkSubmit();" /></td>
                </tr></table>
                
                </div></form>
@@ -1928,48 +5363,52 @@ class ADMIN {
                                )
                        );
                $this->pagefoot();
+=======
+               // 2. delete parts
+               $query = "DELETE FROM %s WHERE tdesc=%d;";
+               $query = sprintf($query, sql_table('template'), (integer) $templateid);
+               DB::execute($query);
+               
+               $data = array('templateid' => $templateid);
+               $manager->notify('PostDeleteAdminTemplate', $data);
+               
+               self::action_admintemplateoverview();
+               return;
+>>>>>>> skinnable-master
        }
        
-    /**
-     * @todo document this
-     */
-    function action_changemembersettings() {
-        global $member, $CONF, $manager;
-
-        $memberid = intRequestVar('memberid');
-
-        // check if allowed
-        ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-        $name           = trim(strip_tags(postVar('name')));
-        $realname       = trim(strip_tags(postVar('realname')));
-        $password       = postVar('password');
-        $repeatpassword = postVar('repeatpassword');
-        $email          = strip_tags(postVar('email'));
-        $url            = strip_tags(postVar('url'));
-
-               # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
-               # original eregi: !eregi("^https?://", $url)
-
-               // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
-               if (!preg_match('#^https?://#', $url) )
+       /**
+        * Admin::action_admintemplatenew()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_admintemplatenew()
+       {
+               global $member;
+               $member->isAdmin() or self::disallow();
+               $name = postVar('name');
+               $desc = postVar('desc');
+               
+               if ( !isValidTemplateName($name) )
                {
+<<<<<<< HEAD
                        $url = 'http://' . $url;
                }
 
         $admin          = postVar('admin');
         $canlogin       = postVar('canlogin');
         $notes          = strip_tags(postVar('notes'));
-        $locale        = postVar('deflang');
+        $locale        = postVar('locale');
 
-        $mem = MEMBER::createFromID($memberid);
+        $mem =& $manager->getMember($memberid);
 
         if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
 
             if (!isValidDisplayName($name))
                 $this->error(_ERROR_BADNAME);
 
-            if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
+            if (($name != $mem->getDisplayName()) && Member::exists($name))
                 $this->error(_ERROR_NICKNAMEINUSE);
 
             if ($password != $repeatpassword)
@@ -1986,18 +5425,24 @@ class ADMIN {
                                        $this->error($pwderror);
                                }
                        }
+=======
+                       self::error(_ERROR_BADTEMPLATENAME);
+                       return;
+>>>>>>> skinnable-master
                }
-               
-               if ( !isValidMailAddress($email) )
+               else if ( !preg_match('#^admin/#', $name) )
                {
-                       $this->error(_ERROR_BADMAILADDRESS);
+                       self::error(_ERROR_BADADMINTEMPLATENAME);
+                       return;
                }
-               if ( !$realname )
+               else if ( Template::exists($name) )
                {
-                       $this->error(_ERROR_REALNAMEMISSING);
+                       self::error(_ERROR_DUPTEMPLATENAME);
+                       return;
                }
+<<<<<<< HEAD
         if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
-            $this->error(_ERROR_NOSUCHLANGUAGE);
+            $this->error(_ERROR_NOSUCHTRANSLATION);
 
         // check if there will remain at least one site member with both the logon and admin rights
         // (check occurs when taking away one of these rights from such a member)
@@ -2005,8 +5450,8 @@ class ADMIN {
              || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
            )
         {
-            $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
-            if (sql_num_rows($r) < 2)
+            $r = DB::getResult('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
+            if ($r->rowCount() < 2)
                 $this->error(_ERROR_ATLEASTONEADMIN);
         }
 
@@ -2038,7 +5483,7 @@ class ADMIN {
 
         // store plugin options
         $aOptions = requestArray('plugoption');
-        NucleusPlugin::_applyPluginOptions($aOptions);
+        NucleusPlugin::apply_plugin_options($aOptions);
         $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
 
         // if email changed, generate new password
@@ -2067,31 +5512,109 @@ class ADMIN {
         }
     }
 
-    /**
-     * @todo document this
-     */
-    function action_memberadd() {
-        global $member, $manager;
-
-        // check if allowed
-        $member->isAdmin() or $this->disallow();
-
-        if (postVar('password') != postVar('repeatpassword'))
-            $this->error(_ERROR_PASSWORDMISMATCH);
-        if (i18n::strlen(postVar('password')) < 6)
-            $this->error(_ERROR_PASSWORDTOOSHORT);
-
-        $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
-        if ($res != 1)
-            $this->error($res);
-
-        // fire PostRegister event
-        $newmem = new MEMBER();
-        $newmem->readFromName(postVar('name'));
-        $manager->notify('PostRegister',array('member' => &$newmem));
+=======
+               
+               $newTemplateId = Template::createNew($name, $desc);
+               self::action_admintemplateoverview();
+               return;
+       }
+       
+>>>>>>> skinnable-master
+       /**
+        * Admin::action_admintemplateclone()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_admintemplateclone()
+       {
+               global $member;
+               $templateid = intRequestVar('templateid');
+               $member->isAdmin() or self::disallow();
+               
+               // 1. read old template
+               $name = Template::getNameFromId($templateid);
+               $desc = Template::getDesc($templateid);
+               
+               // 2. create desc thing
+               $name = $name . "cloned";
+               
+               // if a template with that name already exists:
+               if ( Template::exists($name) )
+               {
+                       $i = 1;
+                       while ( Template::exists($name . $i) )
+                       {
+                               $i++;
+                       }
+                       $name .= $i;
+               }
+               
+               $newid = Template::createNew($name, $desc);
+               
+               // 3. create clone
+               // go through parts of old template and add them to the new one
+               $query = "SELECT tpartname, tcontent FROM %s WHERE tdesc=%d;";
+               $query = sprintf($query, sql_table('template'), (integer) $templateid);
+               
+               $res = DB::getResult($query);
+               foreach ( $res as $row )
+               {
+                       self::addToTemplate($newid, $row['tpartname'], $row['tcontent']);
+               }
+               
+               self::action_admintemplateoverview();
+               return;
+       }
 
-        $this->action_usermanagement();
-    }
+       /**
+        * Admin::action_skinoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinoverview()
+       {
+               global $member, $manager;
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('skinoverview');
+               return;
+       }
+       
+       /**
+        * Admin::action_skinnew()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinnew()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $name = trim(postVar('name'));
+               $desc = trim(postVar('desc'));
+               
+               if ( !isValidSkinName($name) )
+               {
+                       self::error(_ERROR_BADSKINNAME);
+                       return;
+               }
+               else if ( SKIN::exists($name) )
+               {
+                       self::error(_ERROR_DUPSKINNAME);
+                       return;
+               }
+               
+               SKIN::createNew($name, $desc);
+               
+               self::action_skinoverview();
+               return;
+       }
+<<<<<<< HEAD
 
     /**
      * Account activation
@@ -2112,15 +5635,15 @@ class ADMIN {
         global $manager;
 
         // clean up old activation keys
-        MEMBER::cleanupActivationTable();
+        Member::cleanupActivationTable();
 
         // get activation info
-        $info = MEMBER::getActivationInfo($key);
+        $info = Member::getActivationInfo($key);
 
         if (!$info)
             $this->error(_ERROR_ACTIVATE);
 
-        $mem = MEMBER::createFromId($info->vmember);
+        $mem =& $manager->getMember($info['vmember']);
 
         if (!$mem)
             $this->error(_ERROR_ACTIVATE);
@@ -2129,7 +5652,7 @@ class ADMIN {
         $title = '';
         $bNeedsPasswordChange = true;
 
-        switch ($info->vtype)
+        switch ($info['vtype'])
         {
             case 'forgot':
                 $title = _ACTIVATE_FORGOT_TITLE;
@@ -2143,15 +5666,15 @@ class ADMIN {
                 $title = _ACTIVATE_CHANGE_TITLE;
                 $text = _ACTIVATE_CHANGE_TEXT;
                 $bNeedsPasswordChange = false;
-                MEMBER::activate($key);
+                Member::activate($key);
                 break;
         }
 
         $aVars = array(
-            'memberName' => i18n::hsc($mem->getDisplayName())
+            'memberName' => Entity::hsc($mem->getDisplayName())
         );
-        $title = TEMPLATE::fill($title, $aVars);
-        $text = TEMPLATE::fill($text, $aVars);
+        $title = Template::fill($title, $aVars);
+        $text = Template::fill($text, $aVars);
 
         $this->pagehead();
 
@@ -2170,13 +5693,13 @@ class ADMIN {
 
                         <input type="hidden" name="action" value="activatesetpwd" />
                         <?php $manager->addTicketHidden() ?>
-                        <input type="hidden" name="key" value="<?php echo i18n::hsc($key) ?>" />
+                        <input type="hidden" name="key" value="<?php echo Entity::hsc($key) ?>" />
 
                         <table><tr>
-                            <td><?php echo _MEMBERS_PWD?></td>
+                            <td><?php echo _MEMBERS_PWD ?></td>
                             <td><input type="password" maxlength="40" size="16" name="password" /></td>
                         </tr><tr>
-                            <td><?php echo _MEMBERS_REPPWD?></td>
+                            <td><?php echo _MEMBERS_REPPWD ?></td>
                             <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
                         <?php
 
@@ -2205,20 +5728,21 @@ class ADMIN {
      *
      * @author dekarma
      */
-    function action_activatesetpwd() {
-
+    function action_activatesetpwd()
+    {
+               global $manager;
         $key = postVar('key');
 
         // clean up old activation keys
-        MEMBER::cleanupActivationTable();
+        Member::cleanupActivationTable();
 
         // get activation info
-        $info = MEMBER::getActivationInfo($key);
+        $info = Member::getActivationInfo($key);
 
-        if (!$info || ($info->type == 'addresschange'))
+        if (!$info || ($info['type'] == 'addresschange'))
             return $this->_showActivationPage($key, _ERROR_ACTIVATE);
 
-        $mem = MEMBER::createFromId($info->vmember);
+        $mem =& $manager->getMember($info['vmember']);
 
         if (!$mem)
             return $this->_showActivationPage($key, _ERROR_ACTIVATE);
@@ -2254,7 +5778,7 @@ class ADMIN {
         $mem->write();
 
         // do the activation
-        MEMBER::activate($key);
+        Member::activate($key);
 
         $this->pagehead();
             echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
@@ -2262,70 +5786,85 @@ class ADMIN {
         $this->pagefoot();
     }
 
-    /**
-     * Manage team
-     */
-    function action_manageteam() {
-        global $member, $manager;
-
-        $blogid = intRequestVar('blogid');
-
-        // check if allowed
-        $member->blogAdminRights($blogid) or $this->disallow();
-
-        $this->pagehead();
-
-        echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
-
-        echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
-
-        echo '<h3>' . _TEAM_CURRENT . '</h3>';
-
-
-
-        $query =  'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
-               . ' FROM '.sql_table('member').', '.sql_table('team')
-               . ' WHERE tmember=mnumber and tblog=' . $blogid;
-
-        $template['content'] = 'teamlist';
-        $template['tabindex'] = 10;
-
-        $manager->loadClass("ENCAPSULATE");
-        $batch = new BATCH('team');
-        $batch->showlist($query, 'table', $template);
-
-        ?>
-            <h3><?php echo _TEAM_ADDNEW?></h3>
-
-            <form method='post' action='index.php'><div>
-
-            <input type='hidden' name='action' value='teamaddmember' />
-            <input type='hidden' name='blogid' value='<?php echo  $blogid; ?>' />
-            <?php $manager->addTicketHidden() ?>
-
-            <table><tr>
-                <td><?php echo _TEAM_CHOOSEMEMBER?></td>
-                <td><?php                   // TODO: try to make it so only non-team-members are listed
-                    $query =  'SELECT mname as text, mnumber as value'
-                           . ' FROM '.sql_table('member');
-
-                    $template['name'] = 'memberid';
-                    $template['tabindex'] = 10000;
-                    showlist($query,'select',$template);
-                ?></td>
-            </tr><tr>
-                <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
-                <td><?php $this->input_yesno('admin',0,10020); ?></td>
-            </tr><tr>
-                <td><?php echo _TEAM_ADD?></td>
-                <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
-            </tr></table>
-
-            </div></form>
-        <?php
-        $this->pagefoot();
-    }
-
+       /**
+        * Admin::action_manageteam()
+        * 
+        * Manage team
+        * @param       void
+        * @return      void
+        */
+       public function action_manageteam()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               // check if allowed
+               $member->blogAdminRights($blogid) or $this->disallow();
+               
+               $this->pagehead();
+               
+               echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(" . _BACK_TO_BLOGSETTINGS . ")</a></p>\n";
+               
+               echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . "</h2>\n";
+               
+               echo '<h3>' . _TEAM_CURRENT . "</h3>\n";
+               
+               $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
+                      . ' FROM '.sql_table('member').', '.sql_table('team')
+                      . ' WHERE tmember=mnumber and tblog=' . $blogid;
+               
+               $template['content'] = 'teamlist';
+               $template['tabindex'] = 10;
+               
+               $manager->loadClass("ENCAPSULATE");
+               $batch = new Batch('team');
+               $batch->showlist($query, 'table', $template);
+               
+               echo '<h3>' . _TEAM_ADDNEW . "</h3>\n";
+                       
+               echo "<form method=\"post\" action=\"index.php\">\n";
+               echo "<div>\n";
+               
+               echo "<input type=\"hidden\" name=\"action\" value=\"teamaddmember\" />\n";
+               echo "<input type=\"hidden\" name=\"blogid\" value=\"{$blogid}\" />\n";
+               $manager->addTicketHidden();
+                       
+               echo '<table frame="box" rules="all" summary="' . _TEAM_ADDNEW . '">' . "\n";
+               echo "<tr>\n";
+               echo '<td>' . _TEAM_CHOOSEMEMBER . "</td>\n";
+               
+               // TODO: try to make it so only non-team-members are listed
+               echo "<td>\n";
+               
+               $query =  'SELECT mname as text, mnumber as value FROM '.sql_table('member');
+               $template['name'] = 'memberid';
+               $template['tabindex'] = 10000;
+               showlist($query,'select',$template);
+               
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _TEAM_ADMIN;
+               help('teamadmin');
+               echo "</td>\n";
+               echo '<td>';
+               $this->input_yesno('admin',0,10020);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _TEAM_ADD . "</td>\n";
+               echo '<td><input type="submit" value="' . _TEAM_ADD_BTN . '" tabindex="10030" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "</table>\n";
+               
+               echo "</div>\n";
+               echo "</form>\n";
+               
+               $this->pagefoot();
+               return;
+       }
+       
     /**
      * Add member to team
      */
@@ -2356,322 +5895,395 @@ class ADMIN {
         $memberid = intRequestVar('memberid');
         $blogid = intRequestVar('blogid');
 
-        // check if allowed
-        $member->blogAdminRights($blogid) or $this->disallow();
-
-        $teammem = MEMBER::createFromID($memberid);
-        $blog =& $manager->getBlog($blogid);
-
-        $this->pagehead();
-        ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
-
-            <p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo  i18n::hsc($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo  i18n::hsc(strip_tags($blog->getName())) ?></b>
-            </p>
-
-
-            <form method="post" action="index.php"><div>
-            <input type="hidden" name="action" value="teamdeleteconfirm" />
-            <?php $manager->addTicketHidden() ?>
-            <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
-            <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
-            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-            </div></form>
-        <?php
-        $this->pagefoot();
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_teamdeleteconfirm() {
-        global $member;
-
-        $memberid = intRequestVar('memberid');
-        $blogid = intRequestVar('blogid');
-
-        $error = $this->deleteOneTeamMember($blogid, $memberid);
-        if ($error)
-            $this->error($error);
-
-
-        $this->action_manageteam();
-    }
-
-    /**
-     * @todo document this
-     */
-    function deleteOneTeamMember($blogid, $memberid) {
-        global $member, $manager;
-
-        $blogid = intval($blogid);
-        $memberid = intval($memberid);
-
-        // check if allowed
-        if (!$member->blogAdminRights($blogid))
-            return _ERROR_DISALLOWED;
-
-        // check if: - there remains at least one blog admin
-        //           - (there remains at least one team member)
-        $tmem = MEMBER::createFromID($memberid);
-
-        $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
-
-        if ($tmem->isBlogAdmin($blogid)) {
-            // check if there are more blog members left and at least one admin
-            // (check for at least two admins before deletion)
-            $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
-            $r = sql_query($query);
-            if (sql_num_rows($r) < 2)
-                return _ERROR_ATLEASTONEBLOGADMIN;
-        }
-
-        $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
-        sql_query($query);
-
-        $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
-
-        return '';
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_teamchangeadmin() {
-        global $member;
-
-        $blogid = intRequestVar('blogid');
-        $memberid = intRequestVar('memberid');
-
-        // check if allowed
-        $member->blogAdminRights($blogid) or $this->disallow();
-
-        $mem = MEMBER::createFromID($memberid);
-
-        // don't allow when there is only one admin at this moment
-        if ($mem->isBlogAdmin($blogid)) {
-            $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
-            if (sql_num_rows($r) == 1)
-                $this->error(_ERROR_ATLEASTONEBLOGADMIN);
-        }
-
-        if ($mem->isBlogAdmin($blogid))
-            $newval = 0;
-        else
-            $newval = 1;
-
-        $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
-        sql_query($query);
-
-        // only show manageteam if member did not change its own admin privileges
-        if ($member->isBlogAdmin($blogid))
-            $this->action_manageteam();
-        else
-            $this->action_overview(_MSG_ADMINCHANGED);
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_blogsettings() {
-        global $member, $manager;
-
-        $blogid = intRequestVar('blogid');
-
-        // check if allowed
-        $member->blogAdminRights($blogid) or $this->disallow();
-
-        $blog =& $manager->getBlog($blogid);
-
-        $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-        $this->pagehead($extrahead);
-
-        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-        ?>
-        <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
-
-        <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
-
-        <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
-        <?php
-            $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
-            $aMemberNames = array();
-            while ($o = sql_fetch_object($res))
-                array_push($aMemberNames, i18n::hsc($o->mname) . ' (' . i18n::hsc($o->mrealname). ')');
-            echo implode(',', $aMemberNames);
-        ?>
-        </p>
-
-
-
-        <p>
-        <a href="index.php?action=manageteam&amp;blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
-        </p>
-
-        <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
-
-        <form method="post" action="index.php"><div>
-
-        <input type="hidden" name="action" value="blogsettingsupdate" />
-        <?php $manager->addTicketHidden() ?>
-        <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
-        <table><tr>
-            <td><?php echo _EBLOG_NAME?></td>
-            <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo  i18n::hsc($blog->getName()) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
-                <?php echo _EBLOG_SHORTNAME_EXTRA?>
-            </td>
-            <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo  i18n::hsc($blog->getShortName()) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_DESC?></td>
-            <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo  i18n::hsc($blog->getDescription()) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_URL?></td>
-            <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo  i18n::hsc($blog->getURL()) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_DEFSKIN?>
-                <?php help('blogdefaultskin'); ?>
-            </td>
-            <td>
-                <?php
-                    $query =  'SELECT sdname as text, sdnumber as value'
-                           . ' FROM '.sql_table('skin_desc');
-                    $template['name'] = 'defskin';
-                    $template['selected'] = $blog->getDefaultSkin();
-                    $template['tabindex'] = 50;
-                    showlist($query,'select',$template);
-                ?>
-
-            </td>
-        </tr><tr>
-            <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
-            </td>
-            <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
-            </td>
-            <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_DISABLECOMMENTS?>
-            </td>
-            <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_ANONYMOUS?>
-            </td>
-            <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
-        </tr><tr>
-    <td><?php echo _EBLOG_REQUIREDEMAIL?>
-         </td>
-         <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
-      </tr><tr>
-            <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
-            <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo  i18n::hsc($blog->getNotifyAddress()); ?>" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_NOTIFY_ON?></td>
-            <td>
-                <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
-                    <?php if  ($blog->notifyOnComment()) echo "checked='checked'" ?>
-                /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
-                <br />
-                <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
-                    <?php if  ($blog->notifyOnVote()) echo "checked='checked'" ?>
-                /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
-                <br />
-                <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
-                    <?php if  ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
-                /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
-            </td>
-        </tr><tr>
-            <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
-            <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo  i18n::hsc($blog->getMaxComments()); ?>" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
-            <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo  i18n::hsc($blog->getUpdateFile()) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_DEFCAT?></td>
-            <td>
-                <?php
-                    $query =  'SELECT cname as text, catid as value'
-                           . ' FROM '.sql_table('category')
-                           . ' WHERE cblog=' . $blog->getID();
-                    $template['name'] = 'defcat';
-                    $template['selected'] = $blog->getDefaultCategory();
-                    $template['tabindex'] = 110;
-                    showlist($query,'select',$template);
-                ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
-                <br /><?php echo _EBLOG_STIME?> <b><?php echo  i18n::strftime("%H:%M",time()); ?></b>
-                <br /><?php echo _EBLOG_BTIME?> <b><?php echo  i18n::strftime("%H:%M",$blog->getCorrectTime()); ?></b>
-                </td>
-            <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo  i18n::hsc($blog->getTimeOffset()); ?>" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
-            <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
-        </tr>
-        <?php
-            // plugin options
-            $this->_insertPluginOptions('blog',$blogid);
-        ?>
-        <tr>
-            <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
-        </tr><tr>
-            <td><?php echo _EBLOG_CHANGE?></td>
-            <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
-        </tr></table>
+        // check if allowed
+        $member->blogAdminRights($blogid) or $this->disallow();
 
-        </div></form>
+        $teammem =& $manager->getMember($memberid);
+        $blog =& $manager->getBlog($blogid);
 
-        <h3><?php echo _EBLOG_CAT_TITLE?></h3>
+        $this->pagehead();
+        ?>
+            <h2><?php echo _DELETE_CONFIRM ?></h2>
+
+            <p><?php echo _CONFIRMTXT_TEAM1 ?><b><?php echo  Entity::hsc($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2 ?><b><?php echo  Entity::hsc(strip_tags($blog->getName())) ?></b>
+            </p>
 
 
+            <form method="post" action="index.php"><div>
+            <input type="hidden" name="action" value="teamdeleteconfirm" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
+            <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
+            </div></form>
         <?php
-        $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
-        $template['content'] = 'categorylist';
-        $template['tabindex'] = 200;
+        $this->pagefoot();
+    }
 
-        $manager->loadClass("ENCAPSULATE");
-        $batch = new BATCH('category');
-        $batch->showlist($query,'table',$template);
+    /**
+     * @todo document this
+     */
+    function action_teamdeleteconfirm() {
+        global $member;
 
-        ?>
+        $memberid = intRequestVar('memberid');
+        $blogid = intRequestVar('blogid');
 
+        $error = $this->deleteOneTeamMember($blogid, $memberid);
+        if ($error)
+            $this->error($error);
 
-        <form action="index.php" method="post"><div>
-        <input name="action" value="categorynew" type="hidden" />
-        <?php $manager->addTicketHidden() ?>
-        <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
 
-        <table><tr>
-            <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
-        </tr><tr>
-            <td><?php echo _EBLOG_CAT_NAME?></td>
-            <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_CAT_DESC?></td>
-            <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
-        </tr><tr>
-            <td><?php echo _EBLOG_CAT_CREATE?></td>
-            <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
-        </tr></table>
+        $this->action_manageteam();
+    }
 
-        </div></form>
+    /**
+     * @todo document this
+     */
+    function deleteOneTeamMember($blogid, $memberid) {
+        global $member, $manager;
 
-        <?php
+        $blogid = intval($blogid);
+        $memberid = intval($memberid);
+
+        // check if allowed
+        if (!$member->blogAdminRights($blogid))
+            return _ERROR_DISALLOWED;
 
-            echo '<h3>',_PLUGINS_EXTRA,'</h3>';
+        // check if: - there remains at least one blog admin
+        //           - (there remains at least one team member)
+        $tmem =& $manager->getMember($memberid);
 
-            $manager->notify(
-                'BlogSettingsFormExtras',
-                array(
-                    'blog' => &$blog
-                )
-            );
+        $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
 
-        $this->pagefoot();
+        if ($tmem->isBlogAdmin($blogid)) {
+            // check if there are more blog members left and at least one admin
+            // (check for at least two admins before deletion)
+            $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
+            $r = DB::getResult($query);
+            if ($r->rowCount() < 2)
+                return _ERROR_ATLEASTONEBLOGADMIN;
+        }
+
+        $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
+        DB::execute($query);
+
+        $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
+
+        return '';
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_teamchangeadmin() {
+        global $manager, $member;
+
+        $blogid = intRequestVar('blogid');
+        $memberid = intRequestVar('memberid');
+
+        // check if allowed
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $mem =& $manager->getMember($memberid);
+
+        // don't allow when there is only one admin at this moment
+        if ($mem->isBlogAdmin($blogid)) {
+            $r = DB::getResult('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
+            if ($r->rowCount() == 1)
+                $this->error(_ERROR_ATLEASTONEBLOGADMIN);
+        }
+
+        if ($mem->isBlogAdmin($blogid))
+            $newval = 0;
+        else
+            $newval = 1;
+
+        $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
+        DB::execute($query);
+
+        // only show manageteam if member did not change its own admin privileges
+        if ($member->isBlogAdmin($blogid))
+            $this->action_manageteam();
+        else
+            $this->action_overview(_MSG_ADMINCHANGED);
     }
+       
+       /**
+        * Admin::action_blogsettings()
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function action_blogsettings()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               
+               // check if allowed
+               $member->blogAdminRights($blogid) or $this->disallow();
+               
+               $blog =& $manager->getBlog($blogid);
+               
+               $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
+               $this->pagehead($extrahead);
+               
+               echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
+               echo '<h2>' . _EBLOG_TITLE . ": '{$this->bloglink($blog)}'</h2>\n";
+               
+               echo '<h3>' . _EBLOG_TEAM_TITLE . "</h3>\n";
+               
+               echo '<p>' . _EBLOG_CURRENT_TEAM_MEMBER;
+               
+               $query = "SELECT mname, mrealname FROM %s, %s WHERE mnumber=tmember AND tblog=%d;";
+               $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
+               $res = DB::getResult($query);
+               $aMemberNames = array();
+               foreach ( $res as $row )
+               {
+                       $aMemberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
+               }
+               echo implode(',', $aMemberNames);
+                       
+               echo "</p>\n";
+               echo '<p>';
+               echo '<a href="index.php?action=manageteam&amp;blogid=' . $blogid . '">' . _EBLOG_TEAM_TEXT . '</a>';
+               echo "</p>\n";
+               
+               echo '<h3>' . _EBLOG_SETTINGS_TITLE . "</h3>\n";
+               
+               echo "<form method=\"post\" action=\"index.php\">\n";
+               echo "<div>\n";
+               
+               echo "<input type=\"hidden\" name=\"action\" value=\"blogsettingsupdate\" />\n";
+               $manager->addTicketHidden() . "\n";
+               echo "<input type=\"hidden\" name=\"blogid\" value=\"{$blogid}\" />\n";
+               
+               echo '<table frame="box" rules="all" summary="' . _EBLOG_SETTINGS_TITLE . '">' . "\n";
+               echo "<tfoot>\n";
+               echo "<tr>\n";
+               echo '<th colspan="2">' . _EBLOG_CHANGE . "</th>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_CHANGE . "</td>\n";
+               echo '<td><input type="submit" tabindex="130" value="' . _EBLOG_CHANGE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "</tfoot>\n";
+               echo "<tbody>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_NAME . "</td>\n";
+               echo '<td><input name="name" tabindex="10" size="40" maxlength="60" value="' . Entity::hsc($blog->getName()) . '" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_SHORTNAME;
+               help('shortblogname');
+               echo _EBLOG_SHORTNAME_EXTRA;
+               echo "</td>\n";
+               echo '<td><input name="shortname" tabindex="20" maxlength="15" size="15" value="' . Entity::hsc($blog->getShortName()) .'" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_DESC . "</td>\n";
+               echo '<td><input name="desc" tabindex="30" maxlength="200" size="40" value="' . Entity::hsc($blog->getDescription()) . '" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_URL . "</td>\n";
+               echo '<td><input name="url" tabindex="40" size="40" maxlength="100" value="' . Entity::hsc($blog->getURL()) . '" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_DEFSKIN;
+               help('blogdefaultskin');
+               echo "</td>\n";
+               echo "<td>\n";
+               
+               $query = 'SELECT sdname as text, sdnumber as value FROM ' . sql_table('skin_desc');
+               $template['name'] = 'defskin';
+               $template['selected'] = $blog->getDefaultSkin();
+               $template['tabindex'] = 50;
+               showlist($query, 'select', $template);
+               
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_LINEBREAKS;
+               help('convertbreaks');
+               echo "</td>\n";
+               echo '<td>';
+               $this->input_yesno('convertbreaks',$blog->convertBreaks(),55);
+               echo "</td>\n";
+               echo "</tr>\n";
+               
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_ALLOWPASTPOSTING;
+               help('allowpastposting');
+               echo "</td>\n";
+               echo '<td>';
+               $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_DISABLECOMMENTS;
+               echo "</td>\n";
+               echo '<td>';
+               $this->input_yesno('comments', $blog->commentsEnabled(), 60);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_ANONYMOUS . "</td>\n";
+               echo '<td>';
+               $this->input_yesno('public',$blog->isPublic(),70);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_REQUIREDEMAIL . "</td>\n";
+               echo '<td>';
+               $this->input_yesno('reqemail', $blog->emailRequired(),72);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_NOTIFY;
+               help('blognotify');
+               echo "</td>\n";
+               echo '<td><input name="notify" tabindex="80" maxlength="128" size="40" value="' . Entity::hsc($blog->getNotifyAddress()) . '" />' . "</td>\n";
+               echo "</tr>\n";
+               
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_NOTIFY_ON . "</td>\n";
+               echo "<td>\n";
+               
+               if ( !$blog->notifyOnComment() )
+               {
+                       echo "<input name=\"notifyComment\" value=\"3\" type=\"checkbox\" tabindex=\"81\" id=\"notifyComment\" />\n";
+               }
+               else
+               {
+                       echo "<input name=\"notifyComment\" value=\"3\" type=\"checkbox\" tabindex=\"81\" id=\"notifyComment\" checked=\"checked\"/>\n";
+               }
+               echo '<label for="notifyComment">' . _EBLOG_NOTIFY_COMMENT . "</label><br />\n";
+               
+               if ( !$blog->notifyOnVote() )
+               {
+                       echo "<input name=\"notifyVote\" value=\"5\" type=\"checkbox\" tabindex=\"82\" id=\"notifyVote\" />\n";
+               }
+               else
+               {
+                       echo "<input name=\"notifyVote\" value=\"5\" type=\"checkbox\" tabindex=\"82\" id=\"notifyVote\" checked=\"checked\" />\n";
+               }
+               
+               echo '<label for="notifyVote">' . _EBLOG_NOTIFY_KARMA . "</label><br />\n";
+               
+               if ( !$blog->notifyOnNewItem() )
+               {
+                       echo "<input name=\"notifyNewItem\" value=\"7\" type=\"checkbox\" tabindex=\"83\" id=\"notifyNewItem\" />\n";
+               
+               }
+               else
+               {
+                       echo "<input name=\"notifyNewItem\" value=\"7\" type=\"checkbox\" tabindex=\"83\" id=\"notifyNewItem\" checked=\"checked\" />\n";
+               }
+               
+               echo '<label for="notifyNewItem">' . _EBLOG_NOTIFY_ITEM . "</label>\n";
+               
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_MAXCOMMENTS;
+               help('blogmaxcomments');
+               echo "</td>\n";
+               echo '<td><input name="maxcomments" tabindex="90" size="3" value="' . Entity::hsc($blog->getMaxComments()) . '" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_UPDATE;
+               help('blogupdatefile');
+               echo "</td>\n";
+               echo '<td><input name="update" tabindex="100" size="40" maxlength="60" value="' . Entity::hsc($blog->getUpdateFile()) .'" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_DEFCAT . "</td>\n";
+               echo "<td>\n";
+               $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);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_OFFSET;
+               help('blogtimeoffset');
+               echo "<br />\n";
+               echo _EBLOG_STIME;
+               echo ' <b>' . i18n::formatted_datetime('%H:%M', time()) . '</b><br />';
+               echo _EBLOG_BTIME;
+               echo '<b>' . i18n::formatted_datetime('%H:%M', $blog->getCorrectTime()) . '</b>';
+               echo "</td>\n";
+               echo '<td><input name="timeoffset" tabindex="120" size="3" value="' . Entity::hsc($blog->getTimeOffset()) .'" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_SEARCH;
+               help('blogsearchable');
+               echo "</td>\n";
+               echo '<td>';
+               $this->input_yesno('searchable', $blog->getSearchable(), 122);
+               echo "</td>\n";
+               echo "</tr>\n";
+               
+               // plugin options
+               $this->_insertPluginOptions('blog', $blogid);
+               
+               echo "</tbody>\n";
+               echo "</table>\n";
+               
+               echo "</div>\n";
+               echo "</form>\n";
+               
+               echo '<h3>' . _EBLOG_CAT_TITLE . "</h3>\n";
+               
+               $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
+               $template['content'] = 'categorylist';
+               $template['tabindex'] = 200;
+               
+               $manager->loadClass("ENCAPSULATE");
+               $batch = new Batch('category');
+               $batch->showlist($query,'table',$template);
+               
+               echo "<form action=\"index.php\" method=\"post\">\n";
+               echo "<div>\n";
+               echo "<input name=\"action\" value=\"categorynew\" type=\"hidden\" />\n";
+               $manager->addTicketHidden() . "\n";
+               echo "<input name=\"blogid\" value=\"{$blog->getID()}\" type=\"hidden\" />\n";
+               
+               echo '<table frame="box" rules="all" summary="' . _EBLOG_CAT_CREATE . '">' . "\n";
+               echo "<thead>\n";
+               echo "<tr>\n";
+               echo '<th colspan="2">' . _EBLOG_CAT_CREATE . "</th>\n";
+               echo "</tr>\n";
+               echo "</thead>\n";
+               echo "<tbody>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_CAT_NAME . "</td>\n";
+               echo "<td><input name=\"cname\" size=\"40\" maxlength=\"40\" tabindex=\"300\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_CAT_DESC . "</td>\n";
+               echo "<td><input name=\"cdesc\" size=\"40\" maxlength=\"200\" tabindex=\"310\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _EBLOG_CAT_CREATE . "</td>\n";
+               echo '<td><input type="submit" value="' . _EBLOG_CAT_CREATE . '" tabindex="320" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "</tbody>\n";
+               echo "</table>\n";
+               echo "</div>\n";
+               echo "</form>\n";
+               
+               echo '<h3>' . _PLUGINS_EXTRA . "</h3>\n";
+               $manager->notify('BlogSettingsFormExtras', array('blog' => &$blog));
+               
+               $this->pagefoot();
+               return;
+       }
 
     /**
      * @todo document this
@@ -2689,9 +6301,9 @@ class ADMIN {
         if (!isValidCategoryName($cname))
             $this->error(_ERROR_BADCATEGORYNAME);
 
-        $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
-        $res = sql_query($query);
-        if (sql_num_rows($res) > 0)
+        $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=' . DB::quoteValue($cname).' and cblog=' . intval($blogid);
+        $res = DB::getResult($query);
+        if ($res->rowCount() > 0)
             $this->error(_ERROR_DUPCATEGORYNAME);
 
         $blog       =& $manager->getBlog($blogid);
@@ -2717,11 +6329,10 @@ class ADMIN {
 
         $member->blogAdminRights($blogid) or $this->disallow();
 
-        $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
-        $obj = sql_fetch_object($res);
+        $res = DB::getRow('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
 
-        $cname = $obj->cname;
-        $cdesc = $obj->cdesc;
+        $cname = $res['cname'];
+        $cdesc = $res['cdesc'];
 
         $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
         $this->pagehead($extrahead);
@@ -2729,22 +6340,22 @@ class ADMIN {
         echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
 
         ?>
-        <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo i18n::hsc($cname)?>'</h2>
+        <h2><?php echo _EBLOG_CAT_UPDATE ?> '<?php echo Entity::hsc($cname) ?>'</h2>
         <form method='post' action='index.php'><div>
-        <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
-        <input name="catid" type="hidden" value="<?php echo $catid?>" />
-        <input name="desturl" type="hidden" value="<?php echo i18n::hsc($desturl) ?>" />
+        <input name="blogid" type="hidden" value="<?php echo $blogid ?>" />
+        <input name="catid" type="hidden" value="<?php echo $catid ?>" />
+        <input name="desturl" type="hidden" value="<?php echo Entity::hsc($desturl) ?>" />
         <input name="action" type="hidden" value="categoryupdate" />
         <?php $manager->addTicketHidden(); ?>
 
         <table><tr>
             <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
         </tr><tr>
-            <td><?php echo _EBLOG_CAT_NAME?></td>
-            <td><input type="text" name="cname" value="<?php echo i18n::hsc($cname)?>" size="40" maxlength="40" /></td>
+            <td><?php echo _EBLOG_CAT_NAME ?></td>
+            <td><input type="text" name="cname" value="<?php echo Entity::hsc($cname) ?>" size="40" maxlength="40" /></td>
         </tr><tr>
-            <td><?php echo _EBLOG_CAT_DESC?></td>
-            <td><input type="text" name="cdesc" value="<?php echo i18n::hsc($cdesc)?>" size="40" maxlength="200" /></td>
+            <td><?php echo _EBLOG_CAT_DESC ?></td>
+            <td><input type="text" name="cdesc" value="<?php echo Entity::hsc($cdesc) ?>" size="40" maxlength="200" /></td>
         </tr>
         <?php
             // insert plugin options
@@ -2753,8 +6364,8 @@ class ADMIN {
         <tr>
             <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
         </tr><tr>
-            <td><?php echo _EBLOG_CAT_UPDATE?></td>
-            <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
+            <td><?php echo _EBLOG_CAT_UPDATE ?></td>
+            <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN ?>" /></td>
         </tr></table>
 
         </div></form>
@@ -2779,21 +6390,21 @@ class ADMIN {
         if (!isValidCategoryName($cname))
             $this->error(_ERROR_BADCATEGORYNAME);
 
-        $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
-        $res = sql_query($query);
-        if (sql_num_rows($res) > 0)
+        $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=' . DB::quoteValue($cname).' and cblog=' . intval($blogid) . " and not(catid=$catid)";
+        $res = DB::getResult($query);
+        if ($res->rowCount() > 0)
             $this->error(_ERROR_DUPCATEGORYNAME);
 
         $query =  'UPDATE '.sql_table('category').' SET'
-               . " cname='" . sql_real_escape_string($cname) . "',"
-               . " cdesc='" . sql_real_escape_string($cdesc) . "'"
-               . " WHERE catid=" . $catid;
+               . ' cname=' . DB::quoteValue($cname) . ','
+               . ' cdesc=' . DB::quoteValue($cdesc)
+               . ' WHERE catid=' . $catid;
 
-        sql_query($query);
+        DB::execute($query);
 
         // store plugin options
         $aOptions = requestArray('plugoption');
-        NucleusPlugin::_applyPluginOptions($aOptions);
+        NucleusPlugin::apply_plugin_options($aOptions);
         $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
 
 
@@ -2828,25 +6439,25 @@ class ADMIN {
 
         // check if catid is the only category left for blogid
         $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
-        $res = sql_query($query);
-        if (sql_num_rows($res) == 1)
+        $res = DB::getResult($query);
+        if ($res->rowCount() == 1)
             $this->error(_ERROR_DELETELASTCATEGORY);
 
 
         $this->pagehead();
         ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
+            <h2><?php echo _DELETE_CONFIRM ?></h2>
 
             <div>
-            <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo  i18n::hsc($blog->getCategoryName($catid))?></b>
+            <?php echo _CONFIRMTXT_CATEGORY ?><b><?php echo  Entity::hsc($blog->getCategoryName($catid)) ?></b>
             </div>
 
             <form method="post" action="index.php"><div>
             <input type="hidden" name="action" value="categorydeleteconfirm" />
             <?php $manager->addTicketHidden() ?>
-            <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
-            <input type="hidden" name="catid" value="<?php echo $catid?>" />
-            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            <input type="hidden" name="blogid" value="<?php echo $blogid ?>" />
+            <input type="hidden" name="catid" value="<?php echo $catid ?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
             </div></form>
         <?php
         $this->pagefoot();
@@ -2869,209 +6480,515 @@ class ADMIN {
 
         $this->action_blogsettings();
     }
-
-    /**
-     * @todo document this
-     */
-    function deleteOneCategory($catid) {
-        global $manager, $member;
-
-        $catid = intval($catid);
-
-        $blogid = getBlogIDFromCatID($catid);
-
-        if (!$member->blogAdminRights($blogid))
-            return ERROR_DISALLOWED;
-
-        // get blog
-        $blog =& $manager->getBlog($blogid);
-
-        // check if the category is valid
-        if (!$blog || !$blog->isValidCategory($catid))
-            return _ERROR_NOSUCHCATEGORY;
-
-        $destcatid = $blog->getDefaultCategory();
-
-        // don't allow deletion of default category
-        if ($blog->getDefaultCategory() == $catid)
-            return _ERROR_DELETEDEFCATEGORY;
-
-        // check if catid is the only category left for blogid
-        $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
-        $res = sql_query($query);
-        if (sql_num_rows($res) == 1)
-            return _ERROR_DELETELASTCATEGORY;
-
-        $manager->notify('PreDeleteCategory', array('catid' => $catid));
-
-        // change category for all items to the default category
-        $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
-        sql_query($query);
-
-        // delete all associated plugin options
-        NucleusPlugin::_deleteOptionValues('category', $catid);
-
-        // delete category
-        $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
-        sql_query($query);
-
-        $manager->notify('PostDeleteCategory', array('catid' => $catid));
-
-    }
-
-    /**
-     * @todo document this
-     */
-    function moveOneCategory($catid, $destblogid) {
-        global $manager, $member;
-
-        $catid = intval($catid);
-        $destblogid = intval($destblogid);
-
-        $blogid = getBlogIDFromCatID($catid);
-
-        // mover should have admin rights on both blogs
-        if (!$member->blogAdminRights($blogid))
-            return _ERROR_DISALLOWED;
-        if (!$member->blogAdminRights($destblogid))
-            return _ERROR_DISALLOWED;
-
-        // cannot move to self
-        if ($blogid == $destblogid)
-            return _ERROR_MOVETOSELF;
-
-        // get blogs
-        $blog =& $manager->getBlog($blogid);
-        $destblog =& $manager->getBlog($destblogid);
-
-        // check if the category is valid
-        if (!$blog || !$blog->isValidCategory($catid))
-            return _ERROR_NOSUCHCATEGORY;
-
-        // don't allow default category to be moved
-        if ($blog->getDefaultCategory() == $catid)
-            return _ERROR_MOVEDEFCATEGORY;
-
-        $manager->notify(
-            'PreMoveCategory',
-            array(
-                'catid' => &$catid,
-                'sourceblog' => &$blog,
-                'destblog' => &$destblog
-            )
-        );
-
-        // update comments table (cblog)
-        $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
-        $items = sql_query($query);
-        while ($oItem = sql_fetch_object($items)) {
-            sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
-        }
-
-        // update items (iblog)
-        $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
-        sql_query($query);
-
-        // move category
-        $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
-        sql_query($query);
-
-        $manager->notify(
-            'PostMoveCategory',
-            array(
-                'catid' => &$catid,
-                'sourceblog' => &$blog,
-                'destblog' => $destblog
-            )
-        );
-
-    }
-
+=======
+       
+       /**
+        * Admin::action_skinedit()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinedit()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('skinedit');
+               return;
+       }
+       
+       /**
+        * Admin::action_skineditgeneral()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skineditgeneral()
+       {
+               global $member;
+               
+               $skinid = intRequestVar('skinid');
+               
+               $member->isAdmin() or self::disallow();
+               
+               $error = self::skineditgeneral($skinid);
+               if ( $error )
+               {
+                       self::error($error);
+                       return;
+               }
+               
+               self::action_skinedit();
+               return;
+       }
+       
+       static private function action_skinedittype($msg = '')
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               if ( $msg )
+               {
+                       self::$headMess = $msg;
+               }
+               
+               $type = requestVar('type');
+               $type = trim($type);
+               $type = strtolower($type);
+               
+               if ( !isValidShortName($type) )
+               {
+                       self::error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
+                       return;
+               }
+               
+               self::$skin->parse('skinedittype');
+               return;
+       }
+>>>>>>> skinnable-master
+       
+       /**
+        * Admin::action_skinupdate()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinupdate()
+       {
+               global $manager, $member;
+               
+               $skinid = intRequestVar('skinid');
+               $content = trim(postVar('content'));
+               $type = postVar('type');
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skin =& $manager->getSKIN($skinid);
+               $skin->update($type, $content);
+               
+               self::action_skinedittype(_SKIN_UPDATED);
+               return;
+       }
+       
        /**
-        * @todo document this
+        * Admin::action_skindelete()
+        * 
+        * @param       void
+        * @return      void
         */
-       function action_blogsettingsupdate()
+       static private function action_skindelete()
        {
-               global $member, $manager;
+               global $CONF, $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skinid = intRequestVar('skinid');
+               
+               // don't allow default skin to be deleted
+               if ( $skinid == $CONF['BaseSkin'] )
+               {
+                       self::error(_ERROR_DEFAULTSKIN);
+                       return;
+               }
+               
+               // don't allow deletion of default skins for blogs
+               $query = "SELECT bname FROM %s WHERE bdefskin=%d";
+               $query = sprintf($query, sql_table('blog'), (integer) $skinid);
+               
+               $name = DB::getValue($query);
+               if ( $name )
+               {
+                       self::error(_ERROR_SKINDEFDELETE . Entity::hsc($name));
+                       return;
+               }
+               
+               self::$skin->parse('skindelete');
+               return;
+       }
        
-               $blogid = intRequestVar('blogid');
+       /**
+        * Admin::action_skindeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skindeleteconfirm()
+       {
+               global $member, $CONF;
                
-               $member->blogAdminRights($blogid) or $this->disallow();
+               $member->isAdmin() or self::disallow();
                
-               $blog =& $manager->getBlog($blogid);
+               $skinid = intRequestVar('skinid');
+               
+               // don't allow default skin to be deleted
+               if ( $skinid == $CONF['BaseSkin'] )
+               {
+                       self::error(_ERROR_DEFAULTSKIN);
+                       return;
+               }
                
-               $notify         = trim(postVar('notify'));
-               $shortname              = trim(postVar('shortname'));
-               $updatefile     = trim(postVar('update'));
+<<<<<<< HEAD
+               // check if catid is the only category left for blogid
+               $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
+               $res = DB::getResult($query);
+               if ( $res->rowCount() == 1 )
+=======
+               // don't allow deletion of default skins for blogs
+               $query = "SELECT bname FROM %s WHERE bdefskin=%d;";
+               $query = sprintf($query, sql_table('blog'), (integer) $skinid);
                
-               $notifyComment  = intPostVar('notifyComment');
-               $notifyVote             = intPostVar('notifyVote');
-               $notifyNewItem  = intPostVar('notifyNewItem');
+               $name = DB::getValue($query);
+               if ( $name )
+                               {
+                       self::error(_ERROR_SKINDEFDELETE . Entity::hsc($name));
+                       return;
+               }
+               
+               self::skindeleteconfirm($skinid);
+               
+               self::action_skinoverview();
+               return;
+       }
+       
+       /**
+        * Admin::action_skinremovetype()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinremovetype()
+       {
+               global $member, $CONF;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skinid = intRequestVar('skinid');
+               $skintype = requestVar('type');
                
-               if ($notifyComment == 0)
+               if ( !isValidShortName($skintype) )
+>>>>>>> skinnable-master
                {
-                       $notifyComment = 1;
+                       self::error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+                       return;
                }
-               if ($notifyVote == 0)
+               
+               self::$skin->parse('skinremovetype');
+               return;
+       }
+       
+       /**
+        * Admin::action_skinremovetypeconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinremovetypeconfirm()
+       {
+               global $member;
+               
+<<<<<<< HEAD
+               // change category for all items to the default category
+               $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
+               DB::execute($query);
+=======
+               $member->isAdmin() or self::disallow();
+>>>>>>> skinnable-master
+               
+               $skinid = intRequestVar('skinid');
+               $skintype = requestVar('type');
+               
+<<<<<<< HEAD
+               // delete category
+               $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
+               DB::execute($query);
+=======
+               $error = self::skinremovetypeconfirm($skinid, $skintype);
+               if ( $error )
                {
-                       $notifyVote = 1;
+                       self::error($error);
+                       return;
+               }
+>>>>>>> skinnable-master
+               
+               self::action_skinedit();
+               return;
+       }
+       
+       /**
+        * Admin::action_skinclone()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_skinclone()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skinid = intRequestVar('skinid');
+               
+               self::skinclone($skinid);
+               
+               self::action_skinoverview();
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskinoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinoverview()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('adminskinoverview');
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskinnew()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinnew()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $name = trim(postVar('name'));
+               $desc = trim(postVar('desc'));
+               
+               if ( !isValidSkinName($name) )
+               {
+                       self::error(_ERROR_BADSKINNAME);
+                       return;
                }
-               if ($notifyNewItem == 0)
+               else if ( !preg_match('#^admin/#', $name) )
                {
-                       $notifyNewItem = 1;
+                       self::error(_ERROR_BADADMINSKINNAME);
+                       return;
                }
-               $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
+               else if ( Skin::exists($name) )
+               {
+                       self::error(_ERROR_DUPSKINNAME);
+                       return;
+               }
+               
+               Skin::createNew($name, $desc);
+               
+               self::action_adminskinoverview();
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskinedit()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinedit()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('adminskinedit');
+               
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskineditgeneral()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskineditgeneral()
+       {
+               global $member;
+               
+               $skinid = intRequestVar('skinid');
                
-               if ($notify)
+               $member->isAdmin() or self::disallow();
+               
+               $error = self::skineditgeneral($skinid, 'AdminActions');
+               if ( $error )
                {
-                       $not = new NOTIFICATION($notify);
-                       if (!$not->validAddresses())
-                       {
-                               $this->error(_ERROR_BADNOTIFY);
-                       }
+                       self::error($error);
+                       return;
                }
                
-               if (!isValidShortName($shortname))
+               self::action_adminskinedit();
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskinedittype()
+        * 
+        * @param       string  $msg    message for pageheader
+        * @return      void
+        */
+       static private function action_adminskinedittype($msg = '')
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               if ( $msg )
                {
-                       $this->error(_ERROR_BADSHORTBLOGNAME);
+                       self::$headMess = $msg;
                }
+               $type = requestVar('type');
+               $type = trim($type);
+               $type = strtolower($type);
                
-               if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
+               if ( !isValidShortName($type) )
                {
-                       $this->error(_ERROR_DUPSHORTBLOGNAME);
+                       self::error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
+                       return;
                }
-               // check if update file is writable
-               if ($updatefile && !is_writeable($updatefile))
+               
+               self::$skin->parse('adminskinedittype');
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskinupdate()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinupdate()
+       {
+               global $manager, $member;
+               
+               $skinid = intRequestVar('skinid');
+               $content = trim(postVar('content'));
+               $type = postVar('type');
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skin =& $manager->getSkin($skinid, 'AdminActions', 'AdminSkin');
+               $skin->update($type, $content);
+               
+               self::action_adminskinedittype(_SKIN_UPDATED);
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskindelete()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskindelete()
+       {
+               global $CONF, $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skinid = intRequestVar('skinid');
+               
+               // don't allow default skin to be deleted
+               if ( $skinid == $CONF['AdminSkin'] || $skinid == $CONF['BookmarkletSkin'] )
                {
-                       $this->error(_ERROR_UPDATEFILE);
+                       self::error(_ERROR_DEFAULTSKIN);
+                       return;
                }
                
-               $blog->setName(trim(postVar('name')));
-               $blog->setShortName($shortname);
-               $blog->setNotifyAddress($notify);
-               $blog->setNotifyType($notifyType);
-               $blog->setMaxComments(postVar('maxcomments'));
-               $blog->setCommentsEnabled(postVar('comments'));
-               $blog->setTimeOffset(postVar('timeoffset'));
-               $blog->setUpdateFile($updatefile);
-               $blog->setURL(trim(postVar('url')));
-               $blog->setDefaultSkin(intPostVar('defskin'));
-               $blog->setDescription(trim(postVar('desc')));
-               $blog->setPublic(postVar('public'));
-               $blog->setConvertBreaks(intPostVar('convertbreaks'));
-               $blog->setAllowPastPosting(intPostVar('allowpastposting'));
-               $blog->setDefaultCategory(intPostVar('defcat'));
-               $blog->setSearchable(intPostVar('searchable'));
-               $blog->setEmailRequired(intPostVar('reqemail'));
-               $blog->writeSettings();
+               /* don't allow if someone use it as a default*/
+               $query = 'SELECT * FROM %s WHERE madminskin = %d or mbkmklt = %d;';
+               $res = DB::getResult(sprintf($query, sql_table('member'), $skinid, $skinid));
                
-               // store plugin options
-               $aOptions = requestArray('plugoption');
-               NucleusPlugin::_applyPluginOptions($aOptions);
-               $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
+               $members = array();
+               while ( $row = $res->fetch() ) {
+                       $members[] = $row['mrealname'];
+               }
+               if ( count($members) )
+               {
+                       self::error(_ERROR_SKINDEFDELETE . implode(' ' . _AND . ' ', $members));
+                       return;
+               }
+               
+               self::$skin->parse('adminskindelete');
+               return;
+       }
+
+       /**
+        * Admin::action_adminskindeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskindeleteconfirm()
+       {
+               global $member, $CONF;
                
-               $this->action_overview(_MSG_SETTINGSCHANGED);
+               $member->isAdmin() or self::disallow();
+               
+               $skinid = intRequestVar('skinid');
+               
+               // don't allow default skin to be deleted
+               if ( $skinid == $CONF['AdminSkin'] || $skinid == $CONF['BookmarkletSkin'] )
+               {
+                       self::error(_ERROR_DEFAULTSKIN);
+                       return;
+               }
+               
+               /* don't allow if someone use it as a default*/
+               $query = 'SELECT * FROM %s WHERE madminskin = %d or mbkmklt = %d;';
+               $res = DB::getResult(sprintf($query, sql_table('member'), $skinid, $skinid));
+               
+               $members = array();
+               while ( $row = $res->fetch() ) {
+                       $members[] = $row['mrealname'];
+               }
+               if ( count($members) )
+               {
+                       self::error(_ERROR_SKINDEFDELETE . implode(' ' . _AND . ' ', $members));
+                       return;
+               }
+               
+               self::skindeleteconfirm($skinid);
+               
+               self::action_adminskinoverview();
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskinremovetype()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinremovetype()
+       {
+               global $member, $CONF;
+
+               $member->isAdmin() or self::disallow();
+               
+               $skinid = intRequestVar('skinid');
+               $skintype = requestVar('type');
+               
+               if ( !isValidShortName($skintype) )
+               {
+                       self::error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+                       return;
+               }
+               
+               self::$skin->parse('adminskinremovetype');
+               return;
        }
+<<<<<<< HEAD
 
     /**
      * @todo document this
@@ -3091,73 +7008,118 @@ class ADMIN {
 
         $this->pagehead();
         ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
+            <h2><?php echo _DELETE_CONFIRM ?></h2>
 
-            <p><?php echo _WARNINGTXT_BLOGDEL?>
+            <p><?php echo _WARNINGTXT_BLOGDEL ?>
             </p>
 
             <div>
-            <?php echo _CONFIRMTXT_BLOG?><b><?php echo  i18n::hsc($blog->getName())?></b>
+            <?php echo _CONFIRMTXT_BLOG ?><b><?php echo  Entity::hsc($blog->getName()) ?></b>
             </div>
 
             <form method="post" action="index.php"><div>
             <input type="hidden" name="action" value="deleteblogconfirm" />
             <?php $manager->addTicketHidden() ?>
             <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
-            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
             </div></form>
         <?php
         $this->pagefoot();
     }
+=======
+>>>>>>> skinnable-master
+       
+       /**
+        * Admin::action_adminskinremovetypeconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinremovetypeconfirm()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skinid = intRequestVar('skinid');
+               $skintype = requestVar('type');
+               
+               $error = self::skinremovetypeconfirm($skinid, $skintype);
+               if ( $error )
+               {
+                       self::error($error);
+                       return;
+               }
+               
+<<<<<<< HEAD
+               // delete all comments
+               $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
+               DB::execute($query);
+               
+               // delete all items
+               $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
+               DB::execute($query);
+               
+               // delete all team members
+               $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
+               DB::execute($query);
+               
+               // delete all bans
+               $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
+               DB::execute($query);
+               
+               // delete all categories
+               $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
+               DB::execute($query);
+=======
+               self::action_adminskinedit();
+               return;
+       }
 
-    /**
-     * @todo document this
-     */
-    function action_deleteblogconfirm() {
-        global $member, $CONF, $manager;
-
-        $blogid = intRequestVar('blogid');
-
-        $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
-
-        $member->blogAdminRights($blogid) or $this->disallow();
-
-        // check if blog is default blog
-        if ($CONF['DefaultBlog'] == $blogid)
-            $this->error(_ERROR_DELDEFBLOG);
-
-        // delete all comments
-        $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
-        sql_query($query);
-
-        // delete all items
-        $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
-        sql_query($query);
-
-        // delete all team members
-        $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
-        sql_query($query);
-
-        // delete all bans
-        $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
-        sql_query($query);
-
-        // delete all categories
-        $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
-        sql_query($query);
-
-        // delete all associated plugin options
-        NucleusPlugin::_deleteOptionValues('blog', $blogid);
-
-        // delete the blog itself
-        $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
-        sql_query($query);
-
-        $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
-
-        $this->action_overview(_DELETED_BLOG);
-    }
-
+       /**
+        * Admin::action_adminskinclone()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinclone()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $skinid = intRequestVar('skinid');
+>>>>>>> skinnable-master
+               
+               self::skinclone($skinid, 'AdminActions');
+               
+<<<<<<< HEAD
+               // delete the blog itself
+               $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
+               DB::execute($query);
+=======
+               self::action_adminskinoverview();
+               return;
+       }
+       
+       /**
+        * Admin::action_adminskinieoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinieoverview()
+       {
+               global $member;
+>>>>>>> skinnable-master
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('adminskinieoverview');
+               return;
+       }
+<<<<<<< HEAD
+       
     /**
      * @todo document this
      */
@@ -3168,13 +7130,13 @@ class ADMIN {
 
         ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
 
-        $mem = MEMBER::createFromID($memberid);
+        $mem =& $manager->getMember($memberid);
 
         $this->pagehead();
         ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
+            <h2><?php echo _DELETE_CONFIRM ?></h2>
 
-            <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo i18n::hsc($mem->getDisplayName()) ?></b>
+            <p><?php echo _CONFIRMTXT_MEMBER ?><b><?php echo Entity::hsc($mem->getDisplayName()) ?></b>
             </p>
 
             <p>
@@ -3185,71 +7147,71 @@ class ADMIN {
             <input type="hidden" name="action" value="memberdeleteconfirm" />
             <?php $manager->addTicketHidden() ?>
             <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
-            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
             </div></form>
-        <?php
-        $this->pagefoot();
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_memberdeleteconfirm() {
-        global $member;
-
-        $memberid = intRequestVar('memberid');
-
-        ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-        $error = $this->deleteOneMember($memberid);
-        if ($error)
-            $this->error($error);
-
-        if ($member->isAdmin())
-            $this->action_usermanagement();
-        else
-            $this->action_overview(_DELETED_MEMBER);
+        <?php
+        $this->pagefoot();
     }
 
     /**
-     * @static
      * @todo document this
      */
-    function deleteOneMember($memberid) {
-        global $manager;
-
-        $memberid = intval($memberid);
-        $mem = MEMBER::createFromID($memberid);
-
-        if (!$mem->canBeDeleted())
-            return _ERROR_DELETEMEMBER;
-
-        $manager->notify('PreDeleteMember', array('member' => &$mem));
-
-        /* unlink comments from memberid */
-        if ($memberid) {
-            $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. sql_real_escape_string($mem->getDisplayName())
-                        .'" WHERE cmember='.$memberid;
-            sql_query($query);
-        }
-
-        $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
-        sql_query($query);
-
-        $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
-        sql_query($query);
-
-        $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
-        sql_query($query);
-
-        // delete all associated plugin options
-        NucleusPlugin::_deleteOptionValues('member', $memberid);
-
-        $manager->notify('PostDeleteMember', array('member' => &$mem));
-
-        return '';
-    }
+    function action_memberdeleteconfirm() {
+        global $member;
+=======
+>>>>>>> skinnable-master
 
+       /**
+        * Admin::action_adminskinieimport()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinieimport()
+       {
+               global $member;
+               
+<<<<<<< HEAD
+               $memberid = intval($memberid);
+               $mem =& $manager->getMember($memberid);
+               
+               if ( !$mem->canBeDeleted() )
+               {
+                       return _ERROR_DELETEMEMBER;
+               }
+=======
+               $member->isAdmin() or self::disallow();
+>>>>>>> skinnable-master
+               
+               $skinFileRaw = postVar('skinfile');
+               $mode = postVar('mode');
+               
+               $error = self::skinieimport($mode, $skinFileRaw);
+               if ( $error )
+               {
+<<<<<<< HEAD
+                       $query = "UPDATE %s SET cmember=0, cuser=%s WHERE cmember=%d";
+                       $query = sprintf($query, sql_table('comment'), DB::quoteValue($mem->getDisplayName()), $memberid);
+                       DB::execute($query);
+               }
+               
+               $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
+               DB::execute($query);
+               
+               $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
+               DB::execute($query);
+               
+               $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
+               DB::execute($query);
+               
+               // delete all associated plugin options
+               NucleusPlugin::delete_option_values('member', $memberid);
+               
+               $manager->notify('PostDeleteMember', array('member' => &$mem));
+               
+               return '';
+       }
+       
     /**
      * @todo document this
      */
@@ -3263,7 +7225,7 @@ class ADMIN {
 
         echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
         ?>
-        <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
+        <h2><?php echo _EBLOG_CREATE_TITLE ?></h2>
 
         <h3><?php echo _ADMIN_NOTABILIA ?></h3>
 
@@ -3279,7 +7241,7 @@ class ADMIN {
         <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
 
         <p>
-        <?php echo _EBLOG_CREATE_TEXT?>
+        <?php echo _EBLOG_CREATE_TEXT ?>
         </p>
 
         <form method="post" action="index.php"><div>
@@ -3289,18 +7251,18 @@ class ADMIN {
 
 
         <table><tr>
-            <td><?php echo _EBLOG_NAME?></td>
+            <td><?php echo _EBLOG_NAME ?></td>
             <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
         </tr><tr>
-            <td><?php echo _EBLOG_SHORTNAME?>
+            <td><?php echo _EBLOG_SHORTNAME ?>
                 <?php help('shortblogname'); ?>
             </td>
             <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
         </tr><tr>
-            <td><?php echo _EBLOG_DESC?></td>
+            <td><?php echo _EBLOG_DESC ?></td>
             <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
         </tr><tr>
-            <td><?php echo _EBLOG_DEFSKIN?>
+            <td><?php echo _EBLOG_DEFSKIN ?>
                 <?php help('blogdefaultskin'); ?>
             </td>
             <td>
@@ -3314,19 +7276,19 @@ class ADMIN {
                 ?>
             </td>
         </tr><tr>
-            <td><?php echo _EBLOG_OFFSET?>
+            <td><?php echo _EBLOG_OFFSET ?>
                 <?php help('blogtimeoffset'); ?>
-                <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
+                <br /><?php echo _EBLOG_STIME ?> <b><?php echo i18n::formatted_datetime('%H:%M',time()); ?></b>
             </td>
             <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
         </tr><tr>
-            <td><?php echo _EBLOG_ADMIN?>
+            <td><?php echo _EBLOG_ADMIN ?>
                 <?php help('teamadmin'); ?>
             </td>
-            <td><?php echo _EBLOG_ADMIN_MSG?></td>
+            <td><?php echo _EBLOG_ADMIN_MSG ?></td>
         </tr><tr>
-            <td><?php echo _EBLOG_CREATE?></td>
-            <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+            <td><?php echo _EBLOG_CREATE ?></td>
+            <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN ?>" onclick="return checkSubmit();" /></td>
         </tr></table>
 
         </div></form>
@@ -3367,27 +7329,30 @@ class ADMIN {
         );
 
 
-        // add slashes for sql queries
-        $bname =        sql_real_escape_string($bname);
-        $bshortname =   sql_real_escape_string($bshortname);
-        $btimeoffset =  sql_real_escape_string($btimeoffset);
-        $bdesc =        sql_real_escape_string($bdesc);
-        $bdefskin =     sql_real_escape_string($bdefskin);
-
         // create blog
-        $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
-        sql_query($query);
-        $blogid = sql_insert_id();
+               $query = sprintf('INSERT INTO %s (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES (%s, %s, %s, %s, %s)',
+                       sql_table('blog'),
+                       DB::quoteValue($bname),
+                       DB::quoteValue($bshortname),
+                       DB::quoteValue($bdesc),
+                       DB::quoteValue($btimeoffset),
+                       DB::quoteValue($bdefskin)
+               );
+        DB::execute($query);
+        $blogid = DB::getInsertId();
         $blog   =& $manager->getBlog($blogid);
 
         // create new category
         $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
         $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
-        $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
-        sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
-//             sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
-//             sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
-        $catid = sql_insert_id();
+               $query = sprintf('INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, %s, %s)',
+                       sql_table('category'),
+                       $blogid,
+                       DB::quoteValue($catdefname),
+                       DB::quoteValue($catdefdesc)
+               );
+        DB::execute($query);
+        $catid = DB::getInsertId();
 
         // set as default category
         $blog->setDefaultCategory($catid);
@@ -3395,17 +7360,15 @@ class ADMIN {
 
         // create team member
         $memberid = $member->getID();
-        $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
-        sql_query($query);
+        $query = sprintf('INSERT INTO %s (tmember, tblog, tadmin) VALUES (%d, %d, 1)', sql_table('team'), $memberid, $blogid);
+        DB::execute($query);
 
         $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
         $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
 
         $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
-        //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
-
-
 
+        
         $manager->notify(
             'PostAddBlog',
             array(
@@ -3427,23 +7390,23 @@ class ADMIN {
         ?>
         <h2><?php echo _BLOGCREATED_TITLE ?></h2>
 
-        <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, i18n::hsc($bname)) ?></p>
+        <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, Entity::hsc($bname)) ?></p>
 
         <ol>
-            <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, i18n::hsc($bshortname)) ?></a></li>
+            <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, Entity::hsc($bshortname)) ?></a></li>
             <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
         </ol>
 
-        <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, i18n::hsc($bshortname)) ?></a></h3>
+        <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, Entity::hsc($bshortname)) ?></a></h3>
 
-        <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, i18n::hsc($bshortname)) ?></p>
+        <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, Entity::hsc($bshortname)) ?></p>
 <pre><code>&lt;?php
 
-$CONF['Self'] = '<b><?php echo i18n::hsc($bshortname)?>.php</b>';
+$CONF['Self'] = '<b><?php echo Entity::hsc($bshortname) ?>.php</b>';
 
 include('<i>./config.php</i>');
 
-selectBlog('<b><?php echo i18n::hsc($bshortname)?></b>');
+selectBlog('<b><?php echo Entity::hsc($bshortname) ?></b>');
 selector();
 
 ?&gt;</code></pre>
@@ -3455,13 +7418,13 @@ selector();
         <form action="index.php" method="post"><div>
             <input type="hidden" name="action" value="addnewlog2" />
             <?php $manager->addTicketHidden() ?>
-            <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
+            <input type="hidden" name="blogid" value="<?php echo intval($blogid) ?>" />
             <table><tr>
-                <td><?php echo _EBLOG_URL?></td>
-                <td><input name="url" maxlength="100" size="40" value="<?php echo i18n::hsc($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
+                <td><?php echo _EBLOG_URL ?></td>
+                <td><input name="url" maxlength="100" size="40" value="<?php echo Entity::hsc($CONF['IndexURL'].$bshortname.'.php') ?>" /></td>
             </tr><tr>
-                <td><?php echo _EBLOG_CREATE?></td>
-                <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+                <td><?php echo _EBLOG_CREATE ?></td>
+                <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN ?>" onclick="return checkSubmit();" /></td>
             </tr></table>
         </div></form>
 
@@ -3472,13 +7435,13 @@ selector();
         <form action="index.php" method="post"><div>
             <input type="hidden" name="action" value="addnewlog2" />
             <?php $manager->addTicketHidden() ?>
-            <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
+            <input type="hidden" name="blogid" value="<?php echo intval($blogid) ?>" />
             <table><tr>
-                <td><?php echo _EBLOG_URL?></td>
+                <td><?php echo _EBLOG_URL ?></td>
                 <td><input name="url" maxlength="100" size="40" /></td>
             </tr><tr>
-                <td><?php echo _EBLOG_CREATE?></td>
-                <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+                <td><?php echo _EBLOG_CREATE ?></td>
+                <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN ?>" onclick="return checkSubmit();" /></td>
             </tr></table>
         </div></form>
 
@@ -3520,12 +7483,12 @@ selector();
         echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
 
     ?>
-        <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
+        <h2><?php echo _SKINIE_TITLE_IMPORT ?></h2>
 
-                <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
+                <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL ?></label>
                 <?php                   global $DIR_SKINS;
 
-                    $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
+                    $candidates = SkinImport::searchForCandidates($DIR_SKINS);
 
                     if (sizeof($candidates) > 0) {
                         ?>
@@ -3535,12 +7498,12 @@ selector();
                                 <input type="hidden" name="mode" value="file" />
                                 <select name="skinfile" id="skinie_import_local">
                                 <?php                                   foreach ($candidates as $skinname => $skinfile) {
-                                        $html = i18n::hsc($skinfile);
+                                        $html = Entity::hsc($skinfile);
                                         echo '<option value="',$html,'">',$skinname,'</option>';
                                     }
                                 ?>
                                 </select>
-                                <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
+                                <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT ?>" />
                             </div></form>
                         <?php                   } else {
                         echo _SKINIE_NOCANDIDATES;
@@ -3548,58 +7511,58 @@ selector();
                 ?>
                 </p>
 
-                <p><em><?php echo _OR?></em></p>
+                <p><em><?php echo _OR ?></em></p>
 
                 <form method="post" action="index.php"><p>
                     <?php $manager->addTicketHidden() ?>
                     <input type="hidden" name="action" value="skinieimport" />
                     <input type="hidden" name="mode" value="url" />
-                    <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
+                    <label for="skinie_import_url"><?php echo _SKINIE_FROMURL ?></label>
                     <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
-                    <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
+                    <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT ?>" />
                 </p></form>
 
 
-        <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
+        <h2><?php echo _SKINIE_TITLE_EXPORT ?></h2>
         <form method="post" action="index.php"><div>
             <input type="hidden" name="action" value="skinieexport" />
             <?php $manager->addTicketHidden() ?>
 
-            <p><?php echo _SKINIE_EXPORT_INTRO?></p>
+            <p><?php echo _SKINIE_EXPORT_INTRO ?></p>
 
             <table><tr>
-                <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
+                <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS ?></th>
             </tr><tr>
     <?php       // show list of skins
-        $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
-        while ($skinObj = sql_fetch_object($res)) {
-            $id = 'skinexp' . $skinObj->sdnumber;
-            echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']"  id="',$id,'" />';
-            echo '<label for="',$id,'">',i18n::hsc($skinObj->sdname),'</label></td>';
-            echo '<td>',i18n::hsc($skinObj->sddesc),'</td>';
+        $res = DB::getResult('SELECT * FROM '.sql_table('skin_desc'));
+        foreach ( $res as $row) {
+            $id = 'skinexp' . $row['sdnumber'];
+            echo '<td><input type="checkbox" name="skin[',$row['sdnumber'],']"  id="',$id,'" />';
+            echo '<label for="',$id,'">',Entity::hsc($row['sdname']),'</label></td>';
+            echo '<td>',Entity::hsc($row['sddesc']),'</td>';
             echo '</tr><tr>';
         }
 
         echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
 
         // show list of templates
-        $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
-        while ($templateObj = sql_fetch_object($res)) {
-            $id = 'templateexp' . $templateObj->tdnumber;
-            echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
-            echo '<label for="',$id,'">',i18n::hsc($templateObj->tdname),'</label></td>';
-            echo '<td>',i18n::hsc($templateObj->tddesc),'</td>';
+        $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'));
+        foreach ( $res as $row ) {
+            $id = 'templateexp' . $row['tdnumber'];
+            echo '<td><input type="checkbox" name="template[',$row['tdnumber'],']" id="',$id,'" />';
+            echo '<label for="',$id,'">',Entity::hsc($row['tdname']),'</label></td>';
+            echo '<td>',Entity::hsc($row['tddesc']),'</td>';
             echo '</tr><tr>';
         }
 
     ?>
-                <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
+                <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA ?></th>
             </tr><tr>
                 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
             </tr><tr>
-                <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
+                <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT ?></th>
             </tr><tr>
-                <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
+                <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT ?>" /></td>
             </tr></table>
         </div></form>
 
@@ -3622,7 +7585,7 @@ selector();
         $skinFileRaw= postVar('skinfile');
         $mode       = postVar('mode');
 
-        $importer = new SKINIMPORT();
+        $importer = new SkinImport();
 
         // get full filename
         if ($mode == 'file')
@@ -3650,18 +7613,18 @@ selector();
 
         echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
         ?>
-        <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
+        <h2><?php echo _SKINIE_CONFIRM_TITLE ?></h2>
 
         <ul>
-            <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo i18n::hsc($importer->getInfo())?></p></li>
-            <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
-            <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_GENERAL ?></strong> <?php echo Entity::hsc($importer->getInfo()) ?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_SKINS ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames()) ?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames()) ?></p></li>
             <?php
                 if ($hasNameClashes)
                 {
             ?>
-            <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
-            <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
+            <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes) ?></p></li>
+            <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes) ?></p></li>
             <?php
                 } // if (hasNameClashes)
             ?>
@@ -3670,15 +7633,15 @@ selector();
         <form method="post" action="index.php"><div>
             <input type="hidden" name="action" value="skiniedoimport" />
             <?php $manager->addTicketHidden() ?>
-            <input type="hidden" name="skinfile" value="<?php echo i18n::hsc(postVar('skinfile'))?>" />
-            <input type="hidden" name="mode" value="<?php echo i18n::hsc($mode)?>" />
-            <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
+            <input type="hidden" name="skinfile" value="<?php echo Entity::hsc(postVar('skinfile')) ?>" />
+            <input type="hidden" name="mode" value="<?php echo Entity::hsc($mode) ?>" />
+            <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT ?>" />
             <?php
                 if ($hasNameClashes)
                 {
             ?>
             <br />
-            <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
+            <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE ?></label>
             <?php
                 } // if (hasNameClashes)
             ?>
@@ -3718,7 +7681,7 @@ selector();
             $skinFile = $skinFileRaw;
         }
 
-        $importer = new SKINIMPORT();
+        $importer = new SkinImport();
 
         $error = $importer->readFile($skinFile);
 
@@ -3734,12 +7697,12 @@ selector();
 
         echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
     ?>
-        <h2><?php echo _SKINIE_DONE?></h2>
+        <h2><?php echo _SKINIE_DONE ?></h2>
 
         <ul>
-            <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo i18n::hsc($importer->getInfo())?></p></li>
-            <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
-            <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_GENERAL ?></strong> <?php echo Entity::hsc($importer->getInfo()) ?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames()) ?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames()) ?></p></li>
         </ul>
 
     <?php       $this->pagefoot();
@@ -3768,7 +7731,7 @@ selector();
 
         $info = postVar('info');
 
-        $exporter = new SKINEXPORT();
+        $exporter = new SkinExport();
         foreach ($skinList as $skinId) {
             $exporter->addSkin($skinId);
         }
@@ -3808,14 +7771,14 @@ selector();
         <input name="action" value="templatenew" type="hidden" />
         <?php $manager->addTicketHidden() ?>
         <table><tr>
-            <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
+            <td><?php echo _TEMPLATE_NAME ?> <?php help('shortnames'); ?></td>
             <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
         </tr><tr>
-            <td><?php echo _TEMPLATE_DESC?></td>
+            <td><?php echo _TEMPLATE_DESC ?></td>
             <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
         </tr><tr>
-            <td><?php echo _TEMPLATE_CREATE?></td>
-            <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+            <td><?php echo _TEMPLATE_CREATE ?></td>
+            <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN ?>" onclick="return checkSubmit();" /></td>
         </tr></table>
 
         </div></form>
@@ -3835,25 +7798,25 @@ selector();
         $member->isAdmin() or $this->disallow();
 
         $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
-        $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
+        $extrahead .= '<script type="text/javascript">setTemplateEditText('.DB::quoteValue(_EDITTEMPLATE_EMPTY).');</script>';
 
         $this->pagehead($extrahead);
 
-        $templatename = TEMPLATE::getNameFromId($templateid);
-        $templatedescription = TEMPLATE::getDesc($templateid);
+        $templatename = Template::getNameFromId($templateid);
+        $templatedescription = Template::getDesc($templateid);
         $template =& $manager->getTemplate($templatename);
 
         ?>
         <p>
-        <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
+        <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK ?>)</a>
         </p>
 
-        <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo  i18n::hsc($templatename); ?>'</h2>
+        <h2><?php echo _TEMPLATE_EDIT_TITLE ?> '<?php echo  Entity::hsc($templatename); ?>'</h2>
 
         <?php                   if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
         ?>
 
-        <p><?php echo _TEMPLATE_EDIT_MSG?></p>
+        <p><?php echo _TEMPLATE_EDIT_MSG ?></p>
 
         <form method="post" action="index.php">
         <div>
@@ -3863,23 +7826,23 @@ selector();
         <input type="hidden" name="templateid" value="<?php echo  $templateid; ?>" />
 
         <table><tr>
-            <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
+            <th colspan="2"><?php echo _TEMPLATE_SETTINGS ?></th>
         </tr><tr>
-            <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
-            <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo  i18n::hsc($templatename) ?>" /></td>
+            <td><?php echo _TEMPLATE_NAME ?> <?php help('shortnames'); ?></td>
+            <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo  Entity::hsc($templatename) ?>" /></td>
         </tr><tr>
-            <td><?php echo _TEMPLATE_DESC?></td>
-            <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo  i18n::hsc($templatedescription) ?>" /></td>
+            <td><?php echo _TEMPLATE_DESC ?></td>
+            <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo  Entity::hsc($templatedescription) ?>" /></td>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
+            <th colspan="2"><?php echo _TEMPLATE_UPDATE ?></th>
         </tr><tr>
-            <td><?php echo _TEMPLATE_UPDATE?></td>
+            <td><?php echo _TEMPLATE_UPDATE ?></td>
             <td>
-                <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
-                <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
+                <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN ?>" onclick="return checkSubmit();" />
+                <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN ?>" />
             </td>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
+            <th colspan="2"><?php echo _TEMPLATE_ITEMS ?> <?php help('templateitems'); ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
     $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
     $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
@@ -3888,7 +7851,7 @@ selector();
     $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
+            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY ?> <?php help('templatecomments'); ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
     $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
     $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
@@ -3898,34 +7861,34 @@ selector();
     $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
+            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE ?> <?php help('templatecomments'); ?></th>
 <?php
     $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
+            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH ?> <?php help('templatecomments'); ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
+            <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST ?> <?php help('templatearchivelists'); ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
     $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
     $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
+            <th colspan="2"><?php echo _TEMPLATE_BLOGLIST ?> <?php help('templatebloglists'); ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
     $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
     $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
+            <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST ?> <?php help('templatecategorylists'); ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
     $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
     $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
+            <th colspan="2"><?php echo _TEMPLATE_DATETIME ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
     $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
     $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
@@ -3933,18 +7896,18 @@ selector();
     $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
+            <th colspan="2"><?php echo _TEMPLATE_IMAGE ?> <?php help('templatepopups'); ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
     $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
     $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
+            <th colspan="2"><?php echo _TEMPLATE_SEARCH ?></th>
 <?php  $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
     $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
+            <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS ?></th>
 <?php
         $tab = 600;
         $pluginfields = array();
@@ -3952,19 +7915,19 @@ selector();
 
         foreach ($pluginfields as $pfkey=>$pfvalue) {
             echo "</tr><tr>\n";
-            echo '<th colspan="2">' . i18n::hen($pfkey) . "</th>\n";
+            echo '<th colspan="2">' . Entity::hen($pfkey) . "</th>\n";
             foreach ($pfvalue as $pffield=>$pfdesc) {
                 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
             }
         }
 ?>
         </tr><tr>
-            <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
+            <th colspan="2"><?php echo _TEMPLATE_UPDATE ?></th>
         </tr><tr>
-            <td><?php echo _TEMPLATE_UPDATE?></td>
+            <td><?php echo _TEMPLATE_UPDATE ?></td>
             <td>
-                <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
-                <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
+                <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN ?>" onclick="return checkSubmit();" />
+                <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN ?>" />
             </td>
         </tr></table>
 
@@ -3982,8 +7945,8 @@ selector();
         if (!isset($template[$name])) $template[$name] = '';
     ?>
         </tr><tr>
-            <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
-            <td id="td<?php echo $count?>"><textarea class="templateedit" name="<?php echo $name?>" tabindex="<?php echo $tabindex?>" cols="50" rows="<?php echo $big?10:5?>" id="textarea<?php echo $count?>"><?php echo  i18n::hsc($template[$name]); ?></textarea></td>
+            <td><?php echo $description ?> <?php if ($help) help('template'.$help); ?></td>
+            <td id="td<?php echo $count ?>"><textarea class="templateedit" name="<?php echo $name ?>" tabindex="<?php echo $tabindex ?>" cols="50" rows="<?php echo $big?10:5 ?>" id="textarea<?php echo $count ?>"><?php echo  Entity::hsc($template[$name]); ?></textarea></td>
     <?php       $count++;
     }
 
@@ -4003,23 +7966,23 @@ selector();
         if (!isValidTemplateName($name))
             $this->error(_ERROR_BADTEMPLATENAME);
 
-        if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
+        if ((Template::getNameFromId($templateid) != $name) && Template::exists($name))
             $this->error(_ERROR_DUPTEMPLATENAME);
 
 
-        $name = sql_real_escape_string($name);
-        $desc = sql_real_escape_string($desc);
+        $name = DB::quoteValue($name);
+        $desc = DB::quoteValue($desc);
 
         // 1. Remove all template parts
         $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
-        sql_query($query);
+        DB::execute($query);
 
         // 2. Update description
         $query =  'UPDATE '.sql_table('template_desc').' SET'
-               . " tdname='" . $name . "',"
-               . " tddesc='" . $desc . "'"
-               . " WHERE tdnumber=" . $templateid;
-        sql_query($query);
+               . ' tdname=' . $name . ','
+               . ' tddesc=' . $desc
+               . ' WHERE tdnumber=' . $templateid;
+        DB::execute($query);
 
         // 3. Add non-empty template parts
         $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
@@ -4070,24 +8033,60 @@ selector();
 
     }
 
-    /**
-     * @todo document this
-     */
-    function addToTemplate($id, $partname, $content) {
-        $partname = sql_real_escape_string($partname);
-        $content = sql_real_escape_string($content);
-
-        $id = intval($id);
-
-        // don't add empty parts:
-        if (!trim($content)) return -1;
-
-        $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
-               . "VALUES ($id, '$partname', '$content')";
-        sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
-        return sql_insert_id();
-    }
-
+=======
+                       self::error($error);
+                       return;
+               }
+               
+               if ( !is_object(self::$skin) )
+               {
+                       self::action_adminskiniedoimport();
+               }
+               else
+               {
+                       self::$skin->parse('adminskinieimport');
+               }
+               return;
+       }
+       
+>>>>>>> skinnable-master
+       /**
+        * Admin::action_adminskiniedoimport()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskiniedoimport()
+       {
+               global $DIR_SKINS, $member, $CONF;
+               
+               $member->isAdmin() or self::disallow();
+               
+               $mode = postVar('mode');
+               $skinFileRaw = postVar('skinfile');
+               $allowOverwrite = intPostVar('overwrite');
+               
+               $error = self::skiniedoimport($mode, $skinFileRaw, $allowOverwrite);
+               if ( $error )
+               {
+                       self::error($error);
+                       return;
+               }
+               
+<<<<<<< HEAD
+               $partname = DB::quoteValue($partname);
+               $content = DB::quoteValue($content);
+               
+               $query = "INSERT INTO %s (tdesc, tpartname, tcontent) VALUES (%d, %s, %s)";
+               $query = sprintf($query, sql_table('template'), (integer) $id, $partname, $content);
+               if ( DB::execute($query) === FALSE )
+               {
+                       $err = DB::getError();
+                       exit(_ADMIN_SQLDIE_QUERYERROR . $err[2]);
+               }
+               return DB::getInsertId();
+       }
+       
     /**
      * @todo document this
      */
@@ -4101,21 +8100,21 @@ selector();
 
         $this->pagehead();
 
-        $name = TEMPLATE::getNameFromId($templateid);
-        $desc = TEMPLATE::getDesc($templateid);
+        $name = Template::getNameFromId($templateid);
+        $desc = Template::getDesc($templateid);
 
         ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
+            <h2><?php echo _DELETE_CONFIRM ?></h2>
 
             <p>
-            <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo i18n::hsc($name)?></b> (<?php echo  i18n::hsc($desc) ?>)
+            <?php echo _CONFIRMTXT_TEMPLATE ?><b><?php echo Entity::hsc($name) ?></b> (<?php echo  Entity::hsc($desc) ?>)
             </p>
 
             <form method="post" action="index.php"><div>
                 <input type="hidden" name="action" value="templatedeleteconfirm" />
                 <?php $manager->addTicketHidden() ?>
                 <input type="hidden" name="templateid" value="<?php echo  $templateid ?>" />
-                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
             </div></form>
         <?php
         $this->pagefoot();
@@ -4134,10 +8133,10 @@ selector();
         $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
 
         // 1. delete description
-        sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
+        DB::execute('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
 
         // 2. delete parts
-        sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
+        DB::execute('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
 
         $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
 
@@ -4158,10 +8157,10 @@ selector();
         if (!isValidTemplateName($name))
             $this->error(_ERROR_BADTEMPLATENAME);
 
-        if (TEMPLATE::exists($name))
+        if (Template::exists($name))
             $this->error(_ERROR_DUPTEMPLATENAME);
 
-        $newTemplateId = TEMPLATE::createNew($name, $desc);
+        $newTemplateId = Template::createNew($name, $desc);
 
         $this->action_templateoverview();
     }
@@ -4177,79 +8176,87 @@ selector();
         $member->isAdmin() or $this->disallow();
 
         // 1. read old template
-        $name = TEMPLATE::getNameFromId($templateid);
-        $desc = TEMPLATE::getDesc($templateid);
+        $name = Template::getNameFromId($templateid);
+        $desc = Template::getDesc($templateid);
 
         // 2. create desc thing
         $name = "cloned" . $name;
 
         // if a template with that name already exists:
-        if (TEMPLATE::exists($name)) {
+        if (Template::exists($name)) {
             $i = 1;
-            while (TEMPLATE::exists($name . $i))
+            while (Template::exists($name . $i))
                 $i++;
             $name .= $i;
         }
 
-        $newid = TEMPLATE::createNew($name, $desc);
+        $newid = Template::createNew($name, $desc);
 
         // 3. create clone
         // go through parts of old template and add them to the new one
-        $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
-        while ($o = sql_fetch_object($res)) {
-            $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
+        $res = DB::getResult('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
+        foreach ( $res as $row ) {
+            $this->addToTemplate($newid, $row['tpartname'], $row['tcontent']);
         }
 
         $this->action_templateoverview();
     }
-
-    /**
-     * @todo document this
-     */
-    function action_skinoverview() {
-        global $member, $manager;
-
-        $member->isAdmin() or $this->disallow();
-
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-        echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
-
-        echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
-
-        $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
-        $template['content'] = 'skinlist';
-        $template['tabindex'] = 10;
-        showlist($query,'table',$template);
-
-        echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
-
-        ?>
-        <form method="post" action="index.php">
-        <div>
-
-        <input name="action" value="skinnew" type="hidden" />
-        <?php $manager->addTicketHidden() ?>
-        <table><tr>
-            <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
-            <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
-        </tr><tr>
-            <td><?php echo _SKIN_DESC?></td>
-            <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
-        </tr><tr>
-            <td><?php echo _SKIN_CREATE?></td>
-            <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-        </tr></table>
-
-        </div>
-        </form>
-
-        <?php
-        $this->pagefoot();
-    }
-
+       
+       /**
+        * Admin::action_skinoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function action_skinoverview()
+       {
+               global $member, $manager;
+               
+               $member->isAdmin() or $this->disallow();
+               
+               $this->pagehead();
+               
+               echo '<p><a href="index.php?action=manage">(' . _BACKTOMANAGE . ")</a></p>\n";
+               echo '<h2>' . _SKIN_EDIT_TITLE . "</h2>\n";
+               echo '<h3>' . _SKIN_AVAILABLE_TITLE . "</h3>\n";
+               
+               $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname;';
+               $template['content'] = 'skinlist';
+               $template['tabindex'] = 10;
+               
+               showlist($query,'table',$template);
+               
+               echo '<h3>' . _SKIN_NEW_TITLE . "</h3>\n";
+               echo "<form method=\"post\" action=\"index.php\">\n";
+               echo "<div>\n";
+               echo "<input name=\"action\" value=\"skinnew\" type=\"hidden\" />\n";
+               
+               $manager->addTicketHidden() . "\n";
+               
+               echo "<table frame=\"box\" rules=\"all\" summary=\"skinoverview\">\n";
+               echo "<tr>\n";
+               echo "<td>" . _SKIN_NAME;
+               echo help('shortnames');
+               echo "</td>\n";
+               echo "<td><input name=\"name\" tabindex=\"10010\" maxlength=\"20\" size=\"20\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo "<td>" . _SKIN_DESC . "</td>\n";
+               echo "<td><input name=\"desc\" tabindex=\"10020\" maxlength=\"200\" size=\"50\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _SKIN_CREATE . "</td>\n";
+               echo '<td><input type="submit" tabindex="10030" value="' . _SKIN_CREATE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "</table>\n";
+               
+               echo "</div>\n";
+               echo "</form>\n";
+               
+               $this->pagefoot();
+               return;
+       }
+       
     /**
      * @todo document this
      */
@@ -4264,105 +8271,138 @@ selector();
         if (!isValidSkinName($name))
             $this->error(_ERROR_BADSKINNAME);
 
-        if (SKIN::exists($name))
+        if (Skin::exists($name))
             $this->error(_ERROR_DUPSKINNAME);
 
-        $newId = SKIN::createNew($name, $desc);
+        $newId = Skin::createNew($name, $desc);
 
         $this->action_skinoverview();
     }
 
-    /**
-     * @todo document this
-     */
-    function action_skinedit() {
-        global $member, $manager;
-
-        $skinid = intRequestVar('skinid');
-
-        $member->isAdmin() or $this->disallow();
-
-        $skin = new SKIN($skinid);
-
-        $this->pagehead();
-        ?>
-        <p>
-            <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
-        </p>
-        <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo  $skin->getName() ?>'</h2>
-
-        <h3><?php echo _SKIN_PARTS_TITLE?></h3>
-        <?php echo _SKIN_PARTS_MSG?>
-        <ul>
-            <li><a tabindex="10" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=index"><?php echo _SKIN_PART_MAIN?></a> <?php help('skinpartindex')?></li>
-            <li><a tabindex="20" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=item"><?php echo _SKIN_PART_ITEM?></a> <?php help('skinpartitem')?></li>
-            <li><a tabindex="30" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=archivelist"><?php echo _SKIN_PART_ALIST?></a> <?php help('skinpartarchivelist')?></li>
-            <li><a tabindex="40" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=archive"><?php echo _SKIN_PART_ARCHIVE?></a> <?php help('skinpartarchive')?></li>
-            <li><a tabindex="50" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=search"><?php echo _SKIN_PART_SEARCH?></a> <?php help('skinpartsearch')?></li>
-            <li><a tabindex="60" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=error"><?php echo _SKIN_PART_ERROR?></a> <?php help('skinparterror')?></li>
-            <li><a tabindex="70" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=member"><?php echo _SKIN_PART_MEMBER?></a> <?php help('skinpartmember')?></li>
-            <li><a tabindex="75" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=imagepopup"><?php echo _SKIN_PART_POPUP?></a> <?php help('skinpartimagepopup')?></li>
-        </ul>
-
-        <?php
-
-        $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
-        $res = sql_query($query);
-
-        echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
-        echo '<form method="get" action="index.php">' . "\r\n";
-        echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
-        echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
-        echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
-        echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
-        echo '</form>' . "\r\n";
-
-        if ($res && sql_num_rows($res) > 0) {
-            echo '<ul>';
-            $tabstart = 75;
-
-            while ($row = sql_fetch_assoc($res)) {
-                echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&amp;skinid=' . $skinid . '&amp;type=' . i18n::hsc(strtolower($row['stype'])) . '">' . i18n::hsc(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&amp;skinid=' . $skinid . '&amp;type=' . i18n::hsc(strtolower($row['stype'])) . '">remove</a>)</li>';
-            }
-
-            echo '</ul>';
-        }
-
-        ?>
-
-        <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
-        <form method="post" action="index.php">
-        <div>
-
-        <input type="hidden" name="action" value="skineditgeneral" />
-        <?php $manager->addTicketHidden() ?>
-        <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-        <table><tr>
-            <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
-            <td><input name="name" tabindex="90" value="<?php echo  i18n::hsc($skin->getName()) ?>" maxlength="20" size="20" /></td>
-        </tr><tr>
-            <td><?php echo _SKIN_DESC?></td>
-            <td><input name="desc" tabindex="100" value="<?php echo  i18n::hsc($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
-        </tr><tr>
-            <td><?php echo _SKIN_TYPE?></td>
-            <td><input name="type" tabindex="110" value="<?php echo  i18n::hsc($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
-        </tr><tr>
-            <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
-            <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
-        </tr><tr>
-            <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
-            <td><input name="inc_prefix" tabindex="130" value="<?php echo  i18n::hsc($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
-        </tr><tr>
-            <td><?php echo _SKIN_CHANGE?></td>
-            <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
-        </tr></table>
-
-        </div>
-        </form>
-
-
-        <?php       $this->pagefoot();
-    }
+       /**
+        * Admin::action_skinedit()
+        * @param       void
+        * @return      void
+        */
+       public function action_skinedit()
+       {
+               global $member, $manager;
+               
+               $skinid = intRequestVar('skinid');
+               
+               $member->isAdmin() or $this->disallow();
+               
+               $skin = new SKIN($skinid);
+               $default_skin_types = $skin->getDefaultTypes();
+               $available_skin_types = $skin->getAvailableTypes();
+               
+               $this->pagehead();
+               
+               echo "<p>";
+               echo '( <a href="index.php?action=skinoverview">' . _SKIN_BACK . "</a> )";
+               echo "</p>\n";
+               echo '<h2>' . _SKIN_EDITONE_TITLE . $skin->getName() . "</h2>\n";
+               
+               echo '<h3>' . _SKIN_PARTS_TITLE . "</h3>\n";
+               echo _SKIN_PARTS_MSG . "\n";
+               echo "<ul>\n";
+               
+               $tabindex = 10;
+               foreach ( $default_skin_types as $type => $friendly_name )
+               {
+                       echo "<li>\n";
+                       echo "<a tabindex=\"{$tabindex}\" href=\"index.php?action=skinedittype&amp;skinid={$skinid}&amp;type={$type}\">";
+                       echo $friendly_name;
+                       echo "</a>\n";
+                       help("skinpart{$type}");
+                       echo "</li>\n";
+                       $tabindex++;
+               }
+               echo "</ul>\n";
+               
+               echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
+               echo "<form method=\"get\" action=\"index.php\">\n";
+               echo "<input type=\"hidden\" name=\"action\" value=\"skinedittype\" />\n";
+               echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
+               echo "<input type=\"text\" name=\"type\" tabindex=\"89\" size=\"20\" maxlength=\"20\" />\n";
+               echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . "\" onclick=\"return checkSubmit();\" />\n";
+               echo "</form>\n";
+               
+               /* NOTE: special skin parts has FALSE in its value */
+               if ( in_array(FALSE, array_values($available_skin_types)) )
+               {
+                       $tabstart = 75;
+                       
+                       echo '<ul>';
+                       foreach ( $available_skin_types as $type => $friendly_name )
+                       {
+                               if ( !$friendly_name )
+                               {
+                                       $tabstart++;
+                                       echo "<li>\n";
+                                       echo "<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinedittype&amp;skinid={$skinid}&amp;type=" . Entity::hsc(strtolower($type)) . '">';
+                                       echo Entity::hsc(ucfirst($type));
+                                       echo "</a>\n";
+                                       $tabstart++;
+                                       echo "(<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinremovetype&amp;skinid={$skinid}&amp;type=" . Entity::hsc(strtolower($type)) . '">';
+                                       echo _LISTS_DELETE;
+                                       echo "</a>)\n";
+                                       echo "</li>\n";
+                               }
+                       }
+                       echo '</ul>';
+               }
+               
+               echo '<h3>' . _SKIN_GENSETTINGS_TITLE . "</h3>\n";
+               echo "<form method=\"post\" action=\"index.php\">\n";
+               echo "<div>\n";
+               echo "<input type=\"hidden\" name=\"action\" value=\"skineditgeneral\" />\n";
+               $manager->addTicketHidden() . "\n";
+               echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
+               
+               echo '<table frame="box" rules="all" summary="' . _SKIN_GENSETTINGS_TITLE . '">' . "\n";
+               echo "<tr>\n";
+               echo '<td>';
+               echo _SKIN_NAME;
+               help('shortnames');
+               echo "</td>\n";
+               echo '<td><input type="text" name="name" tabindex="90" value="' . Entity::hsc($skin->getName()) . '" maxlength="20" size="20" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _SKIN_DESC . "</td>\n";
+               echo '<td><input type="text" name="desc" tabindex="100" value="' . Entity::hsc($skin->getDescription()) . '" maxlength="200" size="50" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _SKIN_TYPE . "</td>\n";
+               echo '<td><input type="text" name="type" tabindex="110" value="' . Entity::hsc($skin->getContentType()) . '" maxlength="40" size="20" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>';
+               echo _SKIN_INCLUDE_MODE;
+               help('includemode');
+               echo "</td>\n";
+               echo '<td>';
+               $this->input_yesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
+               echo "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>';
+               echo _SKIN_INCLUDE_PREFIX;
+               help('includeprefix');
+               echo "</td>\n";
+               echo '<td><input type="text" name="inc_prefix" tabindex="130" value="' . Entity::hsc($skin->getIncludePrefix()) . '" maxlength="40" size="20" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _SKIN_CHANGE . "</td>\n";
+               echo '<td><input type="submit" tabindex="140" value="' . _SKIN_CHANGE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "</table>\n";
+               
+               echo "</div>\n";
+               echo "</form>\n";
+               $this->pagefoot();
+               return;
+       }
 
     /**
      * @todo document this
@@ -4370,117 +8410,156 @@ selector();
     function action_skineditgeneral() {
         global $member;
 
-        $skinid = intRequestVar('skinid');
-
-        $member->isAdmin() or $this->disallow();
-
-        $name = postVar('name');
-        $desc = postVar('desc');
-        $type = postVar('type');
-        $inc_mode = postVar('inc_mode');
-        $inc_prefix = postVar('inc_prefix');
-
-        $skin = new SKIN($skinid);
-
-        // 1. Some checks
-        if (!isValidSkinName($name))
-            $this->error(_ERROR_BADSKINNAME);
-
-        if (($skin->getName() != $name) && SKIN::exists($name))
-            $this->error(_ERROR_DUPSKINNAME);
-
-        if (!$type) $type = 'text/html';
-        if (!$inc_mode) $inc_mode = 'normal';
-
-        // 2. Update description
-        $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
-
-        $this->action_skinedit();
-
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_skinedittype($msg = '') {
-        global $member, $manager;
-
-        $skinid = intRequestVar('skinid');
-        $type = requestVar('type');
-
-        $member->isAdmin() or $this->disallow();
-
-        $type = trim($type);
-        $type = strtolower($type);
-
-        if (!isValidShortName($type)) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
-        }
-
-        $skin = new SKIN($skinid);
-
-        $friendlyNames = SKIN::getFriendlyNames();
-
-        $this->pagehead();
-        ?>
-        <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
-
-        <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo i18n::hsc($skin->getName()) ?>': <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
-
-        <?php           if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
-        ?>
+        $skinid = intRequestVar('skinid');
 
+        $member->isAdmin() or $this->disallow();
 
-        <form method="post" action="index.php">
-        <div>
+        $name = postVar('name');
+        $desc = postVar('desc');
+        $type = postVar('type');
+        $inc_mode = postVar('inc_mode');
+        $inc_prefix = postVar('inc_prefix');
 
-        <input type="hidden" name="action" value="skinupdate" />
-        <?php $manager->addTicketHidden() ?>
-        <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-        <input type="hidden" name="type" value="<?php echo  $type ?>" />
-
-        <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
-        <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
-        (skin type: <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
-        <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-            help('skinpart' . $type);
-        } else {
-            help('skinpartspecial');
-        }?>
-        <br />
+        $skin = new SKIN($skinid);
 
-        <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo  i18n::hsc($skin->getContent($type)) ?></textarea>
+        // 1. Some checks
+        if (!isValidSkinName($name))
+            $this->error(_ERROR_BADSKINNAME);
 
-        <br />
-        <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
-        <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
-        (skin type: <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
+        if (($skin->getName() != $name) && Skin::exists($name))
+            $this->error(_ERROR_DUPSKINNAME);
 
-        <br /><br />
-        <?php echo _SKIN_ALLOWEDVARS?>
-        <?php           $actions = SKIN::getAllowedActionsForType($type);
+        if (!$type) $type = 'text/html';
+        if (!$inc_mode) $inc_mode = 'normal';
 
-            sort($actions);
+        // 2. Update description
+        $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
 
-            while ($current = array_shift($actions)) {
-                // skip deprecated vars
-                if ($current == 'ifcat') continue;
-                if ($current == 'imagetext') continue;
-                if ($current == 'vars') continue;
+        $this->action_skinedit();
 
-                echo helplink('skinvar-' . $current) . "$current</a>";
-                if (count($actions) != 0) echo ", ";
-            }
-        echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
-        $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
-        showlist($query,'table',array('content'=>'shortblognames'));
-        echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
-        $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
-        showlist($query,'table',array('content'=>'shortnames'));
-        echo '</div></form>';
-        $this->pagefoot();
     }
 
+       /**
+        * Admin::action_skinedittype()
+        * 
+        * @param       string  $msg    message for pageheader
+        * @return      void
+        */
+       public function action_skinedittype($msg = '')
+       {
+               global $member, $manager;
+               
+               $skinid = intRequestVar('skinid');
+               $type = requestVar('type');
+               
+               $member->isAdmin() or $this->disallow();
+               
+               $type = trim($type);
+               $type = strtolower($type);
+               
+               if ( !isValidShortName($type) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
+               }
+               
+               $skin = new SKIN($skinid);
+               $skin_types = $skin->getAvailableTypes();
+               if ( !array_key_exists($type, $skin_types) || !$skin_types[$type] )
+               {
+                       $friendlyName = ucfirst($type);
+               }
+               else
+               {
+                       $friendlyName = $skin_types[$type];
+               }
+               
+               $this->pagehead();
+               
+               echo '<p>(<a href="index.php?action=skinoverview">' . _SKIN_GOBACK . "</a>)</p>\n";
+               
+               echo '<h2>' . _SKIN_EDITPART_TITLE . " '" . Entity::hsc($skin->getName()) . "': " . Entity::hsc($friendlyName) . "</h2>\n";
+               
+               if ( $msg != '')
+               {
+                       echo "<p>" . _MESSAGE . ": $msg</p>\n";
+               }
+               
+               echo "<form method=\"post\" action=\"index.php\">\n";
+               echo "<div>\n";
+               
+               echo "<input type=\"hidden\" name=\"action\" value=\"skinupdate\" />\n";
+               $manager->addTicketHidden() . "\n";
+               echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
+               echo "<input type=\"hidden\" name=\"type\" value=\"{$type}\" />\n";
+               
+               echo '<input type="submit" value="' . _SKIN_UPDATE_BTN . '" onclick="return checkSubmit();" />' . "\n";
+               echo '<input type="reset" value="' . _SKIN_RESET_BTN . '" />' . "\n";
+               echo '(skin type: ' . Entity::hsc($friendlyName) . ")\n";
+               
+               if ( !array_key_exists($type, $skin_types) || !$skin_types[$type] )
+               {
+                       help('skinpartspecial');
+               }
+               else
+               {
+                       help('skinpart' . $type);
+               }
+               echo "<br />\n";
+               
+               echo "<textarea class=\"skinedit\" tabindex=\"10\" rows=\"20\" cols=\"80\" name=\"content\">\n";
+               echo Entity::hsc($skin->getContentFromDB($type)) . "\n";
+               echo "</textarea>\n";
+               
+               echo "<br />\n";
+               echo '<input type="submit" tabindex="20" value="' . _SKIN_UPDATE_BTN . '" onclick="return checkSubmit();" />' . "\n";
+               echo '<input type="reset" value="' . _SKIN_RESET_BTN . '" />' . "\n";
+               echo '(skin type: ' . Entity::hsc($friendlyName) . ")\n";
+               
+               echo "<br />\n";
+               echo "<br />\n";
+               echo _SKIN_ALLOWEDVARS;
+               
+               $actions = $skin->getAllowedActionsForType($type);
+               
+               sort($actions);
+               
+               while ( $current = array_shift($actions) )
+               {
+                       // skip deprecated vars
+                       if ( in_array($current, array('ifcat', 'imagetext', 'vars')) )
+                       {
+                               continue;
+                       }
+                       
+                       echo helplink("skinvar-{$current}") . "{$current}</a>\n";
+                       
+                       if ( count($actions) != 0 )
+                       {
+                               echo ", ";
+                       }
+               }
+               
+               echo "<br />\n";
+               echo "<br />\n";
+               echo _SKINEDIT_ALLOWEDBLOGS;
+               
+               $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
+               showlist($query, 'table', array('content'=>'shortblognames'));
+               
+               echo "<br />\n";
+               echo _SKINEDIT_ALLOWEDTEMPLATESS;
+               
+               $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
+               showlist($query, 'table', array('content'=>'shortnames'));
+               
+               echo "</div>\n";
+               echo "</form>\n";
+               
+               $this->pagefoot();
+               
+               return;
+       }
+
     /**
      * @todo document this
      */
@@ -4515,9 +8594,9 @@ selector();
 
         // don't allow deletion of default skins for blogs
         $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
-        $r = sql_query($query);
-        if ($o = sql_fetch_object($r))
-            $this->error(_ERROR_SKINDEFDELETE . i18n::hsc($o->bname));
+        $r = DB::getValue($query);
+        if ( $r )
+            $this->error(_ERROR_SKINDEFDELETE . Entity::hsc($r));
 
         $this->pagehead();
 
@@ -4526,17 +8605,17 @@ selector();
         $desc = $skin->getDescription();
 
         ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
+            <h2><?php echo _DELETE_CONFIRM ?></h2>
 
             <p>
-                <?php echo _CONFIRMTXT_SKIN?><b><?php echo i18n::hsc($name) ?></b> (<?php echo  i18n::hsc($desc)?>)
+                <?php echo _CONFIRMTXT_SKIN ?><b><?php echo Entity::hsc($name) ?></b> (<?php echo  Entity::hsc($desc) ?>)
             </p>
 
             <form method="post" action="index.php"><div>
                 <input type="hidden" name="action" value="skindeleteconfirm" />
                 <?php $manager->addTicketHidden() ?>
                 <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
             </div></form>
         <?php
         $this->pagefoot();
@@ -4558,97 +8637,126 @@ selector();
 
         // don't allow deletion of default skins for blogs
         $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
-        $r = sql_query($query);
-        if ($o = sql_fetch_object($r))
-            $this->error(_ERROR_SKINDEFDELETE .$o->bname);
+        $r = DB::getValue($query);
+        if ($r)
+            $this->error(_ERROR_SKINDEFDELETE .$r);
 
         $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
 
         // 1. delete description
-        sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
+        DB::execute('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
 
         // 2. delete parts
-        sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
+        DB::execute('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
 
         $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
 
         $this->action_skinoverview();
     }
-
-    /**
-     * @todo document this
-     */
-    function action_skinremovetype() {
-        global $member, $manager, $CONF;
-
-        $skinid = intRequestVar('skinid');
-        $skintype = requestVar('type');
-
-        if (!isValidShortName($skintype)) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-        }
-
-        $member->isAdmin() or $this->disallow();
-
-        // don't allow default skinparts to be deleted
-        if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-        }
-
-        $this->pagehead();
-
-        $skin = new SKIN($skinid);
-        $name = $skin->getName();
-        $desc = $skin->getDescription();
-
-        ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
-
-            <p>
-                <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo i18n::hsc($skintype); ?> (<?php echo i18n::hsc($name); ?>)</b> (<?php echo  i18n::hsc($desc)?>)
-            </p>
-
-            <form method="post" action="index.php"><div>
-                <input type="hidden" name="action" value="skinremovetypeconfirm" />
-                <?php $manager->addTicketHidden() ?>
-                <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
-                <input type="hidden" name="type" value="<?php echo i18n::hsc($skintype); ?>" />
-                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-            </div></form>
-        <?php
-        $this->pagefoot();
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_skinremovetypeconfirm() {
-        global $member, $CONF, $manager;
-
-        $skinid = intRequestVar('skinid');
-        $skintype = requestVar('type');
-
-        if (!isValidShortName($skintype)) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-        }
-
-        $member->isAdmin() or $this->disallow();
-
-        // don't allow default skinparts to be deleted
-        if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-        }
-
-        $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
-
-        // delete part
-        sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
-
-        $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
-
-        $this->action_skinedit();
-    }
-
+       
+       /**
+        * Admin::action_skinremovetype()
+        *
+        * @param       void
+        * @return      void
+        */
+       public function action_skinremovetype()
+       {
+               global $member, $manager, $CONF;
+               
+               $skinid = intRequestVar('skinid');
+               $skintype = requestVar('type');
+               
+               if ( !isValidShortName($skintype) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+               }
+               
+               $member->isAdmin() or $this->disallow();
+               
+               // don't allow default skinparts to be deleted
+               $skin = new Skin($skinid);
+               $default_skin_types = $skin->getDefaultTypes();
+               if ( array_key_exists($skintype, $default_skin_types) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+               }
+               
+               $name = $skin->getName();
+               $desc = $skin->getDescription();
+               
+               $this->pagehead();
+               
+               echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
+               echo "<p>\n";
+               echo _CONFIRMTXT_SKIN_PARTS_SPECIAL;
+               echo Entity::hsc($skintype);
+               echo  '(' . Entity::hsc($name) . ')</b>';
+               echo ' (' . Entity::hsc($desc) . ')';
+               echo "</p>\n";
+               
+               echo "<form method=\"post\" action=\"index.php\">\n";
+               echo "<div>\n";
+               echo "<input type=\"hidden\" name=\"action\" value=\"skinremovetypeconfirm\" />\n";
+               $manager->addTicketHidden();
+               echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
+               echo '<input type="hidden" name="type" value="' . Entity::hsc($skintype) . '" />' . "\n";
+               echo '<input type="submit" tabindex="10" value="' . _DELETE_CONFIRM_BTN . '" />' . "\n";
+               echo "</div>\n";
+               echo "</form>\n";
+               $this->pagefoot();
+               return;
+       }
+       
+       /**
+        * Admin::action_skinremovetypeconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function action_skinremovetypeconfirm()
+       {
+               global $member, $CONF, $manager;
+               
+               $skinid = intRequestVar('skinid');
+               $skintype = requestVar('type');
+               
+               if ( !isValidShortName($skintype) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+               }
+               
+               $member->isAdmin() or $this->disallow();
+               
+               // don't allow default skinparts to be deleted
+               $skin = new Skin($skinid);
+               $default_skin_types = $skin->getDefaultTypes();
+               if ( array_key_exists($skintype, $default_skin_types) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+               }
+               
+               $data = array(
+                       'skinid'        => $skinid,
+                       'skintype'      => $skintype
+               );
+               $manager->notify('PreDeleteSkinPart', $data);
+               
+               // delete part
+               $query = "DELETE FROM %s WHERE sdesc=%d AND stype='%s';";
+               $query = sprintf($query, sql_table('skin'), (integer) $skinid, $skintype);
+               DB::execute($query);
+               
+               $data = array(
+                       'skinid'        => $skinid,
+                       'skintype'      => $skintype
+               );
+               $manager->notify('PostDeleteSkinPart', $data);
+               
+               $this->action_skinedit();
+               return;
+       }
+       
     /**
      * @todo document this
      */
@@ -4665,130 +8773,169 @@ selector();
         $name = "clone_" . $skin->getName();
 
         // if a skin with that name already exists:
-        if (SKIN::exists($name)) {
+        if (Skin::exists($name)) {
             $i = 1;
-            while (SKIN::exists($name . $i))
+            while (Skin::exists($name . $i))
                 $i++;
             $name .= $i;
         }
 
         // 2. create skin desc
-        $newid = SKIN::createNew(
+        $newid = Skin::createNew(
             $name,
             $skin->getDescription(),
             $skin->getContentType(),
             $skin->getIncludeMode(),
             $skin->getIncludePrefix()
         );
-
-
-        // 3. clone
-        /*
-        $this->skinclonetype($skin, $newid, 'index');
-        $this->skinclonetype($skin, $newid, 'item');
-        $this->skinclonetype($skin, $newid, 'archivelist');
-        $this->skinclonetype($skin, $newid, 'archive');
-        $this->skinclonetype($skin, $newid, 'search');
-        $this->skinclonetype($skin, $newid, 'error');
-        $this->skinclonetype($skin, $newid, 'member');
-        $this->skinclonetype($skin, $newid, 'imagepopup');
-        */
-
+        
         $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
-        $res = sql_query($query);
-        while ($row = sql_fetch_assoc($res)) {
+        $res = DB::getResult($query);
+        foreach ( $res as $row) {
             $this->skinclonetype($skin, $newid, $row['stype']);
         }
 
         $this->action_skinoverview();
 
     }
+=======
+               if ( !is_object(self::$skin) )
+               {
+                       global $DIR_SKINS;
+                       $query  = "SELECT min(sdnumber) FROM %s WHERE sdname != 'admin/bookmarklet' AND sdname LIKE 'admin/%%'";
+                       $query  = sprintf($query, sql_table('skin_desc'));
+                       $res    = intval(DB::getValue($query));
+                       $query  = "UPDATE %s SET value = %d WHERE name = 'AdminSkin'";
+                       $query  = sprintf($query, sql_table('config'), $res);
+                       DB::execute($query);
+                       if ( $res )
+                       {
+                               redirect($CONF['AdminURL']);
+                               exit;
+                       }
+                       $skin   = new Skin(0, 'AdminActions', 'AdminSkin');
+                       $skin->parse('importAdmin', $DIR_SKINS . 'admin/defaultimporter.skn');
+               }
+               else
+               {
+                       self::$skin->parse('adminskiniedoimport');
+               }
+               return;
+       }
+>>>>>>> skinnable-master
 
-    /**
-     * @todo document this
-     */
-    function skinclonetype($skin, $newid, $type) {
-        $newid = intval($newid);
-        $content = $skin->getContent($type);
-        if ($content) {
-            $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". sql_real_escape_string($content)."', '". sql_real_escape_string($type)."')";
-            sql_query($query);
-        }
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_settingsedit() {
-        global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
+       /**
+        * Admin::action_adminskinieexport()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_adminskinieexport()
+       {
+<<<<<<< HEAD
+               $newid = intval($newid);
+               $content = $skin->getContentFromDB($type);
+               
+               if ( $content )
+               {
+                       $query = "INSERT INTO %s (sdesc, scontent, stype) VALUES (%d, '%s', '%s')";
+                       $query = sprintf($query, sql_table('skin'), (integer) $newid, $content, $type);
+                       DB::execute($query);
+               }
+=======
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               // load skinie class
+               $aSkins = requestIntArray('skin');
+               $aTemplates = requestIntArray('template');
+               $info = postVar('info');
+               
+               self::skinieexport($aSkins, $aTemplates, $info);
+               
+>>>>>>> skinnable-master
+               return;
+       }
+       
+       /**
+        * Admin::action_settingsedit()
+        * 
+        * @param       Void
+        * @return      Void
+        */
+       static private function action_settingsedit()
+       {
+               global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
+<<<<<<< HEAD
 
-        $member->isAdmin() or $this->disallow();
+               $member->isAdmin() or $this->disallow();
 
-        $this->pagehead();
+               $this->pagehead();
 
-        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-        ?>
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+               ?>
 
-        <h2><?php echo _SETTINGS_TITLE?></h2>
+               <h2><?php echo _SETTINGS_TITLE ?></h2>
 
-        <form action="index.php" method="post">
-        <div>
+               <form action="index.php" method="post">
+               <div>
 
-        <input type="hidden" name="action" value="settingsupdate" />
-        <?php $manager->addTicketHidden() ?>
+               <input type="hidden" name="action" value="settingsupdate" />
+               <?php $manager->addTicketHidden() ?>
 
-        <table><tr>
-            <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
-        </tr><tr>
-            <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
-            <td>
-                <?php
-                    $query =  'SELECT bname as text, bnumber as value'
-                           . ' FROM '.sql_table('blog');
-                    $template['name'] = 'DefaultBlog';
-                    $template['selected'] = $CONF['DefaultBlog'];
-                    $template['tabindex'] = 10;
-                    showlist($query,'select',$template);
-                ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
-            <td>
-                <?php
-                    $query =  'SELECT sdname as text, sdnumber as value'
-                           . ' FROM '.sql_table('skin_desc');
-                    $template['name'] = 'BaseSkin';
-                    $template['selected'] = $CONF['BaseSkin'];
-                    $template['tabindex'] = 1;
-                    showlist($query,'select',$template);
-                ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_ADMINMAIL?></td>
-            <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo  i18n::hsc($CONF['AdminEmail']) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_SITENAME?></td>
-            <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo  i18n::hsc($CONF['SiteName']) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_SITEURL?></td>
-            <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo  i18n::hsc($CONF['IndexURL']) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_ADMINURL?></td>
-            <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo  i18n::hsc($CONF['AdminURL']) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
-            <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo  i18n::hsc($CONF['PluginURL']) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
-            <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo  i18n::hsc($CONF['SkinsURL']) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
-            <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo  i18n::hsc($CONF['ActionURL']) ?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
-            </td>
-            <td>
-                <select name="Language" tabindex="10050">
+               <table><tr>
+                       <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL ?></th>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_DEFBLOG ?> <?php help('defaultblog'); ?></td>
+                       <td>
+                               <?php
+                                       $query =  'SELECT bname as text, bnumber as value'
+                                                  . ' FROM '.sql_table('blog');
+                                       $template['name'] = 'DefaultBlog';
+                                       $template['selected'] = $CONF['DefaultBlog'];
+                                       $template['tabindex'] = 10;
+                                       showlist($query,'select',$template);
+                               ?>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_BASESKIN ?> <?php help('baseskin'); ?></td>
+                       <td>
+                               <?php
+                                       $query =  'SELECT sdname as text, sdnumber as value'
+                                                  . ' FROM '.sql_table('skin_desc');
+                                       $template['name'] = 'BaseSkin';
+                                       $template['selected'] = $CONF['BaseSkin'];
+                                       $template['tabindex'] = 1;
+                                       showlist($query,'select',$template);
+                               ?>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_ADMINMAIL ?></td>
+                       <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo  Entity::hsc($CONF['AdminEmail']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_SITENAME ?></td>
+                       <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo  Entity::hsc($CONF['SiteName']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_SITEURL ?></td>
+                       <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo  Entity::hsc($CONF['IndexURL']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_ADMINURL ?></td>
+                       <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo  Entity::hsc($CONF['AdminURL']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_PLUGINURL ?> <?php help('pluginurl'); ?></td>
+                       <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo  Entity::hsc($CONF['PluginURL']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_SKINSURL ?> <?php help('skinsurl'); ?></td>
+                       <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo  Entity::hsc($CONF['SkinsURL']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_ACTIONSURL ?> <?php help('actionurl'); ?></td>
+                       <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo  Entity::hsc($CONF['ActionURL']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_LOCALE ?> <?php help('locale'); ?>
+                       </td>
+                       <td>
+                               <select name="Locale" tabindex="10050">
                        <?php
                                $locales = i18n::get_available_locale_list();
                                if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
@@ -4818,90 +8965,90 @@ selector();
                        ?>
                        </select>
 
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
-            </td>
-            <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
-                    <br />
-                <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo  i18n::hsc($CONF['DisableSiteURL'])?>" />
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_DIRS?></td>
-            <td><?php echo  i18n::hsc($DIR_NUCLEUS) ?>
-                <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_DBLOGIN?></td>
-            <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
-        </tr><tr>
-            <td>
-            <?php
-                echo _SETTINGS_JSTOOLBAR
-                /* =_SETTINGS_DISABLEJS
-
-                    I temporary changed the meaning of DisableJsTools, until I can find a good
-                    way to select the javascript version to use
-
-                    now, its:
-                        0 : IE
-                        1 : all javascript disabled
-                        2 : 'simpler' javascript (for mozilla/opera/mac)
-                */
-               ?>
-            </td>
-            <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
-                <select name="DisableJsTools" tabindex="10075">
-            <?php                   $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
-                    echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
-                    $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
-                    echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
-                    $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
-                    echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
-            ?>
-                </select>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
-                       <td><?php
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_DISABLESITE ?> <?php help('disablesite'); ?>
+                       </td>
+                       <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
+                                       <br />
+                               <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo  Entity::hsc($CONF['DisableSiteURL']) ?>" />
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_DIRS ?></td>
+                       <td><?php echo  Entity::hsc($DIR_NUCLEUS) ?>
+                               <i><?php echo _SETTINGS_SEECONFIGPHP ?></i></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_DBLOGIN ?></td>
+                       <td><i><?php echo _SETTINGS_SEECONFIGPHP ?></i></td>
+               </tr><tr>
+                       <td>
+                       <?php
+                               echo _SETTINGS_JSTOOLBAR
+                               /* =_SETTINGS_DISABLEJS
+
+                                       I temporary changed the meaning of DisableJsTools, until I can find a good
+                                       way to select the javascript version to use
+
+                                       now, its:
+                                               0 : IE
+                                               1 : all javascript disabled
+                                               2 : 'simpler' javascript (for mozilla/opera/mac)
+                               */
+                          ?>
+                       </td>
+                       <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */ ?>
+                               <select name="DisableJsTools" tabindex="10075">
+                       <?php                              $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
+                                       echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
+                                       $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
+                                       echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
+                                       $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
+                                       echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
+                       ?>
+                               </select>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_URLMODE ?> <?php help('urlmode'); ?></td>
+                                          <td><?php
 
-                       $this->input_yesno('URLMode',$CONF['URLMode'],10077,
-                              'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
+                                          $this->input_yesno('URLMode',$CONF['URLMode'],10077,
+                                                         'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
 
-                       echo ' ', _SETTINGS_URLMODE_HELP;
+                                          echo ' ', _SETTINGS_URLMODE_HELP;
 
-                             ?>
+                                                        ?>
 
-                       </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
-                       <td><?php
+                                          </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_DEBUGVARS ?> <?php help('debugvars'); ?></td>
+                                          <td><?php
 
-                        $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
+                                               $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
 
-                             ?>
+                                                        ?>
 
-                       </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
-            <td>
-            <?php
-                if (!array_key_exists('DefaultListSize',$CONF)) {
-                    sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
-                    $CONF['DefaultListSize'] = 10;
-                }
-            ?>
-                <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo  i18n::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_ADMINCSS?> 
-            </td>
-            <td>
+                                          </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_DEFAULTLISTSIZE ?> <?php help('defaultlistsize'); ?></td>
+                       <td>
+                       <?php
+                               if (!array_key_exists('DefaultListSize',$CONF)) {
+                                       DB::execute("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
+                                       $CONF['DefaultListSize'] = 10;
+                               }
+                       ?>
+                               <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo  Entity::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_ADMINCSS ?> 
+                       </td>
+                       <td>
 
-                <select name="AdminCSS" tabindex="10080">
-                <?php               // show a dropdown list of all available admin css files
-                global $DIR_NUCLEUS;
+                               <select name="AdminCSS" tabindex="10080">
+                               <?php                      // show a dropdown list of all available admin css files
+                               global $DIR_NUCLEUS;
                                
-                $dirhandle = opendir($DIR_NUCLEUS."styles/");
+                               $dirhandle = opendir($DIR_NUCLEUS."styles/");
 
                                while ($filename = readdir($dirhandle) )
                                {
@@ -4931,674 +9078,686 @@ selector();
                                ?>
                                </select>
 
-            </td>
-        </tr><tr>
-            <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
-        </tr><tr>
-            <td><?php echo _SETTINGS_MEDIADIR?></td>
-            <td><?php echo  i18n::hsc($DIR_MEDIA) ?>
-                <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
-                <?php                   if (!is_dir($DIR_MEDIA))
-                        echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
-                    if (!is_readable($DIR_MEDIA))
-                        echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
-                    if (!is_writeable($DIR_MEDIA))
-                        echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
-                ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_MEDIAURL?></td>
-            <td>
-                <input name="MediaURL" tabindex="10090" size="40" value="<?php echo  i18n::hsc($CONF['MediaURL']) ?>" />
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
-            <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
-            <td>
-                <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo  i18n::hsc($CONF['AllowedTypes']) ?>" />
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
-            <td>
-                <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo  i18n::hsc($CONF['MaxUploadSize']) ?>" />
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
-            <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
-
-        </tr><tr>
-            <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
-        </tr><tr>
-            <td><?php echo _SETTINGS_CHANGELOGIN?></td>
-            <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_ALLOWCREATE?>
-                <?php help('allowaccountcreation'); ?>
-            </td>
-            <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
-                <br /><?php echo _SETTINGS_NEWLOGIN2?>
-            </td>
-            <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_MEMBERMSGS?>
-                <?php help('messageservice'); ?>
-            </td>
-            <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_NONMEMBERMSGS?>
-                <?php help('messageservice'); ?>
-            </td>
-            <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
-                <?php help('protectmemnames'); ?>
-            </td>
-            <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
-            </td>
-
-
-
-        </tr><tr>
-            <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
-        </tr><tr>
-            <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
-            <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo  i18n::hsc($CONF['CookiePrefix'])?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
-            <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo  i18n::hsc($CONF['CookieDomain'])?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_COOKIEPATH?></td>
-            <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo  i18n::hsc($CONF['CookiePath'])?>" /></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_COOKIESECURE?></td>
-            <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_COOKIELIFE?></td>
-            <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
-                              1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
-            </td>
-        </tr><tr>
-            <td><?php echo _SETTINGS_LASTVISIT?></td>
-            <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
-
-
-
-        </tr><tr>
-            <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
-        </tr><tr>
-            <td><?php echo _SETTINGS_UPDATE?></td>
-            <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
-        </tr></table>
-
-        </div>
-        </form>
-
-        <?php
-            echo '<h2>',_PLUGINS_EXTRA,'</h2>';
-
-            $manager->notify(
-                'GeneralSettingsFormExtras',
-                array()
-            );
-
-        $this->pagefoot();
-    }
-
-       /**
-        * @todo document this
-        */
-       function action_settingsupdate() {
-               global $member, $CONF;
-               
-               $member->isAdmin() or $this->disallow();
-               
-               // check if email address for admin is valid
-               if ( !isValidMailAddress(postVar('AdminEmail')) )
-               {
-                       $this->error(_ERROR_BADMAILADDRESS);
-               }
-               
-               // save settings
-               $this->updateConfig('DefaultBlog',        postVar('DefaultBlog'));
-               $this->updateConfig('BaseSkin',          postVar('BaseSkin'));
-               $this->updateConfig('IndexURL',          postVar('IndexURL'));
-               $this->updateConfig('AdminURL',          postVar('AdminURL'));
-               $this->updateConfig('PluginURL',                postVar('PluginURL'));
-               $this->updateConfig('SkinsURL',          postVar('SkinsURL'));
-               $this->updateConfig('ActionURL',                postVar('ActionURL'));
-               $this->updateConfig('Language',            postVar('Language'));
-               $this->updateConfig('AdminEmail',          postVar('AdminEmail'));
-               $this->updateConfig('SessionCookie',    postVar('SessionCookie'));
-               $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
-               $this->updateConfig('AllowMemberMail',  postVar('AllowMemberMail'));
-               $this->updateConfig('NonmemberMail',    postVar('NonmemberMail'));
-               $this->updateConfig('ProtectMemNames',  postVar('ProtectMemNames'));
-               $this->updateConfig('SiteName',          postVar('SiteName'));
-               $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
-               $this->updateConfig('DisableSite',        postVar('DisableSite'));
-               $this->updateConfig('DisableSiteURL',   postVar('DisableSiteURL'));
-               $this->updateConfig('LastVisit',                postVar('LastVisit'));
-               $this->updateConfig('MediaURL',          postVar('MediaURL'));
-               $this->updateConfig('AllowedTypes',      postVar('AllowedTypes'));
-               $this->updateConfig('AllowUpload',        postVar('AllowUpload'));
-               $this->updateConfig('MaxUploadSize',    postVar('MaxUploadSize'));
-               $this->updateConfig('MediaPrefix',        postVar('MediaPrefix'));
-               $this->updateConfig('AllowLoginEdit',   postVar('AllowLoginEdit'));
-               $this->updateConfig('DisableJsTools',   postVar('DisableJsTools'));
-               $this->updateConfig('CookieDomain',      postVar('CookieDomain'));
-               $this->updateConfig('CookiePath',          postVar('CookiePath'));
-               $this->updateConfig('CookieSecure',      postVar('CookieSecure'));
-               $this->updateConfig('URLMode',            postVar('URLMode'));
-               $this->updateConfig('CookiePrefix',      postVar('CookiePrefix'));
-               $this->updateConfig('DebugVars',                        postVar('DebugVars'));
-               $this->updateConfig('DefaultListSize',            postVar('DefaultListSize'));
-               $this->updateConfig('AdminCSS',           postVar('AdminCSS'));
-               
-               // load new config and redirect (this way, the new language will be used is necessary)
-               // note that when changing cookie settings, this redirect might cause the user
-               // to have to log in again.
-               getConfig();
-               redirect($CONF['AdminURL'] . '?action=manage');
-               exit;
-       }
-
-    /**
-     *  Give an overview over the used system
-     */
-    function action_systemoverview() {
-        global $member, $nucleus, $CONF;
-
-        $this->pagehead();
-
-        echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
-
-        if ($member->isLoggedIn() && $member->isAdmin()) {
-
-            // Information about the used PHP and MySQL installation
-            echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n";
-
-            // Version of PHP MySQL
-            echo "<table>\n";
-            echo "\t<tr>\n";
-            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
-            echo "\t\t" . '<td>' . phpversion() . "</td>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
-            echo "\t\t" . '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
-            echo "\t</tr>";
-            echo "</table>\n";
-
-            // Important PHP settings
-            echo "<table>\n";
-            echo "\t<tr>\n";
-            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td width="50%">magic_quotes_gpc' . "</td>\n";
-            $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
-            echo "\t\t" . '<td>' . $mqg . "</td>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td>magic_quotes_runtime' . "</td>\n";
-            $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
-            echo "\t\t" . '<td>' . $mqr . "</td>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td>register_globals' . "</td>\n";
-            $rg = ini_get('register_globals') ? 'On' : 'Off';
-            echo "\t\t" . '<td>' . $rg . "</td>\n";
-            echo "\t</tr>";
-            echo "</table>\n";
-
-            // Information about GD library
-            $gdinfo = gd_info();
-            echo "<table>\n";
-            echo "\t<tr>";
-            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
-            echo "\t</tr>\n";
-            foreach ($gdinfo as $key=>$value) {
-                if (is_bool($value)) {
-                    $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
-                } else {
-                    $value = i18n::hsc($value);
-                }
-                echo "\t<tr>";
-                echo "\t\t" . '<td width="50%">' . $key . "</td>\n";
-                echo "\t\t" . '<td>' . $value . "</td>\n";
-                echo "\t</tr>\n";
-            }
-            echo "</table>\n";
-
-            // Check if special modules are loaded
-            ob_start();
-            phpinfo(INFO_MODULES);
-            $im = ob_get_contents();
-            ob_clean();
-            echo "<table>\n";
-            echo "\t<tr>";
-            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td width="50%">mod_rewrite' . "</td>\n";
-            $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
-                        _ADMIN_SYSTEMOVERVIEW_ENABLE :
-                        _ADMIN_SYSTEMOVERVIEW_DISABLE;
-            echo "\t\t" . '<td>' . $modrewrite . "</td>\n";
-            echo "\t</tr>\n";
-            echo "</table>\n";
-
-            // Information about the used Nucleus CMS
-            echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
-            global $nucleus;
-            $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
-            $np = getNucleusPatchLevel();
-            echo "<table>\n";
-            echo "\t<tr>";
-            echo "\t\t" . '<th colspan="2">Nucleus CMS' . "</th>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
-            echo "\t\t" . '<td>' . $nv . "</td>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
-            echo "\t\t" . '<td>' . $np . "</td>\n";
-            echo "\t</tr>\n";
-            echo "</table>\n";
-
-            // Important settings of the installation
-            echo "<table>\n";
-            echo "\t<tr>";
-            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td width="50%">' . '$CONF[' . "'Self']</td>\n";
-            echo "\t\t" . '<td>' . $CONF['Self'] . "</td>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td width="50%">' . '$CONF[' . "'ItemURL']</td>\n";
-            echo "\t\t" . '<td>' . $CONF['ItemURL'] . "</td>\n";
-            echo "\t</tr><tr>\n";
-            echo "\t\t" . '<td width="50%">' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
-            $ohs = $CONF['alertOnHeadersSent'] ?
-                        _ADMIN_SYSTEMOVERVIEW_ENABLE :
-                        _ADMIN_SYSTEMOVERVIEW_DISABLE;
-            echo "\t\t" . '<td>' . $ohs . "</td>\n";
-            echo "\t</tr>\n";
-            echo "</table>\n";
-
-            // Link to the online version test at the Nucleus CMS website
-            echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
-            if ($nucleus['codename'] != '') {
-                $codenamestring = ' &quot;' . $nucleus['codename'] . '&quot;';
-            } else {
-                $codenamestring = '';
-            }
-            echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
-            $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
-            echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
-            echo 'Nucleus CMS ' . $nv . $codenamestring;
-            echo '</a>';
-        //echo '<br />';
-        }
-        else {
-            echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
-        }
-
-        $this->pagefoot();
-    }
-
-    /**
-     * @todo document this
-     */
-    function updateConfig($name, $val) {
-        $name = sql_real_escape_string($name);
-        $val = trim(sql_real_escape_string($val));
-
-        $query = 'UPDATE '.sql_table('config')
-               . " SET value='$val'"
-               . " WHERE name='$name'";
-
-        sql_query($query) or die("Query error: " . sql_error());
-        return sql_insert_id();
-    }
-
-    /**
-     * Error message
-     * @param string $msg message that will be shown
-     */
-    function error($msg) {
-        $this->pagehead();
-        ?>
-        <h2>Error!</h2>
-        <?php       echo $msg;
-        echo "<br />";
-        echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";
-        $this->pagefoot();
-        exit;
-    }
-
-    /**
-     * @todo document this
-     */
-    function disallow() {
-        ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
-
-        $this->error(_ERROR_DISALLOWED);
-    }
-
-    /**
-     * @todo document this
-     */
-    function pagehead($extrahead = '') {
-        global $member, $nucleus, $CONF, $manager;
-
-        $manager->notify(
-            'AdminPrePageHead',
-            array(
-                'extrahead' => &$extrahead,
-                'action' => $this->action
-            )
-        );
-
-        $baseUrl = i18n::hsc($CONF['AdminURL']);
-               if (!array_key_exists('AdminCSS',$CONF)) 
-               {
-                       sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
-                       $CONF['AdminCSS'] = 'original';
-               }
-
-        ?>
-        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-        <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
-        <head>
-            <meta http-equiv="Content-Type" content="text/html; charset=<?php echo i18n::get_current_charset() ?>" />
-            <title><?php echo i18n::hsc($CONF['SiteName'])?> - Admin</title>
-            <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin_<?php echo $CONF["AdminCSS"]?>.css" />
-            <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
-            href="<?php echo $baseUrl?>styles/addedit.css" />
-
-            <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
-            <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
-            <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
-
-      <meta http-equiv='Pragma' content='no-cache' />
-      <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
-      <meta http-equiv='Expires' content='-1' />
-
-            <?php echo $extrahead?>
-        </head>
-        <body>
-        <div id="adminwrapper">
-        <div class="header">
-        <h1><?php echo i18n::hsc($CONF['SiteName'])?></h1>
-        </div>
-        <div id="container">
-        <div id="content">
-        <div class="loginname">
-        <?php           if ($member->isLoggedIn())
-                echo _LOGGEDINAS . ' ' . $member->getDisplayName()
-                    ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
-                    . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
-            else
-                echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
-
-            echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
-
-            echo '<br />(';
-
-            $codenamestring = ($nucleus['codename']!='')? ' &quot;'.$nucleus['codename'].'&quot;':'';
-
-            if ($member->isLoggedIn() && $member->isAdmin()) {
-                $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
-                echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
-                $newestVersion = getLatestVersion();
-                $newestCompare = str_replace('/','.',$newestVersion);
-                $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
-                if ($newestVersion && version_compare($newestCompare,$currentVersion) > 0) {
-                    echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE.'">'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT.$newestVersion.'</a>';
-                }
-            } else {
-                echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
-            }
-            echo ')';
-        echo '</div>';
-    }
-
-    /**
-     * @todo document this
-     */
-    function pagefoot() {
-        global $action, $member, $manager;
-
-        $manager->notify(
-            'AdminPrePageFoot',
-            array(
-                'action' => $this->action
-            )
-        );
-
-        if ($member->isLoggedIn() && ($action != 'showlogin')) {
-            ?>
-            <h2><?php echo  _LOGOUT ?></h2>
-            <ul>
-                <li><a href="index.php?action=overview"><?php echo  _BACKHOME?></a></li>
-                <li><a href='index.php?action=logout'><?php echo  _LOGOUT?></a></li>
-            </ul>
-            <?php       }
-        ?>
-            <div class="foot">
-                <a href="<?php echo _ADMINPAGEFOOT_OFFICIALURL ?>">Nucleus CMS</a> &copy; 2002-<?php echo date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT; ?>
-                -
-                <a href="<?php echo _ADMINPAGEFOOT_DONATEURL ?>"><?php echo _ADMINPAGEFOOT_DONATE ?></a>
-            </div>
-
-            </div><!-- content -->
-
-            <div id="quickmenu">
-
-                <?php               // ---- user settings ----
-                if (($action != 'showlogin') && ($member->isLoggedIn())) {
-                    echo '<ul>';
-                    echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
-                    echo '</ul>';
-
-                    echo '<h2>',_QMENU_ADD,'</h2>';
-                    echo '<form method="get" action="index.php"><div>';
-                    echo '<input type="hidden" name="action" value="createitem" />';
-
-                        $showAll = requestVar('showall');
-                        if (($member->isAdmin()) && ($showAll == 'yes')) {
-                            // Super-Admins have access to all blogs! (no add item support though)
-                            $query =  'SELECT bnumber as value, bname as text'
-                                   . ' FROM ' . sql_table('blog')
-                                   . ' ORDER BY bname';
-                        } else {
-                            $query =  'SELECT bnumber as value, bname as text'
-                                   . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
-                                   . ' 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['shorten'] = 10;
-                        $template['shortenel'] = '';
-                        $template['javascript'] = 'onchange="return form.submit()"';
-                        showlist($query,'select',$template);
-
-                    echo '</div></form>';
-
-                    echo '<h2>' . $member->getDisplayName(). '</h2>';
-                    echo '<ul>';
-                    echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . '</a></li>';
-                    echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . '</a></li>';
-                    echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . '</a></li>';
-                    echo '</ul>';
-
-
-
-
-                    // ---- general settings ----
-                    if ($member->isAdmin()) {
-
-                        echo '<h2>',_QMENU_MANAGE,'</h2>';
-
-                        echo '<ul>';
-                        echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . '</a></li>';
-                        echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . '</a></li>';
-                        echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . '</a></li>';
-                        echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . '</a></li>';
-                        echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . '</a></li>';
-                        echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . '</a></li>';
-                        echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . '</a></li>';
-                        echo '</ul>';
-
-                        echo '<h2>',_QMENU_LAYOUT,'</h2>';
-                        echo '<ul>';
-                        echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . '</a></li>';
-                        echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . '</a></li>';
-                        echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . '</a></li>';
-                        echo '</ul>';
-
-                    }
-
-                    $aPluginExtras = array();
-                    $manager->notify(
-                        'QuickMenu',
-                        array(
-                            'options' => &$aPluginExtras
-                        )
-                    );
-                    if (count($aPluginExtras) > 0)
-                    {
-                        echo '<h2>', _QMENU_PLUGINS, '</h2>';
-                        echo '<ul>';
-                        foreach ($aPluginExtras as $aInfo)
-                        {
-                            echo '<li><a href="'.i18n::hsc($aInfo['url']).'" title="'.i18n::hsc($aInfo['tooltip']).'">'.i18n::hsc($aInfo['title']).'</a></li>';
-                        }
-                        echo '</ul>';
-                    }
-
-                } else if (($action == 'activate') || ($action == 'activatesetpwd')) {
-
-                    echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
-                } else {
-                    // introduction text on login screen
-                    echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
-                }
-                ?>
-            </div>
-
-            <!-- content / quickmenu container -->
-            <div class="clear"></div>    <!-- new -->
-            </div>
-
-            <!-- adminwrapper -->    <!-- new -->
-            </div>     <!-- new -->
-            </body> 
-            </html>
-        <?php   }
-
-    /**
-     * @todo document this
-     */
-    function action_regfile() {
-        global $member, $CONF;
-
-        $blogid = intRequestVar('blogid');
-
-        $member->teamRights($blogid) or $this->disallow();
-
-        // header-code stolen from phpMyAdmin
-        // REGEDIT and bookmarklet code stolen from GreyMatter
-
-        $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
-
-
-        header('Content-Type: application/octetstream');
-        header('Content-Disposition: filename="nucleus.reg"');
-        header('Pragma: no-cache');
-        header('Expires: 0');
-
-        echo "REGEDIT4\n";
-        echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
-        echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
-        echo '"contexts"=hex:31';
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_bookmarklet() {
-        global $member, $manager;
-
-        $blogid = intRequestVar('blogid');
-
-        $member->teamRights($blogid) or $this->disallow();
-
-        $blog =& $manager->getBlog($blogid);
-        $bm = getBookmarklet($blogid);
-
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+                       </td>
+               </tr><tr>
+                       <th colspan="2"><?php echo _SETTINGS_MEDIA ?> <?php help('media'); ?></th>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_MEDIADIR ?></td>
+                       <td><?php echo  Entity::hsc($DIR_MEDIA) ?>
+                               <i><?php echo _SETTINGS_SEECONFIGPHP ?></i>
+                               <?php                              if (!is_dir($DIR_MEDIA))
+                                               echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
+                                       if (!is_readable($DIR_MEDIA))
+                                               echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
+                                       if (!is_writeable($DIR_MEDIA))
+                                               echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
+                               ?>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_MEDIAURL ?></td>
+                       <td>
+                               <input name="MediaURL" tabindex="10090" size="40" value="<?php echo  Entity::hsc($CONF['MediaURL']) ?>" />
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_ALLOWUPLOAD ?></td>
+                       <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_ALLOWUPLOADTYPES ?></td>
+                       <td>
+                               <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo  Entity::hsc($CONF['AllowedTypes']) ?>" />
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_MAXUPLOADSIZE ?></td>
+                       <td>
+                               <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo  Entity::hsc($CONF['MaxUploadSize']) ?>" />
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_MEDIAPREFIX ?></td>
+                       <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
 
-        ?>
+               </tr><tr>
+                       <th colspan="2"><?php echo _SETTINGS_MEMBERS ?></th>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_CHANGELOGIN ?></td>
+                       <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_ALLOWCREATE ?>
+                               <?php help('allowaccountcreation'); ?>
+                       </td>
+                       <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_NEWLOGIN ?> <?php help('allownewmemberlogin'); ?>
+                               <br /><?php echo _SETTINGS_NEWLOGIN2 ?>
+                       </td>
+                       <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_MEMBERMSGS ?>
+                               <?php help('messageservice'); ?>
+                       </td>
+                       <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_NONMEMBERMSGS ?>
+                               <?php help('messageservice'); ?>
+                       </td>
+                       <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_PROTECTMEMNAMES ?>
+                               <?php help('protectmemnames'); ?>
+                       </td>
+                       <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
+                       </td>
 
-        <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
 
-        <p>
-        <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
-        </p>
 
-        <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
-        <p>
-            <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
-            <br />
-            <br />
-            <?php echo '<a href="' . i18n::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, i18n::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
-        </p>
+               </tr><tr>
+                       <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE ?> <?php help('cookies'); ?></th>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_COOKIEPREFIX ?></td>
+                       <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo  Entity::hsc($CONF['CookiePrefix']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_COOKIEDOMAIN ?></td>
+                       <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo  Entity::hsc($CONF['CookieDomain']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_COOKIEPATH ?></td>
+                       <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo  Entity::hsc($CONF['CookiePath']) ?>" /></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_COOKIESECURE ?></td>
+                       <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_COOKIELIFE ?></td>
+                       <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
+                                                         1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
+                       </td>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_LASTVISIT ?></td>
+                       <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
 
-        <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
-        <p>
-            <?php
-                $url = 'index.php?action=regfile&blogid=' . intval($blogid);
-                $url = $manager->addTicketToUrl($url);
-            ?>
-            <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . i18n::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
-        </p>
 
-        <p>
-            <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
-        </p>
 
-        <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
-        <p>
-            <?php echo _BOOKMARKLET_DELETEBAR ?>
-        </p>
+               </tr><tr>
+                       <th colspan="2"><?php echo _SETTINGS_UPDATE ?></th>
+               </tr><tr>
+                       <td><?php echo _SETTINGS_UPDATE ?></td>
+                       <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN ?>" onclick="return checkSubmit();" /></td>
+               </tr></table>
 
-        <p>
-            <?php echo _BOOKMARKLET_DELETERIGHTT ?>
-        </p>
+               </div>
+               </form>
 
-        <ol>
-            <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
-            <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
-            <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
-            <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
-            <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
-        </ol>
+               <?php
+                       echo '<h2>',_PLUGINS_EXTRA,'</h2>';
 
-        <?php
-        $this->pagefoot();
+                       $manager->notify(
+                               'GeneralSettingsFormExtras',
+                               array()
+                       );
 
-    }
+               $this->pagefoot();
+=======
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('settingsedit');
+               return;
+>>>>>>> skinnable-master
+       }
+       
+       /**
+        * Admin::action_settingsupdate()
+        * Update $CONFIG and redirect
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_settingsupdate()
+       {
+               global $member, $CONF;
+               
+               $member->isAdmin() or self::disallow();
+               
+               // check if email address for admin is valid
+               if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )
+               {
+                       self::error(_ERROR_BADMAILADDRESS);
+                       return;
+               }
+               
+               // save settings
+               self::updateConfig('DefaultBlog',               postVar('DefaultBlog'));
+               self::updateConfig('BaseSkin',                  postVar('BaseSkin'));
+               self::updateConfig('IndexURL',                  postVar('IndexURL'));
+               self::updateConfig('AdminURL',                  postVar('AdminURL'));
+               self::updateConfig('PluginURL',                 postVar('PluginURL'));
+               self::updateConfig('SkinsURL',                  postVar('SkinsURL'));
+               self::updateConfig('ActionURL',                 postVar('ActionURL'));
+               self::updateConfig('Locale',                    postVar('Locale'));
+               self::updateConfig('AdminEmail',                postVar('AdminEmail'));
+               self::updateConfig('SessionCookie',             postVar('SessionCookie'));
+               self::updateConfig('AllowMemberCreate', postVar('AllowMemberCreate'));
+               self::updateConfig('AllowMemberMail',   postVar('AllowMemberMail'));
+               self::updateConfig('NonmemberMail',             postVar('NonmemberMail'));
+               self::updateConfig('ProtectMemNames',   postVar('ProtectMemNames'));
+               self::updateConfig('SiteName',                  postVar('SiteName'));
+               self::updateConfig('NewMemberCanLogon', postVar('NewMemberCanLogon'));
+               self::updateConfig('DisableSite',               postVar('DisableSite'));
+               self::updateConfig('DisableSiteURL',    postVar('DisableSiteURL'));
+               self::updateConfig('LastVisit',                 postVar('LastVisit'));
+               self::updateConfig('MediaURL',                  postVar('MediaURL'));
+               self::updateConfig('AllowedTypes',              postVar('AllowedTypes'));
+               self::updateConfig('AllowUpload',               postVar('AllowUpload'));
+               self::updateConfig('MaxUploadSize',             postVar('MaxUploadSize'));
+               self::updateConfig('MediaPrefix',               postVar('MediaPrefix'));
+               self::updateConfig('AllowLoginEdit',    postVar('AllowLoginEdit'));
+               self::updateConfig('DisableJsTools',    postVar('DisableJsTools'));
+               self::updateConfig('CookieDomain',              postVar('CookieDomain'));
+               self::updateConfig('CookiePath',                postVar('CookiePath'));
+               self::updateConfig('CookieSecure',              postVar('CookieSecure'));
+               self::updateConfig('URLMode',                   postVar('URLMode'));
+               self::updateConfig('CookiePrefix',              postVar('CookiePrefix'));
+               self::updateConfig('DebugVars',                 postVar('DebugVars'));
+               self::updateConfig('DefaultListSize',   postVar('DefaultListSize'));
+               self::updateConfig('AdminCSS',                  postVar('AdminCSS'));
+               self::updateConfig('AdminSkin',                 postVar('adminskin'));
+               self::updateConfig('BookmarkletSkin',   postVar('bookmarklet'));
+
+               // load new config and redirect (this way, the new locale will be used is necessary)
+               // note that when changing cookie settings, this redirect might cause the user
+               // to have to log in again.
+               getConfig();
+               redirect($CONF['AdminURL'] . '?action=manage');
+               return;
+       }
+       
+       /**
+        * Admin::action_systemoverview()
+        * Output system overview
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_systemoverview()
+       {
+<<<<<<< HEAD
+               global $member, $nucleus, $CONF;
+               
+               $this->pagehead();
+               
+               echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
+               
+               if ( $member->isLoggedIn() && $member->isAdmin() )
+               {
+                       // Information about the used PHP and MySQL installation
+                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n\n";
+                       
+                       // Version of PHP MySQL
+                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "\" class=\"systemoverview\">\n";
+                       echo "<thead>\n";
+                       echo "<tr>\n";
+                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
+                       echo "</tr>\n";
+                       echo "</thead>\n";
+                       echo "<tbody>\n";
+                       echo "<tr>\n";
+                       echo '<td>' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
+                       echo '<td>' . phpversion() . "</td>\n";
+                       echo "</tr>\n";
+                       echo "<tr>\n";
+                       echo '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
+                       echo '<td>' . DB::getAttribute(PDO::ATTR_SERVER_VERSION) . ' (' . DB::getAttribute(PDO::ATTR_CLIENT_VERSION) . ')' . "</td>\n";
+                       echo "</tr>\n";
+                       echo "</tbody>\n";
+                       echo "</table>\n\n";
+                       
+                       // Important PHP settings
+                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "\" class=\"systemoverview\">\n";
+                       echo "<thead>\n";
+                       echo "<tr>\n";
+                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
+                       echo "</tr>\n";
+                       echo "</thead>\n";
+                       echo "<tbody>\n";
+                       echo "<tr>\n";
+                       echo '<td>magic_quotes_gpc' . "</td>\n";
+                       $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
+                       echo '<td>' . $mqg . "</td>\n";
+                       echo "</tr>\n";
+                       echo "<tr>\n";
+                       echo '<td>magic_quotes_runtime' . "</td>\n";
+                       $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
+                       echo '<td>' . $mqr . "</td>\n";
+                       echo "</tr>\n";
+                       echo "<tr>\n";
+                       echo '<td>register_globals' . "</td>\n";
+                       $rg = ini_get('register_globals') ? 'On' : 'Off';
+                       echo '<td>' . $rg . "</td>\n";
+                       echo "</tr>\n";
+                       echo "</tbody>\n";
+                       echo "</table>\n\n";
+                       
+                       // Information about GD library
+                       $gdinfo = gd_info();
+                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "\" class=\"systemoverview\">\n";
+                       echo "<thead>\n";
+                       echo "<tr>\n";
+                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
+                       echo "</tr>\n";
+                       echo "</thead>\n";
+                       echo "<tbody>\n";
+                       foreach ( $gdinfo as $key=>$value )
+                       {
+                               if ( is_bool($value) )
+                               {
+                                       $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
+                               }
+                               else
+                               {
+                                       $value = Entity::hsc($value);
+                               }
+                               echo "<tr>\n";
+                               echo '<td>' . $key . "</td>\n";
+                               echo '<td>' . $value . "</td>\n";
+                               echo "</tr>\n";
+                       }
+                       echo "</tbody>\n";
+                       echo "</table>\n\n";
+
+                       // Check if special modules are loaded
+                       ob_start();
+                       phpinfo(INFO_MODULES);
+                       $im = ob_get_contents();
+                       ob_clean();
+                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_MODULES . "\" class=\"systemoverview\">\n";
+                       echo "<thead>\n";
+                       echo "<tr>";
+                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
+                       echo "</tr>\n";
+                       echo "<tbody>\n";
+                       echo "<tr>\n";
+                       echo '<td>mod_rewrite' . "</td>\n";
+                       $modrewrite = (i18n::strpos($im, 'mod_rewrite') !== FALSE) ?
+                                               _ADMIN_SYSTEMOVERVIEW_ENABLE :
+                                               _ADMIN_SYSTEMOVERVIEW_DISABLE;
+                       echo '<td>' . $modrewrite . "</td>\n";
+                       echo "</tr>\n";
+                       echo "</tbody>\n";
+                       echo "</table>\n\n";
+
+                       // Information about the used Nucleus CMS
+                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
+                       global $nucleus;
+                       $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
+                       $np = getNucleusPatchLevel();
+                       echo "<table frame=\"box\" rules=\"all\" summary=\"Nucleus CMS\" class=\"systemoverview\" class=\"systemoverview\">\n";
+                       echo "<thead>\n";
+                       echo "<tr>\n";
+                       echo '<th colspan="2">Nucleus CMS' . "</th>\n";
+                       echo "</tr>\n";
+                       echo "</thead>\n";
+                       echo "<tbody>\n";
+                       echo "<tr>\n";
+                       echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
+                       echo '<td>' . $nv . "</td>\n";
+                       echo "</tr>\n";
+                       echo "<tr>\n";
+                       echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
+                       echo '<td>' . $np . "</td>\n";
+                       echo "</tr>\n";
+                       echo "</tbody>\n";
+                       echo "</table>\n\n";
+
+                       // Important settings of the installation
+                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "\" class=\"systemoverview\">\n";
+                       echo "<thead>\n";
+                       echo "<tr>\n";
+                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
+                       echo "</tr>\n";
+                       echo "</thead>\n";
+                       echo "<tbody>\n";
+                       echo "<tr>\n";
+                       echo '<td>' . '$CONF[' . "'Self']</td>\n";
+                       echo '<td>' . $CONF['Self'] . "</td>\n";
+                       echo "</tr>\n";
+                       echo "<tr>\n";
+                       echo '<td>' . '$CONF[' . "'ItemURL']</td>\n";
+                       echo '<td>' . $CONF['ItemURL'] . "</td>\n";
+                       echo "</tr>\n";
+                       echo "<tr>\n";
+                       echo '<td>' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
+                       $ohs = $CONF['alertOnHeadersSent'] ?
+                                               _ADMIN_SYSTEMOVERVIEW_ENABLE :
+                                               _ADMIN_SYSTEMOVERVIEW_DISABLE;
+                       echo '<td>' . $ohs . "</td>\n";
+                       echo "</tr>\n";
+                       echo "<tr>\n";
+                       echo "<td>i18n::get_current_charset()</td>\n";
+                       echo '<td>' . i18n::get_current_charset() . "</td>\n";
+                       echo "</tr>\n";
+                       echo "</tbody>\n";
+                       echo "</table>\n\n";
+
+                       // Link to the online version test at the Nucleus CMS website
+                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
+                       if ( $nucleus['codename'] != '')
+                       {
+                               $codenamestring = ' &quot;' . $nucleus['codename'] . '&quot;';
+                       }
+                       else
+                       {
+                               $codenamestring = '';
+                       }
+                       echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
+                       $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
+                       echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
+                       echo 'Nucleus CMS ' . $nv . $codenamestring;
+                       echo '</a>';
+               }
+               else
+               {
+                       echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
+               }
+               $this->pagefoot();
+=======
+               self::$skin->parse('systemoverview');
+               return;
+>>>>>>> skinnable-master
+       }
+       
+       /**
+        * Admin::updateConfig()
+        * 
+        * @param       string  $name   
+        * @param       string  $val    
+        * @return      integer return the ID in which the latest query posted
+        */
+       static private function updateConfig($name, $val)
+       {
+<<<<<<< HEAD
+               $name = DB::quoteValue($name);
+               $val = DB::quoteValue(trim($val));
+               
+               $query = "UPDATE %s SET value=%s WHERE name=%s";
+               $query = sprintf($query, sql_table('config'), $val, $name);
+               if ( DB::execute($query) === FALSE )
+               {
+                       $err = DB::getError();
+                       die("Query error: " . $err[2]);
+=======
+               $query = "UPDATE %s SET value=%s WHERE name=%s";
+               $query = sprintf($query, sql_table('config'), DB::quoteValue($val), DB::quoteValue($name));
+               if ( DB::execute($query) === FALSE )
+               {
+                       $err = DB::getError();
+                       die(_ADMIN_SQLDIE_QUERYERROR . $err[2]);
+>>>>>>> skinnable-master
+               }
+               return DB::getInsertId();
+       }
+       
+       /**
+        * Admin::error()
+        * Error message
+        * 
+        * @param       string  $msg    message that will be shown
+        * @return      void
+        */
+       static public function error($msg)
+       {
+               self::$headMess = $msg;
+               self::$skin->parse('adminerrorpage');
+               return;
+       }
+       
+       /**
+        * Admin::disallow()
+        * add error log and show error page 
+        * 
+        * @param       void
+        * @return      void
+        */
+       static public function disallow()
+       {
+               ActionLog::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
+               self::error(_ERROR_DISALLOWED);
+               return;
+       }
 
+       /**
+        * Admin::action_PluginAdmin()
+        * Output pluginadmin
+        *
+        * @param       string  $skinContents
+        * @param       string  $extrahead
+        * @return      void
+        */
+       static public function action_PluginAdmin($skinContents, $extrahead = '')
+       {
+               self::$extrahead .= $extrahead;
+               self::$skin->parse('pluginadmin', $skinContents);
+               return;
+       }
+       
+       /**
+        * Admin::action_bookmarklet()
+        * 
+        * @param       void
+        * @return      void
+        */
+<<<<<<< HEAD
+       function pagehead($extrahead = '')
+       {
+               global $member, $nucleus, $CONF, $manager;
+               
+               $manager->notify(
+                       'AdminPrePageHead',
+                       array(
+                               'extrahead' => &$extrahead,
+                               'action' => $this->action));
+               
+               $baseUrl = Entity::hsc($CONF['AdminURL']);
+               if ( !array_key_exists('AdminCSS',$CONF) )
+               {
+                       DB::execute("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
+                       $CONF['AdminCSS'] = 'original';
+               }
+               
+               /* HTTP 1.1 application for no caching */
+               header("Cache-Control: no-cache, must-revalidate");
+               header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
+               
+               $root_element = 'html';
+               $charset = i18n::get_current_charset();
+               $locale = preg_replace('#_#', '-', i18n::get_current_locale());
+               
+               echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
+               echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
+               echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
+               echo "<head>\n";
+               echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
+               echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
+               echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";
+               echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";
+               echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";
+               echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";
+               echo "{$extrahead}\n";
+               echo "</head>\n\n";
+               echo "<body>\n";
+               echo "<div id=\"adminwrapper\">\n";
+               echo "<div class=\"header\">\n";
+               echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
+               echo "</div>\n";
+               echo "<div id=\"container\">\n";
+               echo "<div id=\"content\">\n";
+               echo "<div class=\"loginname\">\n";
+               if ( $member->isLoggedIn() )
+               {
+                       echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
+                       echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
+               }
+               else
+               {
+                       echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
+               }
+               echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
+               echo '(';
+=======
+       static private function action_bookmarklet()
+       {
+               global $member, $manager;
+>>>>>>> skinnable-master
+               
+               $blogid = intRequestVar('blogid');
+               $member->teamRights($blogid) or self::disallow();
+               
+               self::$skin->parse('bookmarklet');
+               return;
+       }
+       
+       /**
+        * Admin::action_actionlog()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_actionlog()
+       {
+               global $member, $manager;
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('actionlog');
+               return;
+       }
+       
+       /**
+        * Admin::action_banlist()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_banlist()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               self::$skin->parse('banlist');
+               return;
+       }
+       
+       /**
+        * Admin::action_banlistdelete()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_banlistdelete()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               self::$skin->parse('banlistdelete');
+               return;
+       }
+       
+       /**
+        * Admin::action_banlistdeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_banlistdeleteconfirm()
+       {
+               global $member, $manager;
+               
+               $blogid         = intPostVar('blogid');
+               $allblogs       = postVar('allblogs');
+               $iprange        = postVar('iprange');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               $deleted = array();
+               
+               if ( !$allblogs )
+               {
+                       if ( Ban::removeBan($blogid, $iprange) )
+                       {
+                               $deleted[] = $blogid;
+                       }
+               }
+               else
+               {
+                       // get blogs fot which member has admin rights
+                       $adminblogs = $member->getAdminBlogs();
+                       foreach ($adminblogs as $blogje)
+                       {
+                               if ( Ban::removeBan($blogje, $iprange) )
+                               {
+                                       $deleted[] = $blogje;
+                               }
+                       }
+               }
+               
+               if ( sizeof($deleted) == 0 )
+               {
+                       self::error(_ERROR_DELETEBAN);
+                       return;
+               }
+               
+               /* TODO: we should use other ways */
+               $_REQUEST['delblogs'] = $deleted;
+               
+               self::$skin->parse('banlistdeleteconfirm');
+               return;
+       }
+       
+       /**
+<<<<<<< HEAD
+        * Admin::action_bookmarklet()
+=======
+        * Admin::action_banlistnewfromitem()
+>>>>>>> skinnable-master
+        * 
+        * @param       void
+        * @return      void
+        */
+<<<<<<< HEAD
+       public function action_bookmarklet()
+       {
+               global $member, $manager;
+               
+               $blogid = intRequestVar('blogid');
+               $member->teamRights($blogid) or $this->disallow();
+               $blog =& $manager->getBlog($blogid);
+               
+               $this->pagehead();
+               
+               echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
+               
+               echo '<h2>' . _BOOKMARKLET_TITLE . "</h2>\n";
+               echo '<p>';
+               echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5;
+               echo "</p>\n";
+               
+               echo '<h3>' . _BOOKMARKLET_BOOKARKLET . "</h3>\n";
+               echo '<p>';
+               echo _BOOKMARKLET_BMARKTEXT . '<small>' . _BOOKMARKLET_BMARKTEST . '</small>';
+               echo "</p>\n";
+               echo '<p>';
+               echo '<a href="javascript:' . rawurlencode(getBookmarklet($blogid)) . '">' . sprintf(_BOOKMARKLET_ANCHOR, Entity::hsc($blog->getName())) . '</a>';
+               echo _BOOKMARKLET_BMARKFOLLOW;
+               echo "</p>\n";
+               
+               $this->pagefoot();
+               return;
+       }
+       
     /**
      * @todo document this
      */
@@ -5614,8 +9773,8 @@ selector();
         $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
 
         ?>
-            <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
-            <p><a href="<?php echo i18n::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
+            <h2><?php echo _ACTIONLOG_CLEAR_TITLE ?></h2>
+            <p><a href="<?php echo Entity::hsc($url) ?>"><?php echo _ACTIONLOG_CLEAR_TEXT ?></a></p>
         <?php
         echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
 
@@ -5672,37 +9831,37 @@ selector();
         $member->blogAdminRights($blogid) or $this->disallow();
 
         $blog =& $manager->getBlog($blogid);
-        $banBlogName =  i18n::hsc($blog->getName());
+        $banBlogName =  Entity::hsc($blog->getName());
 
         $this->pagehead();
         ?>
-            <h2><?php echo _BAN_REMOVE_TITLE?></h2>
+            <h2><?php echo _BAN_REMOVE_TITLE ?></h2>
 
             <form method="post" action="index.php">
 
-            <h3><?php echo _BAN_IPRANGE?></h3>
+            <h3><?php echo _BAN_IPRANGE ?></h3>
 
             <p>
-                <?php echo _CONFIRMTXT_BAN?> <?php echo i18n::hsc($iprange) ?>
-                <input name="iprange" type="hidden" value="<?php echo i18n::hsc($iprange)?>" />
+                <?php echo _CONFIRMTXT_BAN ?> <?php echo Entity::hsc($iprange) ?>
+                <input name="iprange" type="hidden" value="<?php echo Entity::hsc($iprange) ?>" />
             </p>
 
-            <h3><?php echo _BAN_BLOGS?></h3>
+            <h3><?php echo _BAN_BLOGS ?></h3>
 
             <div>
-                <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
+                <input type="hidden" name="blogid" value="<?php echo $blogid ?>" />
                 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
                 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
                 <br />
-                <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
+                <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS ?></label>
             </div>
 
-            <h3><?php echo _BAN_DELETE_TITLE?></h3>
+            <h3><?php echo _BAN_DELETE_TITLE ?></h3>
 
             <div>
                 <?php $manager->addTicketHidden() ?>
                 <input type="hidden" name="action" value="banlistdeleteconfirm" />
-                <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+                <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
             </div>
 
             </form>
@@ -5725,13 +9884,13 @@ selector();
         $deleted = array();
 
         if (!$allblogs) {
-            if (BAN::removeBan($blogid, $iprange))
+            if (Ban::removeBan($blogid, $iprange))
                 array_push($deleted, $blogid);
         } else {
             // get blogs fot which member has admin rights
             $adminblogs = $member->getAdminBlogs();
             foreach ($adminblogs as $blogje) {
-                if (BAN::removeBan($blogje, $iprange))
+                if (Ban::removeBan($blogje, $iprange))
                     array_push($deleted, $blogje);
             }
         }
@@ -5748,7 +9907,7 @@ selector();
         echo "<ul>";
         foreach ($deleted as $delblog) {
             $b =& $manager->getBlog($delblog);
-            echo "<li>" . i18n::hsc($b->getName()). "</li>";
+            echo "<li>" . Entity::hsc($b->getName()). "</li>";
         }
         echo "</ul>";
 
@@ -5780,14 +9939,14 @@ selector();
 
         $this->pagehead();
         ?>
-        <h2><?php echo _BAN_ADD_TITLE?></h2>
+        <h2><?php echo _BAN_ADD_TITLE ?></h2>
 
 
         <form method="post" action="index.php">
 
-        <h3><?php echo _BAN_IPRANGE?></h3>
+        <h3><?php echo _BAN_IPRANGE ?></h3>
 
-        <p><?php echo _BAN_IPRANGE_TEXT?></p>
+        <p><?php echo _BAN_IPRANGE_TEXT ?></p>
 
         <div class="note">
             <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
@@ -5797,7 +9956,7 @@ selector();
         <div>
         <?php
         if ($ip) {
-            $iprangeVal = i18n::hsc($ip);
+            $iprangeVal = Entity::hsc($ip);
         ?>
             <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
             <label for="ip_fixed"><?php echo $iprangeVal ?></label>
@@ -5813,29 +9972,29 @@ selector();
         ?>
         </div>
 
-        <h3><?php echo _BAN_BLOGS?></h3>
+        <h3><?php echo _BAN_BLOGS ?></h3>
 
-        <p><?php echo _BAN_BLOGS_TEXT?></p>
+        <p><?php echo _BAN_BLOGS_TEXT ?></p>
 
         <div>
-            <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
-            <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo i18n::hsc($blog->getName())?>'</label>
+            <input type="hidden" name="blogid" value="<?php echo $blogid ?>" />
+            <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo Entity::hsc($blog->getName()) ?>'</label>
             <br />
-            <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
+            <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS ?></label>
         </div>
 
-        <h3><?php echo _BAN_REASON_TITLE?></h3>
+        <h3><?php echo _BAN_REASON_TITLE ?></h3>
 
-        <p><?php echo _BAN_REASON_TEXT?></p>
+        <p><?php echo _BAN_REASON_TEXT ?></p>
 
         <div><textarea name="reason" cols="40" rows="5"></textarea></div>
 
-        <h3><?php echo _BAN_ADD_TITLE?></h3>
+        <h3><?php echo _BAN_ADD_TITLE ?></h3>
 
         <div>
             <input name="action" type="hidden" value="banlistadd" />
             <?php $manager->addTicketHidden() ?>
-            <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
+            <input type="submit" value="<?php echo _BAN_ADD_BTN ?>" />
         </div>
 
         </form>
@@ -5861,14 +10020,14 @@ selector();
         // TODO: check IP range validity
 
         if (!$allblogs) {
-            if (!BAN::addBan($blogid, $iprange, $reason))
+            if (!Ban::addBan($blogid, $iprange, $reason))
                 $this->error(_ERROR_ADDBAN);
         } else {
             // get blogs fot which member has admin rights
             $adminblogs = $member->getAdminBlogs();
             $failed = 0;
             foreach ($adminblogs as $blogje) {
-                if (!BAN::addBan($blogje, $iprange, $reason))
+                if (!Ban::addBan($blogje, $iprange, $reason))
                     $failed = 1;
             }
             if ($failed)
@@ -5887,7 +10046,7 @@ selector();
 
         $member->isAdmin() or $this->disallow();
 
-        ACTIONLOG::clear();
+        ActionLog::clear();
 
         $this->action_manage(_MSG_ACTIONLOGCLEARED);
     }
@@ -5904,357 +10063,740 @@ selector();
 
         echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
         ?>
-        <h2><?php echo _BACKUPS_TITLE?></h2>
+        <h2><?php echo _BACKUPS_TITLE ?></h2>
 
-        <h3><?php echo _BACKUP_TITLE?></h3>
+        <h3><?php echo _BACKUP_TITLE ?></h3>
 
-        <p><?php echo _BACKUP_INTRO?></p>
+        <p><?php echo _BACKUP_INTRO ?></p>
 
         <form method="post" action="index.php"><p>
         <input type="hidden" name="action" value="backupcreate" />
         <?php $manager->addTicketHidden() ?>
 
-        <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
+        <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES ?></label>
         <br />
-        <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
+        <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO ?></label>
         <br /><br />
-        <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
+        <input type="submit" value="<?php echo _BACKUP_BTN ?>" tabindex="20" />
 
         </p></form>
 
-        <div class="note"><?php echo _BACKUP_NOTE?></div>
+        <div class="note"><?php echo _BACKUP_NOTE ?></div>
 
 
-        <h3><?php echo _RESTORE_TITLE?></h3>
+        <h3><?php echo _RESTORE_TITLE ?></h3>
 
-        <div class="note"><?php echo _RESTORE_NOTE?></div>
+        <div class="note"><?php echo _RESTORE_NOTE ?></div>
 
-        <p><?php echo _RESTORE_INTRO?></p>
+        <p><?php echo _RESTORE_INTRO ?></p>
 
         <form method="post" action="index.php" enctype="multipart/form-data"><p>
             <input type="hidden" name="action" value="backuprestore" />
             <?php $manager->addTicketHidden() ?>
             <input name="backup_file" type="file" tabindex="30" />
             <br /><br />
-            <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
-            <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
-            <br /><?php echo _RESTORE_WARNING?>
+            <input type="submit" value="<?php echo _RESTORE_BTN ?>" tabindex="40" />
+            <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE ?></label>
+            <br /><?php echo _RESTORE_WARNING ?>
         </p></form>
+=======
+       static private function action_banlistnewfromitem()
+       {
+               global $manager;
+               
+               $itemid = intRequestVar('itemid');
+               $item =& $manager->getItem($itemid, 1, 1);
+               self::action_banlistnew($item['blogid']);
+               return;
+       }
+       
+       /**
+        * Admin::action_banlistnew()
+        * 
+        * @param       integer $blogid ID for weblog
+        * @return      void
+        */
+       static private function action_banlistnew($blogid = '')
+       {
+               global $member, $manager;
+               
+               if ( $blogid == '' )
+               {
+                       $blogid = intRequestVar('blogid');
+               }
+               
+               $ip = requestVar('ip');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               /* TODO: we should consider to use the other way instead of this */
+               $_REQUEST['blogid'] = $blogid;          
+               
+               self::$skin->parse('banlistnew');
+               
+               return;
+       }
+>>>>>>> skinnable-master
 
-        <?php       $this->pagefoot();
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_backupcreate() {
-        global $member, $DIR_LIBS;
-
-        $member->isAdmin() or $this->disallow();
-
-        // use compression ?
-        $useGzip = intval(postVar('gzip'));
-
-        include($DIR_LIBS . 'backup.php');
-
-        // try to extend time limit
-        // (creating/restoring dumps might take a while)
-        @set_time_limit(1200);
-
-        $bu = new Backup();
-        $bu->do_backup($useGzip);
-        exit;
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_backuprestore() {
-        global $member, $DIR_LIBS;
-
-        $member->isAdmin() or $this->disallow();
-
-        if (intPostVar('letsgo') != 1)
-            $this->error(_ERROR_BACKUP_NOTSURE);
-
-        include($DIR_LIBS . 'backup.php');
-
-        // try to extend time limit
-        // (creating/restoring dumps might take a while)
-        @set_time_limit(1200);
-
-        $bu = new Backup();
-        $message = $bu->do_restore();
-        if ($message != '')
-            $this->error($message);
-
-        $this->pagehead();
-        ?>
-        <h2><?php echo _RESTORE_COMPLETE?></h2>
-        <?php       $this->pagefoot();
-
-    }
+       /**
+        * Admin::action_banlistadd()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_banlistadd()
+       {
+               global $member;
+               
+               $blogid         = intPostVar('blogid');
+               $allblogs       = postVar('allblogs');
+               $iprange        = postVar('iprange');
+               
+               if ( $iprange == "custom" )
+               {
+                       $iprange = postVar('customiprange');
+               }
+               $reason   = postVar('reason');
+               
+               $member->blogAdminRights($blogid) or self::disallow();
+               
+               // TODO: check IP range validity
+               
+               if ( !$allblogs )
+               {
+                       if ( !Ban::addBan($blogid, $iprange, $reason) )
+                       {
+                               self::error(_ERROR_ADDBAN);
+                               return;
+                       }
+               }
+               else
+               {
+                       // get blogs fot which member has admin rights
+                       $adminblogs = $member->getAdminBlogs();
+                       $failed = 0;
+                       foreach ($adminblogs as $blogje)
+                       {
+                               if ( !Ban::addBan($blogje, $iprange, $reason) )
+                               {
+                                       $failed = 1;
+                               }
+                       }
+                       if ( $failed )
+                       {
+                               self::error(_ERROR_ADDBAN);
+                               return;
+                       }
+               }
+               self::action_banlist();
+               return;
+       }
+       
+       /**
+        * Admin::action_clearactionlog()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_clearactionlog()
+       {
+               global $member;
+               
+               $member->isAdmin() or self::disallow();
+               
+               ActionLog::clear();
+               
+               self::action_manage(_MSG_ACTIONLOGCLEARED);
+               return;
+       }
+       
+       /**
+        * Admin::action_backupoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_backupoverview()
+       {
+               global $member, $manager;
+               
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('backupoverview');
+               return;
+       }
 
+       /**
+        * Admin::action_backupcreate()
+        * create file for backup
+        * 
+        * @param               void
+        * @return      void
+        * 
+        */
+       static private function action_backupcreate()
+       {
+               global $member, $DIR_LIBS;
+               
+               $member->isAdmin() or self::disallow();
+               
+               // use compression ?
+               $useGzip = (integer) postVar('gzip');
+               
+               include($DIR_LIBS . 'backup.php');
+               
+               // try to extend time limit
+               // (creating/restoring dumps might take a while)
+               @set_time_limit(1200);
+               
+               Backup::do_backup($useGzip);
+               return;
+       }
+       
+       /**
+        * Admin::action_backuprestore()
+        * restoring from uploaded file
+        * 
+        * @param               void
+        * @return      void
+        */
+       static private function action_backuprestore()
+       {
+               global $member, $DIR_LIBS;
+               
+               $member->isAdmin() or self::disallow();
+               
+               if ( intPostVar('letsgo') != 1 )
+               {
+                       self::error(_ERROR_BACKUP_NOTSURE);
+                       return;
+               }
+               
+               include($DIR_LIBS . 'backup.php');
+               
+               // try to extend time limit
+               // (creating/restoring dumps might take a while)
+               @set_time_limit(1200);
+               
+               $message = Backup::do_restore();
+               if ( $message != '' )
+               {
+                       self::error($message);
+                       return;
+               }
+               self::$skin->parse('backuprestore');
+               return;
+       }
+       
+       /**
+        * Admin::action_pluginlist()
+        * output the list of installed plugins
+        * 
+        * @param       void
+        * @return      void
+        * 
+        */
+       static private function action_pluginlist()
+       {
+               global $DIR_PLUGINS, $member, $manager;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               self::$skin->parse('pluginlist');
+               return;
+       }
+       
+       /**
+        * Admin::action_pluginhelp()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_pluginhelp()
+       {
+               global $member, $manager, $DIR_PLUGINS, $CONF;
+               
+<<<<<<< HEAD
+               while ( $filename = readdir($dirhandle) )
+               {
+                       if ( preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
+                       {
+                               $name = $matches[1];
+                               
+                               // only show in list when not yet installed
+                               $query = 'SELECT * FROM %s WHERE pfile = %s';
+                               $query = sprintf($query, sql_table('plugin'), DB::quoteValue('NP_'.$name));
+                               $res = DB::getResult($query);
+                               
+                               if ( $res->rowCount() == 0 )
+                               {
+                                       array_push($candidates, $name);
+                               }
+                       }
+               }
+=======
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+>>>>>>> skinnable-master
+               
+               $plugid = intGetVar('plugid');
+               
+               if ( !$manager->pidInstalled($plugid) )
+               {
+                       self::error(_ERROR_NOSUCHPLUGIN);
+                       return;
+               }
+               
+               self::$skin->parse('pluginhelp');
+               return;
+       }
+       
+<<<<<<< HEAD
     /**
      * @todo document this
      */
-    function action_pluginlist() {
-        global $member, $manager;
+    function action_pluginhelp() {
+        global $member, $manager, $DIR_PLUGINS, $CONF;
 
         // check if allowed
         $member->isAdmin() or $this->disallow();
 
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-        echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
-
-        echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' &nbsp;&nbsp;<span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
+        $plugid = intGetVar('plugid');
 
+        if (!$manager->pidInstalled($plugid))
+            $this->error(_ERROR_NOSUCHPLUGIN);
 
-        $query =  'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
+        $plugName = $manager->getPluginNameFromPid($plugid);
 
-        $template['content'] = 'pluginlist';
-        $template['tabindex'] = 10;
-        showlist($query, 'table', $template);
+        $this->pagehead();
 
-?>
-                       <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
+        echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
 
-                       <p><?php echo _PLUGS_TEXT_UPDATE?></p>
+        echo '<h2>',_PLUGS_HELP_TITLE,': ',Entity::hsc($plugName),'</h2>';
 
-                       <form method="post" action="index.php"><div>
-                               <input type="hidden" name="action" value="pluginupdate" />
-                               <?php $manager->addTicketHidden() ?>
-                               <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
-                       </div></form>
+        $plug =& $manager->getPlugin($plugName);
+        $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
 
-                       <h3><?php echo _PLUGS_TITLE_NEW?></h3>
+        if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
+            @readfile($helpFile);
+        } else {
+            echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
+            echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
+        }
 
-<?php
-               // find a list of possibly non-installed plugins
-               $candidates = array();
 
-               global $DIR_PLUGINS;
+        $this->pagefoot();
+    }
 
-               $dirhandle = opendir($DIR_PLUGINS);
+=======
+>>>>>>> skinnable-master
+       /**
+        * Admin::action_pluginadd()
+        * 
+        * @param       Void
+        * @return      Void
+        * 
+        */
+       static private function action_pluginadd()
+       {
+               global $member, $manager, $DIR_PLUGINS;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               $name = postVar('filename');
+               
+               if ( $manager->pluginInstalled($name) )
+               {
+                       self::error(_ERROR_DUPPLUGIN);
+                       return;
+               }
+               
+               if ( !checkPlugin($name) )
+               {
+                       self::error(_ERROR_PLUGFILEERROR . ' (' . Entity::hsc($name) . ')');
+                       return;
+               }
+               
+               // get number of currently installed plugins
+<<<<<<< HEAD
+               $res = DB::getResult('SELECT * FROM '.sql_table('plugin'));
+=======
+               $res = DB::getResult('SELECT * FROM ' . sql_table('plugin'));
+>>>>>>> skinnable-master
+               $numCurrent = $res->rowCount();
+               
+               // plugin will be added as last one in the list
+               $newOrder = $numCurrent + 1;
+               
+               $data = array('file' => &$name);
+               $manager->notify('PreAddPlugin', $data);
+               
+               // do this before calling getPlugin (in case the plugin id is used there)
+<<<<<<< HEAD
+               $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.','.DB::quoteValue($name).')';
+=======
+               $query = "INSERT INTO %s (porder, pfile) VALUES (%d, %s);";
+               $query = sprintf($query, sql_table('plugin'), (integer) $newOrder, DB::quoteValue($name));
+>>>>>>> skinnable-master
+               DB::execute($query);
+               $iPid = DB::getInsertId();
+               
+               $manager->clearCachedInfo('installedPlugins');
+               
+               // Load the plugin for condition checking and instalation
+               $plugin =& $manager->getPlugin($name);
+               
+               // check if it got loaded (could have failed)
+               if ( !$plugin )
+               {
+<<<<<<< HEAD
+                       DB::execute('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
+=======
+                       $query = "DELETE FROM %s WHERE pid=%d;";
+                       $query = sprintf($query, sql_table('plugin'), (integer) $iPid);
+                       
+                       DB::execute($query);
+                       
+>>>>>>> skinnable-master
+                       $manager->clearCachedInfo('installedPlugins');
+                       self::error(_ERROR_PLUGIN_LOAD);
+                       return;
+               }
+               
+               // check if plugin needs a newer Nucleus version
+               if ( getNucleusVersion() < $plugin->getMinNucleusVersion() )
+               {
+                       // uninstall plugin again...
+                       self::deleteOnePlugin($plugin->getID());
+                       
+                       // ...and show error
+                       self::error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc($plugin->getMinNucleusVersion()));
+                       return;
+               }
+               
+               // check if plugin needs a newer Nucleus version
+               if ( (getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()) )
+               {
+                       // uninstall plugin again...
+                       self::deleteOnePlugin($plugin->getID());
+                       
+                       // ...and show error
+                       self::error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
+                       return;
+               }
+               
+               $pluginList = $plugin->getPluginDep();
+               foreach ( $pluginList as $pluginName )
+               {
+                       $res = DB::getResult('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile=' . DB::quoteValue($pluginName));
+                       if ($res->rowCount() == 0)
+                       {
+                               // uninstall plugin again...
+                               self::deleteOnePlugin($plugin->getID());
+                               self::error(sprintf(_ERROR_INSREQPLUGIN, Entity::hsc($pluginName)));
+                               return;
+                       }
+               }
+               
+               // call the install method of the plugin
+               $plugin->install();
+               
+               $data = array('plugin' => &$plugin);
+               $manager->notify('PostAddPlugin', $data);
+               
+               // update all events
+               self::action_pluginupdate();
+               return;
+       }
+       
+       /**
+        * ADMIN:action_pluginupdate():
+        * 
+        * @param       Void
+        * @return      Void
+        * 
+        */
+       static private function action_pluginupdate()
+       {
+               global $member, $manager, $CONF;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               // delete everything from plugin_events
+               DB::execute('DELETE FROM '.sql_table('plugin_event'));
+               
+               // loop over all installed plugins
+               $res = DB::getResult('SELECT pid, pfile FROM '.sql_table('plugin'));
+               foreach ( $res as $row )
+               {
+                       $pid  =  $row['pid'];
+                       $plug =& $manager->getPlugin($row['pfile']);
+                       if ( $plug )
+                       {
+                               $eventList = $plug->getEventList();
+                               foreach ( $eventList as $eventName )
+                               {
+                                       $query = "INSERT INTO %s (pid, event) VALUES (%d, %s)";
+                                       $query = sprintf($query, sql_table('plugin_event'), (integer) $pid, DB::quoteValue($eventName));
+                                       DB::execute($query);
+                               }
+                       }
+               }
+               redirect($CONF['AdminURL'] . '?action=pluginlist');
+               return;
+       }
+       
+       /**
+        * Admin::action_plugindelete()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_plugindelete()
+       {
+               global $member, $manager;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               $pid = intGetVar('plugid');
+               
+               if ( !$manager->pidInstalled($pid) )
+               {
+                       self::error(_ERROR_NOSUCHPLUGIN);
+                       return;
+               }
+               
+               self::$skin->parse('plugindelete');
+               return;
+       }
 
-               while ($filename = readdir($dirhandle) )
+       /**
+        * Admin::action_plugindeleteconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_plugindeleteconfirm()
+       {
+               global $member, $manager, $CONF;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               $pid = intPostVar('plugid');
+               
+               $error = self::deleteOnePlugin($pid, 1);
+               if ( $error )
+               {
+                       self::error($error);
+                       return;
+               }
+               
+               redirect($CONF['AdminURL'] . '?action=pluginlist');
+               return;
+       }
+       
+       /**
+        * Admin::deleteOnePlugin()
+        * 
+        * @param       integer $pid
+        * @param       boolean $callUninstall
+        * @return      string  empty or message if failed
+        */
+       static public function deleteOnePlugin($pid, $callUninstall = 0)
+       {
+               global $manager;
+               
+               $pid = intval($pid);
+               
+               if ( !$manager->pidInstalled($pid) )
+               {
+                       return _ERROR_NOSUCHPLUGIN;
+               }
+               
+               $query = "SELECT pfile as result FROM %s WHERE pid=%d;";
+               $query = sprintf($query, sql_table('plugin'), (integer) $pid);
+               $name = DB::getValue($query);
+               
+               // check dependency before delete
+               $res = DB::getResult('SELECT pfile FROM ' . sql_table('plugin'));
+               foreach ( $res as $row )
+               {
+                       $plug =& $manager->getPlugin($row['pfile']);
+                       if ( $plug )
+                       {
+                               $depList = $plug->getPluginDep();
+                               foreach ( $depList as $depName )
+                               {
+                                       if ( $name == $depName )
+                                       {
+                                               return sprintf(_ERROR_DELREQPLUGIN, $row['pfile']);
+                                       }
+                               }
+                       }
+               }
+               
+               $data = array('plugid' => $pid);
+               $manager->notify('PreDeletePlugin', $data);
+               
+               // call the unInstall method of the plugin
+               if ( $callUninstall )
+               {
+                       $plugin =& $manager->getPlugin($name);
+                       if ( $plugin )
+                       {
+                               $plugin->unInstall();
+                       }
+               }
+               
+               // delete all subscriptions
+               DB::execute('DELETE FROM ' . sql_table('plugin_event') . ' WHERE pid=' . $pid);
+               
+               // delete all options
+               // get OIDs from plugin_option_desc
+               $res = DB::getResult('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
+               $aOIDs = array();
+               foreach ( $res as $row )
+               {
+                       array_push($aOIDs, $row['oid']);
+               }
+               
+               // delete from plugin_option and plugin_option_desc
+               DB::execute('DELETE FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
+               if (count($aOIDs) > 0)
+               {
+                       DB::execute('DELETE FROM ' . sql_table('plugin_option') . ' WHERE oid in (' . implode(',', $aOIDs) . ')');
+               }
+               
+               // update order numbers
+               $res = DB::getValue('SELECT porder FROM ' . sql_table('plugin') . ' WHERE pid=' . $pid);
+               DB::execute('UPDATE ' . sql_table('plugin') . ' SET porder=(porder - 1) WHERE porder>' . $res);
+               
+               // delete row
+               DB::execute('DELETE FROM ' . sql_table('plugin') . ' WHERE pid=' . $pid);
+               
+               $manager->clearCachedInfo('installedPlugins');
+               $data = array('plugid' => $pid);
+               $manager->notify('PostDeletePlugin', $data);
+               
+               return '';
+       }
+       
+       /**
+        * Admin::action_pluginup()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_pluginup()
+       {
+               global $member, $manager, $CONF;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               $plugid = intGetVar('plugid');
+               
+               if ( !$manager->pidInstalled($plugid) )
                {
-
-                       # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
-                       # original ereg: ereg('^NP_(.*)\.php$',$filename,$matches)
-
-                       if (preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
+<<<<<<< HEAD
+                       $res = DB::getResult('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile=' . DB::quoteValue($pluginName));
+                       if ($res->rowCount() == 0)
                        {
-
-                               $name = $matches[1];
-                               // only show in list when not yet installed
-                               $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE `pfile` = "NP_' . sql_real_escape_string($name) . '"');
-
-                               if (sql_num_rows($res) == 0)
-                               {
-                                       array_push($candidates, $name);
-                               }
-
+                               // uninstall plugin again...
+                               $this->deleteOnePlugin($plugin->getID());
+                               $this->error(sprintf(_ERROR_INSREQPLUGIN, Entity::hsc($pluginName)));
                        }
-
+=======
+                       self::error(_ERROR_NOSUCHPLUGIN);
+                       return;
+>>>>>>> skinnable-master
                }
-
-               closedir($dirhandle);
-
-               if (sizeof($candidates) > 0)
+               
+               // 1. get old order number
+               $oldOrder = DB::getValue('SELECT porder FROM ' . sql_table('plugin') . ' WHERE pid=' . $plugid);
+               
+               // 2. calculate new order number
+               $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
+               
+               // 3. update plug numbers
+               DB::execute('UPDATE ' . sql_table('plugin') . ' SET porder=' . $oldOrder . ' WHERE porder=' . $newOrder);
+               DB::execute('UPDATE ' . sql_table('plugin') . ' SET porder=' . $newOrder . ' WHERE pid=' . $plugid);
+               
+               //self::action_pluginlist();
+               // To avoid showing ticket in the URL, redirect to pluginlist, instead.
+               redirect($CONF['AdminURL'] . '?action=pluginlist');
+               return;
+       }
+       
+       /**
+        * Admin::action_plugindown()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_plugindown()
+       {
+               global $member, $manager, $CONF;
+               
+               // check if allowed
+<<<<<<< HEAD
+               $member->isAdmin() or $this->disallow();
+               
+               // delete everything from plugin_events
+               DB::execute('DELETE FROM '.sql_table('plugin_event'));
+               
+               // loop over all installed plugins
+               $res = DB::getResult('SELECT pid, pfile FROM '.sql_table('plugin'));
+               foreach ( $res as $row )
                {
-?>
-                       <p><?php echo _PLUGS_ADD_TEXT?></p>
-
-                       <form method='post' action='index.php'><div>
-                               <input type='hidden' name='action' value='pluginadd' />
-                               <?php $manager->addTicketHidden() ?>
-                               <select name="filename" tabindex="30">
-<?php
-                       foreach($candidates as $name)
+                       $pid = $row['pid'];
+                       $plug =& $manager->getPlugin($row['pfile']);
+                       if ( $plug )
                        {
-                               echo '<option value="NP_',$name,'">',i18n::hsc($name),'</option>';
+                               $eventList = $plug->getEventList();
+                               foreach ( $eventList as $eventName )
+                               {
+                                       $query = "INSERT INTO %s (pid, event) VALUES (%d, %s)";
+                                       $query = sprintf($query, sql_table('plugin_event'), (integer) $pid, DB::quoteValue($eventName));
+                                       DB::execute($query);
+                               }
                        }
-?>
-                               </select>
-                               <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
-                       </div></form>
-
-<?php
-               }
-               else
+=======
+               $member->isAdmin() or self::disallow();
+               
+               $plugid = intGetVar('plugid');
+               if ( !$manager->pidInstalled($plugid) )
                {
-                       echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
+                       self::error(_ERROR_NOSUCHPLUGIN);
+                       return;
+>>>>>>> skinnable-master
                }
-
-               $this->pagefoot();
-
+               
+               // 1. get old order number
+               $oldOrder = DB::getValue('SELECT porder FROM ' . sql_table('plugin') . ' WHERE pid=' . $plugid);
+               
+               $res = DB::getResult('SELECT * FROM ' . sql_table('plugin'));
+               $maxOrder = $res->rowCount();
+               
+               // 2. calculate new order number
+               $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
+               
+               // 3. update plug numbers
+               DB::execute('UPDATE ' . sql_table('plugin') . ' SET porder=' . $oldOrder . ' WHERE porder=' . $newOrder);
+               DB::execute('UPDATE ' . sql_table('plugin') . ' SET porder=' . $newOrder . ' WHERE pid=' . $plugid);
+               
+               //self::action_pluginlist();
+               // To avoid showing ticket in the URL, redirect to pluginlist, instead.
+               redirect($CONF['AdminURL'] . '?action=pluginlist');
+               return;
        }
-
-    /**
-     * @todo document this
-     */
-    function action_pluginhelp() {
-        global $member, $manager, $DIR_PLUGINS, $CONF;
-
-        // check if allowed
-        $member->isAdmin() or $this->disallow();
-
-        $plugid = intGetVar('plugid');
-
-        if (!$manager->pidInstalled($plugid))
-            $this->error(_ERROR_NOSUCHPLUGIN);
-
-        $plugName = getPluginNameFromPid($plugid);
-
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
-
-        echo '<h2>',_PLUGS_HELP_TITLE,': ',i18n::hsc($plugName),'</h2>';
-
-        $plug =& $manager->getPlugin($plugName);
-        $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
-
-        if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
-            @readfile($helpFile);
-        } else {
-            echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
-            echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
-        }
-
-
-        $this->pagefoot();
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_pluginadd() {
-        global $member, $manager, $DIR_PLUGINS;
-
-        // check if allowed
-        $member->isAdmin() or $this->disallow();
-
-        $name = postVar('filename');
-
-        if ($manager->pluginInstalled($name))
-            $this->error(_ERROR_DUPPLUGIN);
-        if (!checkPlugin($name))
-            $this->error(_ERROR_PLUGFILEERROR . ' (' . i18n::hsc($name) . ')');
-
-        // get number of currently installed plugins
-        $res = sql_query('SELECT * FROM '.sql_table('plugin'));
-        $numCurrent = sql_num_rows($res);
-
-        // plugin will be added as last one in the list
-        $newOrder = $numCurrent + 1;
-
-        $manager->notify(
-            'PreAddPlugin',
-            array(
-                'file' => &$name
-            )
-        );
-
-        // do this before calling getPlugin (in case the plugin id is used there)
-        $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
-        sql_query($query);
-        $iPid = sql_insert_id();
-
-        $manager->clearCachedInfo('installedPlugins');
-
-        // Load the plugin for condition checking and instalation
-        $plugin =& $manager->getPlugin($name);
-
-        // check if it got loaded (could have failed)
-        if (!$plugin)
-        {
-            sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
-            $manager->clearCachedInfo('installedPlugins');
-            $this->error(_ERROR_PLUGIN_LOAD);
-        }
-
-        // check if plugin needs a newer Nucleus version
-        if (getNucleusVersion() < $plugin->getMinNucleusVersion())
-        {
-            // uninstall plugin again...
-            $this->deleteOnePlugin($plugin->getID());
-
-            // ...and show error
-            $this->error(_ERROR_NUCLEUSVERSIONREQ . i18n::hsc($plugin->getMinNucleusVersion()));
-        }
-
-        // check if plugin needs a newer Nucleus version
-        if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
-        {
-            // uninstall plugin again...
-            $this->deleteOnePlugin($plugin->getID());
-
-            // ...and show error
-            $this->error(_ERROR_NUCLEUSVERSIONREQ . i18n::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
-        }
-
-        $pluginList = $plugin->getPluginDep();
-        foreach ($pluginList as $pluginName)
-        {
-
-            $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
-            if (sql_num_rows($res) == 0)
-            {
-                // uninstall plugin again...
-                $this->deleteOnePlugin($plugin->getID());
-
-                $this->error(sprintf(_ERROR_INSREQPLUGIN, i18n::hsc($pluginName)));
-            }
-        }
-
-        // call the install method of the plugin
-        $plugin->install();
-
-        $manager->notify(
-            'PostAddPlugin',
-            array(
-                'plugin' => &$plugin
-            )
-        );
-
-        // update all events
-        $this->action_pluginupdate();
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_pluginupdate() {
-        global $member, $manager, $CONF;
-
-        // check if allowed
-        $member->isAdmin() or $this->disallow();
-
-        // delete everything from plugin_events
-        sql_query('DELETE FROM '.sql_table('plugin_event'));
-
-        // loop over all installed plugins
-        $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
-        while($o = sql_fetch_object($res)) {
-            $pid = $o->pid;
-            $plug =& $manager->getPlugin($o->pfile);
-            if ($plug)
-            {
-                $eventList = $plug->getEventList();
-                foreach ($eventList as $eventName)
-                    sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.sql_real_escape_string($eventName).'\')');
-            }
-        }
-
-        redirect($CONF['AdminURL'] . '?action=pluginlist');
-//             $this->action_pluginlist();
-    }
-
+       
+<<<<<<< HEAD
     /**
      * @todo document this
      */
@@ -6271,15 +10813,15 @@ selector();
 
         $this->pagehead();
         ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
+            <h2><?php echo _DELETE_CONFIRM ?></h2>
 
-            <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
+            <p><?php echo _CONFIRMTXT_PLUGIN ?> <strong><?php echo $manager->getPluginNameFromPid($pid) ?></strong>?</p>
 
             <form method="post" action="index.php"><div>
             <?php $manager->addTicketHidden() ?>
             <input type="hidden" name="action" value="plugindeleteconfirm" />
             <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
-            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
             </div></form>
         <?php
         $this->pagefoot();
@@ -6316,7 +10858,7 @@ selector();
         if (!$manager->pidInstalled($pid))
             return _ERROR_NOSUCHPLUGIN;
 
-        $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
+        $name = DB::getValue('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
 
 /*             // call the unInstall method of the plugin
         if ($callUninstall) {
@@ -6325,9 +10867,9 @@ selector();
         }*/
 
         // check dependency before delete
-        $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
-        while($o = sql_fetch_object($res)) {
-            $plug =& $manager->getPlugin($o->pfile);
+        $res = DB::getResult('SELECT pfile FROM '.sql_table('plugin'));
+        foreach ( $res as $row ) {
+            $plug =& $manager->getPlugin($row['pfile']);
             if ($plug)
             {
                 $depList = $plug->getPluginDep();
@@ -6335,7 +10877,7 @@ selector();
                 {
                     if ($name == $depName)
                     {
-                        return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
+                        return sprintf(_ERROR_DELREQPLUGIN, $row['pfile']);
                     }
                 }
             }
@@ -6350,292 +10892,622 @@ selector();
         }
 
         // delete all subscriptions
-        sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
+        DB::execute('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
 
         // delete all options
         // get OIDs from plugin_option_desc
-        $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
+        $res = DB::getResult('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
         $aOIDs = array();
-        while ($o = sql_fetch_object($res)) {
-            array_push($aOIDs, $o->oid);
+        foreach ( $res as $row ) {
+            array_push($aOIDs, $row['oid']);
         }
 
         // delete from plugin_option and plugin_option_desc
-        sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
+        DB::execute('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
         if (count($aOIDs) > 0)
-            sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
-
-        // update order numbers
-        $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
-        $o = sql_fetch_object($res);
-        sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
-
-        // delete row
-        sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
-
-        $manager->clearCachedInfo('installedPlugins');
-        $manager->notify('PostDeletePlugin', array('plugid' => $pid));
-
-        return '';
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_pluginup() {
-        global $member, $manager, $CONF;
-
-        // check if allowed
-        $member->isAdmin() or $this->disallow();
-
-        $plugid = intGetVar('plugid');
-
-        if (!$manager->pidInstalled($plugid))
-            $this->error(_ERROR_NOSUCHPLUGIN);
-
-        // 1. get old order number
-        $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
-        $o = sql_fetch_object($res);
-        $oldOrder = $o->porder;
-
-        // 2. calculate new order number
-        $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
-
-        // 3. update plug numbers
-        sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
-        sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
-
-        //$this->action_pluginlist();
-        // To avoid showing ticket in the URL, redirect to pluginlist, instead.
-        redirect($CONF['AdminURL'] . '?action=pluginlist');
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_plugindown() {
-        global $member, $manager, $CONF;
-
-        // check if allowed
-        $member->isAdmin() or $this->disallow();
-
-        $plugid = intGetVar('plugid');
-        if (!$manager->pidInstalled($plugid))
-            $this->error(_ERROR_NOSUCHPLUGIN);
-
-        // 1. get old order number
-        $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
-        $o = sql_fetch_object($res);
-        $oldOrder = $o->porder;
-
-        $res = sql_query('SELECT * FROM '.sql_table('plugin'));
-        $maxOrder = sql_num_rows($res);
-
-        // 2. calculate new order number
-        $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
-
-        // 3. update plug numbers
-        sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
-        sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
-
-        //$this->action_pluginlist();
-        // To avoid showing ticket in the URL, redirect to pluginlist, instead.
-        redirect($CONF['AdminURL'] . '?action=pluginlist');
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_pluginoptions($message = '') {
-        global $member, $manager;
-
-        // check if allowed
-        $member->isAdmin() or $this->disallow();
-
-        $pid = intRequestVar('plugid');
-        if (!$manager->pidInstalled($pid))
-            $this->error(_ERROR_NOSUCHPLUGIN);
-
-        $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-        $pluginName = i18n::hsc(getPluginNameFromPid($pid));
-        $this->pagehead($extrahead);
-
-        ?>
-            <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
-
-            <h2><?php echo sprintf(_PLUGIN_OPTIONS_TITLE, $pluginName) ?></h2>
-
-            <?php if  ($message) echo $message?>
-
-            <form action="index.php" method="post">
-            <div>
-                <input type="hidden" name="action" value="pluginoptionsupdate" />
-                <input type="hidden" name="plugid" value="<?php echo $pid?>" />
-
-        <?php
-
-        $manager->addTicketHidden();
-
-        $aOptions = array();
-        $aOIDs = array();
-        $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
-        $r = sql_query($query);
-        while ($o = sql_fetch_object($r)) {
-            array_push($aOIDs, $o->oid);
-            $aOptions[$o->oid] = array(
-                        'oid' => $o->oid,
-                        'value' => $o->odef,
-                        'name' => $o->oname,
-                        'description' => $o->odesc,
-                        'type' => $o->otype,
-                        'typeinfo' => $o->oextra,
-                        'contextid' => 0
-            );
-        }
-        // fill out actual values
-        if (count($aOIDs) > 0) {
-            $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
-            while ($o = sql_fetch_object($r))
-                $aOptions[$o->oid]['value'] = $o->ovalue;
-        }
-
-        // call plugins
-        $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
-
-        $template['content'] = 'plugoptionlist';
-        $amount = showlist($aOptions,'table',$template);
-        if ($amount == 0)
-            echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
-
-        ?>
-            </div>
-            </form>
-        <?php       $this->pagefoot();
+            DB::execute('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
 
+        // update order numbers
+        $res = DB::getValue('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
+        DB::execute('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$res);
+
+        // delete row
+        DB::execute('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
 
+        $manager->clearCachedInfo('installedPlugins');
+        $manager->notify('PostDeletePlugin', array('plugid' => $pid));
 
+        return '';
     }
 
     /**
      * @todo document this
      */
-    function action_pluginoptionsupdate() {
-        global $member, $manager;
+    function action_pluginup() {
+        global $member, $manager, $CONF;
 
         // check if allowed
         $member->isAdmin() or $this->disallow();
 
-        $pid = intRequestVar('plugid');
-        if (!$manager->pidInstalled($pid))
+        $plugid = intGetVar('plugid');
+
+        if (!$manager->pidInstalled($plugid))
             $this->error(_ERROR_NOSUCHPLUGIN);
 
-        $aOptions = requestArray('plugoption');
-        NucleusPlugin::_applyPluginOptions($aOptions);
+        // 1. get old order number
+        $oldOrder = DB::getValue('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
+
+        // 2. calculate new order number
+        $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
 
-        $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
+        // 3. update plug numbers
+        DB::execute('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
+        DB::execute('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
 
-        $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
+        //$this->action_pluginlist();
+        // To avoid showing ticket in the URL, redirect to pluginlist, instead.
+        redirect($CONF['AdminURL'] . '?action=pluginlist');
     }
 
     /**
-     * @static
      * @todo document this
      */
-    function _insertPluginOptions($context, $contextid = 0) {
-        // get all current values for this contextid
-        // (note: this might contain doubles for overlapping contextids)
-        $aIdToValue = array();
-        $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
-        while ($o = sql_fetch_object($res)) {
-            $aIdToValue[$o->oid] = $o->ovalue;
-        }
-
-        // get list of oids per pid
-        $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
-               . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
-        $res = sql_query($query);
-        $aOptions = array();
-        while ($o = sql_fetch_object($res)) {
-            if (in_array($o->oid, array_keys($aIdToValue)))
-                $value = $aIdToValue[$o->oid];
-            else
-                $value = $o->odef;
-
-            array_push($aOptions, array(
-                'pid' => $o->pid,
-                'pfile' => $o->pfile,
-                'oid' => $o->oid,
-                'value' => $value,
-                'name' => $o->oname,
-                'description' => $o->odesc,
-                'type' => $o->otype,
-                'typeinfo' => $o->oextra,
-                'contextid' => $contextid,
-                'extra' => ''
-            ));
-        }
-
-        global $manager;
-        $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
-
-
-        $iPrevPid = -1;
-        foreach ($aOptions as $aOption) {
+    function action_plugindown() {
+        global $member, $manager, $CONF;
 
-            // new plugin?
-            if ($iPrevPid != $aOption['pid']) {
-                $iPrevPid = $aOption['pid'];
-                if (!defined('_PLUGIN_OPTIONS_TITLE')) {
-                    define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
-                }
-                echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, i18n::hsc($aOption['pfile'])).'</th></tr>';
-            }
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
 
-            $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
-            if (@$meta['access'] != 'hidden') {
-                echo '<tr>';
-                listplug_plugOptionRow($aOption);
-                echo '</tr>';
-            }
+        $plugid = intGetVar('plugid');
+        if (!$manager->pidInstalled($plugid))
+            $this->error(_ERROR_NOSUCHPLUGIN);
 
-        }
+        // 1. get old order number
+        $oldOrder = DB::getValue('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
 
+        $res = DB::getResult('SELECT * FROM '.sql_table('plugin'));
+        $maxOrder = $res->rowCount();
 
-    }
+        // 2. calculate new order number
+        $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
 
-    /**
-     * Helper functions to create option forms etc.
-     * @todo document parameters
-     */
-    function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
-        $id = i18n::hsc($name);
-        $id = str_replace('[','-',$id);
-        $id = str_replace(']','-',$id);
-        $id1 = $id . i18n::hsc($value1);
-        $id2 = $id . i18n::hsc($value2);
-
-        if ($name=="admin") {
-            echo '<input onclick="selectCanLogin(true);" type="radio" name="', i18n::hsc($name),'" value="', i18n::hsc($value1),'" ';
-        } else {
-            echo '<input type="radio" name="', i18n::hsc($name),'" value="', i18n::hsc($value1),'" ';
-        }
+        // 3. update plug numbers
+        DB::execute('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
+        DB::execute('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
 
-            if ($checkedval == $value1)
-                echo "tabindex='$tabindex' checked='checked'";
-            echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';
-        echo ' ';
-        if ($name=="admin") {
-            echo '<input onclick="selectCanLogin(false);" type="radio" name="', i18n::hsc($name),'" value="', i18n::hsc($value2),'" ';
-        } else {
-            echo '<input type="radio" name="', i18n::hsc($name),'" value="', i18n::hsc($value2),'" ';
-        }
-            if ($checkedval != $value1)
-                echo "tabindex='$tabindex' checked='checked'";
-            if ($isAdmin && $name=="canlogin")
-                echo ' disabled="disabled"';
-            echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';
+        //$this->action_pluginlist();
+        // To avoid showing ticket in the URL, redirect to pluginlist, instead.
+        redirect($CONF['AdminURL'] . '?action=pluginlist');
     }
+       
+=======
+>>>>>>> skinnable-master
+       /**
+        * Admin::action_pluginoptions()
+        * 
+        * Output Plugin option page
+        * 
+        * @access      public
+        * @param       string $message message when fallbacked
+        * @return      void
+        * 
+        */
+       static private function action_pluginoptions($message = '')
+       {
+               global $member, $manager;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               $pid = intRequestVar('plugid');
+               if ( !$manager->pidInstalled($pid) )
+               {
+                       self::error(_ERROR_NOSUCHPLUGIN);
+                       return;
+               }
+               
+<<<<<<< HEAD
+               $pname = $manager->getPluginNameFromPid($pid);
+               
+               /* NOTE: to include translation file */
+               $manager->getPlugin($pname);
+               
+               $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
+               $this->pagehead($extrahead);
+               echo '<p><a href="index.php?action=pluginlist">(' . _PLUGS_BACK . ")</a></p>\n";
+               echo '<h2>' . sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($pname)) . "</h2>\n";
+               
+               if ( isset($message) )
+               {
+                       echo $message;
+               }
+               
+               echo "<form action=\"index.php\" method=\"post\">\n";
+               echo "<div>\n";
+               echo "<input type=\"hidden\" name=\"action\" value=\"pluginoptionsupdate\" />\n";
+               echo "<input type=\"hidden\" name=\"plugid\" value=\"{$pid}\" />\n";
+               $manager->addTicketHidden();
+               
+               $options = array();
+               $query = "SELECT * FROM %s WHERE ocontext='global' and opid=%d ORDER BY oid ASC";
+               $query = sprintf($query, sql_table('plugin_option_desc'), $pid);
+               $result = DB::getResult($query);
+               foreach ( $result as $row )
+               {
+                       $options[$row['oid']] = array(
+                               'oid'           => $row['oid'],
+                               'value'         => $row['odef'],
+                               'name'          => $row['oname'],
+                               'description' => $row['odesc'],
+                               'type'          => $row['otype'],
+                               'typeinfo'      => $row['oextra'],
+                               'contextid'     => 0
+                       );
+               }
+               // fill out actual values
+               if ( count($options) > 0 )
+               {
+                       $query = "SELECT oid, ovalue FROM %s WHERE oid in (%s)";
+                       $query = sprintf($query, sql_table('plugin_option'), implode(',',array_keys($options)));
+                       $result = DB::getResult($query);
+                       foreach ( $result as $row )
+                       {
+                               $options[$row['oid']]['value'] = $row['ovalue'];
+                       }
+               }
+               
+               // call plugins
+               $data = array('context' => 'global', 'plugid' => $pid, 'options'=>&$options);
+               $manager->notify('PrePluginOptionsEdit',$data);
+               
+               $template['content'] = 'plugoptionlist';
+               $amount = showlist($options,'table', $template);
+               if ( $amount == 0 )
+               {
+                       echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
+=======
+               if ( isset($message) )
+               {
+                       self::$headMess = $message;
+>>>>>>> skinnable-master
+               }
+               $plugname       = $manager->getPluginNameFromPid($pid);
+               $plugin         = $manager->getPlugin($plugname);
+               self::$extrahead .= "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/numbercheck.js)%>\"></script>\n";
+               
+               self::$skin->parse('pluginoptions');
+               return;
+       }
+       
+       /**
+        * Admin::action_pluginoptionsupdate()
+        * 
+        * Update plugin options and fallback to plugin option page
+        * 
+        * @access      public
+        * @param       void
+        * @return      void
+        */
+       static private function action_pluginoptionsupdate()
+       {
+               global $member, $manager;
+               
+               // check if allowed
+               $member->isAdmin() or self::disallow();
+               
+               $pid = intRequestVar('plugid');
+               
+               if ( !$manager->pidInstalled($pid) )
+               {
+                       self::error(_ERROR_NOSUCHPLUGIN);
+                       return;
+               }
+               
+               $aOptions = requestArray('plugoption');
+               NucleusPlugin::apply_plugin_options($aOptions);
+               
+               $data = array(
+                       'context'       => 'global',
+                       'plugid'        => $pid
+               );
+               $manager->notify('PostPluginOptionsUpdate', $data);
+               
+               self::action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
+               return;
+       }
+       
+       /**
+        * Admin::skineditgeneral()
+        * 
+        * @param       integer $skinid
+        * @param       string  $handler
+        * @return      string  empty or message if failed
+        */
+       static private function skineditgeneral($skinid, $handler='')
+       {
+               global $manager;
+               
+               $name = postVar('name');
+               $desc = postVar('desc');
+               $type = postVar('type');
+               $inc_mode = postVar('inc_mode');
+               $inc_prefix = postVar('inc_prefix');
+               
+               $skin =& $manager->getSkin($skinid, $handler);
+               
+               // 1. Some checks
+               if ( !isValidSkinName($name) )
+               {
+                       return _ERROR_BADSKINNAME;
+               }
+               
+               if ( ($skin->getName() != $name) && SKIN::exists($name) )
+               {
+                       return _ERROR_DUPSKINNAME;
+               }
+               
+               if ( !$type )
+               {
+                       $type = 'text/html';
+               }
+               
+               if ( !$inc_mode )
+               {
+                       $inc_mode = 'normal';
+               }
+               
+               // 2. Update description
+               $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
+               
+               return '';
+       }
+       /**
+        * Admin::skindeleteconfirm()
+        * 
+        * @param       integer $skinid
+        * @return      void
+        */
+       static private function skindeleteconfirm($skinid)
+       {
+               global $manager;
+               
+               if ( !in_array(self::$action, self::$adminskin_actions) )
+               {
+                       $event_identifier = 'Skin';
+               }
+               else
+               {
+                       $event_identifier = 'AdminSkin';
+               }
 
-} // class ADMIN
-
-?>
+               $data = array('skinid' => $skinid);
+               $manager->notify("PreDelete{$event_identifier}", $data);
+               
+               // 1. delete description
+               $query = "DELETE FROM %s WHERE sdnumber=%d;";
+               $query = sprintf($query, sql_table('skin_desc'), (integer) $skinid);
+               DB::execute($query);
+               
+               // 2. delete parts
+               $query = "DELETE FROM %s WHERE sdesc=%d;";
+               $query = sprintf($query, sql_table('skin'), (integer) $skinid);
+               DB::execute($query);
+               
+               $manager->notify("PostDelete{$event_identifier}", $data);
+               
+               return;
+       }
+       
+       /**
+        * Admin::skinremovetypeconfirm()
+        * 
+        * @param       integer $skinid
+        * @param       string  $skintype
+        * @return      string  empty or message if failed
+        */
+       static private function skinremovetypeconfirm($skinid, $skintype)
+       {
+               global $manager;
+               
+<<<<<<< HEAD
+               /* get current registered plugin option list in this context even if it's not used */
+               $query = 'SELECT * FROM %s AS plugins, %s AS options LEFT OUTER JOIN %s AS added '
+                      . 'ON ( options.oid=added.oid ) '
+                      . 'WHERE plugins.pid=options.opid AND options.ocontext=%s AND added.ocontextid=%d '
+                      . 'ORDER BY options.oid ASC';
+               $query = sprintf($query, sql_table('plugin'), sql_table('plugin_option_desc'), sql_table('plugin_option'), DB::quoteValue($context), intval($contextid));
+               
+               $res = DB::getResult($query);
+               
+               $options = array();
+               foreach ( $res as $row )
+               {
+                       /* NOTE: to include translation file */
+                       $manager->getPlugin($row['pfile']);
+                       
+                       $options[] = array(
+                               'pid'           => $row['pid'],
+                               'pfile'         => $row['pfile'],
+                               'oid'           => $row['oid'],
+                               'value'         => ( !$row['ovalue'] ) ? $row['odef'] : $row['ovalue'],
+                               'name'          => $row['oname'],
+                               'description' => $row['odesc'],
+                               'type'          => $row['otype'],
+                               'typeinfo'      => $row['oextra'],
+                               'contextid'     => $contextid,
+                               'extra'         => ''
+                       );
+               }
+               
+               $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$options));
+               
+               $iPrevPid = -1;
+               foreach ( $options as $option)
+               {
+                       // new plugin?
+                       if ( $iPrevPid != $option['pid'] )
+                       {
+                               $iPrevPid = $option['pid'];
+                               if ( !defined('_PLUGIN_OPTIONS_TITLE') )
+                               {
+                                       define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
+                               }
+                               echo "<tr>\n";
+                               echo '<th colspan="2">' . sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($option['pfile'])) . "</th>\n";
+                               echo "</tr>\n";
+                       }
+                       
+                       $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
+                       if ( @$meta['access'] != 'hidden' )
+                       {
+                               echo '<tr>';
+                               listplug_plugOptionRow($option);
+                               echo '</tr>';
+=======
+               if ( !in_array(self::$action, self::$adminskin_actions) )
+               {
+                       $event_identifier = 'Skin';
+               }
+               else
+               {
+                       $event_identifier = 'AdminSkin';
+               }
+               
+               if ( !isValidShortName($skintype) )
+               {
+                       return _ERROR_SKIN_PARTS_SPECIAL_DELETE;
+               }
+               
+               $data = array(
+                       'skinid'        => $skinid,
+                       'skintype'      => $skintype
+               );
+               $manager->notify("PreDelete{$event_identifier}Part", $data);
+               
+               // delete part
+               $query = 'DELETE FROM %s WHERE sdesc = %d AND stype = %s;';
+               $query = sprintf($query, sql_table('skin'), (integer) $skinid, DB::quoteValue($skintype) );
+               DB::execute($query);
+               
+               $data = array(
+                       'skinid'        => $skinid,
+                       'skintype'      => $skintype
+               );
+               $manager->notify("PostDelete{$event_identifier}Part", $data);
+               
+               return '';
+       }
+       
+       /**
+        * Admin::skinclone()
+        * 
+        * @param       integer $skinid
+        * @param       string  $handler
+        * @return      void
+        */
+       static private function skinclone($skinid, $handler='')
+       {
+               global $manager;
+               
+               // 1. read skin to clone
+               $skin =& $manager->getSkin($skinid, $handler);
+               $name = "{$skin->getName()}_clone";
+               
+               // if a skin with that name already exists:
+               if ( Skin::exists($name) )
+               {
+                       $i = 1;
+                       while ( Skin::exists($name . $i) )
+                       {
+                               $i++;
+                       }
+                       $name .= $i;
+               }
+               
+               // 2. create skin desc
+               $newid = Skin::createNew(
+                       $name,
+                       $skin->getDescription(),
+                       $skin->getContentType(),
+                       $skin->getIncludeMode(),
+                       $skin->getIncludePrefix()
+               );
+               
+               // 3. clone
+               $query = "SELECT stype FROM %s WHERE sdesc=%d;";
+               $query = sprintf($query, sql_table('skin'), (integer) $skinid);
+               
+               $res = DB::getResult($query);
+               foreach ( $res as $row )
+               {
+                       $content = $skin->getContentFromDB($row['stype']);
+                       if ( $content )
+                       {
+                               $query = "INSERT INTO %s (sdesc, scontent, stype) VALUES (%d, %s, %s)";
+                               $query = sprintf($query, sql_table('skin'), (integer) $newid, DB::quoteValue($content), DB::quoteValue($row['stype']));
+                               DB::execute($query);
+>>>>>>> skinnable-master
+                       }
+               }
+               return;
+       }
+       
+       /**
+        * Admin::skinieimport()
+        * 
+        * @param       string  $mode
+        * @param       string  $skinFileRaw
+        * @return      string  empty or message if failed
+        */
+       static private function skinieimport($mode, $skinFileRaw)
+       {
+               global $DIR_LIBS, $DIR_SKINS;
+               
+               // load skinie class
+               include_once($DIR_LIBS . 'skinie.php');
+               
+               $importer = new SkinImport();
+               
+               // get full filename
+               if ( $mode == 'file' )
+               {
+                       $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
+               }
+               else
+               {
+                       $skinFile = $skinFileRaw;
+               }
+               
+               // read only metadata
+               $error = $importer->readFile($skinFile, 1);
+               if ( $error )
+               {
+                       unset($importer);
+                       return $error;
+               }
+               
+               self::$contents['mode']         = $mode;
+               self::$contents['skinfile']     = $skinFileRaw;
+               self::$contents['skininfo']     = $importer->getInfo();
+               self::$contents['skinnames']    = $importer->getSkinNames();
+               self::$contents['tpltnames']    = $importer->getTemplateNames();
+               
+               // clashes
+               $skinNameClashes                = $importer->checkSkinNameClashes();
+               $templateNameClashes    = $importer->checkTemplateNameClashes();
+               $hasNameClashes                 = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
+               
+               self::$contents['skinclashes'] = $skinNameClashes;
+               self::$contents['tpltclashes'] = $templateNameClashes;
+               self::$contents['nameclashes'] = $hasNameClashes ? 1 : 0;
+               
+               unset($importer);
+               return '';
+       }
+       
+       /**
+        * Admin::skinieedoimport()
+        * 
+        * @param       string  $mode
+        * @param       string  $skinFileRaw
+        * @param       boolean $allowOverwrite
+        * @return      string  empty   or message if failed
+        */
+       static private function skiniedoimport($mode, $skinFileRaw, $allowOverwrite)
+       {
+               global $DIR_LIBS, $DIR_SKINS;
+               
+               // load skinie class
+               include_once($DIR_LIBS . 'skinie.php');
+               
+               $importer = new SkinImport();
+               
+               // get full filename
+               if ( $mode == 'file' )
+               {
+                       $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
+               }
+               else
+               {
+                       $skinFile = $skinFileRaw;
+               }
+               
+               $error = $importer->readFile($skinFile);
+               if ( $error )
+               {
+                       unset($importer);
+                       return $error;
+               }
+               
+               $error = $importer->writeToDatabase($allowOverwrite);
+               if ( $error )
+               {
+                       unset($importer);
+                       return $error;
+               }
+               
+               self::$contents['mode']         = $mode;
+               self::$contents['skinfile']     = $skinFileRaw;
+               self::$contents['skininfo']     = $importer->getInfo();
+               self::$contents['skinnames']    = $importer->getSkinNames();
+               self::$contents['tpltnames']    = $importer->getTemplateNames();
+               
+               unset($importer);
+               return '';
+       }
+       
+       /**
+        * Admin::skinieexport()
+        * 
+        * @param       array   $aSkins
+        * @param       array   $aTemplates
+        * @param       string  $info
+        * @return      void
+        */
+       static private function skinieexport($aSkins, $aTemplates, $info)
+       {
+               global $DIR_LIBS;
+               
+               // load skinie class
+               include_once($DIR_LIBS . 'skinie.php');
+               
+               if ( !is_array($aSkins) )
+               {
+                       $aSkins = array();
+               }
+               
+               if (!is_array($aTemplates))
+               {
+                       $aTemplates = array();
+               }
+               
+               $skinList = array_keys($aSkins);
+               $templateList = array_keys($aTemplates);
+               
+               $exporter = new SkinExport();
+               foreach ( $skinList as $skinId )
+               {
+                       $exporter->addSkin($skinId);
+               }
+               foreach ( $templateList as $templateId )
+               {
+                       $exporter->addTemplate($templateId);
+               }
+               $exporter->setInfo($info);
+               $exporter->export();
+               
+               return;
+       }
+       
+       /**
+        * Admin::action_parseSpecialskin()
+        * 
+        * @param       void
+        * @return      void
+        */
+       static private function action_parseSpecialskin()
+       {
+               self::$skin->parse(self::$action);
+               return;
+       }
+}