Documentation TYPO3 par Ameos

wizard_table.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00062 $BACK_PATH='';
00063 require ('init.php');
00064 require ('template.php');
00065 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml');
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00084 class SC_wizard_table {
00085 
00086                         // Internal, dynamic:
00087         var $doc;                                       // Document template object
00088         var $content;                           // Content accumulation for the module.
00089         var $include_once=array();      // List of files to include.
00090         var $inputStyle=0;                      // True, then <input> fields are shown, not textareas.
00091 
00092 
00093                 // Internal, static:
00094         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!
00095         var $numNewRows=1;                      // Number of new rows to add in bottom of wizard
00096         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)
00097 
00098 
00099                 // Internal, static: GPvars
00100         var $P;                                         // Wizard parameters, coming from TCEforms linking to the wizard.
00101         var $TABLECFG;                          // The array which is constantly submitted by the multidimensional form of this wizard.
00102 
00103                 // table parsing
00104         var $tableParsing_quote;                        // quoting of table cells
00105         var $tableParsing_delimiter;            // delimiter between table cells
00106 
00107 
00108 
00109 
00110 
00116         function init() {
00117                 global $BACK_PATH;
00118 
00119                         // GPvars:
00120                 $this->P = t3lib_div::_GP('P');
00121                 $this->TABLECFG = t3lib_div::_GP('TABLE');
00122 
00123                         // Setting options:
00124                 $this->xmlStorage = $this->P['params']['xmlOutput'];
00125                 $this->numNewRows = t3lib_div::intInRange($this->P['params']['numNewRows'],1,50,5);
00126 
00127                         // Textareas or input fields:
00128                 $this->inputStyle=isset($this->TABLECFG['textFields']) ? $this->TABLECFG['textFields'] : 1;
00129 
00130                         // Document template object:
00131                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00132                 $this->doc->docType = 'xhtml_trans';
00133                 $this->doc->backPath = $BACK_PATH;
00134                 $this->doc->JScode=$this->doc->wrapScriptTags('
00135                         function jumpToUrl(URL,formEl)  {       //
00136                                 window.location.href = URL;
00137                         }
00138                 ');
00139 
00140                         // Setting form tag:
00141                 list($rUri) = explode('#',t3lib_div::getIndpEnv('REQUEST_URI'));
00142                 $this->doc->form ='<form action="'.htmlspecialchars($rUri).'" method="post" name="wizardForm">';
00143 
00144                         // Start page:
00145                 $this->content.=$this->doc->startPage('Table');
00146 
00147                         // If save command found, include tcemain:
00148                 if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) {
00149                         $this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php';
00150                 }
00151                 
00152                 $this->tableParsing_delimiter = '|';
00153                 $this->tableParsing_quote = '';
00154         }
00155 
00161         function main() {
00162                 global $LANG;
00163 
00164                 if ($this->P['table'] && $this->P['field'] && $this->P['uid'])  {
00165                         $this->content.=$this->doc->section($LANG->getLL('table_title'),$this->tableWizard(),0,1);
00166                 } else {
00167                         $this->content.=$this->doc->section($LANG->getLL('table_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1);
00168                 }
00169         }
00170 
00176         function printContent() {
00177                 $this->content.= $this->doc->endPage();
00178                 $this->content = $this->doc->insertStylesAndJS($this->content);
00179                 echo $this->content;
00180         }
00181 
00187         function tableWizard()  {
00188 
00189                         // First, check the references by selecting the record:
00190                 $row = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']);
00191                 if (!is_array($row))    {
00192                         t3lib_BEfunc::typo3PrintError ('Wizard Error','No reference to record',0);
00193                         exit;
00194                 }
00195 
00196                         // 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.
00197                 $tableCfgArray = $this->getConfigCode($row);
00198 
00199                         // Generation of the Table Wizards HTML code:
00200                 $content = $this->getTableHTML($tableCfgArray,$row);
00201 
00202                         // Return content:
00203                 return $content;
00204         }
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212         /***************************
00213          *
00214          * Helper functions
00215          *
00216          ***************************/
00217 
00226         function getConfigCode($row)    {
00227 
00228                         // get delimiter settings
00229                 $flexForm = t3lib_div::xml2array($row['pi_flexform']);
00230         
00231                 if (is_array($flexForm)) {
00232                         $this->tableParsing_quote = $flexForm['data']['s_parsing']['lDEF']['tableparsing_quote']['vDEF']?chr(intval($flexForm['data']['s_parsing']['lDEF']['tableparsing_quote']['vDEF'])):'';
00233                         $this->tableParsing_delimiter = $flexForm['data']['s_parsing']['lDEF']['tableparsing_delimiter']['vDEF']?chr(intval($flexForm['data']['s_parsing']['lDEF']['tableparsing_delimiter']['vDEF'])):'|';
00234                 }
00235                 
00236                         // If some data has been submitted, then construct
00237                 if (isset($this->TABLECFG['c']))        {
00238 
00239                                 // Process incoming:
00240                         $this->changeFunc();
00241 
00242 
00243                                 // Convert to string (either line based or XML):
00244                         if ($this->xmlStorage)  {
00245                                         // Convert the input array to XML:
00246                                 $bodyText = t3lib_div::array2xml_cs($this->TABLECFG['c'],'T3TableWizard');
00247 
00248                                         // Setting cfgArr directly from the input:
00249                                 $cfgArr = $this->TABLECFG['c'];
00250                         } else {
00251                                         // Convert the input array to a string of configuration code:
00252                                 $bodyText = $this->cfgArray2CfgString($this->TABLECFG['c']);
00253 
00254                                         // Create cfgArr from the string based configuration - that way it is cleaned up and any incompatibilities will be removed!
00255                                 $cfgArr = $this->cfgString2CfgArray($bodyText,$row[$this->colsFieldName]);
00256                         }
00257 
00258                                 // If a save button has been pressed, then save the new field content:
00259                         if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) {
00260 
00261                                         // Make TCEmain object:
00262                                 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00263                                 $tce->stripslashes_values=0;
00264 
00265                                         // Put content into the data array:
00266                                 $data=array();
00267                                 $data[$this->P['table']][$this->P['uid']][$this->P['field']]=$bodyText;
00268 
00269                                         // Perform the update:
00270                                 $tce->start($data,array());
00271                                 $tce->process_datamap();
00272 
00273                                         // If the save/close button was pressed, then redirect the screen:
00274                                 if ($_POST['saveandclosedok_x'])        {
00275                                         header('Location: '.t3lib_div::locationHeaderUrl($this->P['returnUrl']));
00276                                         exit;
00277                                 }
00278                         }
00279                 } else {        // If nothing has been submitted, load the $bodyText variable from the selected database row:
00280                         if ($this->xmlStorage)  {
00281                                 $cfgArr = t3lib_div::xml2array($row[$this->P['field']]);
00282                         } else {        // Regular linebased table configuration:
00283                                 $cfgArr = $this->cfgString2CfgArray($row[$this->P['field']],$row[$this->colsFieldName]);
00284                         }
00285                         $cfgArr = is_array($cfgArr) ? $cfgArr : array();
00286                 }
00287 
00288                 return $cfgArr;
00289         }
00290 
00299         function getTableHTML($cfgArr,$row)     {
00300                 global $LANG;
00301 
00302                         // Traverse the rows:
00303                 $tRows=array();
00304                 $k=0;
00305                 foreach($cfgArr as $cellArr)    {
00306                         if (is_array($cellArr)) {
00307                                         // Initialize:
00308                                 $cells=array();
00309                                 $a=0;
00310 
00311                                         // Traverse the columns:
00312                                 foreach($cellArr as $cellContent)       {
00313                                         if ($this->inputStyle)  {
00314                                                 $cells[]='<input type="text"'.$this->doc->formWidth(20).' name="TABLE[c]['.(($k+1)*2).']['.(($a+1)*2).']" value="'.htmlspecialchars($cellContent).'" />';
00315                                         } else {
00316                                                 $cellContent=eregi_replace('<br[ ]?[\/]?>',chr(10),$cellContent);
00317                                                 $cells[]='<textarea '.$this->doc->formWidth(20).' rows="5" name="TABLE[c]['.(($k+1)*2).']['.(($a+1)*2).']">'.t3lib_div::formatForTextarea($cellContent).'</textarea>';
00318                                         }
00319 
00320                                                 // Increment counter:
00321                                         $a++;
00322                                 }
00323 
00324                                         // CTRL panel for a table row (move up/down/around):
00325                                 $onClick="document.wizardForm.action+='#ANC_".(($k+1)*2-2)."';";
00326                                 $onClick=' onclick="'.htmlspecialchars($onClick).'"';
00327                                 $ctrl='';
00328 
00329                                 $brTag=$this->inputStyle?'':'<br />';
00330                                 if ($k!=0)      {
00331                                         $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;
00332                                 } else {
00333                                         $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;
00334                                 }
00335                                 $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;
00336 
00337 // FIXME what is $tLines? See wizard_forms.php for the same.
00338                                 if (($k+1)!=count($tLines))     {
00339                                         $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;
00340                                 } else {
00341                                         $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;
00342                                 }
00343                                 $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;
00344 
00345                                 $tRows[]='
00346                                         <tr class="bgColor4">
00347                                                 <td class="bgColor5"><a name="ANC_'.(($k+1)*2).'"></a><span class="c-wizButtonsV">'.$ctrl.'</span></td>
00348                                                 <td>'.implode('</td>
00349                                                 <td>',$cells).'</td>
00350                                         </tr>';
00351 
00352                                         // Increment counter:
00353                                 $k++;
00354                         }
00355                 }
00356 
00357                         // CTRL panel for a table column (move left/right/around/delete)
00358                 $cells=array();
00359                 $cells[]='';
00360                         // Finding first row:
00361                 reset($cfgArr);
00362                 $firstRow=current($cfgArr);
00363                 if (is_array($firstRow))        {
00364 
00365                                 // Init:
00366                         $a=0;
00367                         $cols=count($firstRow);
00368 
00369                                 // Traverse first row:
00370                         foreach($firstRow as $temp)     {
00371                                 $ctrl='';
00372                                 if ($a!=0)      {
00373                                         $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).'" />';
00374                                 } else {
00375                                         $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).'" />';
00376                                 }
00377                                 $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).'" />';
00378                                 if (($a+1)!=$cols)      {
00379                                         $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).'" />';
00380                                 } else {
00381                                         $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).'" />';
00382                                 }
00383                                 $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).'" />';
00384                                 $cells[]='<span class="c-wizButtonsH">'.$ctrl.'</span>';
00385 
00386                                         // Incr. counter:
00387                                 $a++;
00388                         }
00389                         $tRows[]='
00390                                 <tr class="bgColor5">
00391                                         <td align="center">'.implode('</td>
00392                                         <td align="center">',$cells).'</td>
00393                                 </tr>';
00394                 }
00395 
00396                 $content = '';
00397 
00398                         // Add CSH:
00399                 $content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_table_wiz', $GLOBALS['BACK_PATH'],'');
00400 
00401                         // Implode all table rows into a string, wrapped in table tags.
00402                 $content.= '
00403 
00404 
00405                         <!--
00406                                 Table wizard
00407                         -->
00408                         <table border="0" cellpadding="0" cellspacing="1" id="typo3-tablewizard">
00409                                 '.implode('',$tRows).'
00410                         </table>';
00411 
00412                         // Add saving buttons in the bottom:
00413                 $content.= '
00414 
00415                         <!--
00416                                 Save buttons:
00417                         -->
00418                         <div id="c-saveButtonPanel">';
00419                 $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).'" />';
00420                 $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).'" />';
00421                 $content.= '<a href="#" onclick="'.htmlspecialchars('jumpToUrl(unescape(\''.rawurlencode($this->P['returnUrl']).'\')); return false;').'">'.
00422                                         '<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="" />'.
00423                                         '</a>';
00424                 $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).'" />';
00425                 $content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_table_wiz_buttons', $GLOBALS['BACK_PATH'],'');
00426                 $content.= '
00427                         </div>
00428                         ';
00429 
00430                         // Input type checkbox:
00431                 $content.= '
00432 
00433                         <!--
00434                                 Input mode check box:
00435                         -->
00436                         <div id="c-inputMode">
00437                                 '.
00438                                 '<input type="hidden" name="TABLE[textFields]" value="0" />'.
00439                                 '<input type="checkbox" name="TABLE[textFields]" id="textFields" value="1"'.($this->inputStyle?' checked="checked"':'').' /> <label for="textFields">'.
00440                                 $LANG->getLL('table_smallFields').'</label>
00441                         </div>
00442 
00443                         <br /><br />
00444                         ';
00445 
00446                         // Return content:
00447                 return $content;
00448         }
00449 
00456         function changeFunc()   {
00457                 if ($this->TABLECFG['col_remove'])      {
00458                         $kk = key($this->TABLECFG['col_remove']);
00459                         $cmd='col_remove';
00460                 } elseif ($this->TABLECFG['col_add'])   {
00461                         $kk = key($this->TABLECFG['col_add']);
00462                         $cmd='col_add';
00463                 } elseif ($this->TABLECFG['col_start']) {
00464                         $kk = key($this->TABLECFG['col_start']);
00465                         $cmd='col_start';
00466                 } elseif ($this->TABLECFG['col_end'])   {
00467                         $kk = key($this->TABLECFG['col_end']);
00468                         $cmd='col_end';
00469                 } elseif ($this->TABLECFG['col_left'])  {
00470                         $kk = key($this->TABLECFG['col_left']);
00471                         $cmd='col_left';
00472                 } elseif ($this->TABLECFG['col_right']) {
00473                         $kk = key($this->TABLECFG['col_right']);
00474                         $cmd='col_right';
00475                 } elseif ($this->TABLECFG['row_remove'])        {
00476                         $kk = key($this->TABLECFG['row_remove']);
00477                         $cmd='row_remove';
00478                 } elseif ($this->TABLECFG['row_add'])   {
00479                         $kk = key($this->TABLECFG['row_add']);
00480                         $cmd='row_add';
00481                 } elseif ($this->TABLECFG['row_top'])   {
00482                         $kk = key($this->TABLECFG['row_top']);
00483                         $cmd='row_top';
00484                 } elseif ($this->TABLECFG['row_bottom'])        {
00485                         $kk = key($this->TABLECFG['row_bottom']);
00486                         $cmd='row_bottom';
00487                 } elseif ($this->TABLECFG['row_up'])    {
00488                         $kk = key($this->TABLECFG['row_up']);
00489                         $cmd='row_up';
00490                 } elseif ($this->TABLECFG['row_down'])  {
00491                         $kk = key($this->TABLECFG['row_down']);
00492                         $cmd='row_down';
00493                 }
00494 
00495                 if ($cmd && t3lib_div::testInt($kk)) {
00496                         if (substr($cmd,0,4)=='row_')   {
00497                                 switch($cmd)    {
00498                                         case 'row_remove':
00499                                                 unset($this->TABLECFG['c'][$kk]);
00500                                         break;
00501                                         case 'row_add':
00502                                                 for($a=1;$a<=$this->numNewRows;$a++)    {
00503                                                         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.
00504                                                                 $this->TABLECFG['c'][$kk+$a] = array();
00505                                                         } else {
00506                                                                 break;
00507                                                         }
00508                                                 }
00509                                         break;
00510                                         case 'row_top':
00511                                                 $this->TABLECFG['c'][1]=$this->TABLECFG['c'][$kk];
00512                                                 unset($this->TABLECFG['c'][$kk]);
00513                                         break;
00514                                         case 'row_bottom':
00515                                                 $this->TABLECFG['c'][10000000]=$this->TABLECFG['c'][$kk];
00516                                                 unset($this->TABLECFG['c'][$kk]);
00517                                         break;
00518                                         case 'row_up':
00519                                                 $this->TABLECFG['c'][$kk-3]=$this->TABLECFG['c'][$kk];
00520                                                 unset($this->TABLECFG['c'][$kk]);
00521                                         break;
00522                                         case 'row_down':
00523                                                 $this->TABLECFG['c'][$kk+3]=$this->TABLECFG['c'][$kk];
00524                                                 unset($this->TABLECFG['c'][$kk]);
00525                                         break;
00526                                 }
00527                                 ksort($this->TABLECFG['c']);
00528                         }
00529                         if (substr($cmd,0,4)=='col_')   {
00530                                 reset($this->TABLECFG['c']);
00531                                 while(list($cAK)=each($this->TABLECFG['c']))    {
00532                                         switch($cmd)    {
00533                                                 case 'col_remove':
00534                                                         unset($this->TABLECFG['c'][$cAK][$kk]);
00535                                                 break;
00536                                                 case 'col_add':
00537                                                         $this->TABLECFG['c'][$cAK][$kk+1]='';
00538                                                 break;
00539                                                 case 'col_start':
00540                                                         $this->TABLECFG['c'][$cAK][1]=$this->TABLECFG['c'][$cAK][$kk];
00541                                                         unset($this->TABLECFG['c'][$cAK][$kk]);
00542                                                 break;
00543                                                 case 'col_end':
00544                                                         $this->TABLECFG['c'][$cAK][1000000]=$this->TABLECFG['c'][$cAK][$kk];
00545                                                         unset($this->TABLECFG['c'][$cAK][$kk]);
00546                                                 break;
00547                                                 case 'col_left':
00548                                                         $this->TABLECFG['c'][$cAK][$kk-3]=$this->TABLECFG['c'][$cAK][$kk];
00549                                                         unset($this->TABLECFG['c'][$cAK][$kk]);
00550                                                 break;
00551                                                 case 'col_right':
00552                                                         $this->TABLECFG['c'][$cAK][$kk+3]=$this->TABLECFG['c'][$cAK][$kk];
00553                                                         unset($this->TABLECFG['c'][$cAK][$kk]);
00554                                                 break;
00555                                         }
00556                                         ksort($this->TABLECFG['c'][$cAK]);
00557                                 }
00558                         }
00559                 }
00560 
00561                 // Convert line breaks to <br /> tags:
00562                 reset($this->TABLECFG['c']);
00563                 while(list($a)=each($this->TABLECFG['c']))      {
00564                         reset($this->TABLECFG['c'][$a]);
00565                         while(list($b)=each($this->TABLECFG['c'][$a]))  {
00566                                 $this->TABLECFG['c'][$a][$b] = str_replace(chr(10),'<br />',str_replace(chr(13),'',$this->TABLECFG['c'][$a][$b]));
00567                         }
00568                 }
00569         }
00570 
00578         function cfgArray2CfgString($cfgArr)    {
00579 
00580                         // Initialize:
00581                 $inLines=array();
00582 
00583                         // Traverse the elements of the table wizard and transform the settings into configuration code.
00584                 reset($this->TABLECFG['c']);
00585                 while(list($a)=each($this->TABLECFG['c']))      {
00586                         $thisLine=array();
00587                         reset($this->TABLECFG['c'][$a]);
00588                         while(list($b)=each($this->TABLECFG['c'][$a]))  {
00589                                 $thisLine[]=$this->tableParsing_quote.str_replace($this->tableParsing_delimiter,'',$this->TABLECFG['c'][$a][$b]).$this->tableParsing_quote;
00590                         }
00591                         $inLines[]=implode($this->tableParsing_delimiter,$thisLine);
00592                 }
00593 
00594                         // Finally, implode the lines into a string:
00595                 $bodyText = implode(chr(10),$inLines);
00596 
00597                         // Return the configuration code:
00598                 return $bodyText;
00599         }
00600 
00609         function cfgString2CfgArray($cfgStr,$cols)      {
00610 
00611                         // Explode lines in the configuration code - each line is a table row.
00612                 $tLines=explode(chr(10),$cfgStr);
00613 
00614                         // Setting number of columns
00615                 if (!$cols && trim($tLines[0])) {       // auto...
00616                         $cols = count(explode($this->tableParsing_delimiter,$tLines[0]));
00617                 }
00618                 $cols=$cols?$cols:4;
00619 
00620                         // Traverse the number of table elements:
00621                 $cfgArr=array();
00622                 foreach($tLines as $k => $v)    {
00623 
00624                                 // Initialize:
00625                         $vParts = explode($this->tableParsing_delimiter,$v);
00626 
00627                                 // Traverse columns:
00628                         for ($a=0;$a<$cols;$a++)        {
00629                                 if ($this->tableParsing_quote && substr($vParts[$a],0,1) == $this->tableParsing_quote && substr($vParts[$a],-1,1) == $this->tableParsing_quote) {
00630                                         $vParts[$a] = substr(trim($vParts[$a]),1,-1);
00631                                 }
00632                                 $cfgArr[$k][$a]=$vParts[$a];
00633                         }
00634                 }
00635 
00636                         // Return configuration array:
00637                 return $cfgArr;
00638         }
00639 }
00640 
00641 // Include extension?
00642 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_table.php'])  {
00643         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_table.php']);
00644 }
00645 
00646 
00647 
00648 
00649 
00650 
00651 
00652 
00653 
00654 
00655 
00656 
00657 // Make instance:
00658 $SOBE = t3lib_div::makeInstance('SC_wizard_table');
00659 $SOBE->init();
00660 
00661 // Include files?
00662 foreach($SOBE->include_once as $INC_FILE)       include_once($INC_FILE);
00663 
00664 $SOBE->main();
00665 $SOBE->printContent();
00666 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6