Cleanup #14405: Rename test cases from *_testcase to *Test: Rename test files in...
[Packages/TYPO3.CMS.git] / typo3 / view_help.php
old mode 100755 (executable)
new mode 100644 (file)
index 9b1e402..782ac87
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -77,8 +77,6 @@
 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');
 
 
 /**
@@ -149,6 +147,10 @@ class SC_view_help {
 
                        // 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));
@@ -432,8 +434,7 @@ class SC_view_help {
                        $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 ($TCA_DESCR[$table]['columns'] as $field => $value) {
 
                                $fieldValue = isset($TCA[$table]) && strcmp($field,'') ? $TCA[$table]['columns'][$field] : array();
 
@@ -446,7 +447,9 @@ class SC_view_help {
                                }
                        }
 
-                       if (!strcmp($parts,'')) unset($parts[0]);
+                       if (!$parts[0]) {
+                               unset($parts[0]);
+                       }
                        $output.= implode('<br />',$parts);
                }
 
@@ -533,8 +536,8 @@ class SC_view_help {
        function make_seeAlso($value,$anchorTable='')   {
                global $TCA,$BE_USER,$TCA_DESCR;
 
-                       // Split references by comma, vert.line or linebreak
-               $items = preg_split('/[,|' . chr(10) . ']/', $value);
+                       // Split references by comma or linebreak
+               $items = preg_split('/[,' . LF . ']/', $value);
                $lines = array();
 
                foreach($items as $val) {
@@ -584,7 +587,7 @@ class SC_view_help {
                        // Splitting:
                $imgArray = t3lib_div::trimExplode(',', $images, 1);
                if (count($imgArray))   {
-                       $descrArray = explode(chr(10),$descr,count($imgArray));
+                       $descrArray = explode(LF,$descr,count($imgArray));
 
                        foreach($imgArray as $k => $image)      {
                                $descr = $descrArray[$k];
@@ -719,7 +722,7 @@ class SC_view_help {
 
                        $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));
+                                                       (isset($TCA[$table]) ? $TCA[$table]['ctrl']['title'] : preg_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);
@@ -743,7 +746,7 @@ class SC_view_help {
 
                        // Create label:
                $labelStr = $LANG->sL($tableName).
-                                       ($field ? $mergeToken.ereg_replace(':$','', trim($LANG->sL($fieldName))):'');
+                                       ($field ? $mergeToken.rtrim(trim($LANG->sL($fieldName)), ':'):'');
 
                return $labelStr;
        }
@@ -793,8 +796,7 @@ class SC_view_help {
                                        if (is_array($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 ($TCA_DESCR[$cshKey]['columns'] as $field => $data) {
                                                        if ($field)     {
                                                                $this->glossaryWords[$cshKey.'.'.$field] = array(
                                                                        'title' => trim($data['alttitle'] ? $data['alttitle'] : $cshKey),
@@ -831,7 +833,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;