[BUGFIX] Regression: filelistFolderTree constructor is recursive
[Packages/TYPO3.CMS.git] / typo3 / view_help.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Document for viewing the online help texts, also known as TCA_DESCR.
29 * See Inside TYPO3 for details.
30 *
31 * Revised for TYPO3 3.7 5/2004 by Kasper Skårhøj
32 * XHTML-trans compliant
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36
37 require('init.php');
38 require('template.php');
39 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_view_help.xml');
40
41
42 /**
43 * Extension of the parse_html class.
44 *
45 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
46 * @package TYPO3
47 * @subpackage core
48 */
49 class local_t3lib_parsehtml extends t3lib_parsehtml {
50
51 /**
52 * Processing content between tags for HTML_cleaner
53 *
54 * @param string The value
55 * @param integer Direction, either -1 or +1. 0 (zero) means no change to input value.
56 * @param mixed Not used, ignore.
57 * @return string The processed value.
58 * @access private
59 */
60 function processContent($value,$dir,$conf) {
61 $value = $this->pObj->substituteGlossaryWords_htmlcleaner_callback($value);
62
63 return $value;
64 }
65 }
66
67
68
69
70
71
72
73 /**
74 * 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.
75 *
76 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
77 * @package TYPO3
78 * @subpackage core
79 */
80 class SC_view_help {
81 var $allowedHTML = '<strong><em><b><i>';
82
83 // For these vars, see init()
84 var $limitAccess; // If set access to fields and tables is checked. Should be done for TRUE database tables.
85 var $table; // The "table" key
86 var $field; // The "field" key
87 /**
88 * Key used to point to the right CSH resource
89 * In simple cases, is equal to $table
90 *
91 * @var string
92 */
93 protected $mainKey;
94
95 // Internal, static: GPvar:
96 var $tfID; // Table/FIeld id.
97 var $ffID; // Flexform file/field information
98 var $back; // Back (previous tfID)
99 var $renderALL; // If set, then in TOC mode the FULL manual will be printed as well!
100
101 // Internal, dynamic:
102 var $content; // Content accumulation.
103 var $glossaryWords; // Glossary words
104
105
106
107 /**
108 * Initialize the class for various input etc.
109 *
110 * @return void
111 */
112 function init() {
113
114 // Setting GPvars:
115 $this->tfID = t3lib_div::_GP('tfID');
116 // Sanitizes the tfID using whitelisting.
117 if (!preg_match('/^[a-zA-Z0-9_\-\.\*]*$/', $this->tfID)) {
118 $this->tfID = '';
119 }
120 if (!$this->tfID) {
121 if (($this->ffID = t3lib_div::_GP('ffID'))) {
122 $this->ffID = unserialize(base64_decode($this->ffID));
123 }
124 }
125 $this->back = t3lib_div::_GP('back');
126 $this->renderALL = t3lib_div::_GP('renderALL');
127
128 // Set internal table/field to the parts of "tfID" incoming var.
129 $identifierParts = explode('.', $this->tfID);
130 // The table is the first item
131 $this->table = array_shift($identifierParts);
132 $this->mainKey = $this->table;
133 // The field is the second one
134 $this->field = array_shift($identifierParts);
135 // There may be extra parts for FlexForms
136 if (count($identifierParts) > 0) {
137 // There's at least one extra part
138 $extraIdentifierInformation = array();
139 $extraIdentifierInformation[] = array_shift($identifierParts);
140 // Load the TCA details of the table
141 t3lib_div::loadTCA($this->table);
142 // If the ds_pointerField contains a comma, it means the choice of FlexForm DS
143 // is determined by 2 parameters. In this case we have an extra identifier part
144 if (strpos($GLOBALS['TCA'][$this->table]['columns'][$this->field]['config']['ds_pointerField'], ',') !== FALSE) {
145 $extraIdentifierInformation[] = array_shift($identifierParts);
146 }
147 // The remaining parts make up the FlexForm field name itself
148 // (reassembled with dots)
149 $flexFormField = implode('.', $identifierParts);
150 // Assemble a different main key and switch field to use FlexForm field name
151 $this->mainKey .= '.' . $this->field;
152 foreach ($extraIdentifierInformation as $extraKey) {
153 $this->mainKey .= '.' . $extraKey;
154 }
155 $this->field = $flexFormField;
156 }
157
158 // limitAccess is checked if the $this->table really IS a table (and if the user is NOT a translator who should see all!)
159 $showAllToUser = t3lib_BEfunc::isModuleSetInTBE_MODULES('txllxmltranslateM1') && $GLOBALS['BE_USER']->check('modules','txllxmltranslateM1');
160 $this->limitAccess = isset($GLOBALS['TCA'][$this->table]) ? !$showAllToUser : FALSE;
161 }
162
163 /**
164 * Main function, rendering the display
165 *
166 * @return void
167 */
168 function main() {
169
170 // Start HTML output accumulation:
171 $GLOBALS['TBE_TEMPLATE']->divClass = 'typo3-view-help';
172 $this->content .= $GLOBALS['TBE_TEMPLATE']->startPage($GLOBALS['LANG']->getLL('title'));
173
174 if ($this->field == '*') {
175 // If ALL fields is supposed to be shown:
176 $this->createGlossaryIndex();
177 $this->content .= $this->render_Table($this->mainKey);
178
179 } elseif ($this->tfID) {
180 // ... otherwise show only single field:
181 $this->createGlossaryIndex();
182 $this->content .= $this->render_Single($this->mainKey, $this->field);
183
184 } elseif (is_array($this->ffID)) {
185 $this->content .= $this->render_SingleFlex();
186
187 } else {
188 // Render Table Of Contents if nothing else:
189 $this->content.= $this->render_TOC();
190 }
191
192 // Print close-button:
193 # $this->content.='<br /><form action=""><input type="submit" value="'.htmlspecialchars($GLOBALS['LANG']->getLL('close')).'" onclick="self.close(); return false;" /></form><br/>';
194
195 // End page:
196 $this->content.= '<br/>';
197 $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
198 }
199
200 /**
201 * Outputting the accumulated content to screen
202 *
203 * @return void
204 */
205 function printContent() {
206 echo $this->content;
207 }
208
209
210
211
212
213
214
215
216
217 /************************************
218 *
219 * Rendering main modes
220 *
221 ************************************/
222
223 /**
224 * Creates Table Of Contents and possibly "Full Manual" mode if selected.
225 *
226 * @return string HTML content
227 */
228 function render_TOC() {
229 // Initialize:
230 $CSHkeys = array_flip(array_keys($GLOBALS['TCA_DESCR']));
231 $TCAkeys = array_keys($GLOBALS['TCA']);
232
233 $outputSections = array();
234 $tocArray = array();
235
236
237 // TYPO3 Core Features:
238 $GLOBALS['LANG']->loadSingleTableDescription('xMOD_csh_corebe');
239 $this->render_TOC_el('xMOD_csh_corebe', 'core', $outputSections, $tocArray, $CSHkeys);
240
241 // Backend Modules:
242 $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
243 $loadModules->load($GLOBALS['TBE_MODULES']);
244 foreach($loadModules->modules as $mainMod => $info) {
245 $cshKey = '_MOD_'.$mainMod;
246 if ($CSHkeys[$cshKey]) {
247 $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
248 $this->render_TOC_el($cshKey, 'modules', $outputSections, $tocArray, $CSHkeys);
249 }
250
251 if (is_array($info['sub'])) {
252 foreach($info['sub'] as $subMod => $subInfo) {
253 $cshKey = '_MOD_'.$mainMod.'_'.$subMod;
254 if ($CSHkeys[$cshKey]) {
255 $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
256 $this->render_TOC_el($cshKey, 'modules', $outputSections, $tocArray, $CSHkeys);
257 }
258 }
259 }
260 }
261
262 // Database Tables:
263 foreach($TCAkeys as $table) {
264 // Load descriptions for table $table
265 $GLOBALS['LANG']->loadSingleTableDescription($table);
266 if (is_array($GLOBALS['TCA_DESCR'][$table]['columns']) && $GLOBALS['BE_USER']->check('tables_select',$table)) {
267 $this->render_TOC_el($table, 'tables', $outputSections, $tocArray, $CSHkeys);
268 }
269 }
270
271 // Extensions
272 foreach($CSHkeys as $cshKey => $value) {
273 if (t3lib_div::isFirstPartOfStr($cshKey, 'xEXT_') && !isset($GLOBALS['TCA'][$cshKey])) {
274 $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
275 $this->render_TOC_el($cshKey, 'extensions', $outputSections, $tocArray, $CSHkeys);
276 }
277 }
278
279 // Glossary
280 foreach($CSHkeys as $cshKey => $value) {
281 if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($GLOBALS['TCA'][$cshKey])) {
282 $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
283 $this->render_TOC_el($cshKey, 'glossary', $outputSections, $tocArray, $CSHkeys);
284 }
285 }
286
287 // Other:
288 foreach($CSHkeys as $cshKey => $value) {
289 if (!t3lib_div::isFirstPartOfStr($cshKey, '_MOD_') && !isset($GLOBALS['TCA'][$cshKey])) {
290 $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
291 $this->render_TOC_el($cshKey, 'other', $outputSections, $tocArray, $CSHkeys);
292 }
293 }
294
295
296 // COMPILE output:
297 $output = '';
298 $output.= '
299
300 <h1>'.$GLOBALS['LANG']->getLL('manual_title',1).'</h1>';
301
302 $output.= '
303
304 <h2>'.$GLOBALS['LANG']->getLL('introduction',1).'</h2>
305 <p>'.$GLOBALS['LANG']->getLL('description',1).'</p>';
306
307 $output.= '
308
309 <h2>'.$GLOBALS['LANG']->getLL('TOC',1).'</h2>'.
310 $this->render_TOC_makeTocList($tocArray);
311
312 if (!$this->renderALL) {
313 $output.= '
314 <br/>
315 <p class="c-nav"><a href="view_help.php?renderALL=1">'.$GLOBALS['LANG']->getLL('full_manual',1).'</a></p>';
316 }
317
318 if ($this->renderALL) {
319 $output.= '
320
321 <h2>'.$GLOBALS['LANG']->getLL('full_manual_chapters',1).'</h2>'.
322 implode('
323
324
325 <!-- NEW SECTION: -->
326 ',$outputSections);
327 }
328
329 $output .= '<hr /><p class="manual-title">'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';
330
331 return $output;
332 }
333
334 /**
335 * Creates a TOC list element and renders corresponding HELP content if "renderALL" mode is set.
336 *
337 * @param string CSH key / Table name
338 * @param string TOC category keyword: "core", "modules", "tables", "other"
339 * @param array Array for accumulation of rendered HELP Content (in "renderALL" mode). Passed by reference!
340 * @param array TOC array; Here TOC index elements are created. Passed by reference!
341 * @param array CSH keys array. Every item rendered will be unset in this array so finally we can see what CSH keys are not processed yet. Passed by reference!
342 * @return void
343 */
344 function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys) {
345 if ($this->renderALL) { // Render full manual right here!
346 $outputSections[$table] = $this->render_Table($table);
347
348 if ($outputSections[$table]) {
349 $outputSections[$table] = '
350
351 <!-- New CSHkey/Table: '.$table.' -->
352 <p class="c-nav"><a name="ANCHOR_'.$table.'" href="#">'.$GLOBALS['LANG']->getLL('to_top',1).'</a></p>
353 <h2>'.$this->getTableFieldLabel($table).'</h2>
354
355 '.$outputSections[$table];
356 $tocArray[$tocCat][$table] = '<a href="#ANCHOR_'.$table.'">'.$this->getTableFieldLabel($table).'</a>';
357 } else {
358 unset($outputSections[$table]);
359 }
360 } else { // Only TOC:
361 $tocArray[$tocCat][$table] = '<p><a href="view_help.php?tfID='.rawurlencode($table.'.*').'">'.$this->getTableFieldLabel($table).'</a></p>';
362 }
363
364 // Unset CSH key:
365 unset($CSHkeys[$table]);
366 }
367
368 /**
369 * Renders the TOC index as a HTML bullet list from TOC array
370 *
371 * @param array ToC Array.
372 * @return string HTML bullet list for index.
373 */
374 function render_TOC_makeTocList($tocArray) {
375 // The Various manual sections:
376 $keys = explode(',', 'core,modules,tables,extensions,glossary,other');
377
378 // Create TOC bullet list:
379 $output = '';
380 foreach($keys as $tocKey) {
381 if (is_array($tocArray[$tocKey])) {
382 $output.='
383 <li>'.$GLOBALS['LANG']->getLL('TOC_'.$tocKey,1).'
384 <ul>
385 <li>'.implode('</li>
386 <li>',$tocArray[$tocKey]).'</li>
387 </ul>
388 </li>';
389 }
390 }
391
392 // Compile TOC:
393 $output = '
394
395 <!-- TOC: -->
396 <div class="c-toc">
397 <ul>
398 '.$output.'
399 </ul>
400 </div>';
401
402 return $output;
403 }
404
405 /**
406 * Render CSH for a full cshKey/table
407 *
408 * @param string $key Full CSH key (may be different from table name)
409 * @param string $table CSH key / table name
410 * @return string HTML output
411 */
412 function render_Table($key, $table) {
413 $output = '';
414
415 // Load table TCA
416 t3lib_div::loadTCA($key);
417
418 // Load descriptions for table $table
419 $GLOBALS['LANG']->loadSingleTableDescription($key);
420
421 if (is_array($GLOBALS['TCA_DESCR'][$key]['columns']) && (!$this->limitAccess || $GLOBALS['BE_USER']->check('tables_select', $table))) {
422 // Initialize variables:
423 $parts = array();
424 $parts[0] = ''; // Reserved for header of table
425
426 // Traverse table columns as listed in TCA_DESCR
427 foreach ($GLOBALS['TCA_DESCR'][$key]['columns'] as $field => $_) {
428
429 $fieldValue = isset($GLOBALS['TCA'][$key]) && strcmp($field, '') ? $GLOBALS['TCA'][$key]['columns'][$field] : array();
430
431 if (is_array($fieldValue) && (!$this->limitAccess || !$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $field))) {
432 if (!$field) {
433 $parts[0] = $this->printItem($key, '', 1); // Header
434 } else {
435 $parts[] = $this->printItem($key, $field, 1); // Field
436 }
437 }
438 }
439
440 if (!$parts[0]) {
441 unset($parts[0]);
442 }
443 $output .= implode('<br />', $parts);
444 }
445
446 // Substitute glossary words:
447 $output = $this->substituteGlossaryWords($output);
448
449 // TOC link:
450 if (!$this->renderALL) {
451 $tocLink = '<p class="c-nav"><a href="view_help.php">' . $GLOBALS['LANG']->getLL('goToToc', 1) . '</a></p>';
452
453 $output =
454 $tocLink.'
455 <br/>'.
456 $output.'
457 <br />'.
458 $tocLink;
459 }
460
461 return $output;
462 }
463
464 /**
465 * Renders CSH for a single field.
466 *
467 * @param string $key CSH key / table name
468 * @param string $field Sub key / field name
469 * @return string HTML output
470 */
471 function render_Single($key, $field) {
472 $output = '';
473
474 // Load the description field
475 $GLOBALS['LANG']->loadSingleTableDescription($key);
476
477 // Render single item
478 $output.= $this->printItem($key, $field);
479
480 // Substitute glossary words:
481 $output = $this->substituteGlossaryWords($output);
482
483 // Link to Full table description and TOC:
484 $getLLKey = $this->limitAccess ? 'fullDescription' : 'fullDescription_module';
485 $output.= '<br />
486 <p class="c-nav"><a href="view_help.php?tfID=' . rawurlencode($key . '.*') . '">' . $GLOBALS['LANG']->getLL($getLLKey, 1) . '</a></p>
487 <p class="c-nav"><a href="view_help.php">' . $GLOBALS['LANG']->getLL('goToToc', 1) . '</a></p>';
488
489 return $output;
490 }
491
492
493 /**
494 * Renders CSH for a single field.
495 *
496 * @param string CSH key / table name
497 * @param string Sub key / field name
498 * @return string HTML output
499 * @deprecated since TYPO3 4.5, this function will be removed in TYPO3 4.7. Use render_Single() instead.
500 */
501 function render_SingleFlex() {
502 t3lib_div::logDeprecatedFunction();
503 $output = '';
504
505 // Render
506 $output.= $this->printItemFlex();
507
508 // Substitute glossary words:
509 return $this->substituteGlossaryWords($output);
510 }
511
512
513 /************************************
514 *
515 * Rendering CSH items
516 *
517 ************************************/
518
519 /**
520 * Make seeAlso links from $value
521 *
522 * @param string See-also input codes
523 * @param string If $anchorTable is set to a tablename, then references to this table will be made as anchors, not URLs.
524 * @return string See-also links HTML
525 */
526 function make_seeAlso($value,$anchorTable='') {
527 // Split references by comma or linebreak
528 $items = preg_split('/[,' . LF . ']/', $value);
529 $lines = array();
530
531 foreach($items as $val) {
532 $val = trim($val);
533 if ($val) {
534 $iP = explode(':',$val);
535 $iPUrl = t3lib_div::trimExplode('|',$val);
536 // URL reference:
537 if (substr($iPUrl[1],0,4)=='http') {
538 $lines[] = '<a href="'.htmlspecialchars($iPUrl[1]).'" target="_blank"><em>'.htmlspecialchars($iPUrl[0]).'</em></a>';
539 } elseif (substr($iPUrl[1],0,5)=='FILE:') {
540 $fileName = t3lib_div::getFileAbsFileName(substr($iPUrl[1],5),1,1);
541 if ($fileName && @is_file($fileName)) {
542 $fileName = '../'.substr($fileName,strlen(PATH_site));
543 $lines[] = '<a href="'.htmlspecialchars($fileName).'" target="_blank"><em>'.htmlspecialchars($iPUrl[0]).'</em></a>';
544 }
545 } else {
546 // "table" reference
547 t3lib_div::loadTCA($iP[0]);
548
549 if (!isset($GLOBALS['TCA'][$iP[0]]) || ((!$iP[1] || is_array($GLOBALS['TCA'][$iP[0]]['columns'][$iP[1]])) && (!$this->limitAccess || ($GLOBALS['BE_USER']->check('tables_select',$iP[0]) && (!$iP[1] || !$GLOBALS['TCA'][$iP[0]]['columns'][$iP[1]]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$iP[0].':'.$iP[1])))))) { // Checking read access:
550
551 // Load table descriptions:
552 #$GLOBALS['LANG']->loadSingleTableDescription($iP[0]);
553 if (isset($GLOBALS['TCA_DESCR'][$iP[0]])) {
554 // Make see-also link:
555 $href = ($this->renderALL || ($anchorTable && $iP[0]==$anchorTable) ? '#'.implode('.',$iP) : 'view_help.php?tfID='.rawurlencode(implode('.',$iP)).'&back='.$this->tfID);
556 $label = $this->getTableFieldLabel($iP[0],$iP[1],' / ');
557 $lines[] = '<a href="'.htmlspecialchars($href).'">'.htmlspecialchars($label).'</a>';
558 }
559 }
560 }
561 }
562 }
563 return implode('<br />',$lines);
564 }
565
566 /**
567 * Will return an image tag with description in italics.
568 *
569 * @param string Image file reference (list of)
570 * @param string Description string (divided for each image by line break)
571 * @return string Image HTML codes
572 */
573 function printImage($images,$descr) {
574 $code = '';
575 // Splitting:
576 $imgArray = t3lib_div::trimExplode(',', $images, 1);
577 if (count($imgArray)) {
578 $descrArray = explode(LF,$descr,count($imgArray));
579
580 foreach($imgArray as $k => $image) {
581 $descr = $descrArray[$k];
582
583 $absImagePath = t3lib_div::getFileAbsFileName($image,1,1);
584 if ($absImagePath && @is_file($absImagePath)) {
585 $imgFile = substr($absImagePath,strlen(PATH_site));
586 $imgInfo = @getimagesize($absImagePath);
587 if (is_array($imgInfo)) {
588 $imgFile = '../'.$imgFile;
589 $code.= '<br /><img src="'.$imgFile.'" '.$imgInfo[3].' class="c-inlineimg" alt="" /><br />
590 ';
591 $code.= '<p><em>' . htmlspecialchars($descr) . '</em></p>
592 ';
593 } else $code.= '<div style="background-color: red; border: 1px solid black; color: white;">NOT AN IMAGE: '.$imgFile.'</div>';
594 } else $code.= '<div style="background-color: red; border: 1px solid black; color: white;">IMAGE FILE NOT FOUND: '.$image.'</div>';
595 }
596 }
597
598 return $code;
599 }
600
601 /**
602 * Returns header HTML content
603 *
604 * @param string Header text
605 * @param string Header type (1, 0)
606 * @return string The HTML for the header.
607 */
608 function headerLine($str,$type=0) {
609 switch($type) {
610 case 1:
611 $str = '<h2 class="t3-row-header">' . htmlspecialchars($str) . '</h2>
612 ';
613 break;
614 case 0:
615 $str = '<h3 class="divider">' . htmlspecialchars($str) . '</h3>
616 ';
617 break;
618 }
619
620 return $str;
621 }
622
623 /**
624 * Returns prepared content
625 *
626 * @param string Content to format.
627 * @return string Formatted content.
628 */
629 function prepareContent($str) {
630 return '<p>'.nl2br(trim(strip_tags($str,$this->allowedHTML))).'</p>
631 ';
632 }
633
634 /**
635 * Prints a single $table/$field information piece
636 * If $anchors is set, then seeAlso references to the same table will be page-anchors, not links.
637 *
638 * @param string $key CSH key / table name
639 * @param string $field Sub key / field name
640 * @param boolean $anchors If anchors is to be shown.
641 * @return string HTML content
642 */
643 function printItem($key, $field, $anchors = FALSE) {
644 $out = '';
645
646 // Load full table definition in $GLOBALS['TCA']
647 t3lib_div::loadTCA($key);
648
649 if ($key && (!$field || is_array($GLOBALS['TCA_DESCR'][$key]['columns'][$field]))) {
650 // Make seeAlso references.
651 $seeAlsoRes = $this->make_seeAlso($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['seeAlso'], $anchors ? $key : '');
652
653 // Making item:
654 $out = '<a name="' . $key . '.' . $field . '"></a>' .
655 $this->headerLine($this->getTableFieldLabel($key, $field), 1) .
656 $this->prepareContent($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['description']) .
657 ($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['details'] ? $this->headerLine($GLOBALS['LANG']->getLL('details').':').$this->prepareContent($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['details']) : '') .
658 ($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['syntax'] ? $this->headerLine($GLOBALS['LANG']->getLL('syntax').':').$this->prepareContent($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['syntax']) : '') .
659 ($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['image'] ? $this->printImage($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['image'],$GLOBALS['TCA_DESCR'][$key]['columns'][$field]['image_descr']) : '') .
660 ($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['seeAlso'] && $seeAlsoRes ? $this->headerLine($GLOBALS['LANG']->getLL('seeAlso').':').'<p>'.$seeAlsoRes.'</p>' : '') .
661 ($this->back ? '<br /><p><a href="' . htmlspecialchars('view_help.php?tfID=' . rawurlencode($this->back)) . '" class="typo3-goBack">' . htmlspecialchars($GLOBALS['LANG']->getLL('goBack')) . '</a></p>' : '') .
662 '<br />';
663 }
664 return $out;
665 }
666
667 /**
668 * Prints a single $table/$field information piece
669 * If $anchors is set, then seeAlso references to the same table will be page-anchors, not links.
670 *
671 * @param string Table name
672 * @param string Field name
673 * @param boolean If anchors is to be shown.
674 * @return string HTML content
675 * @deprecated since TYPO3 4.5, this function will be removed in TYPO3 4.7. Use printItem() instead.
676 */
677 function printItemFlex() {
678 t3lib_div::logDeprecatedFunction();
679 // Get all texts
680 foreach (explode(',', 'description,details,syntax,image,image_descr,seeAlso') as $var) {
681 // Double $ below is not a error!
682 $$var = $GLOBALS['LANG']->sL($this->ffID['cshFile'] . ':' . $this->ffID['field'] . '.' . $var);
683 }
684 // Make seeAlso references.
685 $seeAlsoRes = $this->make_seeAlso($seeAlso);
686
687 // Making item:
688 $out= $this->headerLine($this->ffID['title'], 1) .
689 $this->prepareContent($description) .
690 ($details ? $this->headerLine($GLOBALS['LANG']->getLL('details').':') . $this->prepareContent($details) : '') .
691 ($syntax ? $this->headerLine($GLOBALS['LANG']->getLL('syntax').':') . $this->prepareContent($syntax) : '') .
692 ($image ? $this->printImage($image, $image_descr) : '') .
693 ($seeAlso && $seeAlsoRes ? $this->headerLine($GLOBALS['LANG']->getLL('seeAlso').':').'<p>'.$seeAlsoRes.'</p>' : '') .
694 '<br />';
695 return $out;
696 }
697
698 /**
699 * Returns labels for a given field in a given structure
700 *
701 * @param string $key CSH key / table name
702 * @param string $field Sub key / field name
703 * @return array Table and field labels in a numeric array
704 */
705 function getTableFieldNames($key, $field) {
706 $GLOBALS['LANG']->loadSingleTableDescription($key);
707
708 // Define the label for the key
709 $keyName = $key;
710 if (is_array($GLOBALS['TCA_DESCR'][$key]['columns']['']) && isset($GLOBALS['TCA_DESCR'][$key]['columns']['']['alttitle'])) {
711 // If there's an alternative title, use it
712 $keyName = $GLOBALS['TCA_DESCR'][$key]['columns']['']['alttitle'];
713 } elseif (isset($GLOBALS['TCA'][$key])) {
714 // Otherwise, if it's a table, use its title
715 $keyName = $GLOBALS['TCA'][$key]['ctrl']['title'];
716 } else {
717 // If no title was found, make sure to remove any "_MOD_"
718 $keyName = preg_replace('/^_MOD_/', '', $key);
719 }
720 // Define the label for the field
721 $fieldName = $field;
722 if (is_array($GLOBALS['TCA_DESCR'][$key]['columns'][$field]) && isset($GLOBALS['TCA_DESCR'][$key]['columns'][$field]['alttitle'])) {
723 // If there's an alternative title, use it
724 $fieldName = $GLOBALS['TCA_DESCR'][$key]['columns'][$field]['alttitle'];
725 } elseif (isset($GLOBALS['TCA'][$key]) && isset($GLOBALS['TCA'][$key]['columns'][$field])) {
726 // Otherwise, if it's a table, use its title
727 $fieldName = $GLOBALS['TCA'][$key]['columns'][$field]['label'];
728 }
729 return array($keyName, $fieldName);
730 }
731
732 /**
733 * Returns composite label for table/field
734 *
735 * @param string $key CSH key / table name
736 * @param string $field Sub key / field name
737 * @param string $mergeToken Token to merge the two strings with
738 * @return string Labels joined with merge token
739 * @see getTableFieldNames()
740 */
741 function getTableFieldLabel($key, $field = '', $mergeToken = ': ') {
742 $tableName = '';
743 $fieldName = '';
744
745 // Get table / field parts:
746 list($tableName, $fieldName) = $this->getTableFieldNames($key, $field);
747
748 // Create label:
749 $labelString = $GLOBALS['LANG']->sL($tableName) .
750 ($field ? $mergeToken . rtrim(trim($GLOBALS['LANG']->sL($fieldName)), ':') : '');
751
752 return $labelString;
753 }
754
755
756
757
758
759
760
761
762
763
764
765 /******************************
766 *
767 * Glossary related
768 *
769 ******************************/
770
771 /**
772 * Creates glossary index in $this->glossaryWords
773 * Glossary is cached in cache_hash cache and so will be updated only when cache is cleared.
774 *
775 * @return void
776 */
777 function createGlossaryIndex() {
778 // Create hash string and try to retrieve glossary array:
779 $hash = md5('typo3/view_help.php:glossary');
780 list($this->glossaryWords,$this->substWords) = unserialize(t3lib_BEfunc::getHash($hash));
781
782 // Generate glossary words if not found:
783 if (!is_array($this->glossaryWords)) {
784
785 // Initialize:
786 $this->glossaryWords = array();
787 $this->substWords = array();
788 $CSHkeys = array_flip(array_keys($GLOBALS['TCA_DESCR']));
789
790 // Glossary
791 foreach($CSHkeys as $cshKey => $value) {
792 if (t3lib_div::isFirstPartOfStr($cshKey, 'xGLOSSARY_') && !isset($GLOBALS['TCA'][$cshKey])) {
793 $GLOBALS['LANG']->loadSingleTableDescription($cshKey);
794
795 if (is_array($GLOBALS['TCA_DESCR'][$cshKey]['columns'])) {
796
797 // Traverse table columns as listed in TCA_DESCR
798 foreach ($GLOBALS['TCA_DESCR'][$cshKey]['columns'] as $field => $data) {
799 if ($field) {
800 $this->glossaryWords[$cshKey.'.'.$field] = array(
801 'title' => trim($data['alttitle'] ? $data['alttitle'] : $cshKey),
802 'description' => str_replace('%22','%23%23%23', rawurlencode($data['description'])),
803 );
804 }
805 }
806 }
807 }
808 }
809
810 // First, create unique list of words:
811 foreach($this->glossaryWords as $key => $value) {
812 $word = strtolower($value['title']); // Making word lowercase in order to filter out same words in different cases.
813
814 if ($word!=='') {
815 $this->substWords[$word] = $value;
816 $this->substWords[$word]['key'] = $key;
817 }
818 }
819
820 krsort($this->substWords);
821
822 t3lib_BEfunc::storeHash($hash,serialize(array($this->glossaryWords,$this->substWords)),'Glossary');
823 }
824 }
825
826 /**
827 * Processing of all non-HTML content in the output
828 * Will be done by a call-back to ->substituteGlossaryWords_htmlcleaner_callback()
829 *
830 * @param string Input HTML code
831 * @return string Output HTML code
832 */
833 function substituteGlossaryWords($code) {
834 $htmlParser = t3lib_div::makeInstance('local_t3lib_parsehtml');
835 $htmlParser->pObj = $this;
836 $code = $htmlParser->HTMLcleaner($code, array(), 1);
837
838 return $code;
839 }
840
841 /**
842 * Substituting glossary words in the CSH
843 * (This is a call-back function from "class local_t3lib_parsehtml extends t3lib_parsehtml", see top of this script)
844 *
845 * @param string Input HTML string
846 * @return string HTML with substituted words in.
847 * @coauthor alex widschwendter, media.res kommunikationsloesungen
848 */
849 function substituteGlossaryWords_htmlcleaner_callback($code) {
850 if (is_array($this->substWords) && count($this->substWords) && strlen(trim($code))) {
851
852 // Substitute words:
853 foreach($this->substWords as $wordKey => $wordSet) {
854 // quoteMeta used so special chars (which should not occur though) in words will not break the regex. Seemed to work (- kasper)
855 $parts = preg_split('/( |[\(])('.quoteMeta($wordSet['title']).')([\.\!\)\?\:\,]+| )/i', ' '.$code.' ', 2, PREG_SPLIT_DELIM_CAPTURE);
856 if (count($parts) == 5) {
857 $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))).'">'.
858 htmlspecialchars($parts[2]).
859 '</a>';
860 $code = substr(implode('',$parts),1,-1);
861
862 // Disable entry so it doesn't get used next time:
863 unset($this->substWords[$wordKey]);
864 }
865 }
866 $code = str_replace('###', '&quot;',rawurldecode($code));
867 }
868
869 return $code;
870 }
871
872 }
873
874
875
876 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/view_help.php'])) {
877 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/view_help.php']);
878 }
879
880
881
882 // Make instance:
883 $SOBE = t3lib_div::makeInstance('SC_view_help');
884 $SOBE->init();
885 $SOBE->main();
886 $SOBE->printContent();
887
888 ?>