[TASK] Clean up phpDoc comments in typo3/
[Packages/TYPO3.CMS.git] / typo3 / wizard_table.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 * Wizard to help make tables (eg. for tt_content elements) of type "table".
29 * Each line is a table row, each cell divided by a |
30 *
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
32 * XHTML compliant
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36
37 $BACK_PATH = '';
38 require('init.php');
39 require('template.php');
40 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xml');
41
42 /**
43 * Script Class for rendering the Table Wizard
44 *
45 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
46 * @package TYPO3
47 * @subpackage core
48 */
49 class SC_wizard_table {
50
51 // Internal, dynamic:
52 /**
53 * document template object
54 *
55 * @var mediumDoc
56 */
57 var $doc;
58 // Content accumulation for the module.
59 var $content;
60 // List of files to include.
61 var $include_once = array();
62 // TRUE, then <input> fields are shown, not textareas.
63 var $inputStyle = 0;
64
65
66 // Internal, static:
67 // If set, the string version of the content is interpreted/written as XML
68 // instead of the original linebased kind. This variable still needs binding
69 // to the wizard parameters - but support is ready!
70 var $xmlStorage = 0;
71 // Number of new rows to add in bottom of wizard
72 var $numNewRows = 1;
73 // Name of field in parent record which MAY contain the number of columns for the table
74 // - here hardcoded to the value of tt_content. Should be set by TCEform parameters (from P)
75 var $colsFieldName = 'cols';
76
77 // Internal, static: GPvars
78 // Wizard parameters, coming from TCEforms linking to the wizard.
79 var $P;
80 // The array which is constantly submitted by the multidimensional form of this wizard.
81 var $TABLECFG;
82
83 // Table parsing
84 // quoting of table cells
85 var $tableParsing_quote;
86 // delimiter between table cells
87 var $tableParsing_delimiter;
88
89 /**
90 * Initialization of the class
91 *
92 * @return void
93 */
94 function init() {
95 // GPvars:
96 $this->P = t3lib_div::_GP('P');
97 $this->TABLECFG = t3lib_div::_GP('TABLE');
98
99 // Setting options:
100 $this->xmlStorage = $this->P['params']['xmlOutput'];
101 $this->numNewRows = t3lib_utility_Math::forceIntegerInRange($this->P['params']['numNewRows'], 1, 50, 5);
102
103 // Textareas or input fields:
104 $this->inputStyle = isset($this->TABLECFG['textFields']) ? $this->TABLECFG['textFields'] : 1;
105
106 // Document template object:
107 $this->doc = t3lib_div::makeInstance('template');
108 $this->doc->backPath = $GLOBALS['BACK_PATH'];
109 $this->doc->setModuleTemplate('templates/wizard_table.html');
110 $this->doc->JScode=$this->doc->wrapScriptTags('
111 function jumpToUrl(URL,formEl) { //
112 window.location.href = URL;
113 }
114 ');
115
116 // Setting form tag:
117 list($rUri) = explode('#', t3lib_div::getIndpEnv('REQUEST_URI'));
118 $this->doc->form ='<form action="'.htmlspecialchars($rUri).'" method="post" name="wizardForm">';
119
120 // If save command found, include tcemain:
121 if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) {
122 $this->include_once[] = PATH_t3lib.'class.t3lib_tcemain.php';
123 }
124
125 $this->tableParsing_delimiter = '|';
126 $this->tableParsing_quote = '';
127 }
128
129 /**
130 * Main function, rendering the table wizard
131 *
132 * @return void
133 */
134 function main() {
135 if ($this->P['table'] && $this->P['field'] && $this->P['uid']) {
136 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('table_title'), $this->tableWizard(), 0, 1);
137 } else {
138 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('table_title'), '<span class="typo3-red">' . $GLOBALS['LANG']->getLL('table_noData', 1) . '</span>', 0, 1);
139 }
140
141 // Setting up the buttons and markers for docheader
142 $docHeaderButtons = $this->getButtons();
143 $markers['CSH'] = $docHeaderButtons['csh'];
144 $markers['CONTENT'] = $this->content;
145
146 // Build the <body> for the module
147 $this->content = $this->doc->startPage('Table');
148 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
149 $this->content .= $this->doc->endPage();
150 $this->content = $this->doc->insertStylesAndJS($this->content);
151 }
152
153 /**
154 * Outputting the accumulated content to screen
155 *
156 * @return void
157 */
158 function printContent() {
159 echo $this->content;
160 }
161
162 /**
163 * Create the panel of buttons for submitting the form or otherwise perform operations.
164 *
165 * @return array All available buttons as an assoc. array
166 */
167 protected function getButtons() {
168 $buttons = array(
169 'csh' => '',
170 'csh_buttons' => '',
171 'close' => '',
172 'save' => '',
173 'save_close' => '',
174 'reload' => '',
175 );
176
177 if ($this->P['table'] && $this->P['field'] && $this->P['uid']) {
178 // CSH
179 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_table_wiz', $GLOBALS['BACK_PATH'], '');
180
181 // CSH Buttons
182 $buttons['csh_buttons'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_table_wiz_buttons', $GLOBALS['BACK_PATH'], '');
183
184 // Close
185 $buttons['close'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(unescape(\'' . rawurlencode(t3lib_div::sanitizeLocalUrl($this->P['returnUrl'])) . '\')); return false;') . '">' .
186 t3lib_iconWorks::getSpriteIcon('actions-document-close', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', TRUE))) .
187 '</a>';
188
189 // Save
190 $buttons['save'] = '<input type="image" class="c-inputButton" name="savedok"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/savedok.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" />';
191
192 // Save & Close
193 $buttons['save_close'] = '<input type="image" class="c-inputButton" name="saveandclosedok"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/saveandclosedok.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc', 1) . '" />';
194
195 // Reload
196 $buttons['reload'] = '<input type="image" class="c-inputButton" name="_refresh"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/refresh_n.gif') . ' title="' . $GLOBALS['LANG']->getLL('forms_refresh', 1) . '" />';
197 }
198
199 return $buttons;
200 }
201
202 /**
203 * Draws the table wizard content
204 *
205 * @return string HTML content for the form.
206 */
207 function tableWizard() {
208
209 // First, check the references by selecting the record:
210 $row = t3lib_BEfunc::getRecord($this->P['table'], $this->P['uid']);
211 if (!is_array($row)) {
212 throw new RuntimeException('Wizard Error: No reference to record', 1294587125);
213 }
214
215 // This will get the content of the form configuration code field to us - possibly cleaned up,
216 // saved to database etc. if the form has been submitted in the meantime.
217 $tableCfgArray = $this->getConfigCode($row);
218
219 // Generation of the Table Wizards HTML code:
220 $content = $this->getTableHTML($tableCfgArray, $row);
221
222 // Return content:
223 return $content;
224 }
225
226 /***************************
227 *
228 * Helper functions
229 *
230 ***************************/
231
232 /**
233 * Will get and return the configuration code string
234 * Will also save (and possibly redirect/exit) the content if a save button has been pressed
235 *
236 * @param array $row Current parent record row
237 * @return array Table config code in an array
238 * @access private
239 */
240 function getConfigCode($row) {
241
242 // Get delimiter settings
243 $flexForm = t3lib_div::xml2array($row['pi_flexform']);
244
245 if (is_array($flexForm)) {
246 $this->tableParsing_quote = $flexForm['data']['s_parsing']['lDEF']['tableparsing_quote']['vDEF']?chr(intval($flexForm['data']['s_parsing']['lDEF']['tableparsing_quote']['vDEF'])):'';
247 $this->tableParsing_delimiter = $flexForm['data']['s_parsing']['lDEF']['tableparsing_delimiter']['vDEF']?chr(intval($flexForm['data']['s_parsing']['lDEF']['tableparsing_delimiter']['vDEF'])):'|';
248 }
249
250 // If some data has been submitted, then construct
251 if (isset($this->TABLECFG['c'])) {
252
253 // Process incoming:
254 $this->changeFunc();
255
256 // Convert to string (either line based or XML):
257 if ($this->xmlStorage) {
258 // Convert the input array to XML:
259 $bodyText = t3lib_div::array2xml_cs($this->TABLECFG['c'], 'T3TableWizard');
260
261 // Setting cfgArr directly from the input:
262 $cfgArr = $this->TABLECFG['c'];
263 } else {
264 // Convert the input array to a string of configuration code:
265 $bodyText = $this->cfgArray2CfgString($this->TABLECFG['c']);
266
267 // Create cfgArr from the string based configuration - that way it is cleaned up and any incompatibilities will be removed!
268 $cfgArr = $this->cfgString2CfgArray($bodyText, $row[$this->colsFieldName]);
269 }
270
271 // If a save button has been pressed, then save the new field content:
272 if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) {
273
274 // Make TCEmain object:
275 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
276 $tce->stripslashes_values=0;
277
278 // Put content into the data array:
279 $data = array();
280 $data[$this->P['table']][$this->P['uid']][$this->P['field']] = $bodyText;
281
282 // Perform the update:
283 $tce->start($data, array());
284 $tce->process_datamap();
285
286 // If the save/close button was pressed, then redirect the screen:
287 if ($_POST['saveandclosedok_x']) {
288 t3lib_utility_Http::redirect(t3lib_div::sanitizeLocalUrl($this->P['returnUrl']));
289 }
290 }
291 } else { // If nothing has been submitted, load the $bodyText variable from the selected database row:
292 if ($this->xmlStorage) {
293 $cfgArr = t3lib_div::xml2array($row[$this->P['field']]);
294 } else { // Regular linebased table configuration:
295 $cfgArr = $this->cfgString2CfgArray($row[$this->P['field']], $row[$this->colsFieldName]);
296 }
297 $cfgArr = is_array($cfgArr) ? $cfgArr : array();
298 }
299
300 return $cfgArr;
301 }
302
303 /**
304 * Creates the HTML for the Table Wizard:
305 *
306 * @param array $cfgArr Table config array
307 * @param array $row Current parent record array
308 * @return string HTML for the table wizard
309 * @access private
310 */
311 function getTableHTML($cfgArr, $row) {
312 // Traverse the rows:
313 $tRows = array();
314 $k = 0;
315 foreach ($cfgArr as $cellArr) {
316 if (is_array($cellArr)) {
317 // Initialize:
318 $cells = array();
319 $a = 0;
320
321 // Traverse the columns:
322 foreach ($cellArr as $cellContent) {
323 if ($this->inputStyle) {
324 $cells[] = '<input type="text"'.$this->doc->formWidth(20).' name="TABLE[c]['.(($k+1)*2).']['.(($a+1)*2).']" value="'.htmlspecialchars($cellContent).'" />';
325 } else {
326 $cellContent = preg_replace('/<br[ ]?[\/]?>/i', LF, $cellContent);
327 $cells[] = '<textarea '.$this->doc->formWidth(20).' rows="5" name="TABLE[c]['.(($k+1)*2).']['.(($a+1)*2).']">'.t3lib_div::formatForTextarea($cellContent).'</textarea>';
328 }
329
330 // Increment counter:
331 $a++;
332 }
333
334 // CTRL panel for a table row (move up/down/around):
335 $onClick = "document.wizardForm.action+='#ANC_".(($k+1)*2-2)."';";
336 $onClick = ' onclick="'.htmlspecialchars($onClick).'"';
337 $ctrl = '';
338
339 $brTag = $this->inputStyle?'':'<br />';
340 if ($k != 0) {
341 $ctrl .= '<input type="image" name="TABLE[row_up]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2up.gif', '').$onClick.' title="'.$GLOBALS['LANG']->getLL('table_up', 1).'" />'.$brTag;
342 } else {
343 $ctrl .= '<input type="image" name="TABLE[row_bottom]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_up.gif', '').$onClick.' title="'.$GLOBALS['LANG']->getLL('table_bottom', 1).'" />'.$brTag;
344 }
345 $ctrl .= '<input type="image" name="TABLE[row_remove]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/garbage.gif', '').$onClick.' title="'.$GLOBALS['LANG']->getLL('table_removeRow', 1).'" />'.$brTag;
346
347 // FIXME what is $tLines? See wizard_forms.php for the same.
348 if (($k+1) != count($tLines)) {
349 $ctrl .= '<input type="image" name="TABLE[row_down]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2down.gif', '').$onClick.' title="'.$GLOBALS['LANG']->getLL('table_down', 1).'" />'.$brTag;
350 } else {
351 $ctrl .= '<input type="image" name="TABLE[row_top]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_down.gif', '').$onClick.' title="'.$GLOBALS['LANG']->getLL('table_top', 1).'" />'.$brTag;
352 }
353 $ctrl .= '<input type="image" name="TABLE[row_add]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/add.gif', '').$onClick.' title="'.$GLOBALS['LANG']->getLL('table_addRow', 1).'" />'.$brTag;
354
355 $tRows[] = '
356 <tr class="bgColor4">
357 <td class="bgColor5"><a name="ANC_'.(($k+1)*2).'"></a><span class="c-wizButtonsV">'.$ctrl.'</span></td>
358 <td>' . implode('</td>
359 <td>', $cells) . '</td>
360 </tr>';
361
362 // Increment counter:
363 $k++;
364 }
365 }
366
367 // CTRL panel for a table column (move left/right/around/delete)
368 $cells = array();
369 $cells[] = '';
370 // Finding first row:
371 $firstRow = reset($cfgArr);
372 if (is_array($firstRow)) {
373
374 // Init:
375 $a = 0;
376 $cols = count($firstRow);
377
378 // Traverse first row:
379 foreach ($firstRow as $temp) {
380 $ctrl = '';
381 if ($a != 0) {
382 $ctrl .= '<input type="image" name="TABLE[col_left]['.(($a+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2left.gif', '').' title="'.$GLOBALS['LANG']->getLL('table_left', 1).'" />';
383 } else {
384 $ctrl .= '<input type="image" name="TABLE[col_end]['.(($a+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_left.gif', '').' title="'.$GLOBALS['LANG']->getLL('table_end', 1).'" />';
385 }
386 $ctrl .= '<input type="image" name="TABLE[col_remove]['.(($a+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/garbage.gif', '').' title="'.$GLOBALS['LANG']->getLL('table_removeColumn', 1).'" />';
387 if (($a+1) != $cols) {
388 $ctrl .= '<input type="image" name="TABLE[col_right]['.(($a+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2right.gif', '').' title="'.$GLOBALS['LANG']->getLL('table_right', 1).'" />';
389 } else {
390 $ctrl .= '<input type="image" name="TABLE[col_start]['.(($a+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_right.gif', '').' title="'.$GLOBALS['LANG']->getLL('table_start', 1).'" />';
391 }
392 $ctrl .= '<input type="image" name="TABLE[col_add]['.(($a+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/add.gif', '').' title="'.$GLOBALS['LANG']->getLL('table_addColumn', 1).'" />';
393 $cells[] = '<span class="c-wizButtonsH">'.$ctrl.'</span>';
394
395 // Incr. counter:
396 $a++;
397 }
398 $tRows[] = '
399 <tr class="bgColor5">
400 <td align="center">' . implode('</td>
401 <td align="center">', $cells) . '</td>
402 </tr>';
403 }
404
405 $content = '';
406
407 // Implode all table rows into a string, wrapped in table tags.
408 $content .= '
409
410
411 <!--
412 Table wizard
413 -->
414 <table border="0" cellpadding="0" cellspacing="1" id="typo3-tablewizard">
415 '.implode('', $tRows).'
416 </table>';
417
418 // Input type checkbox:
419 $content .= '
420
421 <!--
422 Input mode check box:
423 -->
424 <div id="c-inputMode">
425 '.
426 '<input type="hidden" name="TABLE[textFields]" value="0" />'.
427 '<input type="checkbox" name="TABLE[textFields]" id="textFields" value="1"'.($this->inputStyle?' checked="checked"':'').' /> <label for="textFields">'.
428 $GLOBALS['LANG']->getLL('table_smallFields').'</label>
429 </div>
430
431 <br /><br />
432 ';
433
434 // Return content:
435 return $content;
436 }
437
438 /**
439 * Detects if a control button (up/down/around/delete) has been pressed for an item and accordingly it will manipulate the internal TABLECFG array
440 *
441 * @return void
442 * @access private
443 */
444 function changeFunc() {
445 if ($this->TABLECFG['col_remove']) {
446 $kk = key($this->TABLECFG['col_remove']);
447 $cmd = 'col_remove';
448 } elseif ($this->TABLECFG['col_add']) {
449 $kk = key($this->TABLECFG['col_add']);
450 $cmd = 'col_add';
451 } elseif ($this->TABLECFG['col_start']) {
452 $kk = key($this->TABLECFG['col_start']);
453 $cmd = 'col_start';
454 } elseif ($this->TABLECFG['col_end']) {
455 $kk = key($this->TABLECFG['col_end']);
456 $cmd = 'col_end';
457 } elseif ($this->TABLECFG['col_left']) {
458 $kk = key($this->TABLECFG['col_left']);
459 $cmd = 'col_left';
460 } elseif ($this->TABLECFG['col_right']) {
461 $kk = key($this->TABLECFG['col_right']);
462 $cmd = 'col_right';
463 } elseif ($this->TABLECFG['row_remove']) {
464 $kk = key($this->TABLECFG['row_remove']);
465 $cmd = 'row_remove';
466 } elseif ($this->TABLECFG['row_add']) {
467 $kk = key($this->TABLECFG['row_add']);
468 $cmd = 'row_add';
469 } elseif ($this->TABLECFG['row_top']) {
470 $kk = key($this->TABLECFG['row_top']);
471 $cmd = 'row_top';
472 } elseif ($this->TABLECFG['row_bottom']) {
473 $kk = key($this->TABLECFG['row_bottom']);
474 $cmd = 'row_bottom';
475 } elseif ($this->TABLECFG['row_up']) {
476 $kk = key($this->TABLECFG['row_up']);
477 $cmd = 'row_up';
478 } elseif ($this->TABLECFG['row_down']) {
479 $kk = key($this->TABLECFG['row_down']);
480 $cmd = 'row_down';
481 }
482
483 if ($cmd && t3lib_utility_Math::canBeInterpretedAsInteger($kk)) {
484 if (substr($cmd, 0, 4) == 'row_') {
485 switch($cmd) {
486 case 'row_remove':
487 unset($this->TABLECFG['c'][$kk]);
488 break;
489 case 'row_add':
490 for ($a = 1; $a <= $this->numNewRows; $a++) {
491 // Checking if set: The point is that any new row inbetween existing rows
492 // will be TRUE after one row is added while if rows are added in the bottom
493 // of the table there will be no existing rows to stop the addition of new rows
494 // which means it will add up to $this->numNewRows rows then.
495 if (!isset($this->TABLECFG['c'][$kk+$a])) {
496 $this->TABLECFG['c'][$kk+$a] = array();
497 } else {
498 break;
499 }
500 }
501 break;
502 case 'row_top':
503 $this->TABLECFG['c'][1]=$this->TABLECFG['c'][$kk];
504 unset($this->TABLECFG['c'][$kk]);
505 break;
506 case 'row_bottom':
507 $this->TABLECFG['c'][10000000]=$this->TABLECFG['c'][$kk];
508 unset($this->TABLECFG['c'][$kk]);
509 break;
510 case 'row_up':
511 $this->TABLECFG['c'][$kk-3]=$this->TABLECFG['c'][$kk];
512 unset($this->TABLECFG['c'][$kk]);
513 break;
514 case 'row_down':
515 $this->TABLECFG['c'][$kk+3]=$this->TABLECFG['c'][$kk];
516 unset($this->TABLECFG['c'][$kk]);
517 break;
518 }
519 ksort($this->TABLECFG['c']);
520 }
521 if (substr($cmd, 0, 4)=='col_') {
522 foreach ($this->TABLECFG['c'] as $cAK => $value) {
523 switch($cmd) {
524 case 'col_remove':
525 unset($this->TABLECFG['c'][$cAK][$kk]);
526 break;
527 case 'col_add':
528 $this->TABLECFG['c'][$cAK][$kk+1] = '';
529 break;
530 case 'col_start':
531 $this->TABLECFG['c'][$cAK][1]=$this->TABLECFG['c'][$cAK][$kk];
532 unset($this->TABLECFG['c'][$cAK][$kk]);
533 break;
534 case 'col_end':
535 $this->TABLECFG['c'][$cAK][1000000]=$this->TABLECFG['c'][$cAK][$kk];
536 unset($this->TABLECFG['c'][$cAK][$kk]);
537 break;
538 case 'col_left':
539 $this->TABLECFG['c'][$cAK][$kk-3]=$this->TABLECFG['c'][$cAK][$kk];
540 unset($this->TABLECFG['c'][$cAK][$kk]);
541 break;
542 case 'col_right':
543 $this->TABLECFG['c'][$cAK][$kk+3]=$this->TABLECFG['c'][$cAK][$kk];
544 unset($this->TABLECFG['c'][$cAK][$kk]);
545 break;
546 }
547 ksort($this->TABLECFG['c'][$cAK]);
548 }
549 }
550 }
551
552 // Convert line breaks to <br /> tags:
553 foreach ($this->TABLECFG['c'] as $a => $value) {
554 foreach ($this->TABLECFG['c'][$a] as $b => $value2) {
555 $this->TABLECFG['c'][$a][$b] = str_replace(LF, '<br />', str_replace(CR, '', $this->TABLECFG['c'][$a][$b]));
556 }
557 }
558 }
559
560 /**
561 * Converts the input array to a configuration code string
562 *
563 * @param array $cfgArr Array of table configuration (follows the input structure from the table wizard POST form)
564 * @return string The array converted into a string with line-based configuration.
565 * @see cfgString2CfgArray()
566 */
567 function cfgArray2CfgString($cfgArr) {
568
569 // Initialize:
570 $inLines=array();
571
572 // Traverse the elements of the table wizard and transform the settings into configuration code.
573 foreach ($this->TABLECFG['c'] as $a => $value) {
574 $thisLine = array();
575 foreach ($this->TABLECFG['c'][$a] as $b => $value) {
576 $thisLine[] = $this->tableParsing_quote.str_replace($this->tableParsing_delimiter, '', $this->TABLECFG['c'][$a][$b]).$this->tableParsing_quote;
577 }
578 $inLines[] = implode($this->tableParsing_delimiter, $thisLine);
579 }
580
581 // Finally, implode the lines into a string:
582 $bodyText = implode(LF, $inLines);
583
584 // Return the configuration code:
585 return $bodyText;
586 }
587
588 /**
589 * Converts the input configuration code string into an array
590 *
591 * @param string $cfgStr Configuration code
592 * @param integer $cols Default number of columns
593 * @return array Configuration array
594 * @see cfgArray2CfgString()
595 */
596 function cfgString2CfgArray($cfgStr, $cols) {
597
598 // Explode lines in the configuration code - each line is a table row.
599 $tLines = explode(LF, $cfgStr);
600
601 // Setting number of columns
602 // auto...
603 if (!$cols && trim($tLines[0])) {
604 $cols = count(explode($this->tableParsing_delimiter, $tLines[0]));
605 }
606 $cols = $cols ? $cols : 4;
607
608 // Traverse the number of table elements:
609 $cfgArr = array();
610 foreach ($tLines as $k => $v) {
611
612 // Initialize:
613 $vParts = explode($this->tableParsing_delimiter, $v);
614
615 // Traverse columns:
616 for ($a = 0; $a < $cols; $a++) {
617 if ($this->tableParsing_quote && substr($vParts[$a], 0, 1) == $this->tableParsing_quote && substr($vParts[$a], -1, 1) == $this->tableParsing_quote) {
618 $vParts[$a] = substr(trim($vParts[$a]), 1, -1);
619 }
620 $cfgArr[$k][$a] = $vParts[$a];
621 }
622 }
623
624 // Return configuration array:
625 return $cfgArr;
626 }
627 }
628
629 // Make instance:
630 $SOBE = t3lib_div::makeInstance('SC_wizard_table');
631 $SOBE->init();
632
633 // Include files?
634 foreach($SOBE->include_once as $INC_FILE) {
635 include_once($INC_FILE);
636 }
637
638 $SOBE->main();
639 $SOBE->printContent();
640
641 ?>