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