view_help.php 20 KB
Newer Older
Kasper Skårhøj's avatar
Kasper Skårhøj committed
1
2
3
<?php
/***************************************************************
*  Copyright notice
4
*
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
5
*  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
Kasper Skårhøj's avatar
Kasper Skårhøj committed
6
7
*  All rights reserved
*
8
*  This script is part of the TYPO3 project. The TYPO3 project is
Kasper Skårhøj's avatar
Kasper Skårhøj committed
9
10
11
12
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
13
*
Kasper Skårhøj's avatar
Kasper Skårhøj committed
14
15
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
16
*  A copy is found in the textfile GPL.txt and important notices to the license
Kasper Skårhøj's avatar
Kasper Skårhøj committed
17
18
*  from the author is found in LICENSE.txt distributed with these scripts.
*
19
*
Kasper Skårhøj's avatar
Kasper Skårhøj committed
20
21
22
23
24
25
26
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
27
/**
Kasper Skårhøj's avatar
Kasper Skårhøj committed
28
29
30
 * Document for viewing the online help texts, also known as TCA_DESCR.
 * See Inside TYPO3 for details.
 *
31
 * $Id$
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
32
 * Revised for TYPO3 3.7 5/2004 by Kasper Skaarhoj
Kasper Skårhøj's avatar
Kasper Skårhøj committed
33
 * XHTML-trans compliant
34
 *
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
35
 * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
36
37
38
39
40
41
 */
/**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 *
 *
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
42
43
44
45
 *   88: class SC_view_help
 *  111:     function init()
 *  131:     function main()
 *  160:     function printContent()
46
 *
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
47
 *              SECTION: Rendering main modes
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
48
49
50
51
52
 *  183:     function render_TOC()
 *  292:     function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)
 *  324:     function render_TOC_makeTocList($tocArray)
 *  363:     function render_Table($table)
 *  420:     function render_Single($table,$field)
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
53
54
 *
 *              SECTION: Rendering CSH items
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
55
56
57
58
59
60
61
 *  463:     function make_seeAlso($value,$anchorTable='')
 *  512:     function printImage($images,$descr)
 *  547:     function headerLine($str,$type=0)
 *  568:     function prepareContent($str)
 *  583:     function printItem($table,$field,$anchors=0)
 *  616:     function getTableFieldNames($table,$field)
 *  639:     function getTableFieldLabel($table,$field='',$mergeToken=': ')
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
62
 *
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
63
 * TOTAL FUNCTIONS: 15
64
65
 * (This index is automatically created/updated by the extension "extdeveval")
 *
Kasper Skårhøj's avatar
Kasper Skårhøj committed
66
67
 */

Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
68
69
require('init.php');
require('template.php');
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
70
$LANG->includeLLFile('EXT:lang/locallang_view_help.xml');
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
71
require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
Kasper Skårhøj's avatar
Kasper Skårhøj committed
72
73


74
75
76
77
78
79
80
81







/**
82
 * 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.
83
 *
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
84
 * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
85
86
87
 * @package TYPO3
 * @subpackage core
 */
Kasper Skårhøj's avatar
Kasper Skårhøj committed
88
89
90
91
92
93
94
class SC_view_help {
	var $allowedHTML = '<strong><em><b><i>';

		// For these vars, see init()
	var $limitAccess;	// If set access to fields and tables is checked. Should be done for true database tables.
	var $table;			// The "table" key
	var $field;			// The "field" key
95

96
97
98
		// Internal, static: GPvar:
	var $tfID;			// Table/FIeld id.
	var $back;			// Back (previous tfID)
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
99
100
101
102
103
104
	var $renderALL;		// If set, then in TOC mode the FULL manual will be printed as well!

		// Internal, dynamic:
	var $content;	// Content accumulation.


105

Kasper Skårhøj's avatar
Kasper Skårhøj committed
106
	/**
107
	 * Initialize the class for various input etc.
108
109
	 *
	 * @return	void
Kasper Skårhøj's avatar
Kasper Skårhøj committed
110
111
	 */
	function init()	{
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
112
		global $LANG, $TCA;
113

114
			// Setting GPvars:
Kasper Skårhøj's avatar
Kasper Skårhøj committed
115
116
		$this->tfID = t3lib_div::_GP('tfID');
		$this->back = t3lib_div::_GP('back');
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
117
		$this->renderALL = t3lib_div::_GP('renderALL');
Kasper Skårhøj's avatar
Kasper Skårhøj committed
118
119

			// Set internal table/field to the parts of "tfID" incoming var.
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
120
		list($this->table,$this->field) = explode('.',$this->tfID);
121

Kasper Skårhøj's avatar
Kasper Skårhøj committed
122
			// limitAccess is checked if the $this->table really IS a table.
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
123
		$this->limitAccess = isset($TCA[$this->table]) ? TRUE : FALSE;
Kasper Skårhøj's avatar
Kasper Skårhøj committed
124
	}
125

Kasper Skårhøj's avatar
Kasper Skårhøj committed
126
	/**
127
	 * Main function, rendering the display
128
129
	 *
	 * @return	void
Kasper Skårhøj's avatar
Kasper Skårhøj committed
130
131
	 */
	function main()	{
132
		global $BE_USER,$LANG,$TCA_DESCR,$TCA,$TBE_TEMPLATE;
133

Kasper Skårhøj's avatar
Kasper Skårhøj committed
134
			// Start HTML output accumulation:
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
135
136
137
138
139
140
141
142
143
144
		$TBE_TEMPLATE->docType = 'xhtml_trans';
		$TBE_TEMPLATE->divClass = 'typo3-view-help';
		$this->content.= $TBE_TEMPLATE->startPage($LANG->getLL('title'));

		if ($this->field=='*')	{ // If ALL fields is supposed to be shown:
			$this->content.= $this->render_Table($this->table);
		} elseif ($this->tfID) { // ... otherwise show only single field:
			$this->content.= $this->render_Single($this->table,$this->field);
		} else {	// Render Table Of Contents if nothing else:
			$this->content.= $this->render_TOC();
Kasper Skårhøj's avatar
Kasper Skårhøj committed
145
146
147
		}

			// Print close-button:
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
148
#		$this->content.='<br /><form action=""><input type="submit" value="'.htmlspecialchars($LANG->getLL('close')).'" onclick="self.close(); return false;" /></form><br/>';
Kasper Skårhøj's avatar
Kasper Skårhøj committed
149
150

			// End page:
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
151
152
		$this->content.= '<br/>';
		$this->content.= $TBE_TEMPLATE->endPage();
Kasper Skårhøj's avatar
Kasper Skårhøj committed
153
	}
154

Kasper Skårhøj's avatar
Kasper Skårhøj committed
155
	/**
156
	 * Outputting the accumulated content to screen
157
158
	 *
	 * @return	void
Kasper Skårhøj's avatar
Kasper Skårhøj committed
159
160
161
162
	 */
	function printContent()	{
		echo $this->content;
	}
163

Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227








	/************************************
	 *
	 * Rendering main modes
	 *
	 ************************************/

	/**
	 * Creates Table Of Contents and possibly "Full Manual" mode if selected.
	 *
	 * @return	string		HTML content
	 */
	function render_TOC()	{
		global $TCA_DESCR,$TCA,$LANG,$BE_USER,$TBE_MODULES;

			// Initialize:
		$CSHkeys = array_flip(array_keys($TCA_DESCR));
		$TCAkeys = array_keys($TCA);

		$outputSections = array();
		$tocArray = array();


			// TYPO3 Core Features:
		$LANG->loadSingleTableDescription('xMOD_csh_corebe');
		$this->render_TOC_el('xMOD_csh_corebe', 'core', $outputSections, $tocArray, $CSHkeys);

			// Backend Modules:
		$loadModules = t3lib_div::makeInstance('t3lib_loadModules');
		$loadModules->load($TBE_MODULES);
		foreach($loadModules->modules as $mainMod => $info)	{
			$cshKey = '_MOD_'.$mainMod;
			if ($CSHkeys[$cshKey])	{
				$LANG->loadSingleTableDescription($cshKey);
				$this->render_TOC_el($cshKey, 'modules', $outputSections, $tocArray, $CSHkeys);
			}

			if (is_array($info['sub']))	{
				foreach($info['sub'] as $subMod => $subInfo)	{
					$cshKey = '_MOD_'.$mainMod.'_'.$subMod;
					if ($CSHkeys[$cshKey])	{
						$LANG->loadSingleTableDescription($cshKey);
						$this->render_TOC_el($cshKey, 'modules', $outputSections, $tocArray, $CSHkeys);
					}
				}
			}
		}

			// Database Tables:
		foreach($TCAkeys as $table)	{
				// Load descriptions for table $table
			$LANG->loadSingleTableDescription($table);
			if (is_array($TCA_DESCR[$table]['columns']) && $BE_USER->check('tables_select',$table))	{
				$this->render_TOC_el($table, 'tables', $outputSections, $tocArray, $CSHkeys);
			}
		}

Kasper Skårhøj's avatar
Kasper Skårhøj committed
228
229
230
231
232
233
234
235
			// Extensions
		foreach($CSHkeys as $cshKey => $value)	{
			if (t3lib_div::isFirstPartOfStr($cshKey, 'xEXT_') && !isset($TCA[$cshKey]))	{
				$LANG->loadSingleTableDescription($cshKey);
				$this->render_TOC_el($cshKey, 'extensions', $outputSections, $tocArray, $CSHkeys);
			}
		}

Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
			// Other:
		foreach($CSHkeys as $cshKey => $value)	{
			if (!t3lib_div::isFirstPartOfStr($cshKey, '_MOD_') && !isset($TCA[$cshKey]))	{
				$LANG->loadSingleTableDescription($cshKey);
				$this->render_TOC_el($cshKey, 'other', $outputSections, $tocArray, $CSHkeys);
			}
		}


			// COMPILE output:
		$output = '';
		$output.= '

			<h1>'.$LANG->getLL('manual_title',1).'</h1>
			<p>'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';

		$output.= '

			<h1>'.$LANG->getLL('introduction',1).'</h1>
			<p>'.$LANG->getLL('description',1).'</p>';

		$output.= '

			<h1>'.$LANG->getLL('TOC',1).'</h1>'.
			$this->render_TOC_makeTocList($tocArray);

		if (!$this->renderALL)	{
		$output.= '
				<br/>
				<p class="c-nav"><a href="view_help.php?renderALL=1">'.$LANG->getLL('full_manual',1).'</a></p>';
		}

		if ($this->renderALL)	{
			$output.= '

				<h1>'.$LANG->getLL('full_manual_chapters',1).'</h1>'.
				implode('


				<!-- NEW SECTION: -->
				',$outputSections);
		}

		return $output;
	}

	/**
	 * Creates a TOC list element and renders corresponding HELP content if "renderALL" mode is set.
	 *
	 * @param	string		CSH key / Table name
	 * @param	string		TOC category keyword: "core", "modules", "tables", "other"
	 * @param	array		Array for accumulation of rendered HELP Content (in "renderALL" mode). Passed by reference!
	 * @param	array		TOC array; Here TOC index elements are created. Passed by reference!
	 * @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!
	 * @return	void
	 */
	function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)	{
		global $LANG;

		if ($this->renderALL)	{	// Render full manual right here!
			$outputSections[$table] = $this->render_Table($table);

			if ($outputSections[$table])	{
				$outputSections[$table] = '

		<!-- New CSHkey/Table: '.$table.' -->
		<p class="c-nav"><a name="ANCHOR_'.$table.'" href="#">'.$LANG->getLL('to_top',1).'</a></p>
		<h2>'.$this->getTableFieldLabel($table).'</h2>

		'.$outputSections[$table];
				$tocArray[$tocCat][$table] = '<a href="#ANCHOR_'.$table.'">'.$this->getTableFieldLabel($table).'</a>';
			} else {
				unset($outputSections[$table]);
			}
		} else {	// Only TOC:
			$tocArray[$tocCat][$table] = '<p><a href="view_help.php?tfID='.rawurlencode($table.'.*').'">'.$this->getTableFieldLabel($table).'</a></p>';
		}

			// Unset CSH key:
		unset($CSHkeys[$table]);
	}

	/**
	 * Renders the TOC index as a HTML bullet list from TOC array
	 *
	 * @param	array		ToC Array.
	 * @return	string		HTML bullet list for index.
	 */
	function render_TOC_makeTocList($tocArray)	{
		global $LANG;

			// The Various manual sections:
Kasper Skårhøj's avatar
Kasper Skårhøj committed
328
		$keys = explode(',', 'core,modules,tables,extensions,other');
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455

			// Create TOC bullet list:
		$output = '';
		foreach($keys as $tocKey)	{
			if (is_array($tocArray[$tocKey]))	{
				$output.='
					<li>'.$LANG->getLL('TOC_'.$tocKey,1).'
						<ul>
							<li>'.implode('</li>
							<li>',$tocArray[$tocKey]).'</li>
						</ul>
					</li>';
			}
		}

			// Compile TOC:
		$output = '

			<!-- TOC: -->
			<div class="c-toc">
				<ul>
				'.$output.'
				</ul>
			</div>';

		return $output;
	}

	/**
	 * Render CSH for a full cshKey/table
	 *
	 * @param	string		CSH key / table name
	 * @return	string		HTML output
	 */
	function render_Table($table)	{
		global $BE_USER,$TCA_DESCR,$TCA,$LANG;

		$output = '';

			// Load table TCA
		t3lib_div::loadTCA($table);

			// Load descriptions for table $table
		$LANG->loadSingleTableDescription($table);

		if (is_array($TCA_DESCR[$table]['columns']) && (!$this->limitAccess || $BE_USER->check('tables_select',$table)))	{
				// Initialize variables:
			$parts = array();
			$parts[0] = '';	// Reserved for header of table

				// Traverse table columns as listed in TCA_DESCR
			reset($TCA_DESCR[$table]['columns']);
			while(list($field) = each($TCA_DESCR[$table]['columns']))	{

				$fieldValue = isset($TCA[$table]) && strcmp($field,'') ? $TCA[$table]['columns'][$field] : array();

				if (is_array($fieldValue) && (!$this->limitAccess || !$fieldValue['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)))	{
					if (!$field)	{
						$parts[0] = $this->printItem($table,'',1);	// Header
					} else {
						$parts[] = $this->printItem($table,$field,1);	// Field
					}
				}
			}

			if (!strcmp($parts,''))	unset($parts[0]);
			$output.= implode('<br />',$parts);
		}

			// TOC link:
		if (!$this->renderALL)	{
			$tocLink = '<p class="c-nav"><a href="view_help.php">'.$LANG->getLL('goToToc',1).'</a></p>';

			$output =
				$tocLink.'
				<br/>'.
				$output.'
				<br />'.
				$tocLink;
		}

		return $output;
	}

	/**
	 * Renders CSH for a single field.
	 *
	 * @param	string		CSH key / table name
	 * @param	string		Sub key / field name
	 * @return	string		HTML output
	 */
	function render_Single($table,$field)	{
		global $LANG, $TCA;

		$output = '';

			// Load descriptions for table $table
		$LANG->loadSingleTableDescription($table);

			// Render single item:
		$output.= $this->printItem($table,$field);

			// Link to Full table description and TOC:
		$getLLKey = $this->limitAccess ? 'fullDescription' : 'fullDescription_module';
		$output.= '<br />
			<p class="c-nav"><a href="view_help.php?tfID='.rawurlencode($table.'.*').'">'.$LANG->getLL($getLLKey,1).'</a></p>
			<p class="c-nav"><a href="view_help.php">'.$LANG->getLL('goToToc',1).'</a></p>';

		return $output;
	}











	/************************************
	 *
	 * Rendering CSH items
	 *
	 ************************************/

Kasper Skårhøj's avatar
Kasper Skårhøj committed
456
457
	/**
	 * Make seeAlso links from $value
458
	 *
459
460
461
	 * @param	string		See-also input codes
	 * @param	string		If $anchorTable is set to a tablename, then references to this table will be made as anchors, not URLs.
	 * @return	string		See-also links HTML
Kasper Skårhøj's avatar
Kasper Skårhøj committed
462
463
	 */
	function make_seeAlso($value,$anchorTable='')	{
Kasper Skårhøj's avatar
Kasper Skårhøj committed
464
465
		global $TCA,$BE_USER,$TCA_DESCR;

Kasper Skårhøj's avatar
Kasper Skårhøj committed
466
467
			// Split references by comma, vert.line or linebreak
		$items = split(',|'.chr(10),$value);
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
468
469
470
		$lines = array();

		foreach($items as $val)	{
Kasper Skårhøj's avatar
Kasper Skårhøj committed
471
472
473
474
475
476
			$val = trim($val);
			if ($val)	{
				$iP = explode(':',$val);
				$iPUrl = t3lib_div::trimExplode('|',$val);
					// URL reference:
				if (substr($iPUrl[1],0,4)=='http')	{
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
477
					$lines[] = '<a href="'.htmlspecialchars($iPUrl[1]).'" target="_blank"><em>'.htmlspecialchars($iPUrl[0]).'</em></a>';
Kasper Skårhøj's avatar
Kasper Skårhøj committed
478
479
480
481
482
483
				} elseif (substr($iPUrl[1],0,5)=='FILE:')	{
					$fileName = t3lib_div::getFileAbsFileName(substr($iPUrl[1],5),1,1);
					if ($fileName && @is_file($fileName))	{
						$fileName = '../'.substr($fileName,strlen(PATH_site));
						$lines[] = '<a href="'.htmlspecialchars($fileName).'" target="_blank"><em>'.htmlspecialchars($iPUrl[0]).'</em></a>';
					}
Kasper Skårhøj's avatar
Kasper Skårhøj committed
484
				} else {
485
					// "table" reference
Kasper Skårhøj's avatar
Kasper Skårhøj committed
486
					t3lib_div::loadTCA($iP[0]);
Kasper Skårhøj's avatar
Kasper Skårhøj committed
487
488

					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:
Kasper Skårhøj's avatar
Kasper Skårhøj committed
489

Kasper Skårhøj's avatar
Kasper Skårhøj committed
490
491
492
493
494
495
496
497
							// Load table descriptions:
						#$LANG->loadSingleTableDescription($iP[0]);
						if (isset($TCA_DESCR[$iP[0]]))	{
								// Make see-also link:
							$href = ($this->renderALL || ($anchorTable && $iP[0]==$anchorTable) ? '#'.implode('.',$iP) : 'view_help.php?tfID='.rawurlencode(implode('.',$iP)).'&back='.$this->tfID);
							$label = $this->getTableFieldLabel($iP[0],$iP[1],' / ');
							$lines[] = '<a href="'.htmlspecialchars($href).'">'.htmlspecialchars($label).'</a>';
						}
Kasper Skårhøj's avatar
Kasper Skårhøj committed
498
499
500
501
502
503
					}
				}
			}
		}
		return implode('<br />',$lines);
	}
504

Kasper Skårhøj's avatar
Kasper Skårhøj committed
505
506
	/**
	 * Will return an image tag with description in italics.
507
	 *
Kasper Skårhøj's avatar
Kasper Skårhøj committed
508
509
	 * @param	string		Image file reference (list of)
	 * @param	string		Description string (divided for each image by line break)
510
	 * @return	string		Image HTML codes
Kasper Skårhøj's avatar
Kasper Skårhøj committed
511
	 */
Kasper Skårhøj's avatar
Kasper Skårhøj committed
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
	function printImage($images,$descr)	{
		$code = '';
			// Splitting:
		$imgArray = t3lib_div::trimExplode(',', $images, 1);
		if (count($imgArray))	{
			$descrArray = explode(chr(10),$descr,count($imgArray));
#debug($descrArray);
			foreach($imgArray as $k => $image)	{
				$descr = $descrArray[$k];

				$absImagePath = t3lib_div::getFileAbsFileName($image,1,1);
				if ($absImagePath && @is_file($absImagePath))	{
					$imgFile = substr($absImagePath,strlen(PATH_site));
					$imgInfo = @getimagesize($absImagePath);
					if (is_array($imgInfo))	{
						$imgFile = '../'.$imgFile;
Kasper Skårhøj's avatar
Kasper Skårhøj committed
528
						$code.= '<br /><img src="'.$imgFile.'" '.$imgInfo[3].' class="c-inlineimg" alt="" /><br />
Kasper Skårhøj's avatar
Kasper Skårhøj committed
529
						';
Kasper Skårhøj's avatar
Kasper Skårhøj committed
530
						$code.= '<p><em>'.$GLOBALS['LANG']->hscAndCharConv($descr,1).'</em></p>
Kasper Skårhøj's avatar
Kasper Skårhøj committed
531
						';
532
533
					} else $code.= '<div style="background-color: red; border: 1px solid black; color: white;">NOT AN IMAGE: '.$imgFile.'</div>';
				} else $code.= '<div style="background-color: red; border: 1px solid black; color: white;">IMAGE FILE NOT FOUND: '.$image.'</div>';
Kasper Skårhøj's avatar
Kasper Skårhøj committed
534
535
			}
		}
Kasper Skårhøj's avatar
Kasper Skårhøj committed
536
537

		return $code;
Kasper Skårhøj's avatar
Kasper Skårhøj committed
538
539
540
	}

	/**
541
	 * Returns header HTML content
542
	 *
543
544
545
	 * @param	string		Header text
	 * @param	string		Header type (1, 0)
	 * @return	string		The HTML for the header.
Kasper Skårhøj's avatar
Kasper Skårhøj committed
546
547
548
549
550
551
552
553
	 */
	function headerLine($str,$type=0)	{
		switch($type)	{
			case 1:
				$str='<h3>'.htmlspecialchars($str).'</h3>
				';
			break;
			case 0:
554
				$str='<h4 class="uppercase">'.htmlspecialchars($str).'</h4>
Kasper Skårhøj's avatar
Kasper Skårhøj committed
555
556
557
				';
			break;
		}
558

Kasper Skårhøj's avatar
Kasper Skårhøj committed
559
560
		return $str;
	}
561

Kasper Skårhøj's avatar
Kasper Skårhøj committed
562
563
	/**
	 * Returns prepared content
564
	 *
565
566
	 * @param	string		Content to format.
	 * @return	string		Formatted content.
Kasper Skårhøj's avatar
Kasper Skårhøj committed
567
568
569
570
571
572
	 */
	function prepareContent($str)	{
		$str = $GLOBALS['LANG']->hscAndCharConv($str,0);
		return '<p>'.nl2br(trim(strip_tags($str,$this->allowedHTML))).'</p>
		';
	}
573

Kasper Skårhøj's avatar
Kasper Skårhøj committed
574
575
576
	/**
	 * Prints a single $table/$field information piece
	 * If $anchors is set, then seeAlso references to the same table will be page-anchors, not links.
577
	 *
578
579
580
581
	 * @param	string		Table name
	 * @param	string		Field name
	 * @param	boolean		If anchors is to be shown.
	 * @return	string		HTML content
Kasper Skårhøj's avatar
Kasper Skårhøj committed
582
583
584
585
586
587
588
589
590
591
	 */
	function printItem($table,$field,$anchors=0)	{
		global $TCA_DESCR, $LANG, $TCA, $BE_USER;

			// Load full table definition in $TCA
		t3lib_div::loadTCA($table);

		if ($table && (!$field || is_array($TCA_DESCR[$table]['columns'][$field])))	{
				// Make seeAlso references.
			$seeAlsoRes = $this->make_seeAlso($TCA_DESCR[$table]['columns'][$field]['seeAlso'],$anchors?$table:'');
592

Kasper Skårhøj's avatar
Kasper Skårhøj committed
593
594
595
				// Making item:
			$out= '<a name="'.$table.'.'.$field.'"></a>
					'.
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
596
					$this->headerLine($this->getTableFieldLabel($table,$field),1).
Kasper Skårhøj's avatar
Kasper Skårhøj committed
597
598
599
600
601
					$this->prepareContent($TCA_DESCR[$table]['columns'][$field]['description']).
					($TCA_DESCR[$table]['columns'][$field]['details'] ? $this->headerLine($LANG->getLL('details').':').$this->prepareContent($TCA_DESCR[$table]['columns'][$field]['details']) : '').
					($TCA_DESCR[$table]['columns'][$field]['syntax'] ? $this->headerLine($LANG->getLL('syntax').':').$this->prepareContent($TCA_DESCR[$table]['columns'][$field]['syntax']) : '').
					($TCA_DESCR[$table]['columns'][$field]['image'] ? $this->printImage($TCA_DESCR[$table]['columns'][$field]['image'],$TCA_DESCR[$table]['columns'][$field]['image_descr']) : '').
					($TCA_DESCR[$table]['columns'][$field]['seeAlso'] && $seeAlsoRes ? $this->headerLine($LANG->getLL('seeAlso').':').'<p>'.$seeAlsoRes.'</p>' : '').
602
					($this->back ? '<br /><p><a href="'.htmlspecialchars('view_help.php?tfID='.rawurlencode($this->back)).'" class="typo3-goBack">'.htmlspecialchars($LANG->getLL('goBack')).'</a></p>' : '').
Kasper Skårhøj's avatar
Kasper Skårhøj committed
603
604
605
606
			'<br />';
		}
		return $out;
	}
607

Kasper Skårhøj's avatar
Kasper Skårhøj committed
608
609
610
	/**
	 * Returns labels for $table and $field.
	 * If $table is "_MOD_" prefixed, the part after "_MOD_" is returned (non-tables, fx. modules)
611
	 *
612
613
614
	 * @param	string		Table name
	 * @param	string		Field name
	 * @return	array		Table and field labels in a numeric array
Kasper Skårhøj's avatar
Kasper Skårhøj committed
615
616
	 */
	function getTableFieldNames($table,$field)	{
Kasper Skårhøj's avatar
Kasper Skårhøj committed
617
618
619
620
		global $TCA, $TCA_DESCR, $LANG;

			$LANG->loadSingleTableDescription($table);

621
622
			$tableName = is_array($TCA_DESCR[$table]['columns']['']) && $TCA_DESCR[$table]['columns']['']['alttitle'] ?
							$TCA_DESCR[$table]['columns']['']['alttitle'] :
Kasper Skårhøj's avatar
Kasper Skårhøj committed
623
							(isset($TCA[$table]) ? $TCA[$table]['ctrl']['title'] : ereg_replace('^_MOD_','',$table));
624
625
			$fieldName = is_array($TCA_DESCR[$table]['columns'][$field]) && $TCA_DESCR[$table]['columns'][$field]['alttitle'] ?
							$TCA_DESCR[$table]['columns'][$field]['alttitle'] :
Kasper Skårhøj's avatar
Kasper Skårhøj committed
626
627
628
							(isset($TCA[$table])&&isset($TCA[$table]['columns'][$field]) ? $TCA[$table]['columns'][$field]['label'] : $field);
		return array($tableName,$fieldName);
	}
Kasper Skårhøj's avatar
   
Kasper Skårhøj committed
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650

	/**
	 * Returns composite label for table/field
	 *
	 * @param	string		Table name
	 * @param	string		Field name
	 * @param	string		Token to merge the two strings with.
	 * @return	array		Table and field labels in a numeric array
	 * @see getTableFieldNames()
	 */
	function getTableFieldLabel($table,$field='',$mergeToken=': ')	{
		global $LANG;

			// Get table / field parts:
		list($tableName,$fieldName) = $this->getTableFieldNames($table,$field);

			// Create label:
		$labelStr = $LANG->sL($tableName).
					($field ? $mergeToken.ereg_replace(':$','', trim($LANG->sL($fieldName))):'');

		return $labelStr;
	}
Kasper Skårhøj's avatar
Kasper Skårhøj committed
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
}


// Include extension?
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/view_help.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/view_help.php']);
}






// Make instance:
$SOBE = t3lib_div::makeInstance('SC_view_help');
$SOBE->init();
$SOBE->main();
$SOBE->printContent();
?>