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


Généré par Les experts TYPO3 avec  doxygen 1.4.6