Documentation TYPO3 par Ameos |
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 ***************************************************************/ 00063 $BACK_PATH=''; 00064 require ('init.php'); 00065 require ('template.php'); 00066 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml'); 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00175 class SC_wizard_forms { 00176 00177 // Internal, dynamic: 00178 var $doc; // Document template object 00179 var $content; // Content accumulation for the module. 00180 var $include_once=array(); // List of files to include. 00181 var $attachmentCounter = 0; // Used to numerate attachments automatically. 00182 00183 00184 // Internal, static: 00185 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! 00186 00187 00188 // Internal, static: GPvars 00189 var $P; // Wizard parameters, coming from TCEforms linking to the wizard. 00190 var $FORMCFG; // The array which is constantly submitted by the multidimensional form of this wizard. 00191 var $special; // Indicates if the form is of a dedicated type, like "formtype_mail" (for tt_content element "Form") 00192 00193 00194 00195 00196 00197 00203 function init() { 00204 global $BACK_PATH; 00205 00206 // GPvars: 00207 $this->P = t3lib_div::_GP('P'); 00208 $this->special = t3lib_div::_GP('special'); 00209 $this->FORMCFG = t3lib_div::_GP('FORMCFG'); 00210 00211 // Setting options: 00212 $this->xmlStorage = $this->P['params']['xmlOutput']; 00213 00214 // Document template object: 00215 $this->doc = t3lib_div::makeInstance('mediumDoc'); 00216 $this->doc->docType = 'xhtml_trans'; 00217 $this->doc->backPath = $BACK_PATH; 00218 $this->doc->JScode=$this->doc->wrapScriptTags(' 00219 function jumpToUrl(URL,formEl) { // 00220 document.location = URL; 00221 } 00222 '); 00223 00224 // Setting form tag: 00225 list($rUri) = explode('#',t3lib_div::getIndpEnv('REQUEST_URI')); 00226 $this->doc->form ='<form action="'.htmlspecialchars($rUri).'" method="post" name="wizardForm">'; 00227 00228 // Start page: 00229 $this->content=$this->doc->startPage('Form Wizard'); 00230 00231 // If save command found, include tcemain: 00232 if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) { 00233 $this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php'; 00234 } 00235 } 00236 00242 function main() { 00243 global $LANG; 00244 00245 if ($this->P['table'] && $this->P['field'] && $this->P['uid']) { 00246 $this->content.=$this->doc->section($LANG->getLL('forms_title'),$this->formsWizard(),0,1); 00247 } else { 00248 $this->content.=$this->doc->section($LANG->getLL('forms_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1); 00249 } 00250 $this->content.=$this->doc->endPage(); 00251 } 00252 00258 function printContent() { 00259 echo $this->content; 00260 } 00261 00267 function formsWizard() { 00268 00269 // First, check the references by selecting the record: 00270 $row=t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']); 00271 if (!is_array($row)) { 00272 t3lib_BEfunc::typo3PrintError ('Wizard Error','No reference to record',0); 00273 exit; 00274 } 00275 00276 // 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. 00277 $formCfgArray = $this->getConfigCode($row); 00278 00279 // Generation of the Form Wizards HTML code: 00280 $content = $this->getFormHTML($formCfgArray,$row); 00281 00282 // Return content: 00283 return $content; 00284 } 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 /**************************** 00297 * 00298 * Helper functions 00299 * 00300 ***************************/ 00301 00310 function getConfigCode(&$row) { 00311 00312 // If some data has been submitted, then construct 00313 if (isset($this->FORMCFG['c'])) { 00314 00315 // Process incoming: 00316 $this->changeFunc(); 00317 00318 // Convert to string (either line based or XML): 00319 if ($this->xmlStorage) { 00320 // Convert the input array to XML: 00321 $bodyText = t3lib_div::array2xml($this->FORMCFG['c'],'',0,'T3FormWizard'); 00322 00323 // Setting cfgArr directly from the input: 00324 $cfgArr = $this->FORMCFG['c']; 00325 } else { 00326 // Convert the input array to a string of configuration code: 00327 $bodyText = $this->cfgArray2CfgString($this->FORMCFG['c']); 00328 00329 // Create cfgArr from the string based configuration - that way it is cleaned up and any incompatibilities will be removed! 00330 $cfgArr = $this->cfgString2CfgArray($bodyText); 00331 } 00332 00333 // If a save button has been pressed, then save the new field content: 00334 if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) { 00335 00336 // Make TCEmain object: 00337 $tce = t3lib_div::makeInstance('t3lib_TCEmain'); 00338 $tce->stripslashes_values=0; 00339 00340 // Put content into the data array: 00341 $data=array(); 00342 $data[$this->P['table']][$this->P['uid']][$this->P['field']]=$bodyText; 00343 if ($this->special=='formtype_mail') { 00344 $data[$this->P['table']][$this->P['uid']]['subheader']=$this->FORMCFG['recipient']; 00345 } 00346 00347 // Perform the update: 00348 $tce->start($data,array()); 00349 $tce->process_datamap(); 00350 00351 // Re-load the record content: 00352 $row = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']); 00353 00354 // If the save/close button was pressed, then redirect the screen: 00355 if ($_POST['saveandclosedok_x']) { 00356 header('Location: '.t3lib_div::locationHeaderUrl($this->P['returnUrl'])); 00357 exit; 00358 } 00359 } 00360 } else { // If nothing has been submitted, load the $bodyText variable from the selected database row: 00361 if ($this->xmlStorage) { 00362 $cfgArr = t3lib_div::xml2array($row[$this->P['field']]); 00363 } else { // Regular linebased form configuration: 00364 $cfgArr = $this->cfgString2CfgArray($row[$this->P['field']]); 00365 } 00366 $cfgArr = is_array($cfgArr) ? $cfgArr : array(); 00367 } 00368 00369 // Return configuration code: 00370 return $cfgArr; 00371 } 00372 00381 function getFormHTML($formCfgArray,$row) { 00382 global $LANG; 00383 00384 // Initialize variables: 00385 $specParts=array(); 00386 $hiddenFields=array(); 00387 $tRows=array(); 00388 00389 // Set header row: 00390 $cells=array($LANG->getLL('forms_preview',1).':', 00391 $LANG->getLL('forms_element',1).':', 00392 $LANG->getLL('forms_config',1).':', 00393 ); 00394 $tRows[]=' 00395 <tr class="bgColor2" id="typo3-formWizardHeader"> 00396 <td> </td> 00397 <td>'.implode('</td> 00398 <td>',$cells).'</td> 00399 </tr>'; 00400 00401 // Traverse the number of form elements: 00402 $k=0; 00403 foreach($formCfgArray as $confData) { 00404 00405 // Initialize: 00406 $cells=array(); 00407 00408 // If there is a configuration line which is active, then render it: 00409 if (!isset($confData['comment'])) { 00410 00411 // Special parts: 00412 if ($this->special=='formtype_mail' && t3lib_div::inList('formtype_mail,subject,html_enabled',$confData['fieldname'])) { 00413 $specParts[$confData['fieldname']] = $confData['default']; 00414 } else { 00415 00416 // Render title/field preview COLUMN 00417 $cells[]=$confData['type']!='hidden' ? '<strong>'.htmlspecialchars($confData['label']).'</strong>' : ''; 00418 00419 00420 // Render general type/title COLUMN: 00421 $temp_cells=array(); 00422 00423 // Field type selector: 00424 $opt=array(); 00425 $opt[]='<option value=""></option>'; 00426 $types = explode(',','input,textarea,select,check,radio,password,file,hidden,submit,property,label'); 00427 foreach($types as $t) { 00428 $opt[]=' 00429 <option value="'.$t.'"'.($confData['type']==$t?' selected="selected"':'').'>'.$LANG->getLL('forms_type_'.$t,1).'</option>'; 00430 } 00431 $temp_cells[$LANG->getLL('forms_type')]=' 00432 <select name="FORMCFG[c]['.(($k+1)*2).'][type]"> 00433 '.implode(' 00434 ',$opt).' 00435 </select>'; 00436 00437 // Title field: 00438 if (!t3lib_div::inList('hidden,submit',$confData['type'])) { 00439 $temp_cells[$LANG->getLL('forms_label')]='<input type="text"'.$this->doc->formWidth(15).' name="FORMCFG[c]['.(($k+1)*2).'][label]" value="'.htmlspecialchars($confData['label']).'" />'; 00440 } 00441 00442 // Required checkbox: 00443 if (!t3lib_div::inList('check,hidden,submit,label',$confData['type'])) { 00444 $temp_cells[$LANG->getLL('forms_required')]='<input type="checkbox" name="FORMCFG[c]['.(($k+1)*2).'][required]" value="1"'.($confData['required']?' checked="checked"':'').' title="'.$LANG->getLL('forms_required',1).'" />'; 00445 } 00446 00447 // Put sub-items together into table cell: 00448 $cells[]=$this->formatCells($temp_cells); 00449 00450 00451 // Render specific field configuration COLUMN: 00452 $temp_cells=array(); 00453 00454 // Fieldname 00455 if ($this->special=='formtype_mail' && $confData['type']=='file') { 00456 $confData['fieldname'] = 'attachment'.(++$this->attachmentCounter); 00457 } 00458 if (!t3lib_div::inList('label',$confData['type'])) { 00459 $temp_cells[$LANG->getLL('forms_fieldName')]='<input type="text"'.$this->doc->formWidth(10).' name="FORMCFG[c]['.(($k+1)*2).'][fieldname]" value="'.htmlspecialchars($confData['fieldname']).'" title="'.$LANG->getLL('forms_fieldName',1).'" />'; 00460 } 00461 00462 // Field configuration depending on the fields type: 00463 switch((string)$confData['type']) { 00464 case 'textarea': 00465 $temp_cells[$LANG->getLL('forms_cols')]='<input type="text"'.$this->doc->formWidth(5).' name="FORMCFG[c]['.(($k+1)*2).'][cols]" value="'.htmlspecialchars($confData['cols']).'" title="'.$LANG->getLL('forms_cols',1).'" />'; 00466 $temp_cells[$LANG->getLL('forms_rows')]='<input type="text"'.$this->doc->formWidth(5).' name="FORMCFG[c]['.(($k+1)*2).'][rows]" value="'.htmlspecialchars($confData['rows']).'" title="'.$LANG->getLL('forms_rows',1).'" />'; 00467 $temp_cells[$LANG->getLL('forms_extra')]='<input type="checkbox" name="FORMCFG[c]['.(($k+1)*2).'][extra]" value="OFF"'.($confData['extra']=='OFF'?' checked="checked"':'').' title="'.$LANG->getLL('forms_extra',1).'" />'; 00468 break; 00469 case 'input': 00470 case 'password': 00471 $temp_cells[$LANG->getLL('forms_size')]='<input type="text"'.$this->doc->formWidth(5).' name="FORMCFG[c]['.(($k+1)*2).'][size]" value="'.htmlspecialchars($confData['size']).'" title="'.$LANG->getLL('forms_size',1).'" />'; 00472 $temp_cells[$LANG->getLL('forms_max')]='<input type="text"'.$this->doc->formWidth(5).' name="FORMCFG[c]['.(($k+1)*2).'][max]" value="'.htmlspecialchars($confData['max']).'" title="'.$LANG->getLL('forms_max',1).'" />'; 00473 break; 00474 case 'file': 00475 $temp_cells[$LANG->getLL('forms_size')]='<input type="text"'.$this->doc->formWidth(5).' name="FORMCFG[c]['.(($k+1)*2).'][size]" value="'.htmlspecialchars($confData['size']).'" title="'.$LANG->getLL('forms_size',1).'" />'; 00476 break; 00477 case 'select': 00478 $temp_cells[$LANG->getLL('forms_size')]='<input type="text"'.$this->doc->formWidth(5).' name="FORMCFG[c]['.(($k+1)*2).'][size]" value="'.htmlspecialchars($confData['size']).'" title="'.$LANG->getLL('forms_size',1).'" />'; 00479 $temp_cells[$LANG->getLL('forms_autosize')]='<input type="checkbox" name="FORMCFG[c]['.(($k+1)*2).'][autosize]" value="1"'.($confData['autosize']?' checked="checked"':'').' title="'.$LANG->getLL('forms_autosize',1).'" />'; 00480 $temp_cells[$LANG->getLL('forms_multiple')]='<input type="checkbox" name="FORMCFG[c]['.(($k+1)*2).'][multiple]" value="1"'.($confData['multiple']?' checked="checked"':'').' title="'.$LANG->getLL('forms_multiple',1).'" />'; 00481 break; 00482 } 00483 00484 // Field configuration depending on the fields type: 00485 switch((string)$confData['type']) { 00486 case 'textarea': 00487 case 'input': 00488 case 'password': 00489 if (strlen(trim($confData['specialEval']))) { 00490 $hiddenFields[] = '<input type="hidden" name="FORMCFG[c]['.(($k+1)*2).'][specialEval]" value="'.htmlspecialchars($confData['specialEval']).'" />'; 00491 } 00492 break; 00493 } 00494 00495 // Default data 00496 if ($confData['type']=='select' || $confData['type']=='radio') { 00497 $temp_cells[$LANG->getLL('forms_options')]='<textarea '.$this->doc->formWidthText(15).' rows="4" name="FORMCFG[c]['.(($k+1)*2).'][options]" title="'.$LANG->getLL('forms_options',1).'">'.t3lib_div::formatForTextarea($confData['default']).'</textarea>'; 00498 } elseif ($confData['type']=='check') { 00499 $temp_cells[$LANG->getLL('forms_checked')]='<input type="checkbox" name="FORMCFG[c]['.(($k+1)*2).'][default]" value="1"'.(trim($confData['default'])?' checked="checked"':'').' title="'.$LANG->getLL('forms_checked',1).'" />'; 00500 } elseif ($confData['type'] && $confData['type']!='file') { 00501 $temp_cells[$LANG->getLL('forms_default')]='<input type="text"'.$this->doc->formWidth(15).' name="FORMCFG[c]['.(($k+1)*2).'][default]" value="'.htmlspecialchars($confData['default']).'" title="'.$LANG->getLL('forms_default',1).'" />'; 00502 } 00503 00504 $cells[]=$confData['type']?$this->formatCells($temp_cells):''; 00505 00506 // CTRL panel for an item (move up/down/around): 00507 $ctrl=''; 00508 $onClick="document.wizardForm.action+='#ANC_".(($k+1)*2-2)."';"; 00509 $onClick=' onclick="'.htmlspecialchars($onClick).'"'; 00510 00511 $brTag=$inputStyle?'':'<br />'; 00512 if ($k!=0) { 00513 $ctrl.='<input type="image" name="FORMCFG[row_up]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/pil2up.gif','').$onClick.' title="'.$LANG->getLL('table_up',1).'" />'.$brTag; 00514 } else { 00515 $ctrl.='<input type="image" name="FORMCFG[row_bottom]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/turn_up.gif','').$onClick.' title="'.$LANG->getLL('table_bottom',1).'" />'.$brTag; 00516 } 00517 $ctrl.='<input type="image" name="FORMCFG[row_remove]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/garbage.gif','').$onClick.' title="'.$LANG->getLL('table_removeRow',1).'" />'.$brTag; 00518 if (($k+1)!=count($tLines)) { 00519 $ctrl.='<input type="image" name="FORMCFG[row_down]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/pil2down.gif','').$onClick.' title="'.$LANG->getLL('table_down',1).'" />'.$brTag; 00520 } else { 00521 $ctrl.='<input type="image" name="FORMCFG[row_top]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/turn_down.gif','').$onClick.' title="'.$LANG->getLL('table_top',1).'" />'.$brTag; 00522 } 00523 $ctrl.='<input type="image" name="FORMCFG[row_add]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/add.gif','').$onClick.' title="'.$LANG->getLL('table_addRow',1).'" />'.$brTag; 00524 00525 $ctrl='<span class="c-wizButtonsV">'.$ctrl.'</span>'; 00526 00527 // Finally, put together the full row from the generated content above: 00528 $bgC = $confData['type']?' class="bgColor5"':''; 00529 $tRows[]=' 00530 <tr'.$bgC.'> 00531 <td><a name="ANC_'.(($k+1)*2).'"></a>'.$ctrl.'</td> 00532 <td class="bgColor4">'.implode('</td> 00533 <td valign="top">',$cells).'</td> 00534 </tr>'; 00535 } 00536 } else { 00537 $hiddenFields[]='<input type="hidden" name="FORMCFG[c]['.(($k+1)*2).'][comment]" value="'.htmlspecialchars($confData['comment']).'" />'; 00538 } 00539 00540 // Increment counter: 00541 $k++; 00542 } 00543 00544 // If the form is of the special type "formtype_mail" (used for tt_content elements): 00545 if ($this->special=='formtype_mail') { 00546 00547 // Blank spacer: 00548 $tRows[]=' 00549 <tr> 00550 <td colspan="4"> </td> 00551 </tr>'; 00552 00553 // Header: 00554 $tRows[]=' 00555 <tr> 00556 <td colspan="2" class="bgColor2"> </td> 00557 <td colspan="2" class="bgColor2"><strong>'.$LANG->getLL('forms_special_eform',1).':</strong>'. 00558 t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz_formmail_info', $GLOBALS['BACK_PATH'],''). 00559 '</td> 00560 </tr>'; 00561 00562 // "FORM type": 00563 $tRows[]=' 00564 <tr class="bgColor5"> 00565 <td> </td> 00566 <td class="bgColor4"> </td> 00567 <td>'.$LANG->getLL('forms_eform_formtype_mail',1).':</td> 00568 <td> 00569 <input type="hidden" name="FORMCFG[c]['.(1000*2).'][fieldname]" value="formtype_mail" /> 00570 <input type="hidden" name="FORMCFG[c]['.(1000*2).'][type]" value="submit" /> 00571 <input type="text"'.$this->doc->formWidth(15).' name="FORMCFG[c]['.(1000*2).'][default]" value="'.htmlspecialchars($specParts['formtype_mail']).'" /> 00572 </td> 00573 </tr>'; 00574 00575 // "Send HTML mail": 00576 $tRows[]=' 00577 <tr class="bgColor5"> 00578 <td> </td> 00579 <td class="bgColor4"> </td> 00580 <td>'.$LANG->getLL('forms_eform_html_enabled',1).':</td> 00581 <td> 00582 <input type="hidden" name="FORMCFG[c]['.(1001*2).'][fieldname]" value="html_enabled" /> 00583 <input type="hidden" name="FORMCFG[c]['.(1001*2).'][type]" value="hidden" /> 00584 <input type="checkbox" name="FORMCFG[c]['.(1001*2).'][default]" value="1"'.($specParts['html_enabled']?' checked="checked"':'').' /> 00585 </td> 00586 </tr>'; 00587 00588 // "Subject": 00589 $tRows[]=' 00590 <tr class="bgColor5"> 00591 <td> </td> 00592 <td class="bgColor4"> </td> 00593 <td>'.$LANG->getLL('forms_eform_subject',1).':</td> 00594 <td> 00595 <input type="hidden" name="FORMCFG[c]['.(1002*2).'][fieldname]" value="subject" /> 00596 <input type="hidden" name="FORMCFG[c]['.(1002*2).'][type]" value="hidden" /> 00597 <input type="text"'.$this->doc->formWidth(15).' name="FORMCFG[c]['.(1002*2).'][default]" value="'.htmlspecialchars($specParts['subject']).'" /> 00598 </td> 00599 </tr>'; 00600 00601 // Recipient: 00602 $tRows[]=' 00603 <tr class="bgColor5"> 00604 <td> </td> 00605 <td class="bgColor4"> </td> 00606 <td>'.$LANG->getLL('forms_eform_recipient',1).':</td> 00607 <td> 00608 <input type="text"'.$this->doc->formWidth(15).' name="FORMCFG[recipient]" value="'.htmlspecialchars($row['subheader']).'" /> 00609 </td> 00610 </tr>'; 00611 } 00612 00613 $content = ''; 00614 00615 // Add CSH: 00616 $content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz', $GLOBALS['BACK_PATH'],''); 00617 00618 // Implode all table rows into a string, wrapped in table tags. 00619 $content.= ' 00620 00621 <!-- 00622 Form wizard 00623 --> 00624 <table border="0" cellpadding="1" cellspacing="1" id="typo3-formwizard"> 00625 '.implode('',$tRows).' 00626 </table>'; 00627 00628 // Add saving buttons in the bottom: 00629 $content.= ' 00630 00631 <!-- 00632 Save buttons: 00633 --> 00634 <div id="c-saveButtonPanel">'; 00635 $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).'" />'; 00636 $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).'" />'; 00637 $content.= '<a href="#" onclick="'.htmlspecialchars('jumpToUrl(unescape(\''.rawurlencode($this->P['returnUrl']).'\')); return false;').'">'. 00638 '<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="" />'. 00639 '</a>'; 00640 $content.= '<input type="image" class="c-inputButton" name="_refresh"'.t3lib_iconWorks::skinImg('','gfx/refresh_n.gif','').' title="'.$LANG->getLL('forms_refresh',1).'" />'; 00641 // Add CSH: 00642 $content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz_buttons', $GLOBALS['BACK_PATH'],''); 00643 $content.= ' 00644 </div> 00645 '; 00646 00647 // Add hidden fields: 00648 $content.= implode('',$hiddenFields); 00649 00650 // Return content: 00651 return $content; 00652 } 00653 00660 function changeFunc() { 00661 if ($this->FORMCFG['row_remove']) { 00662 $kk = key($this->FORMCFG['row_remove']); 00663 $cmd='row_remove'; 00664 } elseif ($this->FORMCFG['row_add']) { 00665 $kk = key($this->FORMCFG['row_add']); 00666 $cmd='row_add'; 00667 } elseif ($this->FORMCFG['row_top']) { 00668 $kk = key($this->FORMCFG['row_top']); 00669 $cmd='row_top'; 00670 } elseif ($this->FORMCFG['row_bottom']) { 00671 $kk = key($this->FORMCFG['row_bottom']); 00672 $cmd='row_bottom'; 00673 } elseif ($this->FORMCFG['row_up']) { 00674 $kk = key($this->FORMCFG['row_up']); 00675 $cmd='row_up'; 00676 } elseif ($this->FORMCFG['row_down']) { 00677 $kk = key($this->FORMCFG['row_down']); 00678 $cmd='row_down'; 00679 } 00680 00681 if ($cmd && t3lib_div::testInt($kk)) { 00682 if (substr($cmd,0,4)=='row_') { 00683 switch($cmd) { 00684 case 'row_remove': 00685 unset($this->FORMCFG['c'][$kk]); 00686 break; 00687 case 'row_add': 00688 $this->FORMCFG['c'][$kk+1]=array(); 00689 break; 00690 case 'row_top': 00691 $this->FORMCFG['c'][1]=$this->FORMCFG['c'][$kk]; 00692 unset($this->FORMCFG['c'][$kk]); 00693 break; 00694 case 'row_bottom': 00695 $this->FORMCFG['c'][1000000]=$this->FORMCFG['c'][$kk]; 00696 unset($this->FORMCFG['c'][$kk]); 00697 break; 00698 case 'row_up': 00699 $this->FORMCFG['c'][$kk-3]=$this->FORMCFG['c'][$kk]; 00700 unset($this->FORMCFG['c'][$kk]); 00701 break; 00702 case 'row_down': 00703 $this->FORMCFG['c'][$kk+3]=$this->FORMCFG['c'][$kk]; 00704 unset($this->FORMCFG['c'][$kk]); 00705 break; 00706 } 00707 ksort($this->FORMCFG['c']); 00708 } 00709 } 00710 } 00711 00719 function cfgArray2CfgString($cfgArr) { 00720 00721 // Initialize: 00722 $inLines=array(); 00723 00724 // Traverse the elements of the form wizard and transform the settings into configuration code. 00725 foreach($cfgArr as $vv) { 00726 if ($vv['comment']) { // If "content" is found, then just pass it over. 00727 $inLines[]=trim($vv['comment']); 00728 } else { // Begin to put together the single-line configuration code of this field: 00729 00730 // Reset: 00731 $thisLine=array(); 00732 00733 // Set Label: 00734 $thisLine[0]=str_replace('|','',$vv['label']); 00735 00736 // Set Type: 00737 if ($vv['type']) { 00738 $thisLine[1]=($vv['required']?'*':'').str_replace(',','',($vv['fieldname']?$vv['fieldname'].'=':'').$vv['type']); 00739 00740 // Default: 00741 $tArr=array('','','','','',''); 00742 switch((string)$vv['type']) { 00743 case 'textarea': 00744 if (intval($vv['cols'])) $tArr[0]=intval($vv['cols']); 00745 if (intval($vv['rows'])) $tArr[1]=intval($vv['rows']); 00746 if (trim($vv['extra'])) $tArr[2]=trim($vv['extra']); 00747 if (strlen($vv['specialEval'])) { 00748 $thisLine[2] = ''; // Preset blank default value so position 3 can get a value... 00749 $thisLine[3] = $vv['specialEval']; 00750 } 00751 break; 00752 case 'input': 00753 case 'password': 00754 if (intval($vv['size'])) $tArr[0]=intval($vv['size']); 00755 if (intval($vv['max'])) $tArr[1]=intval($vv['max']); 00756 if (strlen($vv['specialEval'])) { 00757 $thisLine[2] = ''; // Preset blank default value so position 3 can get a value... 00758 $thisLine[3] = $vv['specialEval']; 00759 } 00760 break; 00761 case 'file': 00762 if (intval($vv['size'])) $tArr[0]=intval($vv['size']); 00763 break; 00764 case 'select': 00765 if (intval($vv['size'])) $tArr[0]=intval($vv['size']); 00766 if ($vv['autosize']) $tArr[0]='auto'; 00767 if ($vv['multiple']) $tArr[1]='m'; 00768 break; 00769 } 00770 $tArr = $this->cleanT($tArr); 00771 if (count($tArr)) $thisLine[1].=','.implode(',',$tArr); 00772 00773 $thisLine[1]=str_replace('|','',$thisLine[1]); 00774 00775 // Default: 00776 if ($vv['type']=='select' || $vv['type']=='radio') { 00777 $thisLine[2]=str_replace(chr(10),', ',str_replace(',','',$vv['options'])); 00778 } elseif ($vv['type']=='check') { 00779 if ($vv['default']) $thisLine[2]=1; 00780 } elseif (strcmp(trim($vv['default']),'')) { 00781 $thisLine[2]=$vv['default']; 00782 } 00783 if (isset($thisLine[2])) $thisLine[2]=str_replace('|','',$thisLine[2]); 00784 } 00785 00786 // Compile the final line: 00787 $inLines[]=ereg_replace("[\n\r]*",'',implode(' | ',$thisLine)); 00788 } 00789 } 00790 // Finally, implode the lines into a string, and return it: 00791 return implode(chr(10),$inLines); 00792 } 00793 00801 function cfgString2CfgArray($cfgStr) { 00802 00803 // Traverse the number of form elements: 00804 $tLines=explode(chr(10),$cfgStr); 00805 foreach($tLines as $k => $v) { 00806 00807 // Initialize: 00808 $confData=array(); 00809 $val=trim($v); 00810 00811 // Accept a line as configuration if a) it is blank(! - because blank lines indicates new, unconfigured fields) or b) it is NOT a comment. 00812 if (!$val || strcspn($val,'#/')) { 00813 00814 // Split: 00815 $parts = t3lib_div::trimExplode('|',$val); 00816 00817 // Label: 00818 $confData['label'] = trim($parts[0]); 00819 00820 // Field: 00821 $fParts = t3lib_div::trimExplode(',',$parts[1]); 00822 $fParts[0]=trim($fParts[0]); 00823 if (substr($fParts[0],0,1)=='*') { 00824 $confData['required'] = 1; 00825 $fParts[0] = substr($fParts[0],1); 00826 } 00827 00828 $typeParts = t3lib_div::trimExplode('=',$fParts[0]); 00829 $confData['type'] = trim(strtolower(end($typeParts))); 00830 00831 if ($confData['type']) { 00832 if (count($typeParts)==1) { 00833 $confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30); 00834 00835 // Attachment names... 00836 if ($confData['type']=='file') { 00837 $confData['fieldname']='attachment'.$attachmentCounter; 00838 $attachmentCounter=intval($attachmentCounter)+1; 00839 } 00840 } else { 00841 $confData['fieldname'] = str_replace(' ','_',trim($typeParts[0])); 00842 } 00843 00844 switch((string)$confData['type']) { 00845 case 'select': 00846 case 'radio': 00847 $confData['default'] = implode(chr(10),t3lib_div::trimExplode(',',$parts[2])); 00848 break; 00849 default: 00850 $confData['default'] = trim($parts[2]); 00851 break; 00852 } 00853 00854 // Field configuration depending on the fields type: 00855 switch((string)$confData['type']) { 00856 case 'textarea': 00857 $confData['cols'] = $fParts[1]; 00858 $confData['rows'] = $fParts[2]; 00859 $confData['extra'] = strtoupper($fParts[3])=='OFF' ? 'OFF' : ''; 00860 $confData['specialEval'] = trim($parts[3]); 00861 break; 00862 case 'input': 00863 case 'password': 00864 $confData['size'] = $fParts[1]; 00865 $confData['max'] = $fParts[2]; 00866 $confData['specialEval'] = trim($parts[3]); 00867 break; 00868 case 'file': 00869 $confData['size'] = $fParts[1]; 00870 break; 00871 case 'select': 00872 $confData['size'] = intval($fParts[1])?$fParts[1]:''; 00873 $confData['autosize'] = strtolower(trim($fParts[1]))=='auto' ? 1 : 0; 00874 $confData['multiple'] = strtolower(trim($fParts[2]))=='m' ? 1 : 0; 00875 break; 00876 } 00877 } 00878 } else { 00879 // No configuration, only a comment: 00880 $confData=array( 00881 'comment' => $val 00882 ); 00883 } 00884 00885 // Adding config array: 00886 $cfgArr[]=$confData; 00887 } 00888 00889 // Return cfgArr 00890 return $cfgArr; 00891 } 00892 00900 function cleanT($tArr) { 00901 for($a=count($tArr);$a>0;$a--) { 00902 if (strcmp($tArr[$a-1],'')) { 00903 break; 00904 } else { 00905 unset($tArr[$a-1]); 00906 } 00907 } 00908 return $tArr; 00909 } 00910 00918 function formatCells($fArr) { 00919 00920 // Traverse the elements in $fArr and wrap them in table cells: 00921 $lines=array(); 00922 foreach($fArr as $l => $c) { 00923 $lines[]=' 00924 <tr> 00925 <td nowrap="nowrap">'.htmlspecialchars($l.':').' </td> 00926 <td>'.$c.'</td> 00927 </tr>'; 00928 } 00929 00930 // Add a cell which will set a minimum width: 00931 $lines[]=' 00932 <tr> 00933 <td nowrap="nowrap"><img src="clear.gif" width="70" height="1" alt="" /></td> 00934 <td></td> 00935 </tr>'; 00936 00937 // Wrap in table and return: 00938 return ' 00939 <table border="0" cellpadding="0" cellspacing="0"> 00940 '.implode('',$lines).' 00941 </table>'; 00942 } 00943 } 00944 00945 // Include extension? 00946 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_forms.php']) { 00947 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_forms.php']); 00948 } 00949 00950 00951 00952 00953 00954 00955 00956 00957 00958 00959 00960 00961 // Make instance: 00962 $SOBE = t3lib_div::makeInstance('SC_wizard_forms'); 00963 $SOBE->init(); 00964 00965 // Include files? 00966 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE); 00967 00968 $SOBE->main(); 00969 $SOBE->printContent(); 00970 ?>