[TASK] Remove old login labels
[Packages/TYPO3.CMS.git] / typo3 / view_help.php
old mode 100755 (executable)
new mode 100644 (file)
index b8834f0..777cb57
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * Document for viewing the online help texts, also known as TCA_DESCR.
  * See Inside TYPO3 for details.
  *
- * $Id$
- * Revised for TYPO3 3.7 5/2004 by Kasper Skaarhoj
+ * Revised for TYPO3 3.7 5/2004 by Kasper Skårhøj
  * XHTML-trans compliant
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- *   82: class local_t3lib_parsehtml extends t3lib_parsehtml
- *   93:     function processContent($value,$dir,$conf)
- *
- *
- *  114: class SC_view_help
- *  138:     function init()
- *  159:     function main()
- *  190:     function printContent()
- *
- *              SECTION: Rendering main modes
- *  213:     function render_TOC()
- *  330:     function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)
- *  362:     function render_TOC_makeTocList($tocArray)
- *  401:     function render_Table($table)
- *  461:     function render_Single($table,$field)
- *
- *              SECTION: Rendering CSH items
- *  507:     function make_seeAlso($value,$anchorTable='')
- *  556:     function printImage($images,$descr)
- *  591:     function headerLine($str,$type=0)
- *  612:     function prepareContent($str)
- *  627:     function printItem($table,$field,$anchors=0)
- *  660:     function getTableFieldNames($table,$field)
- *  683:     function getTableFieldLabel($table,$field='',$mergeToken=': ')
- *  702:     function createGlossaryIndex()
- *  738:     function substituteGlossaryWords($code)
- *  776:     function substituteGlossaryWords($code)
- *
- * TOTAL FUNCTIONS: 19
- * (This index is automatically created/updated by the extension "extdeveval")
- *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 
 require('init.php');
 require('template.php');
-$LANG->includeLLFile('EXT:lang/locallang_view_help.xml');
-require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
-require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
+$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_view_help.xml');
 
 
 /**
  * Extension of the parse_html class.
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -113,7 +73,7 @@ class local_t3lib_parsehtml extends t3lib_parsehtml {
 /**
  * Script Class for rendering the Context Sensitive Help documents, either the single display in the small pop-up window or the full-table view in the larger window.
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -121,12 +81,20 @@ class SC_view_help {
        var $allowedHTML = '<strong><em><b><i>';
 
                // For these vars, see init()
-       var $limitAccess;       // If set access to fields and tables is checked. Should be done for true database tables.
+       var $limitAccess;       // If set access to fields and tables is checked. Should be done for TRUE database tables.
        var $table;                     // The "table" key
        var $field;                     // The "field" key
+               /**
+                * Key used to point to the right CSH resource
+                * In simple cases, is equal to $table
+                *
+                * @var string
+                */
+       protected $mainKey;
 
                // Internal, static: GPvar:
        var $tfID;                      // Table/FIeld id.
+       var $ffID;                      // Flexform file/field information
        var $back;                      // Back (previous tfID)
        var $renderALL;         // If set, then in TOC mode the FULL manual will be printed as well!
 
@@ -142,19 +110,54 @@ class SC_view_help {
         * @return      void
         */
        function init() {
-               global $LANG, $TCA;
 
                        // Setting GPvars:
                $this->tfID = t3lib_div::_GP('tfID');
+                       // Sanitizes the tfID using whitelisting.
+               if (!preg_match('/^[a-zA-Z0-9_\-\.\*]*$/', $this->tfID)) {
+                       $this->tfID = '';
+               }
+               if (!$this->tfID) {
+                       if (($this->ffID = t3lib_div::_GP('ffID'))) {
+                               $this->ffID = unserialize(base64_decode($this->ffID));
+                       }
+               }
                $this->back = t3lib_div::_GP('back');
                $this->renderALL = t3lib_div::_GP('renderALL');
 
                        // Set internal table/field to the parts of "tfID" incoming var.
-               list($this->table,$this->field) = explode('.',$this->tfID);
+               $identifierParts = explode('.', $this->tfID);
+                       // The table is the first item
+               $this->table = array_shift($identifierParts);
+               $this->mainKey = $this->table;
+                       // The field is the second one
+               $this->field = array_shift($identifierParts);
+                       // There may be extra parts for FlexForms
+               if (count($identifierParts) > 0) {
+                               // There's at least one extra part
+                       $extraIdentifierInformation = array();
+                       $extraIdentifierInformation[] = array_shift($identifierParts);
+                               // Load the TCA details of the table
+                       t3lib_div::loadTCA($this->table);
+                               // If the ds_pointerField contains a comma, it means the choice of FlexForm DS
+                               // is determined by 2 parameters. In this case we have an extra identifier part
+                       if (strpos($GLOBALS['TCA'][$this->table]['columns'][$this->field]['config']['ds_pointerField'], ',') !== FALSE) {
+                               $extraIdentifierInformation[] = array_shift($identifierParts);
+                       }
+                               // The remaining parts make up the FlexForm field name itself
+                               // (reassembled with dots)
+                       $flexFormField = implode('.', $identifierParts);
+                               // Assemble a different main key and switch field to use FlexForm field name
+                       $this->mainKey .= '.' . $this->field;
+                       foreach ($extraIdentifierInformation as $extraKey) {
+                               $this->mainKey .= '.' . $extraKey;
+                       }
+                       $this->field = $flexFormField;
+               }
 
                        // limitAccess is checked if the $this->table really IS a table (and if the user is NOT a translator who should see all!)
                $showAllToUser = t3lib_BEfunc::isModuleSetInTBE_MODULES('txllxmltranslateM1') && $GLOBALS['BE_USER']->check('modules','txllxmltranslateM1');
-               $this->limitAccess = isset($TCA[$this->table]) ? !$showAllToUser : FALSE;
+               $this->limitAccess = isset($GLOBALS['TCA'][$this->table]) ? !$showAllToUser : FALSE;
        }
 
        /**
@@ -163,29 +166,35 @@ class SC_view_help {
         * @return      void
         */
        function main() {
-               global $BE_USER,$LANG,$TCA_DESCR,$TCA,$TBE_TEMPLATE;
 
                        // Start HTML output accumulation:
-               $TBE_TEMPLATE->docType = 'xhtml_trans';
-               $TBE_TEMPLATE->divClass = 'typo3-view-help';
-               $this->content.= $TBE_TEMPLATE->startPage($LANG->getLL('title'));
+               $GLOBALS['TBE_TEMPLATE']->divClass = 'typo3-view-help';
+               $this->content .= $GLOBALS['TBE_TEMPLATE']->startPage($GLOBALS['LANG']->getLL('title'));
 
-               if ($this->field=='*')  { // If ALL fields is supposed to be shown:
+               if ($this->field == '*') {
+                                // If ALL fields is supposed to be shown:
                        $this->createGlossaryIndex();
-                       $this->content.= $this->render_Table($this->table);
-               } elseif ($this->tfID) { // ... otherwise show only single field:
+                       $this->content .= $this->render_Table($this->mainKey);
+
+               } elseif ($this->tfID) {
+                                // ... otherwise show only single field:
                        $this->createGlossaryIndex();
-                       $this->content.= $this->render_Single($this->table,$this->field);
-               } else {        // Render Table Of Contents if nothing else:
+                       $this->content .= $this->render_Single($this->mainKey, $this->field);
+
+               } elseif (is_array($this->ffID)) {
+                       $this->content .= $this->render_Single($this->mainKey, $this->field);
+
+               } else {
+                               // Render Table Of Contents if nothing else:
                        $this->content.= $this->render_TOC();
                }
 
                        // Print close-button:
-#              $this->content.='<br /><form action=""><input type="submit" value="'.htmlspecialchars($LANG->getLL('close')).'" onclick="self.close(); return false;" /></form><br/>';
+#              $this->content.='<br /><form action=""><input type="submit" value="'.htmlspecialchars($GLOBALS['LANG']->getLL('close')).'" onclick="self.close(); return false;" /></form><br/>';
 
                        // End page:
                $this->content.= '<br/>';
-               $this->content.= $TBE_TEMPLATE->endPage();
+               $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
        }
 
        /**
@@ -217,27 +226,25 @@ class SC_view_help {
         * @return      string          HTML content
         */
        function render_TOC()   {
-               global $TCA_DESCR,$TCA,$LANG,$BE_USER,$TBE_MODULES;
-
                        // Initialize:
-               $CSHkeys = array_flip(array_keys($TCA_DESCR));
-               $TCAkeys = array_keys($TCA);
+               $CSHkeys = array_flip(array_keys($GLOBALS['TCA_DESCR']));
+               $TCAkeys = array_keys($GLOBALS['TCA']);
 
                $outputSections = array();
                $tocArray = array();
 
 
                        // TYPO3 Core Features:
-               $LANG->loadSingleTableDescription('xMOD_csh_corebe');
+               $GLOBALS['LANG']->loadSingleTableDescription('xMOD_csh_corebe');
                $this->render_TOC_el('xMOD_csh_corebe', 'core', $outputSections, $tocArray, $CSHkeys);
 
                        // Backend Modules:
                $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
-               $loadModules->load($TBE_MODULES);
+               $loadModules->load($GLOBALS['TBE_MODULES']);
                foreach($loadModules->modules as $mainMod => $info)     {
                        $cshKey = '_MOD_'.$mainMod;
                        if ($CSHkeys[$cshKey])  {
-                               $LANG->loadSingleTableDescription($cshKey);
+                               $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
                                $this->render_TOC_el($cshKey, 'modules', $outputSections, $tocArray, $CSHkeys);
                        }
 
@@ -245,7 +252,7 @@ class SC_view_help {
                                foreach($info['sub'] as $subMod => $subInfo)    {
                                        $cshKey = '_MOD_'.$mainMod.'_'.$subMod;
                                        if ($CSHkeys[$cshKey])  {
-                                               $LANG->loadSingleTableDescription($cshKey);
+                                               $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
                                                $this->render_TOC_el($cshKey, 'modules', $outputSections, $tocArray, $CSHkeys);
                                        }
                                }
@@ -255,32 +262,32 @@ class SC_view_help {
                        // Database Tables:
                foreach($TCAkeys as $table)     {
                                // Load descriptions for table $table
-                       $LANG->loadSingleTableDescription($table);
-                       if (is_array($TCA_DESCR[$table]['columns']) && $BE_USER->check('tables_select',$table)) {
+                       $GLOBALS['LANG']->loadSingleTableDescription($table);
+                       if (is_array($GLOBALS['TCA_DESCR'][$table]['columns']) && $GLOBALS['BE_USER']->check('tables_select',$table)) {
                                $this->render_TOC_el($table, 'tables', $outputSections, $tocArray, $CSHkeys);
                        }
                }
 
                        // Extensions
                foreach($CSHkeys as $cshKey => $value)  {
-                       if (t3lib_div::isFirstPartOfStr($cshKey, 'xEXT_') && !isset($TCA[$cshKey]))     {
-                               $LANG->loadSingleTableDescription($cshKey);
+                       if (t3lib_div::isFirstPartOfStr($cshKey, 'xEXT_') && !isset($GLOBALS['TCA'][$cshKey])) {
+                               $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
                                $this->render_TOC_el($cshKey, 'extensions', $outputSections, $tocArray, $CSHkeys);
                        }
                }
 
                        // Glossary
                foreach($CSHkeys as $cshKey => $value)  {
-                       if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($TCA[$cshKey]))        {
-                               $LANG->loadSingleTableDescription($cshKey);
+                       if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($GLOBALS['TCA'][$cshKey])) {
+                               $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
                                $this->render_TOC_el($cshKey, 'glossary', $outputSections, $tocArray, $CSHkeys);
                        }
                }
 
                        // Other:
                foreach($CSHkeys as $cshKey => $value)  {
-                       if (!t3lib_div::isFirstPartOfStr($cshKey, '_MOD_') && !isset($TCA[$cshKey]))    {
-                               $LANG->loadSingleTableDescription($cshKey);
+                       if (!t3lib_div::isFirstPartOfStr($cshKey, '_MOD_') && !isset($GLOBALS['TCA'][$cshKey])) {
+                               $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
                                $this->render_TOC_el($cshKey, 'other', $outputSections, $tocArray, $CSHkeys);
                        }
                }
@@ -290,29 +297,28 @@ class SC_view_help {
                $output = '';
                $output.= '
 
-                       <h1>'.$LANG->getLL('manual_title',1).'</h1>
-                       <p>'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';
+                       <h1>'.$GLOBALS['LANG']->getLL('manual_title',1).'</h1>';
 
                $output.= '
 
-                       <h1>'.$LANG->getLL('introduction',1).'</h1>
-                       <p>'.$LANG->getLL('description',1).'</p>';
+                       <h2>'.$GLOBALS['LANG']->getLL('introduction',1).'</h2>
+                       <p>'.$GLOBALS['LANG']->getLL('description',1).'</p>';
 
                $output.= '
 
-                       <h1>'.$LANG->getLL('TOC',1).'</h1>'.
+                       <h2>'.$GLOBALS['LANG']->getLL('TOC',1).'</h2>'.
                        $this->render_TOC_makeTocList($tocArray);
 
                if (!$this->renderALL)  {
-               $output.= '
+                       $output.= '
                                <br/>
-                               <p class="c-nav"><a href="view_help.php?renderALL=1">'.$LANG->getLL('full_manual',1).'</a></p>';
+                               <p class="c-nav"><a href="view_help.php?renderALL=1">'.$GLOBALS['LANG']->getLL('full_manual',1).'</a></p>';
                }
 
                if ($this->renderALL)   {
                        $output.= '
 
-                               <h1>'.$LANG->getLL('full_manual_chapters',1).'</h1>'.
+                               <h2>'.$GLOBALS['LANG']->getLL('full_manual_chapters',1).'</h2>'.
                                implode('
 
 
@@ -320,6 +326,8 @@ class SC_view_help {
                                ',$outputSections);
                }
 
+               $output .= '<hr /><p class="manual-title">'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';
+
                return $output;
        }
 
@@ -334,8 +342,6 @@ class SC_view_help {
         * @return      void
         */
        function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)        {
-               global $LANG;
-
                if ($this->renderALL)   {       // Render full manual right here!
                        $outputSections[$table] = $this->render_Table($table);
 
@@ -343,7 +349,7 @@ class SC_view_help {
                                $outputSections[$table] = '
 
                <!-- New CSHkey/Table: '.$table.' -->
-               <p class="c-nav"><a name="ANCHOR_'.$table.'" href="#">'.$LANG->getLL('to_top',1).'</a></p>
+               <p class="c-nav"><a name="ANCHOR_'.$table.'" href="#">'.$GLOBALS['LANG']->getLL('to_top',1).'</a></p>
                <h2>'.$this->getTableFieldLabel($table).'</h2>
 
                '.$outputSections[$table];
@@ -366,8 +372,6 @@ class SC_view_help {
         * @return      string          HTML bullet list for index.
         */
        function render_TOC_makeTocList($tocArray)      {
-               global $LANG;
-
                        // The Various manual sections:
                $keys = explode(',', 'core,modules,tables,extensions,glossary,other');
 
@@ -376,7 +380,7 @@ class SC_view_help {
                foreach($keys as $tocKey)       {
                        if (is_array($tocArray[$tocKey]))       {
                                $output.='
-                                       <li>'.$LANG->getLL('TOC_'.$tocKey,1).'
+                                       <li>'.$GLOBALS['LANG']->getLL('TOC_'.$tocKey,1).'
                                                <ul>
                                                        <li>'.implode('</li>
                                                        <li>',$tocArray[$tocKey]).'</li>
@@ -401,50 +405,55 @@ class SC_view_help {
        /**
         * Render CSH for a full cshKey/table
         *
-        * @param       string          CSH key / table name
-        * @return      string          HTML output
+        * @param string $key Full CSH key (may be different from table name)
+        * @param string $table CSH key / table name
+        * @return string HTML output
         */
-       function render_Table($table)   {
-               global $BE_USER,$TCA_DESCR,$TCA,$LANG;
-
+       function render_Table($key, $table = NULL) {
                $output = '';
 
+                       // take default key if not explicitly specified
+               if ($table === NULL) {
+                       $table = $key;
+               }
+
                        // Load table TCA
-               t3lib_div::loadTCA($table);
+               t3lib_div::loadTCA($key);
 
                        // Load descriptions for table $table
-               $LANG->loadSingleTableDescription($table);
+               $GLOBALS['LANG']->loadSingleTableDescription($key);
 
-               if (is_array($TCA_DESCR[$table]['columns']) && (!$this->limitAccess || $BE_USER->check('tables_select',$table)))        {
+               if (is_array($GLOBALS['TCA_DESCR'][$key]['columns']) && (!$this->limitAccess || $GLOBALS['BE_USER']->check('tables_select', $table))) {
                                // Initialize variables:
                        $parts = array();
                        $parts[0] = ''; // Reserved for header of table
 
                                // Traverse table columns as listed in TCA_DESCR
-                       reset($TCA_DESCR[$table]['columns']);
-                       while(list($field) = each($TCA_DESCR[$table]['columns']))       {
+                       foreach ($GLOBALS['TCA_DESCR'][$key]['columns'] as $field => $_) {
 
-                               $fieldValue = isset($TCA[$table]) && strcmp($field,'') ? $TCA[$table]['columns'][$field] : array();
+                               $fieldValue = isset($GLOBALS['TCA'][$key]) && strcmp($field, '') ? $GLOBALS['TCA'][$key]['columns'][$field] : array();
 
-                               if (is_array($fieldValue) && (!$this->limitAccess || !$fieldValue['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)))       {
+                               if (is_array($fieldValue) && (!$this->limitAccess || !$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $field))) {
                                        if (!$field)    {
-                                               $parts[0] = $this->printItem($table,'',1);      // Header
+                                               $parts[0] = $this->printItem($key, '', 1);      // Header
                                        } else {
-                                               $parts[] = $this->printItem($table,$field,1);   // Field
+                                               $parts[] = $this->printItem($key, $field, 1);   // Field
                                        }
                                }
                        }
 
-                       if (!strcmp($parts,'')) unset($parts[0]);
-                       $output.= implode('<br />',$parts);
+                       if (!$parts[0]) {
+                               unset($parts[0]);
+                       }
+                       $output .= implode('<br />', $parts);
                }
 
                        // Substitute glossary words:
                $output = $this->substituteGlossaryWords($output);
 
                        // TOC link:
-               if (!$this->renderALL)  {
-                       $tocLink = '<p class="c-nav"><a href="view_help.php">'.$LANG->getLL('goToToc',1).'</a></p>';
+               if (!$this->renderALL) {
+                       $tocLink = '<p class="c-nav"><a href="view_help.php">' . $GLOBALS['LANG']->getLL('goToToc', 1) . '</a></p>';
 
                        $output =
                                $tocLink.'
@@ -460,20 +469,18 @@ class SC_view_help {
        /**
         * Renders CSH for a single field.
         *
-        * @param       string          CSH key / table name
-        * @param       string          Sub key / field name
-        * @return      string          HTML output
+        * @param string $key CSH key / table name
+        * @param string $field Sub key / field name
+        * @return string HTML output
         */
-       function render_Single($table,$field)   {
-               global $LANG, $TCA;
-
+       function render_Single($key, $field) {
                $output = '';
 
-                       // Load descriptions for table $table
-               $LANG->loadSingleTableDescription($table);
+                       // Load the description field
+               $GLOBALS['LANG']->loadSingleTableDescription($key);
 
-                       // Render single item:
-               $output.= $this->printItem($table,$field);
+                       // Render single item
+               $output.= $this->printItem($key, $field);
 
                        // Substitute glossary words:
                $output = $this->substituteGlossaryWords($output);
@@ -481,22 +488,12 @@ class SC_view_help {
                        // Link to Full table description and TOC:
                $getLLKey = $this->limitAccess ? 'fullDescription' : 'fullDescription_module';
                $output.= '<br />
-                       <p class="c-nav"><a href="view_help.php?tfID='.rawurlencode($table.'.*').'">'.$LANG->getLL($getLLKey,1).'</a></p>
-                       <p class="c-nav"><a href="view_help.php">'.$LANG->getLL('goToToc',1).'</a></p>';
+                       <p class="c-nav"><a href="view_help.php?tfID=' . rawurlencode($key . '.*') . '">' . $GLOBALS['LANG']->getLL($getLLKey, 1) . '</a></p>
+                       <p class="c-nav"><a href="view_help.php">' . $GLOBALS['LANG']->getLL('goToToc', 1) . '</a></p>';
 
                return $output;
        }
 
-
-
-
-
-
-
-
-
-
-
        /************************************
         *
         * Rendering CSH items
@@ -511,10 +508,8 @@ class SC_view_help {
         * @return      string          See-also links HTML
         */
        function make_seeAlso($value,$anchorTable='')   {
-               global $TCA,$BE_USER,$TCA_DESCR;
-
-                       // Split references by comma, vert.line or linebreak
-               $items = split(',|'.chr(10),$value);
+                       // Split references by comma or linebreak
+               $items = preg_split('/[,' . LF . ']/', $value);
                $lines = array();
 
                foreach($items as $val) {
@@ -535,11 +530,11 @@ class SC_view_help {
                                        // "table" reference
                                        t3lib_div::loadTCA($iP[0]);
 
-                                       if (!isset($TCA[$iP[0]]) || ((!$iP[1] || is_array($TCA[$iP[0]]['columns'][$iP[1]])) && (!$this->limitAccess || ($BE_USER->check('tables_select',$iP[0]) && (!$iP[1] || !$TCA[$iP[0]]['columns'][$iP[1]]['exclude'] || $BE_USER->check('non_exclude_fields',$iP[0].':'.$iP[1]))))))      {       // Checking read access:
+                                       if (!isset($GLOBALS['TCA'][$iP[0]]) || ((!$iP[1] || is_array($GLOBALS['TCA'][$iP[0]]['columns'][$iP[1]])) && (!$this->limitAccess || ($GLOBALS['BE_USER']->check('tables_select',$iP[0]) && (!$iP[1] || !$GLOBALS['TCA'][$iP[0]]['columns'][$iP[1]]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$iP[0].':'.$iP[1]))))))       {       // Checking read access:
 
                                                        // Load table descriptions:
-                                               #$LANG->loadSingleTableDescription($iP[0]);
-                                               if (isset($TCA_DESCR[$iP[0]]))  {
+                                               #$GLOBALS['LANG']->loadSingleTableDescription($iP[0]);
+                                               if (isset($GLOBALS['TCA_DESCR'][$iP[0]]))       {
                                                                // Make see-also link:
                                                        $href = ($this->renderALL || ($anchorTable && $iP[0]==$anchorTable) ? '#'.implode('.',$iP) : 'view_help.php?tfID='.rawurlencode(implode('.',$iP)).'&back='.$this->tfID);
                                                        $label = $this->getTableFieldLabel($iP[0],$iP[1],' / ');
@@ -564,8 +559,8 @@ class SC_view_help {
                        // Splitting:
                $imgArray = t3lib_div::trimExplode(',', $images, 1);
                if (count($imgArray))   {
-                       $descrArray = explode(chr(10),$descr,count($imgArray));
-#debug($descrArray);
+                       $descrArray = explode(LF,$descr,count($imgArray));
+
                        foreach($imgArray as $k => $image)      {
                                $descr = $descrArray[$k];
 
@@ -577,7 +572,7 @@ class SC_view_help {
                                                $imgFile = '../'.$imgFile;
                                                $code.= '<br /><img src="'.$imgFile.'" '.$imgInfo[3].' class="c-inlineimg" alt="" /><br />
                                                ';
-                                               $code.= '<p><em>'.$GLOBALS['LANG']->hscAndCharConv($descr,1).'</em></p>
+                                               $code.= '<p><em>' . htmlspecialchars($descr) . '</em></p>
                                                ';
                                        } else $code.= '<div style="background-color: red; border: 1px solid black; color: white;">NOT AN IMAGE: '.$imgFile.'</div>';
                                } else $code.= '<div style="background-color: red; border: 1px solid black; color: white;">IMAGE FILE NOT FOUND: '.$image.'</div>';
@@ -597,11 +592,11 @@ class SC_view_help {
        function headerLine($str,$type=0)       {
                switch($type)   {
                        case 1:
-                               $str='<h3>'.htmlspecialchars($str).'</h3>
+                               $str = '<h2 class="t3-row-header">' . htmlspecialchars($str) . '</h2>
                                ';
                        break;
                        case 0:
-                               $str='<h4 class="uppercase">'.htmlspecialchars($str).'</h4>
+                               $str = '<h3 class="divider">' . htmlspecialchars($str) . '</h3>
                                ';
                        break;
                }
@@ -616,7 +611,6 @@ class SC_view_help {
         * @return      string          Formatted content.
         */
        function prepareContent($str)   {
-               $str = $GLOBALS['LANG']->hscAndCharConv($str,0);
                return '<p>'.nl2br(trim(strip_tags($str,$this->allowedHTML))).'</p>
                ';
        }
@@ -625,78 +619,90 @@ class SC_view_help {
         * Prints a single $table/$field information piece
         * If $anchors is set, then seeAlso references to the same table will be page-anchors, not links.
         *
-        * @param       string          Table name
-        * @param       string          Field name
-        * @param       boolean         If anchors is to be shown.
-        * @return      string          HTML content
+        * @param string $key CSH key / table name
+        * @param string $field Sub key / field name
+        * @param boolean $anchors If anchors is to be shown.
+        * @return string HTML content
         */
-       function printItem($table,$field,$anchors=0)    {
-               global $TCA_DESCR, $LANG, $TCA, $BE_USER;
+       function printItem($key, $field, $anchors = FALSE) {
+               $out = '';
 
-                       // Load full table definition in $TCA
-               t3lib_div::loadTCA($table);
+                       // Load full table definition in $GLOBALS['TCA']
+               t3lib_div::loadTCA($key);
 
-               if ($table && (!$field || is_array($TCA_DESCR[$table]['columns'][$field])))     {
+               if ($key && (!$field || is_array($GLOBALS['TCA_DESCR'][$key]['columns'][$field])))      {
                                // Make seeAlso references.
-                       $seeAlsoRes = $this->make_seeAlso($TCA_DESCR[$table]['columns'][$field]['seeAlso'],$anchors?$table:'');
+                       $seeAlsoRes = $this->make_seeAlso($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['seeAlso'], $anchors ? $key : '');
 
                                // Making item:
-                       $out= '<a name="'.$table.'.'.$field.'"></a>
-                                       '.
-                                       $this->headerLine($this->getTableFieldLabel($table,$field),1).
-                                       $this->prepareContent($TCA_DESCR[$table]['columns'][$field]['description']).
-                                       ($TCA_DESCR[$table]['columns'][$field]['details'] ? $this->headerLine($LANG->getLL('details').':').$this->prepareContent($TCA_DESCR[$table]['columns'][$field]['details']) : '').
-                                       ($TCA_DESCR[$table]['columns'][$field]['syntax'] ? $this->headerLine($LANG->getLL('syntax').':').$this->prepareContent($TCA_DESCR[$table]['columns'][$field]['syntax']) : '').
-                                       ($TCA_DESCR[$table]['columns'][$field]['image'] ? $this->printImage($TCA_DESCR[$table]['columns'][$field]['image'],$TCA_DESCR[$table]['columns'][$field]['image_descr']) : '').
-                                       ($TCA_DESCR[$table]['columns'][$field]['seeAlso'] && $seeAlsoRes ? $this->headerLine($LANG->getLL('seeAlso').':').'<p>'.$seeAlsoRes.'</p>' : '').
-                                       ($this->back ? '<br /><p><a href="'.htmlspecialchars('view_help.php?tfID='.rawurlencode($this->back)).'" class="typo3-goBack">'.htmlspecialchars($LANG->getLL('goBack')).'</a></p>' : '').
-                       '<br />';
+                       $out = '<a name="' . $key . '.' . $field . '"></a>' .
+                                       $this->headerLine($this->getTableFieldLabel($key, $field), 1) .
+                                       $this->prepareContent($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['description']) .
+                                       ($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['details'] ? $this->headerLine($GLOBALS['LANG']->getLL('details').':').$this->prepareContent($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['details']) : '') .
+                                       ($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['syntax'] ? $this->headerLine($GLOBALS['LANG']->getLL('syntax').':').$this->prepareContent($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['syntax']) : '') .
+                                       ($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['image'] ? $this->printImage($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['image'],$GLOBALS['TCA_DESCR'][$key]['columns'][$field]['image_descr']) : '') .
+                                       ($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['seeAlso'] && $seeAlsoRes ? $this->headerLine($GLOBALS['LANG']->getLL('seeAlso').':').'<p>'.$seeAlsoRes.'</p>' : '') .
+                                       ($this->back ? '<br /><p><a href="' . htmlspecialchars('view_help.php?tfID=' . rawurlencode($this->back)) . '" class="typo3-goBack">' . htmlspecialchars($GLOBALS['LANG']->getLL('goBack')) . '</a></p>' : '') .
+                                       '<br />';
                }
                return $out;
        }
 
        /**
-        * Returns labels for $table and $field.
-        * If $table is "_MOD_" prefixed, the part after "_MOD_" is returned (non-tables, fx. modules)
+        * Returns labels for a given field in a given structure
         *
-        * @param       string          Table name
-        * @param       string          Field name
-        * @return      array           Table and field labels in a numeric array
+        * @param string $key CSH key / table name
+        * @param string $field Sub key / field name
+        * @return array Table and field labels in a numeric array
         */
-       function getTableFieldNames($table,$field)      {
-               global $TCA, $TCA_DESCR, $LANG;
-
-                       $LANG->loadSingleTableDescription($table);
-
-                       $tableName = is_array($TCA_DESCR[$table]['columns']['']) && $TCA_DESCR[$table]['columns']['']['alttitle'] ?
-                                                       $TCA_DESCR[$table]['columns']['']['alttitle'] :
-                                                       (isset($TCA[$table]) ? $TCA[$table]['ctrl']['title'] : ereg_replace('^_MOD_','',$table));
-                       $fieldName = is_array($TCA_DESCR[$table]['columns'][$field]) && $TCA_DESCR[$table]['columns'][$field]['alttitle'] ?
-                                                       $TCA_DESCR[$table]['columns'][$field]['alttitle'] :
-                                                       (isset($TCA[$table])&&isset($TCA[$table]['columns'][$field]) ? $TCA[$table]['columns'][$field]['label'] : $field);
-               return array($tableName,$fieldName);
+       function getTableFieldNames($key, $field) {
+               $GLOBALS['LANG']->loadSingleTableDescription($key);
+
+                       // Define the label for the key
+               $keyName = $key;
+               if (is_array($GLOBALS['TCA_DESCR'][$key]['columns']['']) && isset($GLOBALS['TCA_DESCR'][$key]['columns']['']['alttitle'])) {
+                               // If there's an alternative title, use it
+                       $keyName = $GLOBALS['TCA_DESCR'][$key]['columns']['']['alttitle'];
+               } elseif (isset($GLOBALS['TCA'][$key])) {
+                               // Otherwise, if it's a table, use its title
+                       $keyName = $GLOBALS['TCA'][$key]['ctrl']['title'];
+               } else {
+                               // If no title was found, make sure to remove any "_MOD_"
+                       $keyName = preg_replace('/^_MOD_/', '', $key);
+               }
+                       // Define the label for the field
+               $fieldName = $field;
+               if (is_array($GLOBALS['TCA_DESCR'][$key]['columns'][$field]) && isset($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['alttitle'])) {
+                               // If there's an alternative title, use it
+                       $fieldName = $GLOBALS['TCA_DESCR'][$key]['columns'][$field]['alttitle'];
+               } elseif (isset($GLOBALS['TCA'][$key]) && isset($GLOBALS['TCA'][$key]['columns'][$field])) {
+                               // Otherwise, if it's a table, use its title
+                       $fieldName = $GLOBALS['TCA'][$key]['columns'][$field]['label'];
+               }
+               return array($keyName, $fieldName);
        }
 
        /**
         * Returns composite label for table/field
         *
-        * @param       string          Table name
-        * @param       string          Field name
-        * @param       string          Token to merge the two strings with.
-        * @return      array           Table and field labels in a numeric array
+        * @param string $key CSH key / table name
+        * @param string $field Sub key / field name
+        * @param string $mergeToken Token to merge the two strings with
+        * @return string Labels joined with merge token
         * @see getTableFieldNames()
         */
-       function getTableFieldLabel($table,$field='',$mergeToken=': ')  {
-               global $LANG;
+       function getTableFieldLabel($key, $field = '', $mergeToken = ': ') {
+               $tableName = '';
+               $fieldName = '';
 
                        // Get table / field parts:
-               list($tableName,$fieldName) = $this->getTableFieldNames($table,$field);
+               list($tableName, $fieldName) = $this->getTableFieldNames($key, $field);
 
                        // Create label:
-               $labelStr = $LANG->sL($tableName).
-                                       ($field ? $mergeToken.ereg_replace(':$','', trim($LANG->sL($fieldName))):'');
+               $labelString = $GLOBALS['LANG']->sL($tableName) .
+                                       ($field ? $mergeToken . rtrim(trim($GLOBALS['LANG']->sL($fieldName)), ':') : '');
 
-               return $labelStr;
+               return $labelString;
        }
 
 
@@ -717,13 +723,11 @@ class SC_view_help {
 
        /**
         * Creates glossary index in $this->glossaryWords
-        * Glossary is cached in cache_hash table and so will be updated only when cache is cleared.
+        * Glossary is cached in cache_hash cache and so will be updated only when cache is cleared.
         *
         * @return      void
         */
        function createGlossaryIndex()  {
-               global $TCA_DESCR,$TCA,$LANG;
-
                        // Create hash string and try to retrieve glossary array:
                $hash = md5('typo3/view_help.php:glossary');
                list($this->glossaryWords,$this->substWords) = unserialize(t3lib_BEfunc::getHash($hash));
@@ -734,18 +738,17 @@ class SC_view_help {
                                // Initialize:
                        $this->glossaryWords = array();
                        $this->substWords = array();
-                       $CSHkeys = array_flip(array_keys($TCA_DESCR));
+                       $CSHkeys = array_flip(array_keys($GLOBALS['TCA_DESCR']));
 
                                // Glossary
                        foreach($CSHkeys as $cshKey => $value)  {
-                               if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($TCA[$cshKey]))        {
-                                       $LANG->loadSingleTableDescription($cshKey);
+                               if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($GLOBALS['TCA'][$cshKey])) {
+                                       $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
 
-                                       if (is_array($TCA_DESCR[$cshKey]['columns']))   {
+                                       if (is_array($GLOBALS['TCA_DESCR'][$cshKey]['columns']))        {
 
                                                        // Traverse table columns as listed in TCA_DESCR
-                                               reset($TCA_DESCR[$cshKey]['columns']);
-                                               while(list($field,$data) = each($TCA_DESCR[$cshKey]['columns']))        {
+                                               foreach ($GLOBALS['TCA_DESCR'][$cshKey]['columns'] as $field => $data) {
                                                        if ($field)     {
                                                                $this->glossaryWords[$cshKey.'.'.$field] = array(
                                                                        'title' => trim($data['alttitle'] ? $data['alttitle'] : $cshKey),
@@ -782,7 +785,7 @@ class SC_view_help {
         */
        function substituteGlossaryWords($code) {
                $htmlParser = t3lib_div::makeInstance('local_t3lib_parsehtml');
-               $htmlParser->pObj = &$this;
+               $htmlParser->pObj = $this;
                $code = $htmlParser->HTMLcleaner($code, array(), 1);
 
                return $code;
@@ -822,13 +825,10 @@ class SC_view_help {
 }
 
 
-// Include extension?
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/view_help.php'])    {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/view_help.php']);
-}
-
-
 
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/view_help.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/view_help.php']);
+}
 
 
 
@@ -837,4 +837,5 @@ $SOBE = t3lib_div::makeInstance('SC_view_help');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
+
 ?>
\ No newline at end of file