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