00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00183 require_once(PATH_t3lib.'class.t3lib_diff.php');
00184
00185
00186
00195 class t3lib_TCEforms {
00196
00197
00198 var $palFieldArr = array();
00199 var $disableWizards = 0;
00200 var $isPalettedoc = 0;
00201 var $paletteMargin = 1;
00202 var $defStyle = '';
00203 var $cachedTSconfig = array();
00204 var $cachedTSconfig_fieldLevel = array();
00205 var $transformedRow = array();
00206 var $extJSCODE = '';
00207 var $printNeededJS = array();
00208 var $hiddenFieldAccum=array();
00209 var $TBE_EDITOR_fieldChanged_func='';
00210 var $loadMD5_JS=1;
00211 var $prevBorderStyle='[nothing here...]';
00212 var $allowUpload=0;
00213 var $titleLen=15;
00214 var $defaultLanguageData = array();
00215 var $defaultLanguageData_diff = array();
00216
00217
00218
00219 var $backPath='';
00220 var $returnUrl='';
00221 var $doSaveFieldName='';
00222 var $palettesCollapsed=0;
00223 var $disableRTE=0;
00224 var $globalShowHelp=1;
00225 var $localizationMode='';
00226 var $fieldOrder='';
00227 var $doPrintPalette=1;
00228 var $clipObj=FALSE;
00229 var $enableClickMenu=FALSE;
00230 var $enableTabMenu = FALSE;
00231 var $renderReadonly = FALSE;
00232
00233 var $form_rowsToStylewidth = 9.58;
00234 var $form_largeComp = 1.33;
00235 var $charsPerRow=40;
00236 var $maxTextareaWidth=48;
00237 var $maxInputWidth=48;
00238 var $defaultMultipleSelectorStyle='width:250px;';
00239
00240
00241
00242 var $prependFormFieldNames = 'data';
00243 var $prependFormFieldNames_file = 'data_files';
00244 var $formName = 'editform';
00245
00246
00247
00248
00249 var $perms_clause='';
00250 var $perms_clause_set=0;
00251 var $edit_showFieldHelp='';
00252 var $docLarge=0;
00253 var $clientInfo=array();
00254 var $RTEenabled=0;
00255 var $RTEenabled_notReasons='';
00256 var $RTEcounter = 0;
00257
00258 var $colorScheme;
00259 var $classScheme;
00260 var $defColorScheme;
00261 var $defClassScheme;
00262 var $fieldStyle;
00263 var $borderStyle;
00264
00265 var $commentMessages=array();
00266
00267
00268 var $totalWrap='<hr />|<hr />';
00269 var $fieldTemplate='<b>###FIELD_NAME###</b><br />###FIELD_ITEM###<hr />';
00270 var $sectionWrap='';
00271 var $palFieldTemplateHeader='';
00272 var $palFieldTemplate='';
00273
00274
00275 var $excludeElements='';
00276 var $palettesRendered=array();
00277 var $hiddenFieldListArr = array();
00278 var $requiredFields=array();
00279 var $requiredElements=array();
00280 var $renderDepth=0;
00281 var $savedSchemes=array();
00282
00283
00284 var $additionalCode_pre = array();
00285 var $additionalJS_pre = array();
00286 var $additionalJS_post = array();
00287 var $additionalJS_submit = array();
00288
00289
00290
00291
00292
00293
00294
00300 function t3lib_TCEforms() {
00301 global $CLIENT;
00302
00303 $this->clientInfo = t3lib_div::clientInfo();
00304
00305 $this->RTEenabled = $GLOBALS['BE_USER']->isRTE();
00306 if (!$this->RTEenabled) {
00307 $this->RTEenabled_notReasons = implode(chr(10),$GLOBALS['BE_USER']->RTE_errors);
00308 $this->commentMessages[] = 'RTE NOT ENABLED IN SYSTEM due to:'.chr(10).$this->RTEenabled_notReasons;
00309 }
00310
00311
00312 $this->defColorScheme = array(
00313 $GLOBALS['SOBE']->doc->bgColor,
00314 t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-20),
00315 t3lib_div::modifyHTMLColorAll($GLOBALS['SOBE']->doc->bgColor,-10),
00316 'black',
00317 '#666666'
00318 );
00319 $this->defColorScheme = array();
00320
00321
00322 $this->resetSchemes();
00323
00324
00325 $this->defColorScheme = $this->colorScheme;
00326 $this->defClassScheme = $this->classScheme;
00327 }
00328
00334 function initDefaultBEmode() {
00335 global $BE_USER;
00336 $this->prependFormFieldNames = 'data';
00337 $this->formName = 'editform';
00338 $this->setNewBEDesign();
00339 $this->docLarge = $BE_USER->uc['edit_wideDocument'] ? 1 : 0;
00340 $this->edit_showFieldHelp = $BE_USER->uc['edit_showFieldHelp'];
00341
00342 $this->edit_docModuleUpload = $BE_USER->uc['edit_docModuleUpload'];
00343 $this->titleLen = $BE_USER->uc['titleLen'];
00344 }
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00379 function getSoloField($table,$row,$theFieldToReturn) {
00380 global $TCA;
00381
00382 if ($TCA[$table]) {
00383 t3lib_div::loadTCA($table);
00384 $typeNum = $this->getRTypeNum($table,$row);
00385 if ($TCA[$table]['types'][$typeNum]) {
00386 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
00387 if ($itemList) {
00388 $fields = t3lib_div::trimExplode(',',$itemList,1);
00389 $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00390
00391 reset($fields);
00392 while(list(,$fieldInfo)=each($fields)) {
00393 $parts = explode(';',$fieldInfo);
00394
00395 $theField = trim($parts[0]);
00396 if (!in_array($theField,$excludeElements) && !strcmp($theField,$theFieldToReturn)) {
00397 if ($TCA[$table]['columns'][$theField]) {
00398 $sField = $this->getSingleField($table,$theField,$row,$parts[1],1,$parts[3],$parts[2]);
00399 return $sField['ITEM'];
00400 }
00401 }
00402 }
00403 }
00404 }
00405 }
00406 }
00407
00418 function getMainFields($table,$row,$depth=0) {
00419 global $TCA, $TYPO3_CONF_VARS;
00420
00421 $this->renderDepth=$depth;
00422
00423
00424 $out_array = array(array());
00425 $out_array_meta = array(array(
00426 'title' => $this->getLL('l_generalTab')
00427 ));
00428
00429 $out_pointer=0;
00430 $out_sheet=0;
00431 $this->palettesRendered=array();
00432 $this->palettesRendered[$this->renderDepth][$table]=array();
00433
00434
00435 $hookObjectsArr = array();
00436 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'])) {
00437 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'] as $classRef) {
00438 $hookObjectsArr[] = &t3lib_div::getUserObj($classRef);
00439 }
00440 }
00441
00442
00443 foreach ($hookObjectsArr as $hookObj) {
00444 if (method_exists($hookObj,'getMainFields_preProcess')) {
00445 $hookObj->getMainFields_preProcess($table,$row,$this);
00446 }
00447 }
00448
00449 if ($TCA[$table]) {
00450
00451
00452 t3lib_div::loadTCA($table);
00453
00454
00455 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
00456 $GLOBALS['LANG']->loadSingleTableDescription($table);
00457 }
00458
00459 $typeNum = $this->getRTypeNum($table,$row);
00460
00461
00462 if ($TCA[$table]['types'][$typeNum]) {
00463 $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
00464 if ($itemList) {
00465
00466
00467 $fields = t3lib_div::trimExplode(',',$itemList,1);
00468 if ($this->fieldOrder) {
00469 $fields = $this->rearrange($fields);
00470 }
00471
00472
00473 $excludeElements = $this->excludeElements = $this->getExcludeElements($table,$row,$typeNum);
00474 $fields = $this->mergeFieldsWithAddedFields($fields,$this->getFieldsToAdd($table,$row,$typeNum));
00475
00476
00477 $cc=0;
00478 foreach($fields as $fieldInfo) {
00479
00480 $parts = explode(';',$fieldInfo);
00481
00482
00483 $color_style_parts = t3lib_div::trimExplode('-',$parts[4]);
00484 if (strcmp($color_style_parts[0],'')) {
00485 $this->setColorScheme($GLOBALS['TBE_STYLES']['colorschemes'][intval($color_style_parts[0])]);
00486 }
00487 if (strcmp($color_style_parts[1],'')) {
00488 $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][intval($color_style_parts[1])];
00489 if (!isset($this->fieldStyle)) $this->fieldStyle = $GLOBALS['TBE_STYLES']['styleschemes'][0];
00490 }
00491 if (strcmp($color_style_parts[2],'')) {
00492 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00493 $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][intval($color_style_parts[2])];
00494 if (!isset($this->borderStyle)) $this->borderStyle = $GLOBALS['TBE_STYLES']['borderschemes'][0];
00495 }
00496
00497
00498 $theField = $parts[0];
00499 if (!in_array($theField,$excludeElements)) {
00500 if ($TCA[$table]['columns'][$theField]) {
00501 $sFieldPal='';
00502
00503 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
00504 $sFieldPal=$this->getPaletteFields($table,$row,$parts[2]);
00505 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00506 }
00507 $sField = $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],$parts[2]);
00508 if ($sField) $sField.=$sFieldPal;
00509
00510 $out_array[$out_sheet][$out_pointer].= $sField;
00511 } elseif ($theField=='--div--') {
00512 if ($cc>0) {
00513 $out_array[$out_sheet][$out_pointer].=$this->getDivider();
00514
00515 if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs']) {
00516 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00517 $out_sheet++;
00518 $out_array[$out_sheet] = array();
00519 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00520 }
00521 } else {
00522 $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
00523 }
00524 } elseif($theField=='--palette--') {
00525 if ($parts[2] && !isset($this->palettesRendered[$this->renderDepth][$table][$parts[2]])) {
00526
00527 if ($TCA[$table]['palettes'][$parts[2]]['canNotCollapse'] AND $parts[1]) {
00528 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],$this->sL($parts[1]));
00529 } else {
00530 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$parts[2],'','',$this->sL($parts[1]));
00531 }
00532 $this->palettesRendered[$this->renderDepth][$table][$parts[2]] = 1;
00533 }
00534 }
00535 }
00536
00537 $cc++;
00538 }
00539 }
00540 }
00541 }
00542
00543
00544 foreach ($hookObjectsArr as $hookObj) {
00545 if (method_exists($hookObj,'getMainFields_postProcess')) {
00546 $hookObj->getMainFields_postProcess($table,$row,$this);
00547 }
00548 }
00549
00550
00551 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00552
00553
00554 $this->resetSchemes();
00555
00556
00557 $mParr = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['mainpalette']);
00558 $i = 0;
00559 if (count($mParr)) {
00560 foreach ($mParr as $mP) {
00561 if (!isset($this->palettesRendered[$this->renderDepth][$table][$mP])) {
00562 $temp_palettesCollapsed=$this->palettesCollapsed;
00563 $this->palettesCollapsed=0;
00564 $label = ($i==0?$this->getLL('l_generalOptions'):$this->getLL('l_generalOptions_more'));
00565 $out_array[$out_sheet][$out_pointer].=$this->getPaletteFields($table,$row,$mP,$label);
00566 $this->palettesCollapsed=$temp_palettesCollapsed;
00567 $this->palettesRendered[$this->renderDepth][$table][$mP] = 1;
00568 }
00569 $this->wrapBorder($out_array[$out_sheet],$out_pointer);
00570 $i++;
00571 if ($this->renderDepth) {
00572 $this->renderDepth--;
00573 }
00574 }
00575 }
00576
00577
00578
00579 if ($out_sheet>0) {
00580
00581
00582 $parts = array();
00583 foreach($out_array as $idx => $sheetContent) {
00584 $parts[] = array(
00585 'label' => $out_array_meta[$idx]['title'],
00586 'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
00587 implode('',$sheetContent).
00588 '</table>'
00589 );
00590 }
00591
00592 return '
00593 <tr>
00594 <td colspan="2">
00595 '.$this->getDynTabMenu($parts, 'TCEforms:'.$table.':'.$row['uid']).'
00596 </td>
00597 </tr>';
00598 } else {
00599 return implode('',$out_array[$out_sheet]);
00600 }
00601 }
00602
00613 function getListedFields($table,$row,$list) {
00614 global $TCA;
00615
00616 t3lib_div::loadTCA($table);
00617 if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) {
00618 $GLOBALS['LANG']->loadSingleTableDescription($table);
00619 }
00620
00621 $out='';
00622 $types_fieldConfig=t3lib_BEfunc::getTCAtypes($table,$row,1);
00623
00624 $editFieldList=array_unique(t3lib_div::trimExplode(',',$list,1));
00625 foreach($editFieldList as $theFieldC) {
00626 list($theField,$palFields) = split('\[|\]',$theFieldC);
00627 $theField = trim($theField);
00628 $palFields = trim($palFields);
00629 if ($TCA[$table]['columns'][$theField]) {
00630 $parts = t3lib_div::trimExplode(';',$types_fieldConfig[$theField]['origString']);
00631 $sField= $this->getSingleField($table,$theField,$row,$parts[1],0,$parts[3],0);
00632 $out.= $sField;
00633 } elseif($theField=='--div--') {
00634 $out.=$this->getDivider();
00635 }
00636 if ($palFields) {
00637 $out.=$this->getPaletteFields($table,$row,'','',implode(',',t3lib_div::trimExplode('|',$palFields,1)));
00638 }
00639 }
00640 return $out;
00641 }
00642
00654 function getPaletteFields($table,$row,$palette,$header='',$itemList='',$collapsedHeader='') {
00655 global $TCA;
00656 if (!$this->doPrintPalette) return '';
00657
00658 $out='';
00659 $palParts=array();
00660 t3lib_div::loadTCA($table);
00661
00662
00663 if (!is_array($this->excludeElements)) {
00664 $this->excludeElements = $this->getExcludeElements($table,$row,$this->getRTypeNum($table,$row));
00665 }
00666
00667
00668 if ($TCA[$table] && (is_array($TCA[$table]['palettes'][$palette]) || $itemList)) {
00669 $itemList = $itemList?$itemList:$TCA[$table]['palettes'][$palette]['showitem'];
00670 if ($itemList) {
00671 $fields = t3lib_div::trimExplode(',',$itemList,1);
00672 reset($fields);
00673 while(list(,$fieldInfo)=each($fields)) {
00674 $parts = t3lib_div::trimExplode(';',$fieldInfo);
00675 $theField = $parts[0];
00676
00677 if (!in_array($theField,$this->excludeElements) && $TCA[$table]['columns'][$theField]) {
00678 $this->palFieldArr[$palette][] = $theField;
00679 if ($this->isPalettesCollapsed($table,$palette)) {
00680 $this->hiddenFieldListArr[] = $theField;
00681 }
00682
00683 $part=$this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
00684 if (is_array($part)) {
00685 $palParts[]=$part;
00686 }
00687 }
00688 }
00689 }
00690 }
00691
00692 if (count($palParts)) {
00693 if ($header) {
00694 $out.= $this->intoTemplate(array(
00695 'HEADER' => htmlspecialchars($header)
00696 ),
00697 $this->palFieldTemplateHeader
00698 );
00699 }
00700 $out.= $this->intoTemplate(array(
00701 'PALETTE' => $this->printPalette($palParts)
00702 ),
00703 $this->palFieldTemplate
00704 );
00705 }
00706
00707 if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader) {
00708 $pC= $this->intoTemplate(array(
00709 'PALETTE' => $this->wrapOpenPalette('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" align="top" alt="" /><strong>'.$collapsedHeader.'</strong>',$table,$row,$palette),
00710 ),
00711 $this->palFieldTemplate
00712 );
00713 $out.=$pC;
00714 }
00715 return $out;
00716 }
00717
00730 function getSingleField($table,$field,$row,$altName='',$palette=0,$extra='',$pal=0) {
00731 global $TCA,$BE_USER;
00732
00733 $out = '';
00734 $PA = array();
00735 $PA['altName'] = $altName;
00736 $PA['palette'] = $palette;
00737 $PA['extra'] = $extra;
00738 $PA['pal'] = $pal;
00739
00740
00741 t3lib_div::loadTCA($table);
00742
00743
00744 $PA['fieldConf'] = $TCA[$table]['columns'][$field];
00745 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
00746
00747
00748 if ( is_array($PA['fieldConf']) &&
00749 (!$PA['fieldConf']['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$field)) &&
00750 $PA['fieldConf']['config']['form_type']!='passthrough' &&
00751 ($this->RTEenabled || !$PA['fieldConf']['config']['showIfRTE']) &&
00752 (!$PA['fieldConf']['displayCond'] || $this->isDisplayCondition($PA['fieldConf']['displayCond'],$row)) &&
00753 (!$TCA[$table]['ctrl']['languageField'] || $PA['fieldConf']['l10n_display'] || strcmp($PA['fieldConf']['l10n_mode'],'exclude') || $row[$TCA[$table]['ctrl']['languageField']]<=0) &&
00754 (!$TCA[$table]['ctrl']['languageField'] || !$this->localizationMode || $this->localizationMode===$PA['fieldConf']['l10n_cat'])
00755 ) {
00756
00757
00758
00759
00760 $PA['fieldTSConfig'] = $this->setTSconfig($table,$row,$field);
00761
00762
00763 if (!$PA['fieldTSConfig']['disabled']) {
00764
00765
00766 $PA['itemFormElName']=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']';
00767 $PA['itemFormElName_file']=$this->prependFormFieldNames_file.'['.$table.']['.$row['uid'].']['.$field.']';
00768 $PA['itemFormElValue']=$row[$field];
00769
00770
00771 if ($PA['fieldConf']['l10n_display'] AND t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly') AND $row[$TCA[$table]['ctrl']['languageField']]) {
00772 $PA['fieldConf']['config']['readOnly'] = true;
00773 $PA['itemFormElValue'] = $this->defaultLanguageData[$table.':'.$row['uid']][$field];
00774 }
00775
00776
00777 if (
00778 ($TCA[$table]['ctrl']['type'] && !strcmp($field,$TCA[$table]['ctrl']['type'])) ||
00779 ($TCA[$table]['ctrl']['requestUpdate'] && t3lib_div::inList($TCA[$table]['ctrl']['requestUpdate'],$field))) {
00780 if($GLOBALS['BE_USER']->jsConfirmation(1)) {
00781 $alertMsgOnChange = 'if (confirm('.$GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')).') && TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
00782 } else {
00783 $alertMsgOnChange = 'if (TBE_EDITOR_checkSubmit(-1)){ TBE_EDITOR_submitForm() };';
00784 }
00785 } else {
00786 $alertMsgOnChange = '';
00787 }
00788
00789
00790 if (in_array($field,$this->hiddenFieldListArr)) {
00791 $this->hiddenFieldAccum[]='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
00792 } else {
00793
00794
00795 if (!$PA['palette']) {
00796 if ($PA['pal'] && $this->isPalettesCollapsed($table,$PA['pal'])) {
00797 list($thePalIcon,$palJSfunc) = $this->wrapOpenPalette('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" alt="" />',$table,$row,$PA['pal'],1);
00798 } else {
00799 $thePalIcon = '';
00800 $palJSfunc = '';
00801 }
00802 }
00803
00804 $PA['onFocus'] = ($palJSfunc && !$BE_USER->uc['dontShowPalettesOnFocusInAB']) ? ' onfocus="'.htmlspecialchars($palJSfunc).'"' : '';
00805
00806
00807 $item='';
00808 $PA['label'] = $PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label'];
00809 $PA['label'] = $this->sL($PA['label']);
00810
00811 $PA['fieldChangeFunc']=array();
00812 $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR_fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');";
00813 $PA['fieldChangeFunc']['alert']=$alertMsgOnChange;
00814
00815
00816 $item = $this->getSingleField_SW($table,$field,$row,$PA);
00817
00818
00819
00820 if ($PA['fieldConf']['l10n_display'] && (t3lib_div::inList($PA['fieldConf']['l10n_display'], 'hideDiff') || t3lib_div::inList($PA['fieldConf']['l10n_display'], 'defaultAsReadonly'))) {
00821 $renderLanguageDiff = false;
00822 } else {
00823 $renderLanguageDiff = true;
00824 }
00825
00826 if ($renderLanguageDiff) {
00827 $item = $this->renderDefaultLanguageContent($table,$field,$row,$item);
00828 $item = $this->renderDefaultLanguageDiff($table,$field,$row,$item);
00829 }
00830
00831 $PA['label'] = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
00832 if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf']) {
00833 $lTTS_url = $this->backPath.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.
00834 ($PA['fieldTSConfig']['linkTitleToSelf.']['returnUrl']?'&returnUrl='.rawurlencode($this->thisReturnUrl()):'');
00835 $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
00836 }
00837
00838
00839 if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping']) {
00840 $out = $item;
00841 } elseif ($PA['palette']) {
00842
00843 $out=array(
00844 'NAME'=>$PA['label'],
00845 'ID'=>$row['uid'],
00846 'FIELD'=>$field,
00847 'TABLE'=>$table,
00848 'ITEM'=>$item,
00849 'HELP_ICON' => $this->helpTextIcon($table,$field,1)
00850 );
00851 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00852 } else {
00853
00854 $out=array(
00855 'NAME'=>$PA['label'],
00856 'ITEM'=>$item,
00857 'TABLE'=>$table,
00858 'ID'=>$row['uid'],
00859 'HELP_ICON'=>$this->helpTextIcon($table,$field),
00860 'HELP_TEXT'=>$this->helpText($table,$field),
00861 'PAL_LINK_ICON'=>$thePalIcon,
00862 'FIELD'=>$field
00863 );
00864 $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
00865
00866 $out=$this->intoTemplate($out);
00867 }
00868 }
00869 } else $this->commentMessages[]=$this->prependFormFieldNames.'['.$table.']['.$row['uid'].']['.$field.']: Disabled by TSconfig';
00870 }
00871
00872 return $out;
00873 }
00874
00886 function getSingleField_SW($table,$field,$row,&$PA) {
00887 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
00888
00889 switch($PA['fieldConf']['config']['form_type']) {
00890 case 'input':
00891 $item = $this->getSingleField_typeInput($table,$field,$row,$PA);
00892 break;
00893 case 'text':
00894 $item = $this->getSingleField_typeText($table,$field,$row,$PA);
00895 break;
00896 case 'check':
00897 $item = $this->getSingleField_typeCheck($table,$field,$row,$PA);
00898 break;
00899 case 'radio':
00900 $item = $this->getSingleField_typeRadio($table,$field,$row,$PA);
00901 break;
00902 case 'select':
00903 $item = $this->getSingleField_typeSelect($table,$field,$row,$PA);
00904 break;
00905 case 'group':
00906 $item = $this->getSingleField_typeGroup($table,$field,$row,$PA);
00907 break;
00908 case 'none':
00909 $item = $this->getSingleField_typeNone($table,$field,$row,$PA);
00910 break;
00911 case 'user':
00912 $item = $this->getSingleField_typeUser($table,$field,$row,$PA);
00913 break;
00914 case 'flex':
00915 $item = $this->getSingleField_typeFlex($table,$field,$row,$PA);
00916 break;
00917 default:
00918 $item = $this->getSingleField_typeUnknown($table,$field,$row,$PA);
00919 break;
00920 }
00921
00922 return $item;
00923 }
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00959 function getSingleField_typeInput($table,$field,$row,&$PA) {
00960
00961
00962
00963 $config = $PA['fieldConf']['config'];
00964
00965 # $specConf = $this->getSpecConfForField($table,$row,$field);
00966 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
00967 $size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
00968 $evalList = t3lib_div::trimExplode(',',$config['eval'],1);
00969
00970
00971 if($this->renderReadonly || $config['readOnly']) {
00972 $itemFormElValue = $PA['itemFormElValue'];
00973 if (in_array('date',$evalList)) {
00974 $config['format'] = 'date';
00975 } elseif (in_array('date',$evalList)) {
00976 $config['format'] = 'date';
00977 } elseif (in_array('datetime',$evalList)) {
00978 $config['format'] = 'datetime';
00979 } elseif (in_array('time',$evalList)) {
00980 $config['format'] = 'time';
00981 }
00982 if (in_array('password',$evalList)) {
00983 $itemFormElValue = $itemFormElValue ? '*********' : '';
00984 }
00985 return $this->getSingleField_typeNone_render($config, $itemFormElValue);
00986 }
00987
00988 if (in_array('required',$evalList)) {
00989 $this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
00990 }
00991
00992 $paramsList = "'".$PA['itemFormElName']."','".implode(',',$evalList)."','".trim($config['is_in'])."',".(isset($config['checkbox'])?1:0).",'".$config['checkbox']."'";
00993 if (isset($config['checkbox'])) {
00994
00995 $thisMidnight = mktime(0,0,0);
00996 $checkSetValue = in_array('date',$evalList) ? $thisMidnight : '';
00997 $checkSetValue = in_array('datetime',$evalList) ? time() : $checkSetValue;
00998
00999 $cOnClick = 'typo3FormFieldGet('.$paramsList.',1,\''.$checkSetValue.'\');'.implode('',$PA['fieldChangeFunc']);
01000 $item.='<input type="checkbox"'.$this->insertDefStyle('check').' name="'.$PA['itemFormElName'].'_cb" onclick="'.htmlspecialchars($cOnClick).'" />';
01001 }
01002
01003 $PA['fieldChangeFunc'] = array_merge(array('typo3FormFieldGet'=>'typo3FormFieldGet('.$paramsList.');'), $PA['fieldChangeFunc']);
01004 $mLgd = ($config['max']?$config['max']:256);
01005 $iOnChange = implode('',$PA['fieldChangeFunc']);
01006 $item.='<input type="text" name="'.$PA['itemFormElName'].'_hr" value=""'.$this->formWidth($size).' maxlength="'.$mLgd.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].' />';
01007 $item.='<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01008 $this->extJSCODE.='typo3FormFieldSet('.$paramsList.');';
01009
01010
01011 foreach ($evalList as $evalData) {
01012 if (substr($evalData, 0, 3) == 'tx_') {
01013 $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
01014 if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
01015 $this->extJSCODE .= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
01016 }
01017 }
01018 }
01019
01020
01021 $altItem = '<input type="hidden" name="'.$PA['itemFormElName'].'_hr" value="" />';
01022 $altItem.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01023
01024
01025 $item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
01026
01027 return $item;
01028 }
01029
01040 function getSingleField_typeText($table,$field,$row,&$PA) {
01041
01042
01043 $config = $PA['fieldConf']['config'];
01044
01045 if($this->renderReadonly || $config['readOnly']) {
01046 return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
01047 }
01048
01049
01050 $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
01051
01052
01053 $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
01054 if (strlen($PA['itemFormElValue']) > $this->charsPerRow*2) {
01055 $cols = $this->maxTextareaWidth;
01056 $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue'])/$this->charsPerRow), count(explode(chr(10),$PA['itemFormElValue'])), 20);
01057 if ($rows<$origRows) $rows = $origRows;
01058 }
01059
01060
01061 $RTEwasLoaded = 0;
01062 $RTEwouldHaveBeenLoaded = 0;
01063
01064
01065 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
01066
01067
01068 $altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
01069
01070
01071 if ($this->RTEenabled) {
01072 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
01073 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
01074 t3lib_BEfunc::fixVersioningPid($table,$row);
01075 list($tscPID,$thePidValue) = $this->getTSCpid($table,$row['uid'],$row['pid']);
01076
01077
01078 if ($thePidValue >= 0) {
01079 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
01080 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
01081 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
01082
01083 if (!$thisConfig['disabled']) {
01084 if (!$this->disableRTE) {
01085 $this->RTEcounter++;
01086
01087
01088 $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
01089 $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
01090
01091
01092 $RTEobj = &t3lib_BEfunc::RTEgetObj();
01093 $item = $RTEobj->drawRTE($this,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
01094
01095
01096 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
01097
01098 $RTEwasLoaded = 1;
01099 } else {
01100 $RTEwouldHaveBeenLoaded = 1;
01101 $this->commentMessages[] = $PA['itemFormElName'].': RTE is disabled by the on-page RTE-flag (probably you can enable it by the check-box in the bottom of this page!)';
01102 }
01103 } else $this->commentMessages[] = $PA['itemFormElName'].': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
01104 } else $this->commentMessages[] = $PA['itemFormElName'].': PID value could NOT be fetched. Rare error, normally with new records.';
01105 } else {
01106 if (!isset($specConf['richtext'])) $this->commentMessages[] = $PA['itemFormElName'].': RTE was not configured for this field in TCA-types';
01107 if (!(!$p['flag'] || !$row[$p['flag']])) $this->commentMessages[] = $PA['itemFormElName'].': Field-flag ('.$PA['flag'].') has been set to disable RTE!';
01108 }
01109 }
01110
01111
01112 if (!$RTEwasLoaded) {
01113 if ($specConf['rte_only']) {
01114 $item = '<p><em>'.htmlspecialchars($this->getLL('l_noRTEfound')).'</em></p>';
01115 } else {
01116 if ($specConf['nowrap']) {
01117 $wrap = 'off';
01118 } else {
01119 $wrap = ($config['wrap'] ? $config['wrap'] : 'virtual');
01120 }
01121
01122 $classes = array();
01123 if ($specConf['fixed-font']) { $classes[] = 'fixed-font'; }
01124 if ($specConf['enable-tab']) { $classes[] = 'enable-tab'; }
01125
01126 if (count($classes)) {
01127 $class = ' class="'.implode(' ',$classes).'"';
01128 } else $class='';
01129
01130 $iOnChange = implode('',$PA['fieldChangeFunc']);
01131 $item.= '
01132 <textarea name="'.$PA['itemFormElName'].'"'.$this->formWidthText($cols,$wrap).$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
01133 t3lib_div::formatForTextarea($PA['itemFormElValue']).
01134 '</textarea>';
01135 $item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
01136 }
01137 }
01138
01139
01140 return $item;
01141 }
01142
01153 function getSingleField_typeCheck($table,$field,$row,&$PA) {
01154 $config = $PA['fieldConf']['config'];
01155
01156 $disabled = '';
01157 if($this->renderReadonly || $config['readOnly']) {
01158 $disabled = ' disabled="disabled"';
01159 }
01160
01161
01162 $selItems = $this->initItemArray($PA['fieldConf']);
01163 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
01164
01165 if (!count($selItems)) {
01166 $selItems[]=array('','');
01167 }
01168 $thisValue = intval($PA['itemFormElValue']);
01169
01170 $cols = intval($config['cols']);
01171 if ($cols > 1) {
01172 $item.= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
01173 for ($c=0;$c<count($selItems);$c++) {
01174 $p = $selItems[$c];
01175 if(!($c%$cols)) { $item.='<tr>'; }
01176 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));
01177 $cBName = $PA['itemFormElName'].'_'.$c;
01178 $item.= '<td nowrap="nowrap">'.
01179 '<input type="checkbox"'.$this->insertDefStyle('check').' value="1" name="'.$cBName.'"'.$cBP.$disabled.' />'.
01180 $this->wrapLabels(htmlspecialchars($p[0]).' ').
01181 '</td>';
01182 if(($c%$cols)+1==$cols) {$item.='</tr>';}
01183 }
01184 if ($c%$cols) {
01185 $rest=$cols-($c%$cols);
01186 for ($c=0;$c<$rest;$c++) {
01187 $item.= '<td></td>';
01188 }
01189 if ($c>0) { $item.= '</tr>'; }
01190 }
01191 $item.= '</table>';
01192 } else {
01193 for ($c=0;$c<count($selItems);$c++) {
01194 $p = $selItems[$c];
01195 $cBP = $this->checkBoxParams($PA['itemFormElName'],$thisValue,$c,count($selItems),implode('',$PA['fieldChangeFunc']));