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