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