*** empty log message ***
[Packages/TYPO3.CMS.git] / typo3 / alt_clickmenu.php
index ac27648..c620762 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *  
-*  (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is 
  * Writing content back into a <div>-layer is necessary if we want individualized context menus with any specific content for any specific element.
  * Context menus can appear for either database elements or files 
  * The input to this script is basically the "&init" var which is divided by "|" - each part is a reference to table|uid|listframe-flag.
- * 
- * @author     Kasper Skårhøj <kasper@typo3.com>
- * @package TYPO3
- * @subpackage core
  *
- * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
+ * If you want to integrate a context menu in your scripts, please see template::getContextMenuCode()
+ *
+ * $Id$ 
+ * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
+ * XHTML compliant
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *  123: class clickMenu 
+ *  154:     function init($item)      
+ *  194:     function doDisplayTopFrameCM()    
+ *
+ *              SECTION: DATABASE
+ *  222:     function printDBClickMenu($table,$uid)    
+ *  309:     function printNewDBLevel($table,$uid)     
+ *  346:     function externalProcessingOfDBMenuItems($menuItems)      
+ *  358:     function processingByExtClassArray($menuItems,$table,$uid)        
+ *  377:     function urlRefForCM($url,$retUrl='',$hideCM=1)   
+ *  394:     function DB_copycut($table,$uid,$type)    
+ *  417:     function DB_paste($table,$uid,$type,$elInfo)      
+ *  438:     function DB_info($table,$uid)     
+ *  454:     function DB_history($table,$uid)  
+ *  473:     function DB_perms($table,$uid,$rec)       
+ *  492:     function DB_db_list($table,$uid,$rec)     
+ *  511:     function DB_moveWizard($table,$uid,$rec)  
+ *  532:     function DB_newWizard($table,$uid,$rec)   
+ *  550:     function DB_editAccess($table,$uid)       
+ *  568:     function DB_editPageHeader($uid)  
+ *  586:     function DB_edit($table,$uid)     
+ *  625:     function DB_new($table,$uid)      
+ *  650:     function DB_hideUnhide($table,$rec,$hideField)    
+ *  674:     function DB_delete($table,$uid,$elInfo)   
+ *  695:     function DB_view($id,$anchor='')  
+ *
+ *              SECTION: FILE
+ *  724:     function printFileClickMenu($path)        
+ *  788:     function externalProcessingOfFileMenuItems($menuItems)    
+ *  802:     function FILE_launch($path,$script,$type,$image)  
+ *  821:     function FILE_copycut($path,$type)        
+ *  841:     function FILE_delete($path)       
+ *  863:     function FILE_paste($path,$target,$elInfo)        
+ *
+ *              SECTION: COMMON
+ *  903:     function printItems($menuItems,$item)     
+ *  945:     function printLayerJScode($menuItems)     
+ *  980:     function wrapColorTableCM($str)   
+ *  995:     function menuItemsForTopFrame($menuItems) 
+ * 1012:     function menuItemsForClickMenu($menuItems)        
+ * 1047:     function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)      
+ * 1071:     function excludeIcon($iconCode)   
+ * 1081:     function label($label)    
+ * 1090:     function isCMlayers()     
+ * 1100:     function frameLocation($str)      
+ *
+ *
+ * 1125: class SC_alt_clickmenu 
+ * 1143:     function init()   
+ * 1226:     function main()   
+ * 1266:     function printContent()   
+ *
+ * TOTAL FUNCTIONS: 41
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
  */
 
  
@@ -48,40 +111,54 @@ $LANG->includeLLFile('EXT:lang/locallang_misc.php');
 
 
 
-// ***************************
-// Script Classes
-// ***************************
 
 /**
  * Class for generating the click menu
+ * 
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage core
  * @internal
  */
 class clickMenu {
-       var $backPath='';
-       var $elCount=0;
+
+               // Internal, static: GPvar:
+       var $cmLevel=0;                         // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
+       var $CB;                                        // Clipboard array (submitted by eg. pressing the paste button)
+
+               // Internal, static:
+       var $backPath='';                       // Backpath for scripts/images.
+       var $PH_backPath='###BACK_PATH###';             // BackPath place holder: We need different backPath set whether the clickmenu is written back to a frame which is not in typo3/ dir or if the clickmenu is shown in the top frame (no backpath)
        var $listFrame=0;                       // If set, the calling document should be in the listframe of a frameset.
-       var $isDBmenu=0;                        // If set, the menu is about databsae records, not files. (set if part 2 [1] of the item-var is NOT blank)
-       var $alwaysContentFrame=0;
-       var $iParts=array();
-       var $disabledItems=array();
-       var $editPageIconSet=0;
-       var $dontDisplayTopFrameCM=0;
-       var $leftIcons=0;
-       var $cmLevel=0;
-       var $extClassArray=array();
-       
-       var $editOK=0;
-       var $rec=array();
+       var $isDBmenu=0;                        // If set, the menu is about database records, not files. (set if part 2 [1] of the item-var is NOT blank)
+       var $alwaysContentFrame=0;      // If true, the "content" frame is always used for reference (when condensed mode is enabled)
+       var $iParts=array();            // Stores the parts of the input $item string, splitted by "|"
+       var $disabledItems=array();     // Contains list of keywords of items to disable in the menu
+       var $dontDisplayTopFrameCM=0;   // If true, the context sensitive menu will not appear in the top frame, only as a layer.
+       var $leftIcons=0;                       // If true, Show icons on the left.
+       var $extClassArray=array();             // Array of classes to be used for user processing of the menu content. This is for the API of adding items to the menu from outside.
+
+               // Internal, dynamic:   
+       var $elCount=0;                         // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
+       var $editPageIconSet=0;         // Set, when edit icon is drawn.
+       var $editOK=0;                          // Set to true, if editing of the element is OK.
+       var $rec=array();                       
        
 
 
-       /** 
+       /**
         * Initialize click menu
-        *
-        * @param       string  Input "item" GET var.
-        * @return      string  The clickmenu HTML content
+        * 
+        * @param       string          Input "item" GET var.
+        * @return      string          The clickmenu HTML content
         */
        function init($item)    {
+
+                       // Setting GPvars:
+               $this->cmLevel = intval(t3lib_div::_GP('cmLevel'));
+               $this->CB = t3lib_div::_GP('CB');
+
+
                        // Explode the incoming command:
                $this->iParts = explode('|',$item);
 
@@ -95,26 +172,28 @@ class clickMenu {
                $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
 
                        // &cmLevel flag detected (2nd level menu)
-               $this->cmLevel = intval(t3lib_div::GPvar('cmLevel'));
                if (!$this->cmLevel)    {
                                // Make 1st level clickmenu:
                        if ($this->isDBmenu)    {
-                               return $this->printDBClickMenu($this->iParts[0],$this->iParts[1]);
+                               $CMcontent = $this->printDBClickMenu($this->iParts[0],$this->iParts[1]);
                        } else {
-                               return $this->printFileClickMenu($this->iParts[0]);
+                               $CMcontent = $this->printFileClickMenu($this->iParts[0]);
                        }
                } else {
                                // Make 2nd level clickmenu (only for DBmenus)
                        if ($this->isDBmenu)    {
-                               return $this->printNewDBLevel($this->iParts[0],$this->iParts[1]);
+                               $CMcontent = $this->printNewDBLevel($this->iParts[0],$this->iParts[1]);
                        }
                }
+               
+                       // Return clickmenu conten:
+               return $CMcontent;
        }
 
-       /** 
+       /**
         * Returns true if the menu should (also?) be displayed in topframe, not just <div>-layers
-        *
-        * @return      boolean
+        * 
+        * @return      boolean         
         */
        function doDisplayTopFrameCM()  {
                return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
@@ -137,12 +216,12 @@ class clickMenu {
         *
         ***************************************/
 
-       /** 
+       /**
         * Make 1st level clickmenu:
-        *
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @return      string  HTML content
+        * 
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @return      string          HTML content
         */
        function printDBClickMenu($table,$uid)  {
                global $TCA, $BE_USER;
@@ -191,7 +270,7 @@ class clickMenu {
                                $selItem = $this->clipObj->getSelectedRecord();
                                $elInfo=array(
                                        $selItem['_RECORD_TITLE'],
-                                       ($root?$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div::fixed_lgd(t3lib_BEfunc::getRecordTitle($table,$this->rec),$GLOBALS['BE_USER']->uc['titleLen'])),
+                                       ($root?$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div::fixed_lgd(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen'])),
                                        $this->clipObj->currentMode()
                                );
                                if ($table=='pages' && ($lCP & 8))      {
@@ -203,7 +282,7 @@ class clickMenu {
                        }
 
                                // Delete:
-                       $elInfo=array(t3lib_div::fixed_lgd(t3lib_BEfunc::getRecordTitle($table,$this->rec),$GLOBALS['BE_USER']->uc['titleLen']));
+                       $elInfo=array(t3lib_div::fixed_lgd(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen']));
                        if(!in_array('delete',$this->disabledItems) && !$root && $BE_USER->isPSet($lCP,$table,'delete'))        {
                                $menuItems[]='spacer';
                                $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
@@ -218,20 +297,18 @@ class clickMenu {
                
                        // Return the printed elements:
                return $this->printItems($menuItems,
-                       $this->wrapColorTable(
-                               $root?
-                               '<img src="'.$this->backPath.'gfx/i/_icon_website.gif" width="18" height="16" hspace="5" border="0" align="absmiddle" alt="" /><strong>'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'</strong>':
-                               t3lib_iconWorks::getIconImage($table,$this->rec,$this->backPath,' hspace="5" align="absmiddle"'.t3lib_BEfunc::titleAttrib(t3lib_BEfunc::getRecordIconAltText($this->rec,$table))).'<strong>'.t3lib_BEfunc::getRecordTitle($table,$this->rec,1).'</strong>'
-                       )
+                       $root?
+                       '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' class="absmiddle" alt="" />'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
+                       t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,1)
                );
        }
 
-       /**  
+       /**
         * Make 2nd level clickmenu (only for DBmenus)
-        *
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @return      string  HTML content
+        * 
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @return      string          HTML content
         */
        function printNewDBLevel($table,$uid)   {
                global $TCA, $BE_USER;
@@ -258,31 +335,29 @@ class clickMenu {
                        // Return the printed elements:
                if (!is_array($menuItems))      $menuItems=array();
                return $this->printItems($menuItems,
-                       $this->wrapColorTable(
-                               $root?
-                               '<img src="'.$this->backPath.'gfx/i/_icon_website.gif" width="18" height="16" hspace=5 border="0" align="absmiddle" alt="" /><strong>'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'</strong>':
-                               t3lib_iconWorks::getIconImage($table,$this->rec,$this->backPath,' hspace="5" align="absmiddle"'.t3lib_BEfunc::titleAttrib(t3lib_BEfunc::getRecordIconAltText($this->rec,$table))).'<strong>'.t3lib_BEfunc::getRecordTitle($table,$this->rec,1).'</strong>'
-                       )
+                       $root?
+                       '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' class="absmiddle" alt="" />'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
+                       t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,1)
                );
        }
 
-       /** 
+       /**
         * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
-        *
-        * @param       array   $menuItems array for manipulation. 
-        * @return      array   Processed $menuItems array 
+        * 
+        * @param       array           $menuItems array for manipulation.
+        * @return      array           Processed $menuItems array
         */
        function externalProcessingOfDBMenuItems($menuItems)    {
                return $menuItems;
        }
 
-       /** 
+       /**
         * Processing the $menuItems array by external classes (typ. adding items)
-        *
-        * @param       array   $menuItems array for manipulation. 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @return      array   Processed $menuItems array 
+        * 
+        * @param       array           $menuItems array for manipulation.
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @return      array           Processed $menuItems array
         */
        function processingByExtClassArray($menuItems,$table,$uid)      {
                if (is_array($this->extClassArray))     {
@@ -295,13 +370,13 @@ class clickMenu {
                return $menuItems;
        }
 
-       /** 
+       /**
         * Returning JavaScript for the onClick event linking to the input URL.
-        *
-        * @param       string  The URL relative to TYPO3_mainDir
-        * @param       string  The return_url-parameter
-        * @param       boolean If set, the "hideCM()" will be called
-        * @return      string  JavaScript for an onClick event.
+        * 
+        * @param       string          The URL relative to TYPO3_mainDir
+        * @param       string          The return_url-parameter
+        * @param       boolean         If set, the "hideCM()" will be called
+        * @return      string          JavaScript for an onClick event.
         */
        function urlRefForCM($url,$retUrl='',$hideCM=1) {
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
@@ -311,13 +386,13 @@ class clickMenu {
                return $editOnClick;
        }
 
-       /** 
+       /**
         * Adding CM element for Clipboard "copy" and "cut"
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @param       string  Type: "copy" or "cut"
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @param       string          Type: "copy" or "cut"
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_copycut($table,$uid,$type)  {
@@ -326,19 +401,20 @@ class clickMenu {
                }       
                return $this->linkItem(
                        $this->label($type),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif" width="12" height="12" border=0 align=top>'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
                        "top.loadTopMenu('".$this->clipObj->selUrlDB($table,$uid,($type=='copy'?1:0),($isSel==$type))."');return false;"
                );
        }
 
-       /** 
+       /**
         * Adding CM element for Clipboard "paste into"/"paste after"
         * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record. NOTICE: Special syntax!
-        * @param       string  Type: "into" or "after"
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record. NOTICE: Special syntax!
+        * @param       string          Type: "into" or "after"
+        * @param       array           Contains instructions about whether to copy or cut an element.
+        * @return      array           Item array, element in $menuItems
         * @see t3lib_clipboard::pasteUrl()
         * @internal
         */
@@ -350,90 +426,90 @@ class clickMenu {
                
                return $this->linkItem(
                        $this->label('paste'.$type),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/clip_paste'.$type.'.gif" width="12" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
                        $editOnClick.'return false;'
                );
        }
 
-       /** 
+       /**
         * Adding CM element for Info
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_info($table,$uid)   {
                return $this->linkItem(
                        $this->label('info'),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/zoom2.gif" width="12" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
                        "top.launchView('".$table."', '".$uid."'); return hideCM();"                    
                );
        }
 
-       /** 
+       /**
         * Adding CM element for History
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_history($table,$uid)        {
                $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
                return $this->linkItem(
                        $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/history2.gif" width="13" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
                        $this->urlRefForCM($url,'returnUrl'),
                        0
                );
        }
 
-       /** 
+       /**
         * Adding CM element for Permission setting
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @param       array   The "pages" record with "perms_*" fields inside.
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @param       array           The "pages" record with "perms_*" fields inside.
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_perms($table,$uid,$rec)     {
                $url = 'mod/web/perm/index.php?id='.$uid.($rec['perms_userid']==$GLOBALS['BE_USER']->user['uid']||$GLOBALS['BE_USER']->isAdmin()?'&return_id='.$uid.'&edit=1':'');
                return $this->linkItem(
                        $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/perm.gif" width="7" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
                        $this->urlRefForCM($url),
                        0
                );
        }
 
-       /** 
+       /**
         * Adding CM element for DBlist
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @param       array   Record of the element (needs "pid" field if not pages-record)
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @param       array           Record of the element (needs "pid" field if not pages-record)
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_db_list($table,$uid,$rec)   {
                $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?'':$table).'&id='.($table=='pages'?$uid:$rec['pid']);
                return $this->linkItem(
                        $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/list.gif" width="11" height="11" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/list.gif','width="11" height="11"').' alt="" />'),
                        "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
                        0
                );
        }
 
-       /** 
+       /**
         * Adding CM element for Moving wizard
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @param       array   Record. Needed for tt-content elements which will have the sys_language_uid sent
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @param       array           Record. Needed for tt-content elements which will have the sys_language_uid sent
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_moveWizard($table,$uid,$rec)        {
@@ -442,37 +518,42 @@ class clickMenu {
                                
                return $this->linkItem(
                        $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?'_page':''))),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/move_'.($table=='pages'?'page':'record').'.gif" width="11" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/move_'.($table=='pages'?'page':'record').'.gif','width="11" height="12"').' alt="" />'),
                        $this->urlRefForCM($url,'returnUrl'),
                        0
                );
        }
 
-       /** 
-        * Adding CM element for Create new wizard (either db_new.php or db_new_content_el.php)
+       /**
+        * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @param       array   Record.
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @param       array           Record.
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_newWizard($table,$uid,$rec) {
-               $url = ($table=='pages') ? 'db_new.php?id='.$uid.'&pagesOnly=1' : 'db_new_content_el.php?id='.$rec['pid'].'&sys_language_uid='.intval($rec['sys_language_uid']);
+                       //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
+               $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
+               $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
+               $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : (TYPO3_mainDir.'sysext/cms/layout/db_new_content_el.php');
+
+               $url = ($table=='pages' || !t3lib_extMgm::isLoaded('cms')) ? 'db_new.php?id='.$uid.'&pagesOnly=1' : $newContentWizScriptPath.'?id='.$rec['pid'].'&sys_language_uid='.intval($rec['sys_language_uid']);
                return $this->linkItem(
                        $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/new_'.($table=='pages'?'page':'record').'.gif" width="'.($table=='pages'?'13':'16').'" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'?'page':'record').'.gif','width="'.($table=='pages'?'13':'16').'" height="12"').' alt="" />'),
                        $this->urlRefForCM($url,'returnUrl'),
                        0
                );
        }
 
-       /** 
+       /**
         * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_editAccess($table,$uid)     {
@@ -480,55 +561,58 @@ class clickMenu {
                $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
                return $this->linkItem(
                        $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/editaccess.gif" width="12" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
                        $this->urlRefForCM($url,'returnUrl'),
                        1       // no top frame CM!
                );
        }
 
-       /** 
+       /**
         * Adding CM element for edit page header
         * 
-        * @param       integer page uid to edit (PID)
-        * @return      array   Item array, element in $menuItems
+        * @param       integer         page uid to edit (PID)
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_editPageHeader($uid)        {
                $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
                return $this->linkItem(
                        $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageHeader')),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/edit2.gif" width="11" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
                        $this->urlRefForCM($url,'returnUrl'),
                        1       // no top frame CM!
                );
        }
 
-       /** 
+       /**
         * Adding CM element for regular editing of the element!
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_edit($table,$uid)   {
                global $BE_USER;
+                       // If another module was specified, replace the default Page module with the new one
+               $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
+               $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
 
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
                $addParam='';
-               $theIcon = 'gfx/edit2.gif" width="11" height="12"';
+               $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"');
                if (
                                $this->iParts[0]=='pages' && 
                                $this->iParts[1] && 
-                               $GLOBALS['BE_USER']->check('modules','web_layout')
+                               $BE_USER->check('modules', $pageModule)
                        )       {
-                       $theIcon = 'gfx/edit_page.gif" width="12" height="12"';
+                       $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit_page.gif','width="12" height="12"');
                        $this->editPageIconSet=1;
                        if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms'))      {
                                $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
                        } else {
-                               $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('web_layout',1);";
+                               $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
                        }
                }
                if (!$editOnClick)      {
@@ -537,17 +621,17 @@ class clickMenu {
                
                return $this->linkItem(
                        $this->label('edit'),
-                       $this->excludeIcon('<img src="'.$this->backPath.$theIcon.' border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.$theIcon.' alt="" />'),
                        $editOnClick.'return hideCM();'
                );
        }
 
-       /** 
+       /**
         * Adding CM element for regular Create new element
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_new($table,$uid)    {
@@ -555,24 +639,24 @@ class clickMenu {
                $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
                $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".
                        ($this->listFrame?
-                               $this->backPath."alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
-                               $this->backPath.'db_new.php?id='.intval($uid)."'").
+                               "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
+                               'db_new.php?id='.intval($uid)."'").
                        ';}';
                        
                return $this->linkItem(
                        $this->label('new'),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/new_'.($table=='pages'&&$this->listFrame?'page':'el').'.gif" width="'.($table=='pages'?'13':'11').'" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'&&$this->listFrame?'page':'el').'.gif','width="'.($table=='pages'?'13':'11').'" height="12"').' alt="" />'),
                        $editOnClick.'return hideCM();'
                );
        }
 
-       /** 
+       /**
         * Adding CM element for hide/unhide of the input record
         * 
-        * @param       string  Table name
-        * @param       array   Record
-        * @param       string  Name of the hide field
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       array           Record array
+        * @param       string          Name of the hide field
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_hideUnhide($table,$rec,$hideField)  {
@@ -584,19 +668,19 @@ class clickMenu {
 
                return $this->linkItem(
                        $this->label(($rec[$hideField]?'un':'').'hide'),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/button_'.($rec[$hideField]?'un':'').'hide.gif" width="11" height="10" vspace="1" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/button_'.($rec[$hideField]?'un':'').'hide.gif','width="11" height="10"').' alt="" />'),
                        $editOnClick.'return false;',
                        1
                );
        }
 
-       /** 
+       /**
         * Adding CM element for Delete
         * 
-        * @param       string  Table name
-        * @param       integer UID for the current record.
-        * @param       array   Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
-        * @return      array   Item array, element in $menuItems
+        * @param       string          Table name
+        * @param       integer         UID for the current record.
+        * @param       array           Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_delete($table,$uid,$elInfo) {
@@ -607,24 +691,24 @@ class clickMenu {
 
                return $this->linkItem(
                        $this->label('delete'),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/garbage.gif" width="11" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
                        $editOnClick.'return false;'
                );
        }
 
-       /** 
+       /**
         * Adding CM element for View Page
         * 
-        * @param       integer Page uid (PID)
-        * @param       string  Anchor, if any
-        * @return      array   Item array, element in $menuItems
+        * @param       integer         Page uid (PID)
+        * @param       string          Anchor, if any
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function DB_view($id,$anchor='')        {
                return $this->linkItem(
                        $this->label('view'),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/zoom.gif" width="12" height="12" border="0" align="top" alt="" />'),
-                       t3lib_BEfunc::viewOnClick($id,$this->backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
+                       t3lib_BEfunc::viewOnClick($id,$this->PH_backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
                );
        }
 
@@ -643,11 +727,11 @@ class clickMenu {
         *
         ***************************************/
 
-       /** 
+       /**
         * Make 1st level clickmenu:
-        *
-        * @param       string  The absolute path
-        * @return      string  HTML content
+        * 
+        * @param       string          The absolute path
+        * @return      string          HTML content
         */
        function printFileClickMenu($path)      {
                $menuItems=array();
@@ -656,7 +740,7 @@ class clickMenu {
                        $fI = pathinfo($path);
                        $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
                        $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
-                       $icon = '<img src="gfx/fileicons/'.$icon.'" width="18" height="16" border="0" hspace="5"'.t3lib_BEfunc::titleAttrib($fI['basename'].$size,1).' align="absmiddle" alt="" />';
+                       $icon = '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
 
                                // edit
                        if (!in_array('edit',$this->disabledItems) && is_file($path) && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'],$fI['extension'])) $menuItems['edit']=$this->FILE_launch($path,'file_edit.php','edit','edit_file.gif');
@@ -703,32 +787,28 @@ class clickMenu {
                $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
 
                        // Return the printed elements:
-               return $this->printItems($menuItems,
-                       $this->wrapColorTable(
-                               $icon.'<strong>'.basename($path).'</strong>'
-                       )
-               );
+               return $this->printItems($menuItems,$icon.basename($path));
        }
 
 
-       /** 
+       /**
         * Processing the $menuItems array (for extension classes) (FILES)
-        *
-        * @param       array   $menuItems array for manipulation. 
-        * @return      array   Processed $menuItems array 
+        * 
+        * @param       array           $menuItems array for manipulation.
+        * @return      array           Processed $menuItems array
         */
        function externalProcessingOfFileMenuItems($menuItems)  {
                return $menuItems;
        }
 
-       /** 
+       /**
         * Multi-function for adding an entry to the $menuItems array
-        *
-        * @param       string  Path to the file/directory (target)
-        * @param       string  Script (eg. file_edit.php) to pass &target= to
-        * @param       string  "type" is the code which fetches the correct label for the element from "cm."
-        * @param       string  icon image-filename from "gfx/" (12x12 icon)
-        * @return      array   Item array, element in $menuItems
+        * 
+        * @param       string          Path to the file/directory (target)
+        * @param       string          Script (eg. file_edit.php) to pass &target= to
+        * @param       string          "type" is the code which fetches the correct label for the element from "cm."
+        * @param       string          icon image-filename from "gfx/" (12x12 icon)
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function FILE_launch($path,$script,$type,$image)        {
@@ -737,17 +817,17 @@ class clickMenu {
                
                return $this->linkItem(
                        $this->label($type),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/'.$image.'" width="12" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
                        $editOnClick.'return hideCM();'
                );
        }
 
-       /** 
+       /**
         * Returns element for copy or cut of files.
-        *
-        * @param       string  Path to the file/directory (target)
-        * @param       string  Type: "copy" or "cut"
-        * @return      array   Item array, element in $menuItems
+        * 
+        * @param       string          Path to the file/directory (target)
+        * @param       string          Type: "copy" or "cut"
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function FILE_copycut($path,$type)      {
@@ -758,16 +838,16 @@ class clickMenu {
                }       
                return $this->linkItem(
                        $this->label($type),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif" width="12" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
                        "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type))."');return false;"
                );
        }
 
-       /** 
+       /**
         * Creates element for deleting of target
-        *
-        * @param       string  Path to the file/directory (target)
-        * @return      array   Item array, element in $menuItems
+        * 
+        * @param       string          Path to the file/directory (target)
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function FILE_delete($path)     {
@@ -778,30 +858,30 @@ class clickMenu {
                
                return $this->linkItem(
                        $this->label('delete'),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/garbage.gif" width="11" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
                        $editOnClick.'return false;'
                );
        }
 
-       /** 
+       /**
         * Creates element for pasting files.
-        *
-        * @param       string  Path to the file/directory (target)
-        * @param       string  target - NOT USED.
-        * @param       array   Various values for the labels.
-        * @return      array   Item array, element in $menuItems
+        * 
+        * @param       string          Path to the file/directory (target)
+        * @param       string          target - NOT USED.
+        * @param       array           Various values for the labels.
+        * @return      array           Item array, element in $menuItems
         * @internal
         */
        function FILE_paste($path,$target,$elInfo)      {       
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-               $conf=$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess'.($elInfo[2]=='copy'?'copy':'move').'_into'),$elInfo[0],$elInfo[1])).")";
+               $conf=$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.($elInfo[2]=='copy'?'copy':'move').'_into'),$elInfo[0],$elInfo[1])).")";
                $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
                        "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
                
                return $this->linkItem(
                        $this->label('pasteinto'),
-                       $this->excludeIcon('<img src="'.$this->backPath.'gfx/clip_pasteinto.gif" width="12" height="12" border="0" align="top" alt="" />'),
+                       $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
                        $editOnClick.'return false;'
                );
        }
@@ -824,31 +904,45 @@ class clickMenu {
         *
         **************************************/
 
-       /** 
+       /**
         * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers. 
         * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
-        *
-        * @param       array   $menuItems array
-        * @param       string  HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
-        * @return      string  HTML code
+        * 
+        * @param       array           $menuItems array
+        * @param       string          HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
+        * @return      string          HTML code
         */
        function printItems($menuItems,$item)   {
                $out='';
 
                        // Adding topframe part (horizontal clickmenu)
                if ($this->doDisplayTopFrameCM())       {
-                       $out.= '<img src="clear.gif" width="1" height="10" alt="" /><br />
-                       <table border="0" cellpadding="0" cellspacing="0">
-                               <tr>
-                                       <td nowrap="nowrap" valign="top">'.
-                                               implode('</td><td valign="top"><img src="gfx/acm_spacer2.gif" width="8" height="12" alt="" /></td><td nowrap="nowrap" valign="top">',$this->menuItemsForTopFrame($menuItems)).
-                                       '</td>
-                                       <td><img src="clear.gif" width="10" height="1" alt="" /></td>
-                                       <td nowrap="nowrap" valign="top"><a href="#" onclick="hideCM();return false;"><img src="gfx/close_12h.gif" width="11" height="12" vspace="2" hspace="5" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close'),1).' alt="" /></a></td>
-                                       <td>'.$item.'</td>
-                               </tr>
-                       </table>
-                       <br /><br />';
+                       $out.= '
+                       
+                               <!--
+                                       Table, which contains the click menu when shown in the top frame of the backend:
+                               -->
+                               <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
+                                       <tr>
+                                                       
+                                                       <!-- Items: -->
+                                               <td class="c-item">'.
+                                                       implode('</td>
+                                               <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
+                                               <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
+                                               '</td>
+                                               
+                                                       <!-- Close button: -->
+                                               <td class="c-closebutton"><a href="#" onclick="hideCM();return false;"><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/close_12h.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close',1).'" alt="" /></a></td>
+                                               
+                                                       <!-- The item of the clickmenu: -->
+                                               <td class="c-itemicon">'.$item.'</td>
+                                       </tr>
+                               </table>
+                       ';
+               
+                               // Set remaining BACK_PATH to blank (if any)
+                       $out = str_replace($this->PH_backPath,'',$out);
                }
                        // Adding JS part:
                $out.=$this->printLayerJScode($menuItems);
@@ -857,11 +951,11 @@ class clickMenu {
                return $out;
        }
 
-       /** 
+       /**
         * Create the JavaScript section
         * 
-        * @param       array   The $menuItems array to print
-        * @return      string  The JavaScript section which will print the content of the CM to the div-layer in the target frame.
+        * @param       array           The $menuItems array to print
+        * @return      string          The JavaScript section which will print the content of the CM to the div-layer in the target frame.
         */
        function printLayerJScode($menuItems)   {
                $script='';
@@ -870,13 +964,17 @@ class clickMenu {
                        if ($this->alwaysContentFrame)  $frameName='';
 
                                // Create the table displayed in the clickmenu layer:                   
-                       $CMtable = '<table border="0" cellpadding="0" cellspacing="0" bgcolor="'.$GLOBALS['TBE_TEMPLATE']->bgColor4.'">'.
-                                               implode('',$this->menuItemsForClickMenu($menuItems)).
-                                               '</table>';
+                       $CMtable = '
+                               <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
+                                       '.implode('',$this->menuItemsForClickMenu($menuItems)).'
+                               </table>';
 
                                // Wrap the inner table in another table to create outer border:
                        $CMtable = $this->wrapColorTableCM($CMtable);
                                
+                               // Set back path place holder to real back path
+                       $CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
+
                                // Create JavaScript section:
                        $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
                        
@@ -890,40 +988,35 @@ if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLay
                return $script;
        }
 
-       /** 
+       /**
         * Wrapping the input string in a table with background color 4 and a black border style.
-        *
-        * @param       string  
-        * @return      string
+        * For the pop-up menu
+        * 
+        * @param       string          HTML content to wrap in table.
+        * @return      string          
         */
        function wrapColorTableCM($str) {
-               $str = '<table border="0" cellpadding="1" cellspacing="0" bgcolor="'.$GLOBALS['TBE_TEMPLATE']->bgColor4.'" style="border: solid 1px black;">
-                       <tr><td>'.$str.'</td></tr>
-               </table>';
+       
+                       // Clear-gifs needed if opera is to set the table row height correctly in skins.
+               $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
+                               <tr class="c-rowA">
+                                       <td class="c-aa">'.$str.'</td>
+                                       <td class="c-ab"></td>
+                               </tr>
+                               <tr class="c-rowB">
+                                       <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
+                                       <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
+                               </tr>
+                       </table>';
                return $str;
        }
 
-
-       /** 
-        * Wrapping the input string in a table with background color 2 and a black border style.
-        *
-        * @param       string  
-        * @return      string
-        */
-       function wrapColorTable($str)   {
-               return '<table border="0" cellpadding="0" cellspacing="0" bgcolor="'.$GLOBALS['TBE_TEMPLATE']->bgColor2.'" style="border: solid 1px black;">
-                       <tr>
-                               <td>'.$str.'</td>
-                               <td><img src=clear.gif width=10 height=1></td>
-                       </tr>
-               </table>';
-       }
-
-       /** 
+       /**
         * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
-        *
-        * @param       array   $menuItem array
-        * @param       array   Array with HTML content to be imploded between <td>-tags
+        * 
+        * @param       array           $menuItem array
+        * @param       array           Array with HTML content to be imploded between <td>-tags
+        * @return      array           Array of menu items for top frame.
         */
        function menuItemsForTopFrame($menuItems)       {
                reset($menuItems);
@@ -935,19 +1028,21 @@ if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLay
                return $out;
        }
 
-       /** 
+       /**
         * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
-        *
-        * @param       array   $menuItem array
-        * @param       array   Array with HTML content to be imploded between <td>-tags
+        * 
+        * @param       array           $menuItem array
+        * @param       array           Array with HTML content to be imploded between <td>-tags
+        * @return      array           array for implosion in the CM div-layers table.
         */
        function menuItemsForClickMenu($menuItems)      {
                reset($menuItems);
                $out=array();
                while(list($cc,$i)=each($menuItems))    {
                        if (is_string($i) && $i=='spacer')      {       // MAKE horizontal spacer
-                               $out[]='<tr style="background:'.$GLOBALS['TBE_TEMPLATE']->bgColor2.'">
-                                       <td colspan="4"><img src="clear.gif" width="1" height="1" alt="" /></td>
+                               $out[]='
+                                       <tr class="bgColor2">
+                                               <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
                                        </tr>';
                        } else {        // Just make normal element:
                                $onClick=$i[3];
@@ -956,37 +1051,32 @@ if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLay
                                $onClick=eregi_replace('hideCM\(\);','',$onClick);
                                if (!$i[5])     $onClick.='hideEmpty();';
                                
-                               $out[]='<tr onclick="'.htmlspecialchars($onClick).'" style="cursor:hand;" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';">'.
-                                       (!$this->leftIcons?'
-                                       <td nowrap="nowrap">&nbsp;'.$i[1].'</td>
-                                       <td><img src="clear.gif" width="20" height="14" alt="" /></td>
-                                       <td align="center">'.$i[2].'</td>
-                                       <td>&nbsp;</td>'
-                                               :
-                                       '<td><img src="clear.gif" width="2" height="14" alt="" /></td>
-                                       <td align="center">'.$i[2].'</td>
-                                       <td nowrap="nowrap">&nbsp;'.$i[1].'</td>
-                                       <td>&nbsp;</td>').
-                               '</tr>';
+                               $out[]='
+                                       <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';">
+                                               '.(!$this->leftIcons?'<td class="typo3-CSM-item">'.$i[1].'</td><td align="center">'.$i[2].'</td>' : '<td align="center">'.$i[2].'</td><td class="typo3-CSM-item">'.$i[1].'</td>').'
+                                       </tr>';
                        }
                }
                return $out;
        }
 
-       /** 
+       /**
         * Creating an array with various elements for the clickmenu entry
-        *
-        * @param       string  The label, htmlspecialchar'ed already
-        * @param       string  <img>-tag for the icon
-        * @param       string  JavaScript onclick event for label/icon
-        * @param       boolean ==1 and the element will NOT appear in clickmenus in the topframe (unless clickmenu is totally unavailable)! ==2 and the item will NEVER appear in top frame. (This is mostly for "less important" options since the top frame is not capable of holding so many elements horizontally)
-        * @param       boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
-        * @return      array   $menuItem entry with 6 numerical entries: [0] is the HTML for display of the element with link and icon an mouseover etc., [1]-[5] is simply the input params passed through!
+        * 
+        * @param       string          The label, htmlspecialchar'ed already
+        * @param       string          <img>-tag for the icon
+        * @param       string          JavaScript onclick event for label/icon
+        * @param       boolean         ==1 and the element will NOT appear in clickmenus in the topframe (unless clickmenu is totally unavailable)! ==2 and the item will NEVER appear in top frame. (This is mostly for "less important" options since the top frame is not capable of holding so many elements horizontally)
+        * @param       boolean         If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
+        * @return      array           $menuItem entry with 6 numerical entries: [0] is the HTML for display of the element with link and icon an mouseover etc., [1]-[5] is simply the input params passed through!
         */
        function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)    {
                $this->elCount++;
+               
+               $WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
+               
                return array(
-                       '<img src="clear.gif" width="7" height="10" align="top" hspace="1" name="roimg_'.$this->elCount.'" alt="" />'.
+                       '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount.'" alt="" />'.
                                '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
                                $str.$icon.
                                '</a>',
@@ -998,40 +1088,40 @@ if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLay
                );
        }
 
-       /** 
+       /**
         * Returns the input string IF not a user setting has disabled display of icons.
-        *
-        * @param       string  The icon-image tag
-        * @return string       The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
+        * 
+        * @param       string          The icon-image tag
+        * @return      string          The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
         */
        function excludeIcon($iconCode) {
                return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'],'icons')) ? '' : ' '.$iconCode;
        }
 
-       /** 
+       /**
         * Get label from locallang_core.php:cm.*
-        *
-        * @param       string  The "cm."-suffix to get.
-        * @return      string
+        * 
+        * @param       string          The "cm."-suffix to get.
+        * @return      string          
         */
        function label($label)  {
                return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
        }
 
-       /** 
+       /**
         * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
-        *
-        * @return      boolean 
+        * 
+        * @return      boolean         
         */
        function isCMlayers()   {
-               return $GLOBALS['SOBE']->doc->isCMlayers() && !t3lib_div::GPvar('CB');
+               return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
        }
 
-       /** 
+       /**
         * Appends ".location" to input string
-        *
-        * @param       string
-        * @return      string
+        * 
+        * @param       string          Input string, probably a JavaScript document reference
+        * @return      string          
         */
        function frameLocation($str)    {
                return $str.'.location';
@@ -1050,32 +1140,56 @@ if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLay
 
 
 
-/** 
- * Main Script Class
+/**
+ * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
+ * 
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage core
+ * @see template::getContextMenuCode()
  */
 class SC_alt_clickmenu {
+       
+               // Internal, static: GPvar:
+       var $backPath;                                  // Back path.
+       var $item;                                              // Definition of which item the click menu should be made for.
+
+               // Internal:
        var $content='';                                // Content accumulation
        var $doc;                                               // Template object 
        var $include_once=array();              // Files to include_once() - set in init() function
        var $extClassArray=array();             // Internal array of classes for extending the clickmenu
        var $dontDisplayTopFrameCM=0;   // If set, then the clickmenu will NOT display in the top frame.
 
-       /** 
-        * Constructor:
+       /**
+        * Constructor function for script class.
+        * 
+        * @return      void            
         */
        function init() {
                global $BE_USER,$BACK_PATH;
+               
+                       // Setting GPvars:
+               $this->backPath = t3lib_div::_GP('backPath');
+               $this->item = t3lib_div::_GP('item');
 
                        // Setting pseudo module name
                $this->MCONF['name']='xMOD_alt_clickmenu.php';
+
+                       // Takes the backPath as a parameter BUT since we are worried about someone forging a backPath (XSS security hole) we will check with sent md5 hash:
+               $inputBP = explode('|',$this->backPath);
+               if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
+                       $this->backPath = $inputBP[0];
+               } else {
+                       $this->backPath = $BACK_PATH;
+               }
                
                        // Setting internal array of classes for extending the clickmenu:
                $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
 
                        // Traversing that array and setting files for inclusion:
                if (is_array($this->extClassArray))     {
-                       reset($this->extClassArray);
-                       while(list(,$extClassConf)=each($this->extClassArray))  {
+                       foreach($this->extClassArray as $extClassConf)  {
                                if ($extClassConf['path'])      $this->include_once[]=$extClassConf['path'];
                        }
                }
@@ -1083,13 +1197,12 @@ class SC_alt_clickmenu {
                        // Initialize template object
                $this->doc = t3lib_div::makeInstance('template');
                $this->doc->docType='xhtml_trans';
-               $this->doc->inDocStyles = 'BODY {background-color: '.$this->doc->bgColor2.'; background-image: url(gfx/alt_topmenu_back_full.gif)}';
                $this->doc->backPath = $BACK_PATH;
                
                        // Setting mode for display and background image in the top frame
-               $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
+               $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
                if ($this->dontDisplayTopFrameCM)       {
-                       $this->doc->inDocStyles = 'BODY {background-color: '.$this->doc->bgColor2.'; background-image: url(gfx/alt_topmenu_back_dummy.gif)}';
+                       $this->doc->bodyTagId.= '-notop';
                }
 
                        // Setting clickmenu timeout            
@@ -1101,27 +1214,26 @@ class SC_alt_clickmenu {
        var mo_timeout = Math.floor(date.getTime()/1000);
 
        roImg =new Image(); 
-       roImg.src = "gfx/content_client.gif";
+       roImg.src = "'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
 
        routImg =new Image(); 
        routImg.src = "clear.gif";
 
-       function mo(c)  {
+       function mo(c)  {       //
                var name="roimg_"+c;
                document[name].src = roImg.src;
                updateTime();
        }
-       function mout(c)        {
+       function mout(c)        {       //
                var name="roimg_"+c;
                document[name].src = routImg.src;
                updateTime();
        }
-       function updateTime()   {
+       function updateTime()   {       //
                date = new Date();
                mo_timeout = Math.floor(date.getTime()/1000);
        }       
-       
-       function timeout_func() {
+       function timeout_func() {       //
                date = new Date();
                if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.')     {
                        hideCM();
@@ -1130,7 +1242,7 @@ class SC_alt_clickmenu {
                        window.setTimeout("timeout_func();",1*1000);
                }
        }
-       function hideCM()       {
+       function hideCM()       {       //
                document.location="alt_topmenu_dummy.php";
                return false;
        }
@@ -1140,11 +1252,12 @@ class SC_alt_clickmenu {
                ');
        }
 
-       /** 
+       /**
         * Main function - generating the click menu in whatever form it has.
+        * 
+        * @return      void            
         */
        function main() {
-               global $HTTP_GET_VARS;
 
                        // Initialize Clipboard object:
                $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
@@ -1152,7 +1265,8 @@ class SC_alt_clickmenu {
                $clipObj->lockToNormal();       // This locks the clipboard to the Normal for this request.
                
                        // Update clipboard if some actions are sent.
-               $CB = $HTTP_GET_VARS['CB'];
+               $CB = t3lib_div::_GET('CB');
+               
                $clipObj->setCmd($CB);
                $clipObj->cleanCurrent();
                $clipObj->endClipboard();       // Saves
@@ -1164,22 +1278,19 @@ class SC_alt_clickmenu {
                $clickMenu->clipObj = $clipObj;
                $clickMenu->extClassArray = $this->extClassArray;
                $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
-               
-                       // Takes the backPath as a parameter BUT since we are worried about someone forging a backPath (XSS security hole) we will check with sent md5 hash:
-               $inputBP = explode('|',t3lib_div::GPvar('backPath'));
-               if (count($inputBP)==2 && $inputBP[1]==md5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
-                       $clickMenu->backPath = $inputBP[0];
-               }
+               $clickMenu->backPath = $this->backPath;
 
                        // Start page 
                $this->content.=$this->doc->startPage('Context Sensitive Menu');
                
                        // Set content of the clickmenu with the incoming var, "item"
-               $this->content.= $clickMenu->init(t3lib_div::GPvar('item'));
+               $this->content.= $clickMenu->init($this->item);
        }
 
-       /** 
+       /**
         * End page and output content.
+        * 
+        * @return      void            
         */
        function printContent() {
                $this->content.= $this->doc->endPage();
@@ -1206,10 +1317,8 @@ $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
 $SOBE->init();
 
 // Include files?
-reset($SOBE->include_once);    
-while(list(,$INC_FILE)=each($SOBE->include_once))      {include_once($INC_FILE);}
+foreach($SOBE->include_once as $INC_FILE)      include_once($INC_FILE);
 
 $SOBE->main();
 $SOBE->printContent();
-
 ?>
\ No newline at end of file