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
00031 require_once(t3lib_extMgm::extPath('kickstarter').'class.tx_kickstarter_sectionbase.php');
00032
00033 class tx_kickstarter_section_fields extends tx_kickstarter_sectionbase {
00034 var $sectionID = 'fields';
00035
00039 function render_wizard() {
00040 $lines=array();
00041
00042 $action = explode(':',$this->wizard->modData['wizAction']);
00043 if ($action[0]=='edit') {
00044 $this->regNewEntry($this->sectionID,$action[1]);
00045 $lines = $this->catHeaderLines($lines,$this->sectionID,$this->wizard->options[$this->sectionID],' ',$action[1]);
00046 $piConf = $this->wizard->wizArray[$this->sectionID][$action[1]];
00047 $ffPrefix='['.$this->sectionID.']['.$action[1].']';
00048
00049 }
00050
00051
00052
00053 $optValues = array(
00054 'tt_content' => 'Content (tt_content)',
00055 'fe_users' => 'Frontend Users (fe_users)',
00056 'fe_groups' => 'Frontend Groups (fe_groups)',
00057 'be_users' => 'Backend Users (be_users)',
00058 'be_groups' => 'Backend Groups (be_groups)',
00059 'tt_news' => 'News (tt_news)',
00060 'tt_address' => 'Address (tt_address)',
00061 'pages' => 'Pages (pages)',
00062 );
00063
00064 foreach($GLOBALS['TCA'] as $tablename => $tableTCA) {
00065 if(!$optValues[$tablename]) {
00066 $optValues[$tablename] = $GLOBALS['LANG']->sL($tableTCA['ctrl']['title']).' ('.$tablename.')';
00067 }
00068 }
00069
00070 $subContent = '<strong>Which table:<BR></strong>'.
00071 $this->renderSelectBox($ffPrefix.'[which_table]',$piConf['which_table'],$optValues).
00072 $this->whatIsThis('Select the table which should be extended with these extra fields.');
00073 $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).
00074 '<input type="hidden" name="' . $this->piFieldName('wizArray_upd') . $ffPrefix . '[title]" value="' . ($piConf['which_table']?$optValues[$piConf['which_table']]:'') . '"></td></tr>';
00075
00076
00077
00078
00079
00080
00081 $selPresetBox=$this->presetBox($piConf['fields']);
00082
00083
00084 $c=array(0);
00085 $this->usedNames=array();
00086 if (is_array($piConf['fields'])) {
00087 $piConf['fields'] = $this->cleanFieldsAndDoCommands($piConf['fields'],$this->sectionID,$action[1]);
00088
00089
00090 reset($piConf['fields']);
00091 while(list($k,$v)=each($piConf['fields'])) {
00092 $c[]=$k;
00093 $subContent=$this->renderField($ffPrefix.'[fields]['.$k.']',$v);
00094 $lines[]='<tr'.$this->bgCol(2).'><td>'.$this->fw('<strong>FIELD:</strong> <em>'.$v['fieldname'].'</em>').'</td></tr>';
00095 $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00096 }
00097 }
00098
00099
00100
00101 $k=max($c)+1;
00102 $v=array();
00103 $lines[]='<tr'.$this->bgCol(2).'><td>'.$this->fw('<strong>NEW FIELD:</strong>').'</td></tr>';
00104 $subContent=$this->renderField($ffPrefix.'[fields]['.$k.']',$v,1);
00105 $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00106
00107
00108 $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw('<BR><BR>Load preset fields: <BR>'.$selPresetBox).'</td></tr>';
00109
00110
00111 if(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['kickstarter']['add_cat_fields'])) {
00112 foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['kickstarter']['add_cat_fields'] as $_funcRef) {
00113 $lines = t3lib_div::callUserFunction($_funcRef, $lines, $this);
00114 }
00115 }
00116
00117 $content = '<table border=0 cellpadding=2 cellspacing=2>'.implode('',$lines).'</table>';
00118 return $content;
00119 }
00120
00121
00122
00123
00124 function presetBox(&$piConfFields) {
00125 $_PRESETS = $this->wizard->modData['_PRESET'];
00126
00127 $optValues = array();
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 $ses_optValues=array();
00141 $sesdat = $GLOBALS['BE_USER']->getSessionData('kickstarter');
00142 if (is_array($sesdat['presets'])) {
00143 foreach($sesdat['presets'] as $kk1=>$vv1) {
00144 if (is_array($vv1)) {
00145 foreach($vv1 as $kk2=>$vv2) {
00146 $ses_optValues[]='<option value="'.htmlspecialchars($kk1.'.'.$vv2['fieldname']).'">'.htmlspecialchars($kk1.': '.$vv2['title'].' ('.$vv2['fieldname'].', type: '.$vv2['type'].')').'</option>';
00147 if (is_array($_PRESETS) && in_array($kk1.'.'.$vv2['fieldname'],$_PRESETS)) {
00148 if (!is_array($piConfFields)) $piConfFields=array();
00149 $piConfFields[] = $vv2;
00150 }
00151 }
00152 }
00153 }
00154 }
00155 if (count($ses_optValues)) {
00156 $optValues = array_merge($optValues,count($optValues)?array('<option value=""></option>'):array(),array('<option value="">__Fields picked up in this session__:</option>'),$ses_optValues);
00157 }
00158 if (count($optValues)) $selPresetBox = '<select name="'.$this->piFieldName('_PRESET').'[]" size='.t3lib_div::intInRange(count($optValues),1,10).' multiple>'.implode('',$optValues).'</select>';
00159 return $selPresetBox;
00160 }
00161 function cleanFieldsAndDoCommands($fConf,$catID,$action) {
00162 $newFConf=array();
00163 $downFlag=0;
00164 foreach($fConf as $k=>$v) {
00165 if ($v['type'] && trim($v['fieldname'])) {
00166 $v['fieldname'] = $this->cleanUpFieldName($v['fieldname']);
00167
00168 if (!$v['_DELETE']) {
00169 $newFConf[$k]=$v;
00170 if (t3lib_div::_GP($this->varPrefix.'_CMD_'.$v['fieldname'].'_UP_x') || $downFlag) {
00171 if (count($newFConf)>=2) {
00172 $lastKeys = array_slice(array_keys($newFConf),-2);
00173
00174 $buffer = Array();
00175 $buffer[$lastKeys[1]] = $newFConf[$lastKeys[1]];
00176 $buffer[$lastKeys[0]] = $newFConf[$lastKeys[0]];
00177
00178 unset($newFConf[$lastKeys[0]]);
00179 unset($newFConf[$lastKeys[1]]);
00180
00181 $newFConf[$lastKeys[1]] = $buffer[$lastKeys[1]];
00182 $newFConf[$lastKeys[0]] = $buffer[$lastKeys[0]];
00183 }
00184 $downFlag=0;
00185 } elseif (t3lib_div::_GP($this->varPrefix.'_CMD_'.$v['fieldname'].'_DOWN_x')) {
00186 $downFlag=1;
00187 }
00188 }
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 } else {
00212
00213
00214 }
00215 }
00216
00217 $this->wizard->wizArray[$catID][$action]['fields'] = $newFConf;
00218 $sesdat = $GLOBALS['BE_USER']->getSessionData('kickstarter');
00219 $sesdat['presets'][$this->wizard->extKey.'-'.$catID.'-'.$action]=$newFConf;
00220 $GLOBALS['BE_USER']->setAndSaveSessionData('kickstarter',$sesdat);
00221
00222 #debug($newFConf);
00223 return $newFConf;
00224 }
00225
00226
00227 function addOtherExtensionTables($optValues) {
00228 if (is_array($this->wizard->wizArray['tables'])) {
00229 foreach($this->wizard->wizArray['tables'] as $k=>$info) {
00230 if (trim($info['tablename'])) {
00231 $tableName = $this->returnName($this->wizard->extKey,'tables',trim($info['tablename']));
00232 $optValues[$tableName]='Extension table: '.$info['title'].' ('.$tableName.')';
00233 }
00234 }
00235 }
00236 return $optValues;
00237 }
00238 function cleanUpFieldName($str) {
00239 $fieldName = ereg_replace('[^[:alnum:]_]','',strtolower($str));
00240 if (!$fieldName || t3lib_div::inList($this->wizard->reservedTypo3Fields.','.$this->wizard->mysql_reservedFields,$fieldName) || in_array($fieldName,$this->usedNames)) {
00241 $fieldName.=($fieldName?'_':'').t3lib_div::shortmd5(microtime());
00242 }
00243 $this->usedNames[]=$fieldName;
00244 return $fieldName;
00245 }
00246
00247
00248 function renderField($prefix,$fConf,$dontRemove=0) {
00249 $onCP = $this->getOnChangeParts($prefix.'[fieldname]');
00250 $fieldName = $this->renderStringBox($prefix.'[fieldname]',$fConf['fieldname']).
00251 (!$dontRemove?' (Remove:'.$this->renderCheckBox($prefix.'[_DELETE]',0).')'.
00252 '<input type="image" hspace=2 src="'.$this->wizard->siteBackPath.TYPO3_mainDir.'gfx/pil2up.gif" name="'.$this->varPrefix.'_CMD_'.$fConf["fieldname"].'_UP" onClick="'.$onCP[1].'">'.
00253 '<input type="image" hspace=2 src="'.$this->wizard->siteBackPath.TYPO3_mainDir.'gfx/pil2down.gif" name="'.$this->varPrefix.'_CMD_'.$fConf["fieldname"].'_DOWN" onClick="'.$onCP[1].'">'.
00254 '<input type="image" hspace=2 src="'.$this->wizard->siteBackPath.TYPO3_mainDir.'gfx/savesnapshot.gif" name="'.$this->varPrefix.'_CMD_'.$fConf["fieldname"].'_SAVE" onClick="'.$onCP[1].'" title="Save this field setting as a preset.">':'');
00255
00256 $fieldTitle = ((string)$fConf['type'] != 'passthrough') ? $this->renderStringBox_lang('title',$prefix,$fConf) : '';
00257 $typeCfg = '';
00258
00259
00260 $optValues = array(
00261 '' => '',
00262 'input' => 'String input',
00263 'input+' => 'String input, advanced',
00264 'textarea' => 'Text area',
00265 'textarea_rte' => 'Text area with RTE',
00266 'textarea_nowrap' => 'Text area, No wrapping',
00267 'check' => 'Checkbox, single',
00268 'check_4' => 'Checkbox, 4 boxes in a row',
00269 'check_10' => 'Checkbox, 10 boxes in two rows (max)',
00270 'link' => 'Link',
00271 'date' => 'Date',
00272 'datetime' => 'Date and time',
00273 'integer' => 'Integer, 10-1000',
00274 'select' => 'Selectorbox',
00275 'radio' => 'Radio buttons',
00276 'rel' => 'Database relation',
00277 'files' => 'Files',
00278 'none' => 'Not editable, only displayed',
00279 'passthrough' => '[Passthrough]',
00280 );
00281 $typeCfg.=$this->renderSelectBox($prefix.'[type]',$fConf['type'],$optValues);
00282 $typeCfg.=$this->renderCheckBox($prefix.'[excludeField]',isset($fConf['excludeField'])?$fConf['excludeField']:1).' Is Exclude-field '.$this->whatIsThis('If a field is marked "Exclude-field", users can edit it ONLY if the field is specifically listed in one of the backend user groups of the user.\nIn other words, if a field is marked "Exclude-field" you can control which users can edit it and which cannot.').'<BR>';
00283
00284 $fDetails='';
00285 switch((string)$fConf['type']) {
00286 case 'input+':
00287 $typeCfg.=$this->resImg('t_input.png','','');
00288
00289 $fDetails.=$this->renderStringBox($prefix.'[conf_size]',$fConf['conf_size'],50).' Field width (5-48 relative, 30 default)<BR>';
00290 $fDetails.=$this->renderStringBox($prefix.'[conf_max]',$fConf['conf_max'],50).' Max characters<BR>';
00291 $fDetails.=$this->renderCheckBox($prefix.'[conf_required]',$fConf['conf_required']).'Required<BR>';
00292 $fDetails.=$this->resImg('t_input_required.png','hspace=20','','<BR><BR>');
00293
00294 $fDetails.=$this->renderCheckBox($prefix.'[conf_varchar]',$fConf['conf_varchar']).'Create VARCHAR, not TINYTEXT field (if not forced INT)<BR>';
00295
00296 $fDetails.=$this->renderCheckBox($prefix.'[conf_check]',$fConf['conf_check']).'Apply checkbox<BR>';
00297 $fDetails.=$this->resImg('t_input_check.png','hspace=20','','<BR><BR>');
00298
00299 $optValues = array(
00300 '' => '',
00301 'date' => 'Date (day-month-year)',
00302 'time' => 'Time (hours, minutes)',
00303 'timesec' => 'Time + seconds',
00304 'datetime' => 'Date + Time',
00305 'year' => 'Year',
00306 'int' => 'Integer',
00307 'int+' => 'Integer 0-1000',
00308 'double2' => 'Floating point, x.xx',
00309 'alphanum' => 'Alphanumeric only',
00310 'upper' => 'Upper case',
00311 'lower' => 'Lower case',
00312 );
00313 $fDetails.='<BR>Evaluate value to:<BR>'.$this->renderSelectBox($prefix.'[conf_eval]',$fConf['conf_eval'],$optValues).'<BR>';
00314 $fDetails.=$this->renderCheckBox($prefix.'[conf_stripspace]',$fConf['conf_stripspace']).'Strip space<BR>';
00315 $fDetails.=$this->renderCheckBox($prefix.'[conf_pass]',$fConf['conf_pass']).'Is password field<BR>';
00316 $fDetails.=$this->resImg('t_input_password.png','hspace=20','','<BR><BR>');
00317
00318 $fDetails.='<BR>';
00319 $fDetails.=$this->renderRadioBox($prefix.'[conf_unique]',$fConf['conf_unique'],'G').'Unique in whole database<BR>';
00320 $fDetails.=$this->renderRadioBox($prefix.'[conf_unique]',$fConf['conf_unique'],'L').'Unique inside parent page<BR>';
00321 $fDetails.=$this->renderRadioBox($prefix.'[conf_unique]',$fConf['conf_unique'],'').'Not unique (default)<BR>';
00322 $fDetails.='<BR>';
00323 $fDetails.=$this->renderCheckBox($prefix.'[conf_wiz_color]',$fConf['conf_wiz_color']).'Add colorpicker wizard<BR>';
00324 $fDetails.=$this->resImg('t_input_colorwiz.png','hspace=20','','<BR><BR>');
00325 $fDetails.=$this->renderCheckBox($prefix.'[conf_wiz_link]',$fConf['conf_wiz_link']).'Add link wizard<BR>';
00326 $fDetails.=$this->resImg('t_input_link2.png','hspace=20','','<BR><BR>');
00327 break;
00328 case 'input':
00329 $typeCfg.=$this->resImg('t_input.png','','');
00330
00331 $fDetails.=$this->renderStringBox($prefix.'[conf_size]',$fConf['conf_size'],50).' Field width (5-48 relative, 30 default)<BR>';
00332 $fDetails.=$this->renderStringBox($prefix.'[conf_max]',$fConf['conf_max'],50).' Max characters<BR>';
00333 $fDetails.=$this->renderCheckBox($prefix.'[conf_required]',$fConf['conf_required']).'Required<BR>';
00334 $fDetails.=$this->resImg('t_input_required.png','hspace=20','','<BR><BR>');
00335
00336 $fDetails.=$this->renderCheckBox($prefix.'[conf_varchar]',$fConf['conf_varchar']).'Create VARCHAR, not TINYTEXT field<BR>';
00337 break;
00338 case 'textarea':
00339 case 'textarea_nowrap':
00340 $typeCfg.=$this->resImg('t_textarea.png','','');
00341
00342 $fDetails.=$this->renderStringBox($prefix.'[conf_cols]',$fConf['conf_cols'],50).' Textarea width (5-48 relative, 30 default)<BR>';
00343 $fDetails.=$this->renderStringBox($prefix.'[conf_rows]',$fConf['conf_rows'],50).' Number of rows (height)<BR>';
00344 $fDetails.='<BR>';
00345 $fDetails.=$this->renderCheckBox($prefix.'[conf_wiz_example]',$fConf['conf_wiz_example']).'Add wizard example<BR>';
00346 $fDetails.=$this->resImg('t_textarea_wiz.png','hspace=20','','<BR><BR>');
00347 break;
00348 case 'textarea_rte':
00349 $typeCfg.=$this->resImg($fConf['conf_rte']!='tt_content'?'t_rte.png':'t_rte2.png','','');
00350
00351 $optValues = array(
00352 'tt_content' => 'Transform content like the Content Element "Bodytext" field (default/old)',
00353 'basic' => 'Typical basic setup (new "Bodytext" field based on CSS stylesheets)',
00354 'moderate' => 'Moderate transform of images and links',
00355 'none' => 'No transformation at all',
00356 'custom' => 'Custom'
00357 );
00358 $fDetails.='<BR>Rich Text Editor Mode:<BR>'.$this->renderSelectBox($prefix.'[conf_rte]',$fConf['conf_rte'],$optValues).'<BR>';
00359 if ((string)$fConf['conf_rte']=='custom') {
00360 $optValues = array(
00361 'cut' => array('Cut button'),
00362 'copy' => array('Copy button'),
00363 'paste' => array('Paste button'),
00364 'formatblock' => array('Paragraph formatting','<DIV>, <P>'),
00365 'class' => array('Character formatting','<SPAN>)'),
00366 'fontstyle' => array('Font face','<FONT face=>)'),
00367 'fontsize' => array('Font size','<FONT size=>)'),
00368 'textcolor' => array('Font color','<FONT color=>'),
00369 'bold' => array('Bold','<STRONG>, <B>'),
00370 'italic' => array('italic','<EM>, <I>'),
00371 'underline' => array('Underline','<U>'),
00372 'left' => array('Left align','<DIV>, <P>'),
00373 'center' => array('Center align','<DIV>, <P>'),
00374 'right' => array('Right align','<DIV>, <P>'),
00375 'orderedlist' => array('Ordered bulletlist','<OL>, <LI>'),
00376 'unorderedlist' => array('Unordered bulletlist','<UL>, <LI>'),
00377 'outdent' => array('Outdent block','<BLOCKQUOTE>'),
00378 'indent' => array('Indent block','<BLOCKQUOTE>'),
00379 'link' => array('Link','<A>'),
00380 'table' => array('Table','<TABLE>, <TR>, <TD>'),
00381 'image' => array('Image','<IMG>'),
00382 'line' => array('Ruler','<HR>'),
00383 'user' => array('User defined',''),
00384 'chMode' => array('Edit source?','')
00385 );
00386 $subLines=array();
00387 $subLines[]='<tr>
00388 <td> </td>
00389 <td> </td>
00390 <td><strong>'.$this->fw('Button name:').'</strong></td>
00391 <td><strong>'.$this->fw('Tags allowed:').'</strong></td>
00392 </tr>';
00393 foreach($optValues as $kk=>$vv) {
00394 $subLines[]='<tr>
00395 <td>'.$this->renderCheckBox($prefix.'[conf_rte_b_'.$kk.']',$fConf['conf_rte_b_'.$kk]).'</td>
00396 <td>'.$this->resIcon($kk.'.png').'</td>
00397 <td>'.$this->fw($vv[0]).'</td>
00398 <td>'.$this->fw(htmlspecialchars($vv[1])).'</td>
00399 </tr>';
00400 }
00401 $fDetails.='<table border=0 cellpadding=2 cellspacing=2>'.implode('',$subLines).'</table><BR>';
00402
00403 $fDetails.='<BR><strong>Define specific colors:</strong><BR>
00404 <em>Notice: Use only HEX-values for colors ("blue" should be #0000ff etc.)</em><BR>';
00405 for($a=1;$a<4;$a++) {
00406 $fDetails.='Color #'.$a.': '.$this->renderStringBox($prefix.'[conf_rte_color'.$a.']',$fConf['conf_rte_color'.$a],70).'<BR>';
00407 }
00408 $fDetails.=$this->resImg('t_rte_color.png','','','<BR><BR>');
00409
00410 $fDetails.=$this->renderCheckBox($prefix.'[conf_rte_removecolorpicker]',$fConf['conf_rte_removecolorpicker']).'Hide colorpicker<BR>';
00411 $fDetails.=$this->resImg('t_rte_colorpicker.png','hspace=20','','<BR><BR>');
00412
00413 $fDetails.='<BR><strong>Define classes:</strong><BR>';
00414 for($a=1;$a<7;$a++) {
00415 $fDetails.='Class Title:'.$this->renderStringBox($prefix.'[conf_rte_class'.$a.']',$fConf['conf_rte_class'.$a],100).
00416 '<BR>CSS Style: {'.$this->renderStringBox($prefix.'[conf_rte_class'.$a.'_style]',$fConf['conf_rte_class'.$a.'_style'],250).'}'.
00417 '<BR>';
00418 }
00419 $fDetails.=$this->resImg('t_rte_class.png','','','<BR><BR>');
00420
00421 # $fDetails.=$this->renderCheckBox($prefix."[conf_rte_removePdefaults]",$fConf["conf_rte_removePdefaults"])."<BR>";
00422 $optValues = array(
00423 '0' => '',
00424 '1' => 'Hide Hx and PRE from Paragraph selector.',
00425 'H2H3' => 'Hide all, but H2,H3,P,PRE',
00426 );
00427 $fDetails.='<BR>Hide Paragraph Items:<BR>'.$this->renderSelectBox($prefix.'[conf_rte_removePdefaults]',$fConf['conf_rte_removePdefaults'],$optValues).'<BR>';
00428 $fDetails.=$this->resImg('t_rte_hideHx.png','hspace=20','','<BR><BR>');
00429
00430 $fDetails.='<BR><strong>Misc:</strong><BR>';
00431
00432 $fDetails.=$this->renderCheckBox($prefix.'[conf_rte_div_to_p]',isset($fConf['conf_rte_div_to_p'])?$fConf['conf_rte_div_to_p']:1).htmlspecialchars('Convert all <DIV> to <P>').'<BR>';
00433 }
00434
00435 $fDetails.='<BR>';
00436 $fDetails.=$this->renderCheckBox($prefix.'[conf_rte_fullscreen]',isset($fConf['conf_rte_fullscreen'])?$fConf['conf_rte_fullscreen']:1).'Fullscreen link<BR>';
00437 $fDetails.=$this->resImg('t_rte_fullscreen.png','hspace=20','','<BR><BR>');
00438
00439 if (t3lib_div::inList('moderate,basic,custom',$fConf['conf_rte'])) {
00440 $fDetails.='<BR>';
00441 $fDetails.=$this->renderCheckBox($prefix.'[conf_rte_separateStorageForImages]',isset($fConf['conf_rte_separateStorageForImages'])?$fConf['conf_rte_separateStorageForImages']:1).'Storage of images in separate folder (in uploads/[extfolder]/rte/)<BR>';
00442 }
00443 if (t3lib_div::inList('moderate,custom',$fConf['conf_rte'])) {
00444 $fDetails.='<BR>';
00445 $fDetails.=$this->renderCheckBox($prefix.'[conf_mode_cssOrNot]',isset($fConf['conf_mode_cssOrNot'])?$fConf['conf_mode_cssOrNot']:1) . 'Use "ts_css" transformation instead of "ts_images-ts-reglinks"<BR>';
00446 }
00447 break;
00448 case 'check':
00449 $typeCfg.=$this->resImg('t_input_link.png','','');
00450 $fDetails.=$this->renderCheckBox($prefix.'[conf_check_default]',$fConf['conf_check_default']).'Checked by default<BR>';
00451 break;
00452 case 'select':
00453 case 'radio':
00454 if ($fConf['type']=='radio') {
00455 $typeCfg.=$this->resImg('t_radio.png','','');
00456 } else {
00457 $typeCfg.=$this->resImg('t_sel.png','','');
00458 }
00459 $fDetails.='<BR><strong>Define values:</strong><BR>';
00460 $subLines=array();
00461 $subLines[]='<tr>
00462 <td valign=top>'.$this->fw('Item label:').'</td>
00463 <td valign=top>'.$this->fw('Item value:').'</td>
00464 </tr>';
00465 $nItems = $fConf['conf_select_items'] = isset($fConf['conf_select_items'])?t3lib_div::intInRange(intval($fConf['conf_select_items']),0,20):4;
00466 for($a=0;$a<$nItems;$a++) {
00467 $subLines[]='<tr>
00468 <td valign=top>'.$this->fw($this->renderStringBox_lang('conf_select_item_'.$a,$prefix,$fConf)).'</td>
00469 <td valign=top>'.$this->fw($this->renderStringBox($prefix.'[conf_select_itemvalue_'.$a.']',isset($fConf['conf_select_itemvalue_'.$a])?$fConf['conf_select_itemvalue_'.$a]:$a,50)).'</td>
00470 </tr>';
00471 }
00472 $fDetails.='<table border=0 cellpadding=2 cellspacing=2>'.implode('',$subLines).'</table><BR>';
00473 $fDetails.=$this->renderStringBox($prefix.'[conf_select_items]',$fConf['conf_select_items'],50).' Number of values<BR>';
00474
00475 if ($fConf['type']=='select') {
00476 $fDetails.=$this->renderCheckBox($prefix.'[conf_select_icons]',$fConf['conf_select_icons']).'Add a dummy set of icons<BR>';
00477 $fDetails.=$this->resImg('t_select_icons.png','hspace=20','','<BR><BR>');
00478
00479 $fDetails.=$this->renderStringBox($prefix.'[conf_relations]',t3lib_div::intInRange($fConf['conf_relations'],1,1000),50).' Max number of relations<BR>';
00480 $fDetails.=$this->renderStringBox($prefix.'[conf_relations_selsize]',t3lib_div::intInRange($fConf['conf_relations_selsize'],1,50),50).' Size of selector box<BR>';
00481
00482 $fDetails.=$this->renderCheckBox($prefix.'[conf_select_pro]',$fConf['conf_select_pro']).'Add pre-processing with PHP-function<BR>';
00483 }
00484 break;
00485 case 'rel':
00486 if ($fConf['conf_rel_type']=='group' || !$fConf['conf_rel_type']) {
00487 $typeCfg.=$this->resImg('t_rel_group.png','','');
00488 } elseif(intval($fConf['conf_relations'])>1) {
00489 $typeCfg.=$this->resImg('t_rel_selmulti.png','','');
00490 } elseif(intval($fConf['conf_relations_selsize'])>1) {
00491 $typeCfg.=$this->resImg('t_rel_selx.png','','');
00492 } else {
00493 $typeCfg.=$this->resImg('t_rel_sel1.png','','');
00494 }
00495
00496
00497 $optValues = array(
00498 'pages' => 'Pages table, (pages)',
00499 'fe_users' => 'Frontend Users, (fe_users)',
00500 'fe_groups' => 'Frontend Usergroups, (fe_groups)',
00501 'tt_content' => 'Content elements, (tt_content)',
00502 '_CUSTOM' => 'Custom table (enter name below)',
00503 '_ALL' => 'All tables allowed!',
00504 );
00505 if ($fConf['conf_rel_type']!='group') {unset($optValues['_ALL']);}
00506 $optValues = $this->addOtherExtensionTables($optValues);
00507 $fDetails.='<BR>Create relation to table:<BR>'.$this->renderSelectBox($prefix.'[conf_rel_table]',$fConf['conf_rel_table'],$optValues).'<BR>';
00508 if ($fConf['conf_rel_table']=='_CUSTOM') $fDetails.='Custom table name: '.$this->renderStringBox($prefix.'[conf_custom_table_name]',$fConf['conf_custom_table_name'],200).'<BR>';
00509
00510 $optValues = array(
00511 'group' => 'Field with Element Browser',
00512 'select' => 'Selectorbox, select global',
00513 'select_cur' => 'Selectorbox, select from current page',
00514 'select_root' => 'Selectorbox, select from root page',
00515 'select_storage' => 'Selectorbox, select from storage page',
00516 );
00517 $fDetails.='<BR>Type:<BR>'.$this->renderSelectBox($prefix.'[conf_rel_type]',$fConf['conf_rel_type']?$fConf['conf_rel_type']:'group',$optValues).'<BR>';
00518 if (t3lib_div::intInRange($fConf['conf_relations'],1,1000)==1 && $fConf['conf_rel_type']!='group') {
00519 $fDetails.=$this->renderCheckBox($prefix.'[conf_rel_dummyitem]',$fConf['conf_rel_dummyitem']).'Add a blank item to the selector<BR>';
00520 }
00521
00522 $fDetails.=$this->renderStringBox($prefix.'[conf_relations]',t3lib_div::intInRange($fConf['conf_relations'],1,1000),50).' Max number of relations<BR>';
00523 $fDetails.=$this->renderStringBox($prefix.'[conf_relations_selsize]',t3lib_div::intInRange($fConf['conf_relations_selsize'],1,50),50).' Size of selector box<BR>';
00524 $fDetails.=$this->renderCheckBox($prefix.'[conf_relations_mm]',$fConf['conf_relations_mm']).'True M-M relations (otherwise commalist of values)<BR>';
00525
00526
00527 if ($fConf['conf_rel_type']!='group') {
00528 $fDetails.='<BR>';
00529 $fDetails.=$this->renderCheckBox($prefix.'[conf_wiz_addrec]',$fConf['conf_wiz_addrec']).'Add "Add record" link<BR>';
00530 $fDetails.=$this->renderCheckBox($prefix.'[conf_wiz_listrec]',$fConf['conf_wiz_listrec']).'Add "List records" link<BR>';
00531 $fDetails.=$this->renderCheckBox($prefix.'[conf_wiz_editrec]',$fConf['conf_wiz_editrec']).'Add "Edit record" link<BR>';
00532 $fDetails.=$this->resImg("t_rel_wizards.png",'hspace=20','','<BR><BR>');
00533 }
00534 break;
00535 case 'files':
00536 if ($fConf['conf_files_type']=='images') {
00537 $typeCfg.=$this->resImg('t_file_img.png','','');
00538 } elseif ($fConf['conf_files_type']=='webimages') {
00539 $typeCfg.=$this->resImg('t_file_web.png','','');
00540 } else {
00541 $typeCfg.=$this->resImg('t_file_all.png','','');
00542 }
00543
00544 $optValues = array(
00545 'images' => 'Imagefiles',
00546 'webimages' => 'Web-imagefiles (gif,jpg,png)',
00547 'all' => 'All files, except php/php3 extensions',
00548 );
00549 $fDetails.='<BR>Extensions:<BR>'.$this->renderSelectBox($prefix.'[conf_files_type]',$fConf['conf_files_type'],$optValues).'<BR>';
00550
00551 $fDetails.=$this->renderStringBox($prefix.'[conf_files]',t3lib_div::intInRange($fConf['conf_files'],1,1000),50).' Max number of files<BR>';
00552 $fDetails.=$this->renderStringBox($prefix.'[conf_max_filesize]',t3lib_div::intInRange($fConf['conf_max_filesize'],1,1000,500),50).' Max filesize allowed (kb)<BR>';
00553 $fDetails.=$this->renderStringBox($prefix.'[conf_files_selsize]',t3lib_div::intInRange($fConf['conf_files_selsize'],1,50),50).' Size of selector box<BR>';
00554 $fDetails.=$this->resImg('t_file_size.png','','','<BR><BR>');
00555
00556 $fDetails.=$this->renderCheckBox($prefix.'[conf_files_thumbs]',$fConf['conf_files_thumbs']).'Show thumbnails<BR>';
00557 $fDetails.=$this->resImg('t_file_thumb.png','hspace=20','','<BR><BR>');
00558 break;
00559 case 'integer':
00560 $typeCfg.=$this->resImg('t_integer.png','','');
00561 break;
00562 case 'check_4':
00563 case 'check_10':
00564 if ((string)$fConf['type']=='check_4') {
00565 $typeCfg.=$this->resImg('t_check4.png','','');
00566 } else {
00567 $typeCfg.=$this->resImg('t_check10.png','','');
00568 }
00569 $nItems= t3lib_div::intInRange($fConf['conf_numberBoxes'],1,10,(string)$fConf['type']=='check_4'?4:10);
00570 $fDetails.=$this->renderStringBox($prefix.'[conf_numberBoxes]',$nItems,50).' Number of checkboxes<BR>';
00571
00572 for($a=0;$a<$nItems;$a++) {
00573 $fDetails.='<BR>Label '.($a+1).':<BR>'.$this->renderStringBox_lang('conf_boxLabel_'.$a,$prefix,$fConf);
00574 }
00575 break;
00576 case 'date':
00577 $typeCfg.=$this->resImg('t_date.png','','');
00578 break;
00579 case 'datetime':
00580 $typeCfg.=$this->resImg('t_datetime.png','','');
00581 break;
00582 case 'link':
00583 $typeCfg.=$this->resImg('t_link.png','','');
00584 break;
00585 }
00586
00587 if ($fConf['type']) $typeCfg.=$this->textSetup('',$fDetails);
00588
00589 $content='<table border=0 cellpadding=0 cellspacing=0>
00590 <tr><td valign=top>'.$this->fw('Field name:').'</td><td valign=top>'.$this->fw($fieldName).'</td></tr>
00591 <tr><td valign=top>'.$this->fw('Field title:').'</td><td valign=top>'.$this->fw($fieldTitle).'</td></tr>
00592 <tr><td valign=top>'.$this->fw('Field type:').'</td><td valign=top>'.$this->fw($typeCfg).'</td></tr>
00593 </table>';
00594 return $content;
00595 }
00596
00597
00598
00599
00603 function render_extPart($k,$config,$extKey) {
00604 $WOP='[fields]['.$k.']';
00605 $tableName=$config['which_table'];
00606 # $tableName = $this->returnName($extKey,'fields',$tableName);
00607 # $prefix = 'tx_'.str_replace('_','',$extKey).'_';
00608 $prefix = $this->returnName($extKey,'fields').'_';
00609
00610 $DBfields=array();
00611 $columns=array();
00612 $ctrl=array();
00613 $enFields=array();
00614
00615 if (is_array($config['fields'])) {
00616 reset($config['fields']);
00617 while(list($i,$fConf)=each($config['fields'])) {
00618 $fConf['fieldname'] = $prefix.$fConf['fieldname'];
00619 $this->makeFieldTCA($DBfields,$columns,$fConf,$WOP.'[fields]['.$i.']',$tableName,$extKey);
00620 }
00621 }
00622
00623 if ($tableName=='tt_address') $this->wizard->EM_CONF_presets['dependencies'][]='tt_address';
00624 if ($tableName=='tt_news') $this->wizard->EM_CONF_presets['dependencies'][]='tt_news';
00625 if (t3lib_div::inList('tt_content,fe_users,fe_groups',$tableName)) $this->wizard->EM_CONF_presets['dependencies'][]='cms';
00626
00627 $createTable = $this->wrapBody('
00628 #
00629 # Table structure for table \''.$tableName.'\'
00630 #
00631 CREATE TABLE '.$tableName.' (
00632 ', ereg_replace(',[[:space:]]*$','',implode(chr(10),$DBfields)), '
00633
00634 );
00635 ');
00636 $this->wizard->ext_tables_sql[]=chr(10).$createTable.chr(10);
00637
00638
00639
00640 $this->wizard->ext_tables[]=$this->wrapBody('
00641 $tempColumns = Array (
00642 ', implode(chr(10),$columns) ,'
00643 );
00644 ');
00645
00646
00647 list($typeList) = $this->implodeColumns($columns);
00648 $applyToAll=1;
00649 if (is_array($this->wizard->wizArray['pi'])) {
00650 reset($this->wizard->wizArray['pi']);
00651 while(list(,$fC)=each($this->wizard->wizArray['pi'])) {
00652 if ($fC['apply_extended']==$k) {
00653 $applyToAll=0;
00654 $this->wizard->_apply_extended_types[$k]=$typeList;
00655 }
00656 }
00657 }
00658 $this->wizard->ext_tables[]=$this->sPS('
00659 t3lib_div::loadTCA("'.$tableName.'");
00660 t3lib_extMgm::addTCAcolumns("'.$tableName.'",$tempColumns,1);
00661 '.($applyToAll?'t3lib_extMgm::addToAllTCAtypes("'.$tableName.'","'.$typeList.'");':'').'
00662 ');
00663 }
00664
00665
00666
00667
00668
00669 function implodeColumns($columns) {
00670 reset($columns);
00671 $outems=array();
00672 $paltems=array();
00673 $c=0;
00674 $hiddenFlag=0;
00675 $titleDivFlag=0;
00676 while(list($fN)=each($columns)) {
00677 if (!$hiddenFlag || !t3lib_div::inList('starttime,endtime,fe_group',$fN)) {
00678 $outTem = array($fN,'','','','');
00679 $outTem[3] = $this->wizard->_typeP[$fN];
00680 if ($c==0) $outTem[4]='1-1-1';
00681 if ($fN=='title') {
00682 $outTem[4]='2-2-2';
00683 $titleDivFlag=1;
00684 } elseif ($titleDivFlag) {
00685 $outTem[4]='3-3-3';
00686 $titleDivFlag=0;
00687 }
00688 if ($fN=='hidden') {
00689 $outTem[2]='1';
00690 $hiddenFlag=1;
00691 }
00692 $outems[] = str_replace(',','',str_replace(chr(9),';',trim(str_replace(';','',implode(chr(9),$outTem)))));
00693 $c++;
00694 } else {
00695 $paltems[]=$fN;
00696 }
00697 }
00698 return array(implode(', ',$outems),implode(', ',$paltems));
00699 }
00700 function makeFieldTCA(&$DBfields,&$columns,$fConf,$WOP,$table,$extKey) {
00701 if (!(string)$fConf['type']) return;
00702 $id = $table.'_'.$fConf['fieldname'];
00703 #debug($fConf);
00704
00705 $configL=array();
00706 $t = (string)$fConf['type'];
00707 switch($t) {
00708 case 'input':
00709 case 'input+':
00710 $isString =1;
00711 $configL[]='"type" => "input", ' . $this->WOPcomment('WOP:'.$WOP.'[type]');
00712 $configL[]='"size" => "' . t3lib_div::intInRange($fConf['conf_size'],5,48,30) . '", ' .$this->WOPcomment('WOP:'.$WOP.'[conf_size]');
00713 if (intval($fConf['conf_max'])) $configL[]='"max" => "' . t3lib_div::intInRange($fConf['conf_max'],1,255).'", '.$this->WOPcomment('WOP:'.$WOP.'[conf_max]');
00714
00715 $evalItems=array();
00716 if ($fConf['conf_required']) {$evalItems[0][] = 'required'; $evalItems[1][] = $WOP.'[conf_required]';}
00717
00718 if ($t=='input+') {
00719 $isString = !$fConf['conf_eval'] || t3lib_div::inList('alphanum,upper,lower',$fConf['conf_eval']);
00720 if ($fConf['conf_varchar'] && $isString) {$evalItems[0][] = 'trim'; $evalItems[1][] = $WOP.'[conf_varchar]';}
00721 if ($fConf['conf_eval']=='int+') {
00722 $configL[]='"range" => Array ("lower"=>0,"upper"=>1000), '.$this->WOPcomment('WOP:'.$WOP.'[conf_eval] = int+ results in a range setting');
00723 $fConf['conf_eval']='int';
00724 }
00725 if ($fConf['conf_eval']) {$evalItems[0][] = $fConf['conf_eval']; $evalItems[1][] = $WOP.'[conf_eval]';}
00726 if ($fConf['conf_check']) $configL[]='"checkbox" => "'.($isString?'':'0').'", '.$this->WOPcomment('WOP:'.$WOP.'[conf_check]');
00727
00728 if ($fConf['conf_stripspace']) {$evalItems[0][] = 'nospace'; $evalItems[1][] = $WOP.'[conf_stripspace]';}
00729 if ($fConf['conf_pass']) {$evalItems[0][] = 'password'; $evalItems[1][] = $WOP.'[conf_pass]';}
00730 if ($fConf['conf_unique']) {
00731 if ($fConf['conf_unique']=='L') {$evalItems[0][] = 'uniqueInPid'; $evalItems[1][] = $WOP.'[conf_unique] = Local (unique in this page (PID))';}
00732 if ($fConf['conf_unique']=='G') {$evalItems[0][] = 'unique'; $evalItems[1][] = $WOP.'[conf_unique] = Global (unique in whole database)';}
00733 }
00734
00735 $wizards =array();
00736 if ($fConf['conf_wiz_color']) {
00737 $wizards[] = trim($this->sPS('
00738 '.$this->WOPcomment('WOP:'.$WOP.'[conf_wiz_color]').'
00739 "color" => Array(
00740 "title" => "Color:",
00741 "type" => "colorbox",
00742 "dim" => "12x12",
00743 "tableStyle" => "border:solid 1px black;",
00744 "script" => "wizard_colorpicker.php",
00745 "JSopenParams" => "height=300,width=250,status=0,menubar=0,scrollbars=1",
00746 ),
00747 '));
00748 }
00749 if ($fConf['conf_wiz_link']) {
00750 $wizards[] = trim($this->sPS('
00751 '.$this->WOPcomment('WOP:'.$WOP.'[conf_wiz_link]').'
00752 "link" => Array(
00753 "type" => "popup",
00754 "title" => "Link",
00755 "icon" => "link_popup.gif",
00756 "script" => "browse_links.php?mode=wizard",
00757 "JSopenParams" => "height=300,width=500,status=0,menubar=0,scrollbars=1"
00758 ),
00759 '));
00760 }
00761 if (count($wizards)) {
00762 $configL[]=trim($this->wrapBody('
00763 "wizards" => Array(
00764 "_PADDING" => 2,
00765 ',implode(chr(10),$wizards),'
00766 ),
00767 '));
00768 }
00769 } else {
00770 if ($fConf['conf_varchar']) {$evalItems[0][] = 'trim'; $evalItems[1][] = $WOP.'[conf_varchar]';}
00771 }
00772
00773 if (count($evalItems)) $configL[]='"eval" => "'.implode(",",$evalItems[0]).'", '.$this->WOPcomment('WOP:'.implode(" / ",$evalItems[1]));
00774
00775 if (!$isString) {
00776 $DBfields[] = $fConf['fieldname'] . ' int(11) DEFAULT \'0\' NOT NULL,';
00777 } elseif (!$fConf['conf_varchar']) {
00778 $DBfields[] = $fConf['fieldname'] . ' tinytext NOT NULL,';
00779 } else {
00780 $varCharLn = (intval($fConf['conf_max'])?t3lib_div::intInRange($fConf['conf_max'],1,255):255);
00781 $DBfields[] = $fConf['fieldname'] . ' ' . ($varCharLn>$this->wizard->charMaxLng?'var':'') . 'char(' . $varCharLn .') DEFAULT "" NOT NULL,';
00782 }
00783 break;
00784 case 'link':
00785 $DBfields[] = $fConf['fieldname'].' tinytext NOT NULL,';
00786 $configL[]=trim($this->sPS('
00787 "type" => "input",
00788 "size" => "15",
00789 "max" => "255",
00790 "checkbox" => "",
00791 "eval" => "trim",
00792 "wizards" => Array(
00793 "_PADDING" => 2,
00794 "link" => Array(
00795 "type" => "popup",
00796 "title" => "Link",
00797 "icon" => "link_popup.gif",
00798 "script" => "browse_links.php?mode=wizard",
00799 "JSopenParams" => "height=300,width=500,status=0,menubar=0,scrollbars=1"
00800 )
00801 )
00802 '));
00803 break;
00804 case 'datetime':
00805 case 'date':
00806 $DBfields[] = $fConf['fieldname'].' int(11) DEFAULT \'0\' NOT NULL,';
00807 $configL[]=trim($this->sPS('
00808 "type" => "input",
00809 "size" => "'.($t=="datetime"?12:8).'",
00810 "max" => "20",
00811 "eval" => "'.$t.'",
00812 "checkbox" => "0",
00813 "default" => "0"
00814 '));
00815 break;
00816 case 'integer':
00817 $DBfields[] = $fConf['fieldname'] . ' int(11) DEFAULT \'0\' NOT NULL,';
00818 $configL[]=trim($this->sPS('
00819 "type" => "input",
00820 "size" => "4",
00821 "max" => "4",
00822 "eval" => "int",
00823 "checkbox" => "0",
00824 "range" => Array (
00825 "upper" => "1000",
00826 "lower" => "10"
00827 ),
00828 "default" => 0
00829 '));
00830 break;
00831 case 'textarea':
00832 case 'textarea_nowrap':
00833 $DBfields[] = $fConf['fieldname'].' text NOT NULL,';
00834 $configL[]='"type" => "text",';
00835 if ($t=='textarea_nowrap') {
00836 $configL[]='"wrap" => "OFF",';
00837 }
00838 $configL[]='"cols" => "'.t3lib_div::intInRange($fConf["conf_cols"],5,48,30).'", '.$this->WOPcomment('WOP:'.$WOP.'[conf_cols]');
00839 $configL[]='"rows" => "'.t3lib_div::intInRange($fConf["conf_rows"],1,20,5).'", '.$this->WOPcomment('WOP:'.$WOP.'[conf_rows]');
00840 if ($fConf["conf_wiz_example"]) {
00841 $wizards =array();
00842 $wizards[] = trim($this->sPS('
00843 '.$this->WOPcomment('WOP:'.$WOP.'[conf_wiz_example]').'
00844 "example" => Array(
00845 "title" => "Example Wizard:",
00846 "type" => "script",
00847 "notNewRecords" => 1,
00848 "icon" => t3lib_extMgm::extRelPath("'.$extKey.'")."'.$id.'/wizard_icon.gif",
00849 "script" => t3lib_extMgm::extRelPath("'.$extKey.'")."'.$id.'/index.php",
00850 ),
00851 '));
00852
00853 $cN = $this->returnName($extKey,'class',$id.'wiz');
00854 $this->writeStandardBE_xMod(
00855 $extKey,
00856 array('title'=>'Example Wizard title...'),
00857 $id.'/',
00858 $cN,
00859 0,
00860 $id.'wiz'
00861 );
00862 $this->addFileToFileArray($id.'/wizard_icon.gif',t3lib_div::getUrl(t3lib_extMgm::extPath('kickstarter').'res/notfound.gif'));
00863
00864 $configL[]=trim($this->wrapBody('
00865 "wizards" => Array(
00866 "_PADDING" => 2,
00867 ',implode(chr(10),$wizards),'
00868 ),
00869 '));
00870 }
00871 break;
00872 case 'textarea_rte':
00873 $DBfields[] = $fConf['fieldname'].' text NOT NULL,';
00874 $configL[]='"type" => "text",';
00875