Documentation TYPO3 par Ameos

view_help.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00075 require('init.php');
00076 require('template.php');
00077 $LANG->includeLLFile('EXT:lang/locallang_view_help.xml');
00078 require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
00079 require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
00080 
00081 
00089 class local_t3lib_parsehtml extends t3lib_parsehtml {
00090 
00100         function processContent($value,$dir,$conf)      {
00101                 $value = $this->pObj->substituteGlossaryWords_htmlcleaner_callback($value);
00102 
00103                 return $value;
00104         }
00105 }
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00120 class SC_view_help {
00121         var $allowedHTML = '<strong><em><b><i>';
00122 
00123                 // For these vars, see init()
00124         var $limitAccess;       // If set access to fields and tables is checked. Should be done for true database tables.
00125         var $table;                     // The "table" key
00126         var $field;                     // The "field" key
00127 
00128                 // Internal, static: GPvar:
00129         var $tfID;                      // Table/FIeld id.
00130         var $back;                      // Back (previous tfID)
00131         var $renderALL;         // If set, then in TOC mode the FULL manual will be printed as well!
00132 
00133                 // Internal, dynamic:
00134         var $content;   // Content accumulation.
00135         var $glossaryWords;             // Glossary words
00136 
00137 
00138 
00144         function init() {
00145                 global $LANG, $TCA;
00146 
00147                         // Setting GPvars:
00148                 $this->tfID = t3lib_div::_GP('tfID');
00149                 $this->back = t3lib_div::_GP('back');
00150                 $this->renderALL = t3lib_div::_GP('renderALL');
00151 
00152                         // Set internal table/field to the parts of "tfID" incoming var.
00153                 list($this->table,$this->field) = explode('.',$this->tfID);
00154 
00155                         // limitAccess is checked if the $this->table really IS a table (and if the user is NOT a translator who should see all!)
00156                 $showAllToUser = t3lib_BEfunc::isModuleSetInTBE_MODULES('txllxmltranslateM1') && $GLOBALS['BE_USER']->check('modules','txllxmltranslateM1');
00157                 $this->limitAccess = isset($TCA[$this->table]) ? !$showAllToUser : FALSE;
00158         }
00159 
00165         function main() {
00166                 global $BE_USER,$LANG,$TCA_DESCR,$TCA,$TBE_TEMPLATE;
00167 
00168                         // Start HTML output accumulation:
00169                 $TBE_TEMPLATE->docType = 'xhtml_trans';
00170                 $TBE_TEMPLATE->divClass = 'typo3-view-help';
00171                 $this->content.= $TBE_TEMPLATE->startPage($LANG->getLL('title'));
00172 
00173                 if ($this->field=='*')  { // If ALL fields is supposed to be shown:
00174                         $this->createGlossaryIndex();
00175                         $this->content.= $this->render_Table($this->table);
00176                 } elseif ($this->tfID) { // ... otherwise show only single field:
00177                         $this->createGlossaryIndex();
00178                         $this->content.= $this->render_Single($this->table,$this->field);
00179                 } else {        // Render Table Of Contents if nothing else:
00180                         $this->content.= $this->render_TOC();
00181                 }
00182 
00183                         // Print close-button:
00184 #               $this->content.='<br /><form action=""><input type="submit" value="'.htmlspecialchars($LANG->getLL('close')).'" onclick="self.close(); return false;" /></form><br/>';
00185 
00186                         // End page:
00187                 $this->content.= '<br/>';
00188                 $this->content.= $TBE_TEMPLATE->endPage();
00189         }
00190 
00196         function printContent() {
00197                 echo $this->content;
00198         }
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208         /************************************
00209          *
00210          * Rendering main modes
00211          *
00212          ************************************/
00213 
00219         function render_TOC()   {
00220                 global $TCA_DESCR,$TCA,$LANG,$BE_USER,$TBE_MODULES;
00221 
00222                         // Initialize:
00223                 $CSHkeys = array_flip(array_keys($TCA_DESCR));
00224                 $TCAkeys = array_keys($TCA);
00225 
00226                 $outputSections = array();
00227                 $tocArray = array();
00228 
00229 
00230                         // TYPO3 Core Features:
00231                 $LANG->loadSingleTableDescription('xMOD_csh_corebe');
00232                 $this->render_TOC_el('xMOD_csh_corebe', 'core', $outputSections, $tocArray, $CSHkeys);
00233 
00234                         // Backend Modules:
00235                 $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00236                 $loadModules->load($TBE_MODULES);
00237                 foreach($loadModules->modules as $mainMod => $info)     {
00238                         $cshKey = '_MOD_'.$mainMod;
00239                         if ($CSHkeys[$cshKey])  {
00240                                 $LANG->loadSingleTableDescription($cshKey);
00241                                 $this->render_TOC_el($cshKey, 'modules', $outputSections, $tocArray, $CSHkeys);
00242                         }
00243 
00244                         if (is_array($info['sub']))     {
00245                                 foreach($info['sub'] as $subMod => $subInfo)    {
00246                                         $cshKey = '_MOD_'.$mainMod.'_'.$subMod;
00247                                         if ($CSHkeys[$cshKey])  {
00248                                                 $LANG->loadSingleTableDescription($cshKey);
00249                                                 $this->render_TOC_el($cshKey, 'modules', $outputSections, $tocArray, $CSHkeys);
00250                                         }
00251                                 }
00252                         }
00253                 }
00254 
00255                         // Database Tables:
00256                 foreach($TCAkeys as $table)     {
00257                                 // Load descriptions for table $table
00258                         $LANG->loadSingleTableDescription($table);
00259                         if (is_array($TCA_DESCR[$table]['columns']) && $BE_USER->check('tables_select',$table)) {
00260                                 $this->render_TOC_el($table, 'tables', $outputSections, $tocArray, $CSHkeys);
00261                         }
00262                 }
00263 
00264                         // Extensions
00265                 foreach($CSHkeys as $cshKey => $value)  {
00266                         if (t3lib_div::isFirstPartOfStr($cshKey, 'xEXT_') && !isset($TCA[$cshKey]))     {
00267                                 $LANG->loadSingleTableDescription($cshKey);
00268                                 $this->render_TOC_el($cshKey, 'extensions', $outputSections, $tocArray, $CSHkeys);
00269                         }
00270                 }
00271 
00272                         // Glossary
00273                 foreach($CSHkeys as $cshKey => $value)  {
00274                         if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($TCA[$cshKey]))        {
00275                                 $LANG->loadSingleTableDescription($cshKey);
00276                                 $this->render_TOC_el($cshKey, 'glossary', $outputSections, $tocArray, $CSHkeys);
00277                         }
00278                 }
00279 
00280                         // Other:
00281                 foreach($CSHkeys as $cshKey => $value)  {
00282                         if (!t3lib_div::isFirstPartOfStr($cshKey, '_MOD_') && !isset($TCA[$cshKey]))    {
00283                                 $LANG->loadSingleTableDescription($cshKey);
00284                                 $this->render_TOC_el($cshKey, 'other', $outputSections, $tocArray, $CSHkeys);
00285                         }
00286                 }
00287 
00288 
00289                         // COMPILE output:
00290                 $output = '';
00291                 $output.= '
00292 
00293                         <h1>'.$LANG->getLL('manual_title',1).'</h1>
00294                         <p>'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';
00295 
00296                 $output.= '
00297 
00298                         <h1>'.$LANG->getLL('introduction',1).'</h1>
00299                         <p>'.$LANG->getLL('description',1).'</p>';
00300 
00301                 $output.= '
00302 
00303                         <h1>'.$LANG->getLL('TOC',1).'</h1>'.
00304                         $this->render_TOC_makeTocList($tocArray);
00305 
00306                 if (!$this->renderALL)  {
00307                 $output.= '
00308                                 <br/>
00309                                 <p class="c-nav"><a href="view_help.php?renderALL=1">'.$LANG->getLL('full_manual',1).'</a></p>';
00310                 }
00311 
00312                 if ($this->renderALL)   {
00313                         $output.= '
00314 
00315                                 <h1>'.$LANG->getLL('full_manual_chapters',1).'</h1>'.
00316                                 implode('
00317 
00318 
00319                                 <!-- NEW SECTION: -->
00320                                 ',$outputSections);
00321                 }
00322 
00323                 return $output;
00324         }
00325 
00336         function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)        {
00337                 global $LANG;
00338 
00339                 if ($this->renderALL)   {       // Render full manual right here!
00340                         $outputSections[$table] = $this->render_Table($table);
00341 
00342                         if ($outputSections[$table])    {
00343                                 $outputSections[$table] = '
00344 
00345                 <!-- New CSHkey/Table: '.$table.' -->
00346                 <p class="c-nav"><a name="ANCHOR_'.$table.'" href="#">'.$LANG->getLL('to_top',1).'</a></p>
00347                 <h2>'.$this->getTableFieldLabel($table).'</h2>
00348 
00349                 '.$outputSections[$table];
00350                                 $tocArray[$tocCat][$table] = '<a href="#ANCHOR_'.$table.'">'.$this->getTableFieldLabel($table).'</a>';
00351                         } else {
00352                                 unset($outputSections[$table]);
00353                         }
00354                 } else {        // Only TOC:
00355                         $tocArray[$tocCat][$table] = '<p><a href="view_help.php?tfID='.rawurlencode($table.'.*').'">'.$this->getTableFieldLabel($table).'</a></p>';
00356                 }
00357 
00358                         // Unset CSH key:
00359                 unset($CSHkeys[$table]);
00360         }
00361 
00368         function render_TOC_makeTocList($tocArray)      {
00369                 global $LANG;
00370 
00371                         // The Various manual sections:
00372                 $keys = explode(',', 'core,modules,tables,extensions,glossary,other');
00373 
00374                         // Create TOC bullet list:
00375                 $output = '';
00376                 foreach($keys as $tocKey)       {
00377                         if (is_array($tocArray[$tocKey]))       {
00378                                 $output.='
00379                                         <li>'.$LANG->getLL('TOC_'.$tocKey,1).'
00380                                                 <ul>
00381                                                         <li>'.implode('</li>
00382                                                         <li>',$tocArray[$tocKey]).'</li>
00383                                                 </ul>
00384                                         </li>';
00385                         }
00386                 }
00387 
00388                         // Compile TOC:
00389                 $output = '
00390 
00391                         <!-- TOC: -->
00392                         <div class="c-toc">
00393                                 <ul>
00394                                 '.$output.'
00395                                 </ul>
00396                         </div>';
00397 
00398                 return $output;
00399         }
00400 
00407         function render_Table($table)   {
00408                 global $BE_USER,$TCA_DESCR,$TCA,$LANG;
00409 
00410                 $output = '';
00411 
00412                         // Load table TCA
00413                 t3lib_div::loadTCA($table);
00414 
00415                         // Load descriptions for table $table
00416                 $LANG->loadSingleTableDescription($table);
00417 
00418                 if (is_array($TCA_DESCR[$table]['columns']) && (!$this->limitAccess || $BE_USER->check('tables_select',$table)))        {
00419                                 // Initialize variables:
00420                         $parts = array();
00421                         $parts[0] = ''; // Reserved for header of table
00422 
00423                                 // Traverse table columns as listed in TCA_DESCR
00424                         reset($TCA_DESCR[$table]['columns']);
00425                         while(list($field) = each($TCA_DESCR[$table]['columns']))       {
00426 
00427                                 $fieldValue = isset($TCA[$table]) && strcmp($field,'') ? $TCA[$table]['columns'][$field] : array();
00428 
00429                                 if (is_array($fieldValue) && (!$this->limitAccess || !$fieldValue['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)))       {
00430                                         if (!$field)    {
00431                                                 $parts[0] = $this->printItem($table,'',1);      // Header
00432                                         } else {
00433                                                 $parts[] = $this->printItem($table,$field,1);   // Field
00434                                         }
00435                                 }
00436                         }
00437 
00438                         if (!strcmp($parts,'')) unset($parts[0]);
00439                         $output.= implode('<br />',$parts);
00440                 }
00441 
00442                         // Substitute glossary words:
00443                 $output = $this->substituteGlossaryWords($output);
00444 
00445                         // TOC link:
00446                 if (!$this->renderALL)  {
00447                         $tocLink = '<p class="c-nav"><a href="view_help.php">'.$LANG->getLL('goToToc',1).'</a></p>';
00448 
00449                         $output =
00450                                 $tocLink.'
00451                                 <br/>'.
00452                                 $output.'
00453                                 <br />'.
00454                                 $tocLink;
00455                 }
00456 
00457                 return $output;
00458         }
00459 
00467         function render_Single($table,$field)   {
00468                 global $LANG, $TCA;
00469 
00470                 $output = '';
00471 
00472                         // Load descriptions for table $table
00473                 $LANG->loadSingleTableDescription($table);
00474 
00475                         // Render single item:
00476                 $output.= $this->printItem($table,$field);
00477 
00478                         // Substitute glossary words:
00479                 $output = $this->substituteGlossaryWords($output);
00480 
00481                         // Link to Full table description and TOC:
00482                 $getLLKey = $this->limitAccess ? 'fullDescription' : 'fullDescription_module';
00483                 $output.= '<br />
00484                         <p class="c-nav"><a href="view_help.php?tfID='.rawurlencode($table.'.*').'">'.$LANG->getLL($getLLKey,1).'</a></p>
00485                         <p class="c-nav"><a href="view_help.php">'.$LANG->getLL('goToToc',1).'</a></p>';
00486 
00487                 return $output;
00488         }
00489 
00490 
00491 
00492 
00493 
00494 
00495 
00496 
00497 
00498 
00499 
00500         /************************************
00501          *
00502          * Rendering CSH items
00503          *
00504          ************************************/
00505 
00513         function make_seeAlso($value,$anchorTable='')   {
00514                 global $TCA,$BE_USER,$TCA_DESCR;
00515 
00516                         // Split references by comma, vert.line or linebreak
00517                 $items = split(',|'.chr(10),$value);
00518                 $lines = array();
00519 
00520                 foreach($items as $val) {
00521                         $val = trim($val);
00522                         if ($val)       {
00523                                 $iP = explode(':',$val);
00524                                 $iPUrl = t3lib_div::trimExplode('|',$val);
00525                                         // URL reference:
00526                                 if (substr($iPUrl[1],0,4)=='http')      {
00527                                         $lines[] = '<a href="'.htmlspecialchars($iPUrl[1]).'" target="_blank"><em>'.htmlspecialchars($iPUrl[0]).'</em></a>';
00528                                 } elseif (substr($iPUrl[1],0,5)=='FILE:')       {
00529                                         $fileName = t3lib_div::getFileAbsFileName(substr($iPUrl[1],5),1,1);
00530                                         if ($fileName && @is_file($fileName))   {
00531                                                 $fileName = '../'.substr($fileName,strlen(PATH_site));
00532                                                 $lines[] = '<a href="'.htmlspecialchars($fileName).'" target="_blank"><em>'.htmlspecialchars($iPUrl[0]).'</em></a>';
00533                                         }
00534                                 } else {
00535                                         // "table" reference
00536                                         t3lib_div::loadTCA($iP[0]);
00537 
00538                                         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:
00539 
00540                                                         // Load table descriptions:
00541                                                 #$LANG->loadSingleTableDescription($iP[0]);
00542                                                 if (isset($TCA_DESCR[$iP[0]]))  {
00543                                                                 // Make see-also link:
00544                                                         $href = ($this->renderALL || ($anchorTable && $iP[0]==$anchorTable) ? '#'.implode('.',$iP) : 'view_help.php?tfID='.rawurlencode(implode('.',$iP)).'&back='.$this->tfID);
00545                                                         $label = $this->getTableFieldLabel($iP[0],$iP[1],' / ');
00546                                                         $lines[] = '<a href="'.htmlspecialchars($href).'">'.htmlspecialchars($label).'</a>';
00547                                                 }
00548                                         }
00549                                 }
00550                         }
00551                 }
00552                 return implode('<br />',$lines);
00553         }
00554 
00562         function printImage($images,$descr)     {
00563                 $code = '';
00564                         // Splitting:
00565                 $imgArray = t3lib_div::trimExplode(',', $images, 1);
00566                 if (count($imgArray))   {
00567                         $descrArray = explode(chr(10),$descr,count($imgArray));
00568 #debug($descrArray);
00569                         foreach($imgArray as $k => $image)      {
00570                                 $descr = $descrArray[$k];
00571 
00572                                 $absImagePath = t3lib_div::getFileAbsFileName($image,1,1);
00573                                 if ($absImagePath && @is_file($absImagePath))   {
00574                                         $imgFile = substr($absImagePath,strlen(PATH_site));
00575                                         $imgInfo = @getimagesize($absImagePath);
00576                                         if (is_array($imgInfo)) {
00577                                                 $imgFile = '../'.$imgFile;
00578                                                 $code.= '<br /><img src="'.$imgFile.'" '.$imgInfo[3].' class="c-inlineimg" alt="" /><br />
00579                                                 ';
00580                                                 $code.= '<p><em>'.$GLOBALS['LANG']->hscAndCharConv($descr,1).'</em></p>
00581                                                 ';
00582                                         } else $code.= '<div style="background-color: red; border: 1px solid black; color: white;">NOT AN IMAGE: '.$imgFile.'</div>';
00583                                 } else $code.= '<div style="background-color: red; border: 1px solid black; color: white;">IMAGE FILE NOT FOUND: '.$image.'</div>';
00584                         }
00585                 }
00586 
00587                 return $code;
00588         }
00589 
00597         function headerLine($str,$type=0)       {
00598                 switch($type)   {
00599                         case 1:
00600                                 $str='<h3>'.htmlspecialchars($str).'</h3>
00601                                 ';
00602                         break;
00603                         case 0:
00604                                 $str='<h4 class="uppercase">'.htmlspecialchars($str).'</h4>
00605                                 ';
00606                         break;
00607                 }
00608 
00609                 return $str;
00610         }
00611 
00618         function prepareContent($str)   {
00619                 $str = $GLOBALS['LANG']->hscAndCharConv($str,0);
00620                 return '<p>'.nl2br(trim(strip_tags($str,$this->allowedHTML))).'</p>
00621                 ';
00622         }
00623 
00633         function printItem($table,$field,$anchors=0)    {
00634                 global $TCA_DESCR, $LANG, $TCA, $BE_USER;
00635 
00636                         // Load full table definition in $TCA
00637                 t3lib_div::loadTCA($table);
00638 
00639                 if ($table && (!$field || is_array($TCA_DESCR[$table]['columns'][$field])))     {
00640                                 // Make seeAlso references.
00641                         $seeAlsoRes = $this->make_seeAlso($TCA_DESCR[$table]['columns'][$field]['seeAlso'],$anchors?$table:'');
00642 
00643                                 // Making item:
00644                         $out= '<a name="'.$table.'.'.$field.'"></a>
00645                                         '.
00646                                         $this->headerLine($this->getTableFieldLabel($table,$field),1).
00647                                         $this->prepareContent($TCA_DESCR[$table]['columns'][$field]['description']).
00648                                         ($TCA_DESCR[$table]['columns'][$field]['details'] ? $this->headerLine($LANG->getLL('details').':').$this->prepareContent($TCA_DESCR[$table]['columns'][$field]['details']) : '').
00649                                         ($TCA_DESCR[$table]['columns'][$field]['syntax'] ? $this->headerLine($LANG->getLL('syntax').':').$this->prepareContent($TCA_DESCR[$table]['columns'][$field]['syntax']) : '').
00650                                         ($TCA_DESCR[$table]['columns'][$field]['image'] ? $this->printImage($TCA_DESCR[$table]['columns'][$field]['image'],$TCA_DESCR[$table]['columns'][$field]['image_descr']) : '').
00651                                         ($TCA_DESCR[$table]['columns'][$field]['seeAlso'] && $seeAlsoRes ? $this->headerLine($LANG->getLL('seeAlso').':').'<p>'.$seeAlsoRes.'</p>' : '').
00652                                         ($this->back ? '<br /><p><a href="'.htmlspecialchars('view_help.php?tfID='.rawurlencode($this->back)).'" class="typo3-goBack">'.htmlspecialchars($LANG->getLL('goBack')).'</a></p>' : '').
00653                         '<br />';
00654                 }
00655                 return $out;
00656         }
00657 
00666         function getTableFieldNames($table,$field)      {
00667                 global $TCA, $TCA_DESCR, $LANG;
00668 
00669                         $LANG->loadSingleTableDescription($table);
00670 
00671                         $tableName = is_array($TCA_DESCR[$table]['columns']['']) && $TCA_DESCR[$table]['columns']['']['alttitle'] ?
00672                                                         $TCA_DESCR[$table]['columns']['']['alttitle'] :
00673                                                         (isset($TCA[$table]) ? $TCA[$table]['ctrl']['title'] : ereg_replace('^_MOD_','',$table));
00674                         $fieldName = is_array($TCA_DESCR[$table]['columns'][$field]) && $TCA_DESCR[$table]['columns'][$field]['alttitle'] ?
00675                                                         $TCA_DESCR[$table]['columns'][$field]['alttitle'] :
00676                                                         (isset($TCA[$table])&&isset($TCA[$table]['columns'][$field]) ? $TCA[$table]['columns'][$field]['label'] : $field);
00677                 return array($tableName,$fieldName);
00678         }
00679 
00689         function getTableFieldLabel($table,$field='',$mergeToken=': ')  {
00690                 global $LANG;
00691 
00692                         // Get table / field parts:
00693                 list($tableName,$fieldName) = $this->getTableFieldNames($table,$field);
00694 
00695                         // Create label:
00696                 $labelStr = $LANG->sL($tableName).
00697                                         ($field ? $mergeToken.ereg_replace(':$','', trim($LANG->sL($fieldName))):'');
00698 
00699                 return $labelStr;
00700         }
00701 
00702 
00703 
00704 
00705 
00706 
00707 
00708 
00709 
00710 
00711 
00712         /******************************
00713          *
00714          * Glossary related
00715          *
00716          ******************************/
00717 
00724         function createGlossaryIndex()  {
00725                 global $TCA_DESCR,$TCA,$LANG;
00726 
00727                         // Create hash string and try to retrieve glossary array:
00728                 $hash = md5('typo3/view_help.php:glossary');
00729                 list($this->glossaryWords,$this->substWords) = unserialize(t3lib_BEfunc::getHash($hash));
00730 
00731                         // Generate glossary words if not found:
00732                 if (!is_array($this->glossaryWords)) {
00733 
00734                                 // Initialize:
00735                         $this->glossaryWords = array();
00736                         $this->substWords = array();
00737                         $CSHkeys = array_flip(array_keys($TCA_DESCR));
00738 
00739                                 // Glossary
00740                         foreach($CSHkeys as $cshKey => $value)  {
00741                                 if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($TCA[$cshKey]))        {
00742                                         $LANG->loadSingleTableDescription($cshKey);
00743 
00744                                         if (is_array($TCA_DESCR[$cshKey]['columns']))   {
00745 
00746                                                         // Traverse table columns as listed in TCA_DESCR
00747                                                 reset($TCA_DESCR[$cshKey]['columns']);
00748                                                 while(list($field,$data) = each($TCA_DESCR[$cshKey]['columns']))        {
00749                                                         if ($field)     {
00750                                                                 $this->glossaryWords[$cshKey.'.'.$field] = array(
00751                                                                         'title' => trim($data['alttitle'] ? $data['alttitle'] : $cshKey),
00752                                                                         'description' =>  str_replace('%22','%23%23%23', rawurlencode($data['description'])),
00753                                                                 );
00754                                                         }
00755                                                 }
00756                                         }
00757                                 }
00758                         }
00759 
00760                                 // First, create unique list of words:
00761                         foreach($this->glossaryWords as $key => $value) {
00762                                 $word = strtolower($value['title']);    // Making word lowercase in order to filter out same words in different cases.
00763 
00764                                 if ($word!=='') {
00765                                         $this->substWords[$word] = $value;
00766                                         $this->substWords[$word]['key'] = $key;
00767                                 }
00768                         }
00769 
00770                         krsort($this->substWords);
00771 
00772                         t3lib_BEfunc::storeHash($hash,serialize(array($this->glossaryWords,$this->substWords)),'Glossary');
00773                 }
00774         }
00775 
00783         function substituteGlossaryWords($code) {
00784                 $htmlParser = t3lib_div::makeInstance('local_t3lib_parsehtml');
00785                 $htmlParser->pObj = &$this;
00786                 $code = $htmlParser->HTMLcleaner($code, array(), 1);
00787 
00788                 return $code;
00789         }
00790 
00799         function substituteGlossaryWords_htmlcleaner_callback($code)    {
00800                 if (is_array($this->substWords) && count($this->substWords) && strlen(trim($code)))     {
00801 
00802                                 // Substitute words:
00803                         foreach($this->substWords as $wordKey => $wordSet)      {
00804                                         // quoteMeta used so special chars (which should not occur though) in words will not break the regex. Seemed to work (- kasper)
00805                                 $parts = preg_split('/( |[\(])('.quoteMeta($wordSet['title']).')([\.\!\)\?\:\,]+| )/i', ' '.$code.' ', 2, PREG_SPLIT_DELIM_CAPTURE);
00806                                 if (count($parts) == 5) {
00807                                         $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))).'">'.
00808                                                                 htmlspecialchars($parts[2]).
00809                                                                 '</a>';
00810                                         $code = substr(implode('',$parts),1,-1);
00811 
00812                                                 // Disable entry so it doesn't get used next time:
00813                                         unset($this->substWords[$wordKey]);
00814                                 }
00815                         }
00816                         $code = str_replace('###', '&quot;',rawurldecode($code));
00817                 }
00818 
00819                 return $code;
00820         }
00821 
00822 }
00823 
00824 
00825 // Include extension?
00826 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/view_help.php'])     {
00827         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/view_help.php']);
00828 }
00829 
00830 
00831 
00832 
00833 
00834 
00835 // Make instance:
00836 $SOBE = t3lib_div::makeInstance('SC_view_help');
00837 $SOBE->init();
00838 $SOBE->main();
00839 $SOBE->printContent();
00840 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6