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