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