Added feature #15783: Improve ExtJS skin: Tabs
[Packages/TYPO3.CMS.git] / typo3 / view_help.php
old mode 100755 (executable)
new mode 100644 (file)
index 9a1d774..e066649
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * 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 <kasper@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *   87: class SC_view_help
- *  110:     function init()
- *  130:     function main()
- *  158:     function printContent()
+ *   91: class local_t3lib_parsehtml extends t3lib_parsehtml
+ *  102:     function processContent($value,$dir,$conf)
+ *
+ *
+ *  122: class SC_view_help
+ *  146:     function init()
+ *  167:     function main()
+ *  198:     function printContent()
  *
  *              SECTION: Rendering main modes
- *  181:     function render_TOC()
- *  280:     function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)
- *  311:     function render_TOC_makeTocList($tocArray)
- *  346:     function render_Table($table)
- *  391:     function render_Single($table,$field)
+ *  221:     function render_TOC()
+ *  338:     function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)
+ *  370:     function render_TOC_makeTocList($tocArray)
+ *  409:     function render_Table($table)
+ *  469:     function render_Single($table,$field)
  *
  *              SECTION: Rendering CSH items
- *  433:     function make_seeAlso($value,$anchorTable='')
- *  471:     function printImage($image,$descr)
- *  493:     function headerLine($str,$type=0)
- *  514:     function prepareContent($str)
- *  529:     function printItem($table,$field,$anchors=0)
- *  565:     function getTableFieldNames($table,$field)
+ *  515:     function make_seeAlso($value,$anchorTable='')
+ *  564:     function printImage($images,$descr)
+ *  599:     function headerLine($str,$type=0)
+ *  620:     function prepareContent($str)
+ *  635:     function printItem($table,$field,$anchors=0)
+ *  668:     function getTableFieldNames($table,$field)
+ *  691:     function getTableFieldLabel($table,$field='',$mergeToken=': ')
  *
- * TOTAL FUNCTIONS: 14
+ *              SECTION: Glossary related
+ *  726:     function createGlossaryIndex()
+ *  785:     function substituteGlossaryWords($code)
+ *  801:     function substituteGlossaryWords_htmlcleaner_callback($code)
+ *
+ * TOTAL FUNCTIONS: 19
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 require('init.php');
 require('template.php');
 $LANG->includeLLFile('EXT:lang/locallang_view_help.xml');
-require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
 
 
+/**
+ * Extension of the parse_html class.
+ *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage core
+ */
+class local_t3lib_parsehtml extends t3lib_parsehtml {
+
+       /**
+        * Processing content between tags for HTML_cleaner
+        *
+        * @param       string          The value
+        * @param       integer         Direction, either -1 or +1. 0 (zero) means no change to input value.
+        * @param       mixed           Not used, ignore.
+        * @return      string          The processed value.
+        * @access private
+        */
+       function processContent($value,$dir,$conf)      {
+               $value = $this->pObj->substituteGlossaryWords_htmlcleaner_callback($value);
+
+               return $value;
+       }
+}
 
 
 
@@ -80,7 +113,7 @@ require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
 /**
  * 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 <kasper@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -94,11 +127,13 @@ class SC_view_help {
 
                // 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!
 
                // Internal, dynamic:
        var $content;   // Content accumulation.
+       var $glossaryWords;             // Glossary words
 
 
 
@@ -112,14 +147,24 @@ 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));
+                       }
+               }
                $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);
 
-                       // limitAccess is checked if the $this->table really IS a table.
-               $this->limitAccess = isset($TCA[$this->table]) ? TRUE : FALSE;
+                       // 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;
        }
 
        /**
@@ -131,14 +176,18 @@ class SC_view_help {
                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'));
 
                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->createGlossaryIndex();
                        $this->content.= $this->render_Single($this->table,$this->field);
+               }
+               elseif (is_array($this->ffID)) {
+                       $this->content.= $this->render_SingleFlex();
                } else {        // Render Table Of Contents if nothing else:
                        $this->content.= $this->render_TOC();
                }
@@ -224,6 +273,22 @@ class SC_view_help {
                        }
                }
 
+                       // Extensions
+               foreach($CSHkeys as $cshKey => $value)  {
+                       if (t3lib_div::isFirstPartOfStr($cshKey, 'xEXT_') && !isset($TCA[$cshKey]))     {
+                               $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);
+                               $this->render_TOC_el($cshKey, 'glossary', $outputSections, $tocArray, $CSHkeys);
+                       }
+               }
+
                        // Other:
                foreach($CSHkeys as $cshKey => $value)  {
                        if (!t3lib_div::isFirstPartOfStr($cshKey, '_MOD_') && !isset($TCA[$cshKey]))    {
@@ -237,21 +302,20 @@ class SC_view_help {
                $output = '';
                $output.= '
 
-                       <h1>'.$LANG->getLL('manual_title',1).'</h1>
-                       <p>'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';
+                       <h1>'.$LANG->getLL('manual_title',1).'</h1>';
 
                $output.= '
 
-                       <h1>'.$LANG->getLL('introduction',1).'</h1>
+                       <h2>'.$LANG->getLL('introduction',1).'</h2>
                        <p>'.$LANG->getLL('description',1).'</p>';
 
                $output.= '
 
-                       <h1>'.$LANG->getLL('TOC',1).'</h1>'.
+                       <h2>'.$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>';
                }
@@ -259,7 +323,7 @@ class SC_view_help {
                if ($this->renderALL)   {
                        $output.= '
 
-                               <h1>'.$LANG->getLL('full_manual_chapters',1).'</h1>'.
+                               <h2>'.$LANG->getLL('full_manual_chapters',1).'</h2>'.
                                implode('
 
 
@@ -267,6 +331,8 @@ class SC_view_help {
                                ',$outputSections);
                }
 
+               $output .= '<hr /><p class="manual-title">'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';
+
                return $output;
        }
 
@@ -316,7 +382,7 @@ class SC_view_help {
                global $LANG;
 
                        // The Various manual sections:
-               $keys = explode(',', 'core,modules,tables,other');
+               $keys = explode(',', 'core,modules,tables,extensions,glossary,other');
 
                        // Create TOC bullet list:
                $output = '';
@@ -368,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();
 
@@ -382,10 +447,15 @@ class SC_view_help {
                                }
                        }
 
-                       if (!strcmp($parts,'')) unset($parts[0]);
+                       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>';
@@ -419,6 +489,9 @@ class SC_view_help {
                        // Render single item:
                $output.= $this->printItem($table,$field);
 
+                       // Substitute glossary words:
+               $output = $this->substituteGlossaryWords($output);
+
                        // Link to Full table description and TOC:
                $getLLKey = $this->limitAccess ? 'fullDescription' : 'fullDescription_module';
                $output.= '<br />
@@ -429,13 +502,22 @@ 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
+        */
+       function render_SingleFlex() {
+               $output = '';
 
+                       // Render
+               $output.= $this->printItemFlex();
 
-
-
-
-
-
+                       // Substitute glossary words:
+               return $this->substituteGlossaryWords($output);
+       }
 
 
        /************************************
@@ -452,9 +534,10 @@ class SC_view_help {
         * @return      string          See-also links HTML
         */
        function make_seeAlso($value,$anchorTable='')   {
-               global $TCA,$BE_USER;
-                       // Split references by comma, vert.line or linebreak
-               $items = split(',|'.chr(10),$value);
+               global $TCA,$BE_USER,$TCA_DESCR;
+
+                       // Split references by comma or linebreak
+               $items = preg_split('/[,' . LF . ']/', $value);
                $lines = array();
 
                foreach($items as $val) {
@@ -465,16 +548,26 @@ class SC_view_help {
                                        // URL reference:
                                if (substr($iPUrl[1],0,4)=='http')      {
                                        $lines[] = '<a href="'.htmlspecialchars($iPUrl[1]).'" target="_blank"><em>'.htmlspecialchars($iPUrl[0]).'</em></a>';
+                               } elseif (substr($iPUrl[1],0,5)=='FILE:')       {
+                                       $fileName = t3lib_div::getFileAbsFileName(substr($iPUrl[1],5),1,1);
+                                       if ($fileName && @is_file($fileName))   {
+                                               $fileName = '../'.substr($fileName,strlen(PATH_site));
+                                               $lines[] = '<a href="'.htmlspecialchars($fileName).'" target="_blank"><em>'.htmlspecialchars($iPUrl[0]).'</em></a>';
+                                       }
                                } else {
                                        // "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:
 
-                                                       // 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],' / ');
-                                               $lines[] = '<a href="'.htmlspecialchars($href).'">'.htmlspecialchars($label).'</a>';
+                                                       // Load table descriptions:
+                                               #$LANG->loadSingleTableDescription($iP[0]);
+                                               if (isset($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],' / ');
+                                                       $lines[] = '<a href="'.htmlspecialchars($href).'">'.htmlspecialchars($label).'</a>';
+                                               }
                                        }
                                }
                        }
@@ -494,8 +587,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];
 
@@ -505,12 +598,12 @@ class SC_view_help {
                                        $imgInfo = @getimagesize($absImagePath);
                                        if (is_array($imgInfo)) {
                                                $imgFile = '../'.$imgFile;
-                                               $code.= '<br /><img src="'.$imgFile.'" '.$imgInfo[3].' alt="" /><br />
+                                               $code.= '<br /><img src="'.$imgFile.'" '.$imgInfo[3].' class="c-inlineimg" alt="" /><br />
                                                ';
-                                               $code.= '<p><em>'.$GLOBALS['LANG']->hscAndCharConv($descr,0).'</em></p>
+                                               $code.= '<p><em>'.$GLOBALS['LANG']->hscAndCharConv($descr,1).'</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>';
                        }
                }
 
@@ -527,11 +620,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;
                }
@@ -586,6 +679,35 @@ 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
+        */
+       function printItemFlex() {
+               // Get all texts
+               foreach (explode(',', 'description,details,syntax,image,image_descr,seeAlso') as $var) {
+                       // Double $ below is not a error!
+                       $$var = $GLOBALS['LANG']->sL($this->ffID['cshFile'] . ':' . $this->ffID['field'] . '.' . $var);
+               }
+               // Make seeAlso references.
+               $seeAlsoRes = $this->make_seeAlso($seeAlso);
+
+                       // Making item:
+               $out= $this->headerLine($this->ffID['title'], 1) .
+                               $this->prepareContent($description) .
+                               ($details ? $this->headerLine($GLOBALS['LANG']->getLL('details').':') . $this->prepareContent($details) : '') .
+                               ($syntax ? $this->headerLine($GLOBALS['LANG']->getLL('syntax').':') . $this->prepareContent($syntax) : '') .
+                               ($image ? $this->printImage($image, $image_descr) : '') .
+                               ($seeAlso && $seeAlsoRes ? $this->headerLine($GLOBALS['LANG']->getLL('seeAlso').':').'<p>'.$seeAlsoRes.'</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)
         *
@@ -594,10 +716,13 @@ class SC_view_help {
         * @return      array           Table and field labels in a numeric array
         */
        function getTableFieldNames($table,$field)      {
-               global $TCA, $TCA_DESCR;
+               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));
+                                                       (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);
@@ -621,20 +746,137 @@ 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;
        }
-}
 
 
-// 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']);
+
+
+
+
+
+
+
+
+
+       /******************************
+        *
+        * Glossary related
+        *
+        ******************************/
+
+       /**
+        * Creates glossary index in $this->glossaryWords
+        * 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));
+
+                       // Generate glossary words if not found:
+               if (!is_array($this->glossaryWords)) {
+
+                               // Initialize:
+                       $this->glossaryWords = array();
+                       $this->substWords = array();
+                       $CSHkeys = array_flip(array_keys($TCA_DESCR));
+
+                               // Glossary
+                       foreach($CSHkeys as $cshKey => $value)  {
+                               if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($TCA[$cshKey]))        {
+                                       $LANG->loadSingleTableDescription($cshKey);
+
+                                       if (is_array($TCA_DESCR[$cshKey]['columns']))   {
+
+                                                       // Traverse table columns as listed in TCA_DESCR
+                                               foreach ($TCA_DESCR[$cshKey]['columns'] as $field => $data) {
+                                                       if ($field)     {
+                                                               $this->glossaryWords[$cshKey.'.'.$field] = array(
+                                                                       'title' => trim($data['alttitle'] ? $data['alttitle'] : $cshKey),
+                                                                       'description' =>  str_replace('%22','%23%23%23', rawurlencode($data['description'])),
+                                                               );
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+
+                               // First, create unique list of words:
+                       foreach($this->glossaryWords as $key => $value) {
+                               $word = strtolower($value['title']);    // Making word lowercase in order to filter out same words in different cases.
+
+                               if ($word!=='') {
+                                       $this->substWords[$word] = $value;
+                                       $this->substWords[$word]['key'] = $key;
+                               }
+                       }
+
+                       krsort($this->substWords);
+
+                       t3lib_BEfunc::storeHash($hash,serialize(array($this->glossaryWords,$this->substWords)),'Glossary');
+               }
+       }
+
+       /**
+        * Processing of all non-HTML content in the output
+        * Will be done by a call-back to ->substituteGlossaryWords_htmlcleaner_callback()
+        *
+        * @param       string          Input HTML code
+        * @return      string          Output HTML code
+        */
+       function substituteGlossaryWords($code) {
+               $htmlParser = t3lib_div::makeInstance('local_t3lib_parsehtml');
+               $htmlParser->pObj = $this;
+               $code = $htmlParser->HTMLcleaner($code, array(), 1);
+
+               return $code;
+       }
+
+       /**
+        * Substituting glossary words in the CSH
+        * (This is a call-back function from "class local_t3lib_parsehtml extends t3lib_parsehtml", see top of this script)
+        *
+        * @param       string          Input HTML string
+        * @return      string          HTML with substituted words in.
+        * @coauthor    alex widschwendter, media.res kommunikationsloesungen
+        */
+       function substituteGlossaryWords_htmlcleaner_callback($code)    {
+               if (is_array($this->substWords) && count($this->substWords) && strlen(trim($code)))     {
+
+                               // Substitute words:
+                       foreach($this->substWords as $wordKey => $wordSet)      {
+                                       // quoteMeta used so special chars (which should not occur though) in words will not break the regex. Seemed to work (- kasper)
+                               $parts = preg_split('/( |[\(])('.quoteMeta($wordSet['title']).')([\.\!\)\?\:\,]+| )/i', ' '.$code.' ', 2, PREG_SPLIT_DELIM_CAPTURE);
+                               if (count($parts) == 5) {
+                                       $parts[2] = '<a class="glossary-term" href="'.htmlspecialchars('view_help.php?tfID='.rawurlencode($wordSet['key']).'&back='.$this->tfID).'" title="'.rawurlencode(htmlspecialchars(t3lib_div::fixed_lgd_cs(rawurldecode($wordSet['description']),80))).'">'.
+                                                               htmlspecialchars($parts[2]).
+                                                               '</a>';
+                                       $code = substr(implode('',$parts),1,-1);
+
+                                               // Disable entry so it doesn't get used next time:
+                                       unset($this->substWords[$wordKey]);
+                               }
+                       }
+                       $code = str_replace('###', '&quot;',rawurldecode($code));
+               }
+
+               return $code;
+       }
+
 }
 
 
 
+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']);
+}
 
 
 
@@ -643,4 +885,5 @@ $SOBE = t3lib_div::makeInstance('SC_view_help');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
+
 ?>
\ No newline at end of file