PageRenderTime 95ms CodeModel.GetById 3ms app.highlight 79ms RepoModel.GetById 1ms app.codeStats 0ms

/mth_feedit_sm/class.tx_mthfeedit.php

https://github.com/michael-cannon/typo3-extensions
PHP | 1647 lines | 1477 code | 62 blank | 108 comment | 46 complexity | 87b55ec44d63c9d03dce16a506d5be9f MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1<?php
  2/***************************************************************
  3*  Copyright notice
  4*
  5*  (c) 2005 Morten Tranberg Hansen (mth@daimi.au.dk)
  6*  All rights reserved
  7*
  8*  This script is part of the TYPO3 project. The TYPO3 project is
  9*  free software; you can redistribute it and/or modify
 10*  it under the terms of the GNU General Public License as published by
 11*  the Free Software Foundation; either version 2 of the License, or
 12*  (at your option) any later version.
 13*
 14*  The GNU General Public License can be found at
 15*  http://www.gnu.org/copyleft/gpl.html.
 16*
 17*  This script is distributed in the hope that it will be useful,
 18*  but WITHOUT ANY WARRANTY; without even the implied warranty of
 19*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 20*  GNU General Public License for more details.
 21*
 22*  This copyright notice MUST APPEAR in all copies of the script!
 23***************************************************************/
 24/**
 25 * This is a API for crating and editing records in the frontend.
 26 * The API is build on top of fe_adminLib.
 27 * See documentation or extensions 'news_feedit' and 'joboffers_feedit' for examples how to use this API
 28 *
 29 * @author	Morten Tranberg Hansen <mth@daimi.au.dk>
 30 */
 31
 32/* $Id: class.tx_mthfeedit.php,v 1.1.1.1 2010/04/15 10:03:51 peimic.comprock Exp $ */
 33//Jaspreet Singh: This is a generic plugin for frontend editing that was modified adhoc just to get it
 34//working fast for Savvy Miss blogs.  There are some hacks.  You have been warned.
 35
 36require_once(PATH_tslib.'class.tslib_pibase.php');
 37require_once(PATH_site.TYPO3_mainDir.'sysext/lang/lang.php');
 38require_once(PATH_t3lib.'class.t3lib_parsehtml_proc.php');
 39define(PATH_typo3,PATH_site.TYPO3_mainDir); // used in template.php
 40require_once(PATH_site.TYPO3_mainDir.'template.php');
 41if(t3lib_extmgm::isLoaded('rtehtmlarea')) require_once(t3lib_extMgm::extPath('rtehtmlarea').'pi2/class.tx_rtehtmlarea_pi2.php');
 42if(t3lib_extmgm::isLoaded('rlmp_dateselectlib')) require_once(t3lib_extMgm::extPath('rlmp_dateselectlib').'class.tx_rlmpdateselectlib.php');
 43
 44class tx_mthfeedit {
 45  // Private fields
 46  var $prefixId = 'tx_mthfeedit';		// Same as class name
 47  var $scriptRelPath = 'class.tx_mthfeedit.php';	// Path to this script relative to the extension dir.
 48  var $extKey = 'mth_feedit';	// The extension key.
 49
 50  var $conf;
 51  var $cObj; // contains an initialized cObj, so we can use the cObj functions whenever we want to.
 52  var $templateObj; // contains an initialized templateObj, so we can use the template functions whenever we want to.(ex with dynamic tabs)
 53  var $caller; // the caller
 54  var $table; // the table
 55  var $TCA; // contains the complete TCA of the $table
 56  var $cmd; // this is 'hopefully' the same value as fe_adminLib's cmd.
 57  var $id_field = ''; // the field from a record witch will identify the record.
 58  var $additionalJS_end = array(); // JS to be added after the end of the content.
 59#  var $LANG; // language object, used to translate 'complicated' label strings to the single label.
 60
 61
 62  // Fields for the RTE API
 63  var $strEntryField;
 64
 65  var $RTEObj;
 66  var $docLarge = 0;
 67  var $RTEcounter = 0;
 68  var $formName;
 69  var $additionalJS_initial = '';// Initial JavaScript to be printed before the form (should be in head, but cannot due to IE6 timing bug)
 70  var $additionalJS_pre = array();// Additional JavaScript to be printed before the form (works in Mozilla/Firefox when included in head, but not in IE6)
 71  var $additionalJS_post = array();// Additional JavaScript to be printed after the form
 72  var $additionalJS_submit = array();// Additional JavaScript to be executed on submit
 73  var $PA = array(
 74		  'itemFormElName' =>  '',
 75		  'itemFormElValue' => '',
 76		  );
 77  var $specConf = array();
 78  var $thisConfig = array();
 79  var $RTEtypeVal = 'text';
 80  var $thePidValue;
 81
 82  /**
 83   * [Put your description here]
 84   */
 85  function init($caller,$conf)	{
 86
 87    $GLOBALS['TSFE']->set_no_cache();  
 88
 89    /**** SET PRIVATE VARS ****/
 90    $this->conf = $this->array_merge_recursive2($this->getDefaultConfArray(),$conf);
 91    $this->cObj = t3lib_div::makeInstance('tslib_cObj');
 92    $this->templateObj = t3lib_div::makeInstance('mediumDoc');
 93    $this->table = $conf["table"];
 94    $this->caller = $caller;   
 95#    debug($this->conf);
 96    $this->cmd = (string)t3lib_div::_GP('cmd') ? (string)t3lib_div::_GP('cmd') : $this->conf['defaultCmd'];
 97    if (!$this->cmd) debug("WARNING:: NO COMMAND SPECIFIED FOR THE SCRIPT","NO COMMAND");
 98
 99    $this->id_field = $GLOBALS["TCA"][$this->table]["ctrl"]["label"];
100
101    // init $this->RTEObj if rtehtmlarea is availiable
102    if(t3lib_extmgm::isLoaded('rtehtmlarea') && !$this->RTEObj) 
103      $this->RTEObj = t3lib_div::makeInstance('tx_rtehtmlarea_pi2');//&t3lib_BEfunc::RTEgetObj();//
104
105    /**** LOAD LOCALLANG ****/
106    // loads default locallang
107    $this->LOCAL_LANG = $GLOBALS['TSFE']->readLLfile(t3lib_extMgm::extPath($this->extKey).'locallang.php');
108    // loads callers locallang
109    $this->LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($this->LOCAL_LANG,$caller->LOCAL_LANG);  
110    // if LANG object is there, loads it with the frontend language from TSFE object
111    if(is_object($GLOBALS['LANG'])) {
112      $GLOBALS['LANG']->init($GLOBALS['TSFE']->lang);
113    }
114
115    /**** LOAD TCA_DESCR ****/
116    if($this->conf['help']) {
117      t3lib_extMgm::addLLrefForTCAdescr($this->table,$this->conf['help.']['file']); 
118      $GLOBALS['LANG']->loadSingleTableDescription($this->table);     
119      // set default values.
120      $this->conf['help.']['type_keys'] = $this->conf['help.']['type_keys'] ? $this->conf['help.']['type_keys'] : 'description';
121      $this->conf['help.']['window.']['width'] = intval($this->conf['help.']['window.']['width'])?intval($this->conf['help.']['window.']['width']):'300';
122      $this->conf['help.']['window.']['height'] = intval($this->conf['help.']['window.']['height'])?intval($this->conf['help.']['window.']['height']):'40';
123#      debug($GLOBALS['TCA_DESCR']);
124    }
125
126    /**** LOAD TCA ****/
127    $GLOBALS['TSFE']->includeTCA(); // THIS IS VERY IMPORTANT! If loaded here, it wont be loaded again and out extra TCA configurations will NOT be overriden
128    t3lib_div::loadTCA($this->table);   
129    // Set private TCA var
130    $this->TCA = &$GLOBALS["TCA"][$this->table];    
131
132	// MLC set blogs
133	$this->TCA["ctrl"]["title"]	= "Blog Entry";
134	#    debug($this->TCA,'TCA');
135
136    /**** CONFIGURE TCA ****/
137    $GLOBALS["TCA"][$this->table]["feInterface"]["fe_admin_fieldList"] = $this->conf['create.']['fields'] ? $this->conf['create.']['fields'].($this->conf['edit.']['fields']?','.$this->conf['edit.']['fields']:'') : $this->conf['edit.']['fields'];
138    if($this->conf['fe_cruser_id']) 
139      $GLOBALS["TCA"][$this->table]['ctrl']['fe_cruser_id'] = $this->conf['fe_cruser_id'];
140    if($this->conf['fe_crgroup_id'] && $this->conf['allowedGroups']) {
141      $GLOBALS["TCA"][$this->table]['ctrl']['fe_crgroup_id'] = $this->conf['fe_crgroup_id'];
142    }
143
144#    debug($this->TCA);
145#    debug(t3lib_div::_GP('FE'),'FE');
146#    debug($_FILES,'$_FILES');
147#    debug($this->conf);
148
149    /**** Init language object (used for translation of labels) ****/
150    $GLOBALS['TSFE']->initLLvars();
151
152    /**** Init Robert Lemkes dateselectlib if it is loaded  ****/
153    if(t3lib_extmgm::isLoaded('rlmp_dateselectlib')) tx_rlmpdateselectlib::includeLib();
154
155    /**** DO ADDITIONAL REQUIRED STUFF FOR THE FIELDS ****/
156    $fieldArray = explode(',',$this->conf[$this->cmd.'.']['show_fields']);
157    foreach((array)$fieldArray as $fN) { //runs through the different fields
158      // make sure --div-- is in allowed fields list
159      $parts = explode(";",$fN);
160      if($parts[0]=='--div--') {
161	$this->conf[$this->cmd.'.']['fields'] .= $this->conf[$this->cmd.'.']['fields'] ? $this->conf[$this->cmd.'.']['fields'].','.$fN : $fN;
162      }
163      // do stuff according to type from TCA
164      switch((string)$this->TCA['columns'][$fN]['config']['type']) {
165      case 'group':
166	if($this->TCA['columns'][$fN]['config']['internal_type']=='file') {
167	  $this->conf[$this->cmd.'.']['fields'] .= ','.$fN.'_file'; // add the upload field to the allowed fields
168	  $GLOBALS['TCA'][$this->table]['columns'][$fN.'_file']['config']['uploadfolder'] = $GLOBALS['TCA'][$this->table]['columns'][$fN]['config']['uploadfolder']; // the new upload field should have the same upload folder as the original field
169	  $this->conf['parseValues.'][$fN.'_file'] = 'files['.ereg_replace(',',';',$this->TCA['columns'][$fN]['config']['allowed']).']['.$this->TCA['columns'][$fN]['config']['max_size'].']'; // adds the parse options for the new field, so it will be parsed as a file.
170	}
171      }
172    }
173
174    /**** CHECK IF LOGIN IS REQUIRED ****/
175    if($this->conf['requireLogin'] && !$GLOBALS['TSFE']->loginUser) return $this->getLL("login_required_message");
176
177    /**** FE ADMIN LIB ****/
178    $feAConf = $this->conf;
179    $feAConf["templateContent"]= $this->getDefaultTemplate(); // gets the default template
180#    debug($feAConf);
181
182    $content = $this->cObj->cObjGetSingle('USER_INT',$feAConf);
183
184    /**** ADDS THE REQUIRED JAVASCRIPTS ****/    
185    $content = $this->getJSBefore() . $content;
186    $content .= $this->getJSAfter();
187
188#    debug($content,'content');
189    return $content;
190  }
191
192  /*
193   * Default configurations for fe_adminLib
194   */
195  function getDefaultConfArray() {
196    return array(
197		 'userFunc' => 'user_feAdmin->init',
198		 'includeLibs' => 'media/scripts/fe_adminLib.inc',
199		 'userFunc_updateArray' => 'tx_mthfeedit->updateArray',
200		 'evalFunc' => 'tx_mthfeedit->processDataArray',
201
202		 'create' => 1,
203		 'create.' => array(
204				    'preview' => 1,
205				    'userFunc_afterSave' => 'tx_mthfeedit->afterSave',
206				    ),
207		 'edit' => 1,
208		 'edit.' => array(
209				  'preview' => 1,
210				  'menuLockPid' => 1,
211				  'userFunc_afterSave' => 'tx_mthfeedit->afterSave',
212				  ),
213		 'delete' => 1,
214		 'delete.' => array(
215				  'preview' => 1,
216				  ),
217		 'setfixed' => 1,
218		 'setfixed.' => array(
219				      'approve.' => array(
220							  'hidden' => 0,
221							  '_FIELDLIST' => 'uid,pid',
222							  ),
223				      'DELETE' => 1,
224				      'DELETE.' => array(
225							  '_FIELDLIST' => 'uid,pid',
226							  ),
227				    ),
228
229		 'no_cache' => 1,
230		 'no_header' => 0,
231		 'keep_piVars' => '',
232		 'defaultCmd' => 'edit',
233		 'infomail' => 0,
234		 'required_marker' => '*',
235		 'clearCacheOfPages' => $GLOBALS['TSFE']->id,
236		 );
237  }
238
239
240  /**********************************************************************************************
241   * TEMPLATE FUNCTIONS
242   **********************************************************************************************/
243
244  /**
245   * Gets a default template made from the TCA.
246   * The template there is returned depends on what $this->cmd is.
247   */
248  function getDefaultTemplate()	{
249    $callerMethods = get_class_methods(get_class($this->caller));
250    
251    $template = array_search('getrequiredtemplate',$callerMethods) || array_search('getRequiredTemplate',$callerMethods)? 
252      $this->caller->getRequiredTemplate() : $this->getRequiredTemplate();
253    $template .= array_search('getemailtemplate',$callerMethods) || array_search('getEmailTemplate',$callerMethods)? 
254      $this->caller->getEmailTemplate() : $this->getEmailTemplate();
255    switch((string)$this->cmd) {
256    case 'edit':
257      $template .= array_search('getedittemplate',$callerMethods) || array_search('getEditTemplate',$callerMethods)? 
258	$this->caller->getEditTemplate() : $this->getEditTemplate();
259      $template .= array_search('geteditmenutemplate',$callerMethods) || array_search('getEditMenuTemplate',$callerMethods)? 
260	$this->caller->getEditMenuTemplate() : $this->getEditMenuTemplate();
261      break;
262    case 'create':
263      $template .= array_search('getcreatetemplate',$callerMethods) || array_search('getCreateTemplate',$callerMethods)? 
264	$this->caller->getCreateTemplate() : $this->getCreateTemplate();
265      break;
266    case 'delete':
267      $template .= array_search('getdeletetemplate',$callerMethods) || array_search('getDeleteTemplate',$callerMethods)? 
268	$this->caller->getDeleteTemplate() : $this->getDeleteTemplate();
269      break;
270    case 'setfixed':
271      $template .= array_search('getsetfixedtemplate',$callerMethods) || array_search('getSetfixedTemplate',$callerMethods)? 
272	$this->caller->getSetfixedTemplate() : $this->getSetfixedTemplate();
273      break;
274    default:
275      debug('mth_feedit->getDefaultTemplate():: No template found for cmd='.$this->cmd,'No Template');
276      $template = '';
277    }
278#    debug(array($template));
279    return $template;
280  }
281
282
283  /**
284   * Makes the form content from the TCA according to the configuration for the $cmd
285   * @param	string		The cmd. Should be 'edit' or 'create'.
286   */
287  function makeHTMLForm($cmd)	{
288    $fields = array_intersect( array_unique(t3lib_div::trimExplode(",",$this->conf[$cmd.'.']['show_fields'],1)) , array_unique(t3lib_div::trimExplode(",",$this->conf[$cmd.'.']['fields'],1)));
289    $reqFields = array_intersect( array_unique(t3lib_div::trimExplode(",",$this->conf[$cmd.'.']["required"],1)) , array_unique(t3lib_div::trimExplode(",",$this->conf[$cmd.'.']['show_fields'],1)));
290
291    $out_array = array();
292    $out_sheet = 0;
293
294#    debug($fields,'fields');
295    while(list(,$fN)=each($fields))	{
296      $parts = explode(';',$fN);
297      $fN = $parts[0];
298      
299      if($fN=='--div--') {
300	if($this->conf["divide2tabs"]) {
301	    $out_sheet++;
302	    $out_array[$out_sheet] = array();
303	    $out_array[$out_sheet]['title'] = $this->getLL($parts[1],'Tab '.$out_sheet);
304	}
305      } else {
306
307#      debug(is_object($GLOBALS['TBE_TEMPLATE']));      
308	$fieldCode = $this->getFormFieldCode($cmd,$fN);
309	if ($fieldCode)	{
310
311	  // NOTE: There are two ways to make a field required. The new way is to include 'required' in evalValues for a field. The old one is to have the the field in the required list.
312	  //       The new way take precedence over the old way. So if the new field has some evalValues, it makes no different if the field is in the required list or not.
313	  $feData=t3lib_div::_GP('FE');
314	  if($this->conf[$cmd.'.']['evalValues.'][$fN]) {        // evalValues defined
315	    $msg = is_array($feData[$this->table]) ? '<div'.$this->caller->pi_classParam('form-error-field').'>###EVAL_ERROR_FIELD_'.$fN.'###</div>' : '';  // if no data is sent, no data is evaluated, and then no error msg should be displayed
316	    $reqMarker = in_array('required',t3lib_div::trimExplode(',',$this->conf[$cmd.'.']['evalValues.'][$fN])) ? $this->conf['required_marker'] : '';
317	  } elseif (in_array($fN,$reqFields)) {                                  // No evalValues, but field listed in required list.
318	    $msg = '<!--###SUB_REQUIRED_FIELD_'.$fN.'###--><div'.$this->caller->pi_classParam('form-required-message').'>'.$this->getLL("required_message").'</div><!--###SUB_REQUIRED_FIELD_'.$fN.'###-->';
319	    $reqMarker = $this->conf['required_marker'];	
320	  } else {                                                               
321	    $msg = '';
322	    $reqMarker = '';
323	  }
324	  
325	  $helpIcon = ($this->conf['help'] ? '<div'.$this->caller->pi_classParam('form-help-icon').'>'.$this->helpIcon($fN).'</div>' : '');
326
327	  $out_array[$out_sheet][]='<div class="'.$this->caller->pi_getClassName('form-row').' '.$this->caller->pi_getClassName('form-row-'.$fN).'">
328	             <div class="'.$this->caller->pi_getClassName('form-label').' '.$this->caller->pi_getClassName('form-label-'.$fN).'">
329                       <div'.$this->caller->pi_classParam('form-required-marker').'>'.$reqMarker.'</div>
330                       '.$this->getLLFromLabel($this->TCA["columns"][$fN]["label"]). '
331                       '.$helpIcon.'
332                     </div>
333		     <div'.$this->caller->pi_classParam('form-field').'>'.$fieldCode.'</div>
334                     '.$msg.'
335		   </div>';
336	}
337      }
338    }
339
340    if ($out_sheet>0) {	 // There were --div-- dividers around. Create parts array for the tab menu:
341      $parts = array();
342      foreach($out_array as $idx => $sheetContent)	{
343	unset($sheetContent['title']);
344	$parts[] = array(
345			 'label' => $out_array[$idx]['title'],
346			 'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
347			 implode(chr(10),$sheetContent).
348			 '</table>'
349			 );
350      }
351      
352      $content = $this->addCallersPiVars($this->templateObj->getDynTabMenu($parts, 'TCEforms:'.$table.':'.$row['uid']));
353    } else {	        // Only one, so just implode:
354      $content = is_array($out_array[$out_sheet]) ? $this->addCallersPiVars(implode(chr(10),$out_array[$out_sheet])) : 'makeHTMLForm() :: No form generated! (Proberly no fields defined in typoscript option show_fields)';
355    }
356
357    return $content;	
358  }
359
360  /**
361   * Returns a help icon for the field
362   * @param	string		The field to get the help icon for
363   * @param	boolean		The help icon with link to javascript popup, with help in.
364   */
365  function helpIcon($field) {
366    //    debug($this->conf);
367    $cshArray = $GLOBALS['TCA_DESCR'][$this->table]['columns'][$field];
368    if(!is_array($cshArray)) return '';
369
370    $label = $this->getLLFromLabel($this->TCA['columns'][$field]['label']);
371    $fieldDescription = '<p'.$this->caller->pi_classParam('help-header').'>'.$label. '</p>';
372    foreach(t3lib_div::trimExplode(',',$this->conf['help.']['type_keys'],1) as $type_key) {
373      $fieldDescription .= $cshArray[$type_key] ? '<p'.$this->caller->pi_classParam('help-description').'>'.$cshArray[$type_key] . '</p>' : '';
374    }
375
376    if(empty($fieldDescription)) return '';
377
378    else { 
379      //      $aOnClick = 'confirm(\''.$fieldDescription.'\');return false;';
380      $fieldDescription = '<html><head><title>'.$label.'</title><style type="text/css">'.preg_replace("(\r)"," ",preg_replace("(\n)"," ",$this->conf['help.']['window.']['style'])).'</style></head><body'.$this->caller->pi_classParam('help-body').'><div'.$this->caller->pi_classParam('help-text').'>'.preg_replace("(\r)"," ",preg_replace("(\n)"," ",$fieldDescription)).'</div></body></html>';
381      $script = '
382      <script type="text/javascript">
383      /*<![CDATA[*/
384	function '.$this->caller->prefixId.'_helpWindow_'.$field.'() { 
385           top.vHWin=window.open(\'\',\'viewFieldHelpFE\',\'height='.$this->conf['help.']['window.']['height'].',width='.$this->conf['help.']['window.']['width'].',status=0,menubar=0,scrollbars=1\');
386           top.vHWin.document.writeln(\''.$fieldDescription.'\');
387           top.vHWin.document.close();
388           top.vHWin.focus();
389        }
390      /*]]>*/
391      </script>';
392
393      require_once(PATH_t3lib . 'class.t3lib_iconworks.php');
394      return 
395	$script.'<a href="#" onclick="'.htmlspecialchars($this->caller->prefixId.'_helpWindow_'.$field.'();return false;').'">'.
396	'<img'.t3lib_iconWorks::skinImg('typo3/','gfx/helpbubble.gif','width="14" height="14"').' hspace="2" border="0" class="absmiddle"'.($GLOBALS['CLIENT']['FORMSTYLE']?' style="cursor:help;"':'').' alt="" />'.
397	'</a>';
398    }
399  }
400
401  /**
402   * Makes a preview of the form content according to the configuration for the $cmd
403   * @param	string		The cmd. Should be 'edit' or 'create' or 'all'.
404   * @param	boolean		Should the output be wrapped in html or not.
405   */
406  function makeHTMLPreview($cmd, $withHTML = true) {
407    $fields = (string)$cmd=='all' ? array_unique(t3lib_div::trimExplode(",",($this->conf['create.']['show_fields'] ? $this->conf['create.']['show_fields'].($this->conf['edit.']['show_fields']?','.$this->conf['edit.']['show_fields']:'') : $this->conf['edit.']['show_fields']))) : array_unique(t3lib_div::trimExplode(",",$this->conf[$cmd.'.']['show_fields']));
408    $result = array();
409
410    $hiddenFields = array();
411    foreach((array)$fields as $fN) {
412      $parts = explode(';',$fN);
413      if(($parts[0]=='--div--')) continue;
414
415      $label = $this->getLLFromLabel($this->TCA['columns'][$fN]['label']);
416      $fieldCode = $this->getPreviewFieldCode($cmd, $fN, $withHTML);
417
418      // filter out empty fields or replace empty values by a default label (this label is not saved to DB))
419      $feData = t3lib_div::_POST('FE');
420      if(empty($feData[$this->table][$fN]) && ($this->TCA["columns"][$fN]["config"]["type"]=='input' || $this->TCA["columns"][$fN]["config"]["type"]=='text')) {
421	$fieldCode = $this->getLL('no_value');                           // replace fieldcode with default label
422	if($this->conf[$cmd.'.']['preview.']['dontDisplayEmptyFields']   // if dontDisplayEmptyFields is set, skib the field
423	   || ($cmd == 'all' && ($this->conf['create.']['preview.']['dontDisplayEmptyFields'] || $this->conf['edit.']['preview.']['dontDisplayEmptyFields']))) {  
424	  continue;
425	}
426      }
427
428      if(!$withHTML) {
429	$result[] = $label.chr(10).$fieldCode.chr(10);
430      } else {
431	$result[] = '<div'.$this->caller->pi_classParam('preview-row').'>
432                     <div class="'.$this->caller->pi_getClassName('preview-label').' '.$this->caller->pi_getClassName('preview-label-'.$fN).'">
433                       '.$label.'
434                     </div>
435                     <div class="'.$this->caller->pi_getClassName('preview-value').' '.$this->caller->pi_getClassName('preview-value-'.$fN).'">
436                     '.$fieldCode.'
437                     </div>
438                     </div>';
439#       $hiddenFields[] = '<input type="hidden" name="FE['.$this->table.']['.$fN.']" />';
440      }     
441    }
442
443#    $result[] = ''.implode(chr(10),$hiddenFields);
444
445    //jsmodified
446	$implodedResult = implode(chr(10),$result);
447	
448	// Keep callers piVars
449    if($withHTML) {
450		return $this->addCallersPiVars($implodedResult); 
451	}
452	else { 
453		$plainText = $this->htmlToPlainText($implodedResult);
454		return $plainText;
455	 }
456	  
457  }
458  
459	/**
460	* Converts HTML to plain text.  Taken with thanks from PHP help.
461	* @param HTML text
462	* @return plain text
463	*/
464	function htmlToPlainText( $htmlBody )
465	{
466		
467		$search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
468				"'<[\/\!]*?[^<>]*?>'si",           // Strip out HTML tags
469				"'([\r\n])[\s]+'",                 // Strip out white space
470				"'&(quot|#34);'i",                 // Replace HTML entities
471				"'&(amp|#38);'i",
472				"'&(lt|#60);'i",
473				"'&(gt|#62);'i",
474				"'&(nbsp|#160);'i",
475				"'&(iexcl|#161);'i",
476				"'&(cent|#162);'i",
477				"'&(pound|#163);'i",
478				"'&(copy|#169);'i",
479				"'&#(\d+);'e");                    // evaluate as php
480		
481		$replace = array ("",
482				 "",
483				 "\\1",
484				 "\"",
485				 "&",
486				 "<",
487				 ">",
488				 " ",
489				 chr(161),
490				 chr(162),
491				 chr(163),
492				 chr(169),
493				 "chr(\\1)");
494		
495		$text = preg_replace($search, $replace, $htmlBody);
496	
497		return $text;
498	}
499	
500	
501  /**
502   * A dummy methor for making a NON HTML preview of the form content according to the configurations for the $cmd
503   * @param	string		The cmd. Should be 'edit' or 'create'.
504   */
505  function makeTEXTPreview($cmd) {
506    //jsmod hardocode HTML
507	//return $this->makeHTMLPreview($cmd,false);
508	return $this->makeHTMLPreview($cmd,false);
509  }
510
511  /**
512   * Add callers piVars as hidden input fields to the result array
513   * @param	string		The string to add piVars as input fields to
514   * @result	string		The result string with added piVars input fields
515   */
516  function addCallersPiVars($result) {
517    $keep_piVars = t3lib_div::trimExplode(',',$this->conf['keep_piVars']);
518    foreach($keep_piVars as $piVar) {
519      if(!empty($piVar))
520	$result .= '<input type="hidden" name="'.$this->caller->prefixId.'['.$piVar.']" value="'.$this->caller->piVars[$piVar].'" />';
521    }
522    return $result;
523  }
524  
525  /**
526   * Gets the PREVIEW fieldcode for field ($fN) of the form. This depends on the fields type.
527   * @param	string		The field to get the fieldcode for.
528   * @param	boolean		Should the output be with html (input fields) or not.
529   */
530  function getPreviewFieldCode($cmd,$fN,$withHTML) {
531#    debug('getPreviewFieldCode():: fN='.$fN.', cmd='.$cmd,'function call');
532    $fieldName = 'FE['.$this->table.']['.$fN.']';
533    $type = $this->TCA["columns"][$fN]["config"]["type"];
534    $feData = t3lib_div::_POST('FE');
535    
536#    debug(intval($feData[$this->table]['datetime']),'datetime');
537    switch((string)$type) {
538    case "input":
539      $evalValuesArr = t3lib_div::trimExplode(',',$this->conf[$cmd.'.']['evalValues.'][$fN]);
540      $displayTwice = false;
541      $isPassword = false;
542      foreach((array)$evalValuesArr as $eval) {
543	switch((string)$eval) {
544	case 'twice':
545	  $displayTwice = true;
546	  break;
547	case 'password':
548	  $isPassword = true;
549	  break;
550	}
551      }
552      
553      $values = '###FIELD_'.$fN.'###';
554      $feData = t3lib_div::_POST("FE");
555      // Format the values.                TODO: This only shows the date on a nice format if it is send to the page, not if it is from an overrideValue.
556      if($isPassword) $values = '********';
557      else if($this->TCA['columns'][$fN]["config"]["eval"]=='date' && !empty($feData[$this->table][$fN])) {     
558	$values = strftime("%e-%m-%Y",$feData[$this->table][$fN]);
559      } else if($this->TCA['columns'][$fN]["config"]["eval"]=='datetime' && !empty($feData[$this->table][$fN])) {
560	$values = strftime("%H:%M %e-%m-%Y",$feData[$this->table][$fN]);
561      }
562      
563      if($displayTwice) {
564	$fieldName_again = 'FE['.$this->table.']['.$fN.'_again]';
565	return $withHTML?'<input type="hidden" name="'.$fieldName.'" /><input type="hidden" name="'.$fieldName_again.'" />'.$values:$values;
566      } else {
567	return $withHTML?'<input type="hidden" name="'.$fieldName.'" />'.$values:$values;
568      }
569      break;
570    case "group":     
571      return $withHTML?'<input type="hidden" name="'.$fieldName.'" /><input type="hidden" name="FE['.$this->table.']['.$fN.'_file]" />###FIELD_'.$fN.'###,###FIELD_'.$fN.'_file###':'###FIELD_'.$fN.'###, ###FIELD_'.$fN.'_file###';
572      break;
573    case "select":
574      $values = '###FIELD_'.$fN.'###';
575      if($this->TCA['columns'][$fN]["config"]["foreign_table"]) {  // reference to elements from another table
576	$label = $GLOBALS["TCA"][$this->TCA['columns'][$fN]["config"]["foreign_table"]]["ctrl"]["label"];
577	$feData = t3lib_div::_POST('FE');
578	if($feData[$this->table][$fN]) {
579	  $uids = t3lib_div::trimExplode(',',$feData[$this->table][$fN]);
580	  $orClause = '';
581	  foreach($uids as $uid) $orClause .= $orClause ? 'OR uid LIKE \''.$uid.'\'' : 'uid = \''.$uid.'\'';
582	  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',$this->TCA['columns'][$fN]["config"]["foreign_table"],$orClause);
583	  if($GLOBALS['TYPO3_DB']->sql_error()) debug($GLOBALS['TYPO3_DB']->sql_error(),'sql error');
584	  $values = '';
585	  while($resRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
586	    $values .= $values ? ', ' . $resRow[$label] : $resRow[$label];
587	  }
588	}
589      } elseif($this->TCA['columns'][$fN]["config"]["items"]) {                // fixed items
590	
591	// get items array..
592	$items = $this->TCA['columns'][$fN]["config"]["items"];		
593	if($this->TCA['columns'][$fN]["config"]["itemsProcFunc"]) {     // if itemsProcFunc is set to fill the items array
594	  $options = '';
595	  $params = $this->TCA['columns'][$fN];
596	  $params['items'] = &$items;
597	  t3lib_div::callUserFunction($this->TCA['columns'][$fN]["config"]["itemsProcFunc"], $params, $this);
598	} 
599
600	// find the right label according to the value, compared to the $items
601	$feData = t3lib_div::_POST('FE');
602	if($feData[$this->table][$fN]) {
603	  $vals = t3lib_div::trimExplode(',',$feData[$this->table][$fN]);
604	  $values = '';
605	  foreach($items as $item) {
606	    if(!empty($item)) {
607	      list($label,$val) = $item;
608	      if(in_array($val,$vals)) {
609		$values .= $values ? ', ' . $label : $label;
610	      }
611	    }
612	  }    
613	}
614      }
615      return $withHTML?'<input type="hidden" name="'.$fieldName.'" />'.$values:$values;
616      break;
617    case "text":
618      $values = '###FIELD_'.$fN.'###';
619      $feData = t3lib_div::_POST('FE');
620      if($feData[$this->table]['_TRANSFORM_'.$fN]) { // if rte output, we need to process it instead of parsing it through htmlspecialchar as the other values gets.
621	$dataArr = $feData[$this->table];
622	$dataArr = $this->rteProcessDataArr($dataArr, $this->table, $fN, 'db');
623	$dataArr = $this->rteProcessDataArr($dataArr, $this->table, $fN, 'rte');
624	$values = $withHTML ? $dataArr[$fN] : strip_tags($dataArr[$fN]);
625      }
626      return $withHTML?'<input type="hidden" name="'.$fieldName.'" />'.$values:$values;
627      break;
628    default:
629      return $withHTML?'<input type="hidden" name="'.$fieldName.'" />###FIELD_'.$fN.'###':'###FIELD_'.$fN.'###';
630      break;
631    }
632  }
633
634
635  /**
636   * Gets the fieldcode for field ($fN) of the form. This depends on the fields type.
637   * @param	string		The cmd. Should be 'edit' or 'create'.
638   * @param	string		The field to get the fieldcode for.
639   */
640  function getFormFieldCode($cmd,$fN) {
641#    $this->TCA['columns']['title']["config"]["eval"] = 'date';
642    $fieldName = 'FE['.$this->table.']['.$fN.']';
643    $class = 'class="'.$this->caller->pi_getClassName('form-data-'.$fN).' '.$this->caller->pi_getClassName('form-data').'"';
644    $defaultParams = ' name="'.$fieldName.'"'.$class;
645    $type = $this->TCA["columns"][$fN]["config"]["type"];
646#    debug($this->TCA['columns']);
647    switch((string)$type) {
648    case "input":
649      $onChange = 'onChange="feedit_'.$this->table.'_formGet('."'".$fieldName."','".$this->TCA['columns'][$fN]["config"]["eval"]."','".$is_in."','".$checkbox."','".$checkboxVal."','".$checkbox_off."');".'"';
650      $evalValuesArr = t3lib_div::trimExplode(',',$this->conf[$cmd.'.']['evalValues.'][$fN]);
651      $displayTwice = false;
652      $isPassword = false;
653      foreach((array)$evalValuesArr as $eval) {
654	switch((string)$eval) {
655	case 'twice':
656	  $displayTwice = true;
657	  break;
658	case 'password':
659	  $isPassword = true;
660	  break;
661	}
662      }
663
664      $type = 'text';
665      if($isPassword) $type = 'password';
666
667#      debug($this->TCA['columns'][$fN]['config'],'config '.$fN);
668      if($displayTwice) {
669	$fieldName_again = 'FE['.$this->table.']['.$fN.'_again]';
670	$onChange_again = 'onChange="feedit_'.$this->table.'_formGet('."'".$fieldName_again."','".$this->TCA['columns'][$fN]["config"]["eval"]."','".$is_in."','".$checkbox."','".$checkboxVal."','".$checkbox_off."');".'"';
671
672	$this->additionalJS_end['feedit_'.$fN.'_set_data'] = 'feedit_'.$this->table.'_formSet('."'".$fieldName."','".$this->TCA['columns'][$fN]["config"]["eval"]."','".$is_in."','".$checkbox. "','".$checkboxVal."','".$checkbox_off."')".';';
673	$this->additionalJS_end['feedit_'.$fN.'_again_set_data'] = 'feedit_'.$this->table.'_formSet('."'".$fieldName_again."','".$this->TCA['columns'][$fN]["config"]["eval"]."','".$is_in."','".$checkbox. "','".$checkboxVal."','".$checkbox_off."')".';';
674	return '<input type="'.$type.'" name="'.$fieldName.'_feVal" '.$class.' maxlength="'.$this->TCA["columns"][$fN]["config"]["max"].'" '.$onChange.' />
675                <input type="hidden" name="'.$fieldName.'" />
676		<input type="'.$type.'" name="'.$fieldName_again.'_feVal" '.$class.' maxlength="'.$this->TCA["columns"][$fN]["config"]["max"].'" '.$onChange_again.' />
677                <input type="hidden" name="'.$fieldName_again.'" />';
678
679      } else {
680	$this->additionalJS_end['feedit_'.$fN.'_set_data'] = 'feedit_'.$this->table.'_formSet('."'".$fieldName."','".$this->TCA['columns'][$fN]["config"]["eval"]."','".$is_in."','".$checkbox. "','".$checkboxVal."','".$checkbox_off."')".';';
681
682	return 
683	  '<input type="'.$type.'" name="'.$fieldName.'_feVal" id="'.$fieldName.'_feVal" '.$class.' maxlength="'.$this->TCA["columns"][$fN]["config"]["max"].'" '.$onChange.' />' .
684	  '<input type="hidden" name="'.$fieldName.'" />' .
685	  // inserts button for rlmp_dateselectlib
686	  (t3lib_extmgm::isLoaded('rlmp_dateselectlib') && 
687	   !empty($this->TCA['columns'][$fN]["config"]["eval"]) ?
688	   (is_int(array_search('date',t3lib_div::trimExplode(',',$this->TCA['columns'][$fN]["config"]["eval"]))) 
689	    ?
690	    tx_rlmpdateselectlib::getInputButton($fieldName.'_feVal',array('calConf.'=>array('inputFieldDateTimeFormat'=>'%e-%m-%Y'))) 
691	    :
692	    (is_int(array_search('datetime',t3lib_div::trimExplode(',',$this->TCA['columns'][$fN]["config"]["eval"])))
693	     ?
694	     tx_rlmpdateselectlib::getInputButton($fieldName.'_feVal',array('calConf.'=>array('inputFieldDateTimeFormat'=>'%H:%M %e-%m-%Y')))
695	     : ''))
696	   : ''); 
697      }
698      break;
699    case "text":
700      // Get the specialConf for the field. Placed in type array.
701      $specialConf = $this->getFieldSpecialConf($this->table,$fN);
702
703      /**** USE RTE OR NOT  ****/
704      if(!empty($specialConf) && is_object($this->RTEObj) && $this->RTEObj->isAvailable()) {   // use RTE
705
706	$this->RTEcounter++;
707	$this->formName = $this->table.'_form';
708	$this->strEntryField = $fN;
709	$this->PA['itemFormElName'] = $fieldName;
710	$feData = t3lib_div::_POST('FE');
711	$this->PA['itemFormElValue'] = $feData[$this->table][$fN];
712	$this->specConf = $specialConf;
713	
714	$pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
715	
716# THIS WILL NOT WORK YET! mail sendt to author of rtehtmlarea STAN
717	/*	if(is_array($pageTSConfig['RTE.']['default.']['FE.']) && is_array($pageTSConfig['RTE.']['config.'][$this->table.'.'][$fN.'.']['FE.'])) {
718	  $this->thisConfig = t3lib_div::array_merge_recursive_overrule($pageTSConfig['RTE.']['default.']['FE.'], 
719									$pageTSConfig['RTE.']['config.'][$this->table.'.'][$fN.'.']['FE.']);
720	} else {*/
721	$this->thisConfig = $pageTSConfig['RTE.']['default.']['FE.'];
722	//	}
723      
724	$this->thePidValue = $GLOBALS['TSFE']->id;
725	$RTEItem = $this->RTEObj->drawRTE($this,$this->table,$fN,$row=array(), $this->PA, $this->specConf, $this->thisConfig, $this->RTEtypeVal, '', $this->thePidValue);
726	return $RTEItem . '<div'.$this->caller->pi_classParam('rte-clearer').'></div>';
727      } else {                                                                   // dont use RTE
728	return '<textarea'.$defaultParams.' cols="'.$this->TCA["columns"][$fN]["config"]["cols"].'" rows="'.$this->TCA["columns"][$fN]["config"]["rows"].'" wrap="VIRTUAL"></textarea>';
729      }
730      break;
731    case "check":
732      if($this->TCA['columns'][$fN]['config']['cols']>1) debug("getFormFieldCode():: WARNING, checkbox have more cols, not implementet yet.");
733      return '<input type="hidden" '.$defaultParams.' value="0"><input type="checkbox" '.$defaultParams.' value="1">';
734      break;
735    case "group":
736      if($this->TCA['columns'][$fN]["config"]["internal_type"]=='file')	{
737	// fetch data from table
738	$feData = t3lib_div::_POST('FE');
739	$uid = $feData[$this->table]['uid'] ? $feData[$this->table]['uid'] : t3lib_div::_GET('rU');
740	$rec = $GLOBALS['TSFE']->sys_page->getRawRecord($this->table,$uid);
741	
742	// make option tags from existing data.
743	$options = "";
744	foreach(explode(",",$rec[$fN]) as $opt)
745	  $options .= '<option value="'.$opt.'">'.$opt.'</option>';
746
747	
748	$result .= '<select size="'.$this->TCA['columns'][$fN]["config"]["size"].'" name="FE['.$this->table.']['.$fN.']_select" style="width:250px;">
749                   '.$options.'
750                   </select>
751                   <input type="hidden" name="'.$fieldName.'">
752                   <a onClick="feedit_manipulateGroup(\''.$fieldName.'\');return false;"><img border="0" src="typo3/gfx/group_clear.gif"></a>';
753
754#	unset($result);
755	if($this->TCA['columns'][$fN]["config"]["maxitems"]>sizeof(explode(",",$rec[$fN]))) {
756	  $result .= $this->TCA['columns'][$fN]["config"]["allowed"].'<input type="file" name="FE['.$this->table.']['.$fN.'_file][]" />';
757	}
758	
759	return $result;
760      } else {
761	debug("getFormFieldCode()::GROUP TYPE 'DB' NOT SUPPORTET YET");
762      }
763      break;
764    case "select":
765      $feData = t3lib_div::_POST('FE');
766      $uid = $feData[$this->table]['uid'] ? $feData[$this->table]['uid'] : t3lib_div::_GET('rU');
767      $rec = $GLOBALS['TSFE']->sys_page->getRawRecord($this->table,$uid);
768
769      if($this->TCA['columns'][$fN]["config"]["foreign_table"]) {               // reference to elements from another table
770	$label = $GLOBALS["TCA"][$this->TCA['columns'][$fN]["config"]["foreign_table"]]["ctrl"]["label"];
771
772	$foreignTable = $this->TCA['columns'][$fN]["config"]["foreign_table"];
773	$whereClause = $this->TCA['columns'][$fN]["config"]["foreign_table_where"];
774
775	$storageAndSiteroot = $GLOBALS["TSFE"]->getStorageSiterootPids();        
776	$whereClause = str_replace('###CURRENT_PID###',intval($storageAndSiteroot["_STORAGE_PID"])/*intval($GLOBALS["TSFE"]->page['uid'])*/,$whereClause); // replaced with STORAGE_PID cause it makes more sense ;) 
777
778#	$whereClause = str_replace('###THIS_UID###',,$whereClause);
779#	$whereClause = str_replace('###THIS_CID###',,$whereClause);
780	$whereClause = str_replace('###STORAGE_PID###',intval($storageAndSiteroot["_STORAGE_PID"]),$whereClause);
781	$whereClause = str_replace('###SITEROOT###',intval($storageAndSiteroot['_SITEROOT']),$whereClause);
782
783	$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',$foreignTable,'1=1 '.$this->cObj->enableFields($foreignTable).' '.$whereClause);
784	if ($GLOBALS['TYPO3_DB']->sql_error())	debug(array($GLOBALS['TYPO3_DB']->sql_error()),'getFormFieldCode()::field='.$fN);
785		
786	// gets uids of selected records.
787	$uids = $this->getUidsOfSelectedRecords($rec,$fN,$this->table);
788	debug($uids,'uids');
789
790	while($resRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
791	  $selected = in_array($resRow["uid"],$uids)?"selected":"";
792	  $options .= '<option value="'.$resRow["uid"].'" '.$selected.'>'.$resRow[$label].'</option>';
793	}
794      } elseif($this->TCA['columns'][$fN]["config"]["items"]) {                // fixed items
795	
796	// Get selected uids.
797	$uids = array();
798	if($feData[$this->table][$fN]) {                                // from post var
799	  $uids = explode(",",$feData[$this->table][$fN]);
800	} elseif(!is_null($rec)) {                                      // clean from DB
801	  $uids = explode(",",$rec[$fN]);	
802	} elseif($cmd=='create' && ($this->TCA['columns'][$fN]['config']['default'] || $this->conf[$cmd.'.']['defaultValues.'][$fN])) { // default value taken from mthfeedit typoscript or TCA
803	  $uids = explode(",",$this->conf[$cmd.'.']['defaultValues.'][$fN]?$this->conf[$cmd.'.']['defaultValues.'][$fN]:$this->TCA['columns'][$fN]['config']['default']);
804	}
805
806	$items = $this->TCA['columns'][$fN]["config"]["items"];		
807	$options = '<option value="0">-----</option>';	
808
809	if($this->TCA['columns'][$fN]["config"]["itemsProcFunc"]) {     // if itemsProcFunc is set to fill the select box
810	  $options = '';
811	  $params = $this->TCA['columns'][$fN];
812	  $params['items'] = &$items;
813	  t3lib_div::callUserFunction($this->TCA['columns'][$fN]["config"]["itemsProcFunc"], $params, $this);
814	}
815	
816	
817	foreach((array)$items as $key => $item) {
818	  $selected = in_array($item[1],$uids)?"selected":"";
819	  if($key!=0)
820	    $options .= '<option value="'.$item[1].'"'.$selected.'>'.$this->getLLFromLabel($item[0]).'</option>';
821	}
822
823      } else {                                                                 // unknown TCA config
824	$options = '<option><em>Unknown TCA-configuration</em></option>';
825      }
826      
827      if($this->TCA['columns'][$fN]["config"]["size"]) {
828	$size = ' size="'.$this->TCA['columns'][$fN]["config"]["size"].'" ';
829	
830	if($this->TCA['columns'][$fN]["config"]["maxitems"]>1) { 
831	  $size .= ' multiple ';
832	  $onChange = ' onChange="feedit_manipulateMultipleSelect(\''.$fieldName.'\')" ';
833	  $hr = '<input type="hidden" name="'.$fieldName.'" value="'.implode(",",$uids).'">';
834	  $name = substr($name,0,-1).'_select" ';
835	}
836      }
837      $row .= '<select '.$size.' '.$onChange.' name="FE['.$this->table.']['.$fN.']_select">
838                    '.$options.'
839                    </select>'.$hr;
840      return $row;
841      break;
842    case "user":
843      debug("getFormFieldCode():: user fields not implementet yet.");
844    case "radio":
845      debug("getFormFieldCode():: radio buttons not implementet yet.");
846    case "flex":
847      debug("getFormFieldCode():: flex fields not implementet yet.");
848    default:
849      debug("getFormFieldCode():: Unknown type (".$type.") with field ".$fN);
850      return '<input type="text"'.$defaultParams.' />';
851      break;
852    }
853  }
854
855  
856
857  function getEditMenuTemplate() {
858    return '
859<!-- ###TEMPLATE_EDITMENU### begin -->
860	<br />'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-editmenu').'">'.$this->getLL("edit_menu_header").'</h1>').'
861	<div class="'.$this->caller->pi_getClassName('message').' '.$this->caller->pi_getClassName('message-editmenu').'">'.$this->getLL("edit_menu_description").'</div>
862	<div'.$this->caller->pi_classParam('editmenu-list').'>
863		<!-- ###ALLITEMS### begin -->
864			<!-- ###ITEM### begin -->
865				<div><a href="###FORM_URL###&rU=###FIELD_uid###&cmd=edit&backURL=###FORM_URL_ENC###'.rawurlencode('&cmd=edit').'">###FIELD_'.strtolower($this->id_field).'###</a></div>
866			<!-- ###ITEM### end -->
867		<!-- ###ALLITEMS### end -->
868	</div>
869	<div class="'.$this->caller->pi_getClassName('link').' '.$this->caller->pi_getClassName('link-editmenu').'"><div><a href="###FORM_URL###&cmd=create">'.$this->getLL("edit_menu_createnew_label").'</a></div></div>
870<!-- ###TEMPLATE_EDITMENU### -->
871
872<!-- ###TEMPLATE_EDITMENU_NOITEMS### begin -->
873	'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-editmenu-noitems').'">'.$this->getLL("edit_menu_noitems_header").'</h1>').'
874	<div class="'.$this->caller->pi_getClassName('message').' '.$this->caller->pi_getClassName('message-editmenu-noitems').'">'.$this->getLL("edit_menu_noitems_description").'</div>
875	<div class="'.$this->caller->pi_getClassName('link').' '.$this->caller->pi_getClassName('link-editmenu-noitems').'"><div><a href="###FORM_URL###&cmd=create">'.$this->getLL("edit_menu_createnew_label").'</a></div></div>
876<!-- ###TEMPLATE_EDITMENU_NOITEMS### -->
877';
878  }
879
880  function getEditTemplate() {
881    $HTMLFormEdit = $this->makeHTMLForm('edit');
882    $HTMLPreviewEdit = $this->makeHTMLPreview('edit');
883
884    if($this->conf['delete.']['preview']) {
885      $deleteLink = '<div><a href="###FORM_URL###&cmd=delete&preview=1&backURL=###FORM_URL_ENC###&rU=###REC_UID###">'.$this->getLL("edit_delete_label").'</a></div>';
886    } else {
887      $deleteLink = '<div><a href="###FORM_URL###&cmd=delete&backURL=###FORM_URL_ENC###&rU=###REC_UID###" onClick="return confirm(\''.$this->getLL("edit_delete_confirm").'\');">'.$this->getLL("edit_delete_label").'</a></div>';
888    }
889    if(!$this->conf['delete']) $deleteLink = '';
890    return '
891<!-- ###TEMPLATE_EDIT### -->
892'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-edit').'">'.$this->getLL("edit_header_prefix").' "###FIELD_'.strtolower($this->id_field).'###"</h1>').'
893'.($this->conf['text_in_top_of_form']?'<div'.$this->caller->pi_classParam('form-text').'>'.$this->cObj->stdWrap($this->conf['text_in_top_of_form'],$this->conf['text_in_top_of_form.']).'</div>':'').'
894<div'.$this->caller->pi_classParam('form-wrap').'>
895<form name="'.$this->table.'_form" method="post" action="###FORM_URL###" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'" onsubmit="'.implode(';', $this->additionalJS_submit).'">
896'.$HTMLFormEdit.'
897<div'.$this->caller->pi_classParam('form-row').'>
898   ###HIDDENFIELDS###
899   <input type="Submit" name="submit" value="'.($this->conf['edit.']['preview']?$this->getLL("edit_submit_label"):$this->getLL("edit_preview_submit_label")).'"'.$this->caller->pi_classParam('form-submit').'>
900</div>
901</form>
902
903</div>
904<div class="'.$this->caller->pi_getClassName('link').' '.$this->caller->pi_getClassName('link-edit').'">
905'.$deleteLink.'
906<div><a href="###FORM_URL###&cmd=edit">'.$this->getLL("back_label").'</a></div>
907</div>
908<!-- ###TEMPLATE_EDIT### end-->
909
910<!-- ###TEMPLATE_EDIT_PREVIEW### -->
911'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-edit-preview').'">'.$this->getLL("edit_header_prefix").' "###FIELD_'.strtolower($this->id_field).'###"</h1>').'
912'.($this->conf['text_in_top_of_preview']?'<div'.$this->caller->pi_classParam('preview-text').'>'.$this->cObj->stdWrap($this->conf['text_in_top_of_preview'],$this->conf['text_in_top_of_preview.']).'</div>':'').'
913<div'.$this->caller->pi_classParam('preview-wrap').'>
914<form name="'.$this->table.'_form" method="post" action="###FORM_URL###" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">
915'.$HTMLPreviewEdit.'
916<div'.$this->caller->pi_classParam('preview-row').'>
917    ###HIDDENFIELDS###
918    <input type="Submit" name="doNotSave" value="'.$this->getLL("edit_preview_donotsave_label").'"'.$this->caller->pi_classParam('preview-donotsave').'>
919    <input type="Submit" name="submit" value="'.$this->getLL("edit_preview_submit_label").'"'.$this->caller->pi_classParam('preview-submit').'>
920</div>
921</form>
922</div>
923<!-- ###TEMPLATE_EDIT_PREVIEW### end-->
924
925<!-- ###TEMPLATE_EDIT_SAVED### begin-->
926'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-edit-saved').'">'.$this->getLL("edit_saved_header").'</h1>').'
927<div class="'.$this->caller->pi_getClassName('message').' '.$this->caller->pi_getClassName('message-edit-saved').'">'.$this->getLL("edit_saved_message").'</div>
928<div class="'.$this->caller->pi_getClassName('link').' '.$this->caller->pi_getClassName('link-edit-saved').'"><div><a href="###FORM_URL###&cmd=edit">'.$this->getLL("back_label").'</a></div></div>
929<!-- ###TEMPLATE_EDIT_SAVED### end-->
930';
931  }
932
933
934  function getCreateTemplate() {
935    $HTMLFormCreate = $this->makeHTMLForm('create');
936    $HTMLPreviewCreate = $this->makeHTMLPreview('create');
937    return '
938
939<!-- ###TEMPLATE_CREATE_LOGIN### -->
940'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-create-login').'">'.$this->getLL("create_header_prefix").' '.$this->getLLFromLabel($this->TCA["ctrl"]["title"]).'</h1>').'
941'.($this->conf['text_in_top_of_form']?'<div'.$this->caller->pi_classParam('form-text').'>'.$this->cObj->stdWrap($this->conf['text_in_top_of_form'],$this->conf['text_in_top_of_form.']).'</div>':'').'
942<div'.$this->caller->pi_classParam('form-wrap').'>
943<form name="'.$this->table.'_form" method="post" action="###FORM_URL###" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'" onsubmit="'.implode(';', $this->additionalJS_submit).'">
944'.$HTMLFormCreate.'
945<div'.$this->caller->pi_classParam('form-row').'>
946   ###HIDDENFIELDS###
947   <input type="Submit" name="submit" value="'.($this->conf['create.']['preview']?$this->getLL("create_submit_label"):$this->getLL("create_preview_submit_label")).'"'.$this->caller->pi_classParam('form-submit').'>
948</div>
949</form>
950</div>
951<div class="'.$this->caller->pi_getClassName('link').' '.$this->caller->pi_getClassName('link-create-login').'"><div><a href="###FORM_URL###&cmd=edit">'.$this->getLL("create_edit_link").'</a></div></div>
952<!-- ###TEMPLATE_CREATE_LOGIN### end-->
953
954
955<!-- ###TEMPLATE_CREATE_LOGIN_PREVIEW### begin-->
956'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-create-login-preview').'">'.$this->getLL("create_header_prefix").' '.$this->getLLFromLabel($this->TCA["ctrl"]["title"]).'</h1>').'
957'.($this->conf['text_in_top_of_preview']?'<div'.$this->caller->pi_classParam('preview-text').'>'.$this->cObj->stdWrap($this->conf['text_in_top_of_preview'],$this->conf['text_in_top_of_preview.']).'</div>':'').'
958<div'.$this->caller->pi_classParam('preview-wrap').'>
959<form name="'.$this->table.'_form" method="post" action="###FORM_URL###" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">
960'.$HTMLPreviewCreate.'
961<div'.$this->caller->pi_classParam('preview-row').'>
962    ###HIDDENFIELDS###
963    <input type="Submit" name="doNotSave" value="'.$this->getLL("create_preview_donotsave_label").'"'.$this->caller->pi_classParam('preview-donotsave').'>
964    <input type="Submit" name="submit" value="'.$this->getLL("create_preview_submit_label").'"'.$this->caller->pi_classParam('preview-submit').'>
965</div>
966</form>
967</div>
968<!-- ###TEMPLATE_CREATE_LOGIN_PREVIEW### end-->
969
970<!-- ###TEMPLATE_CREATE### -->
971'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-create').'">'.$this->getLL("create_header_prefix").' '.$this->getLLFromLabel($this->TCA["ctrl"]["title"]).'</h1>').'
972'.($this->conf['text_in_top_of_form']?'<div'.$this->caller->pi_classParam('form-text').'>'.$this->cObj->stdWrap($this->conf['text_in_top_of_form'],$this->conf['text_in_top_of_form.']).'</div>':'').'
973<div'.$this->caller->pi_classParam('form-wrap').'>
974<form name="'.$this->table.'_form" method="post" action="###FORM_URL###" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'" onsubmit="'.implode(';', $this->additionalJS_submit).'">
975'.$HTMLFormCreate.'
976<div'.$this->caller->pi_classParam('form-row').'>
977   ###HIDDENFIELDS###
978   <input type="Submit" name="submit" value="'.($this->conf['create.']['preview']?$this->getLL("create_submit_label"):$this->getLL("create_preview_submit_label")).'"'.$this->caller->pi_classParam('form-submit').'>
979</div>
980</form>
981
982</div>
983<!-- ###TEMPLATE_CREATE### end-->
984
985
986<!-- ###TEMPLATE_CREATE_PREVIEW### begin-->
987'.($this->conf['no_header']?'':'<h1 class="'.$this->caller->pi_getClassName('header').' '.$this->caller->pi_getClassName('header-create-preview').'">'.$this->getLL("create_header_prefix").' '.$this->getLLFromLabel($this->TCA["ctrl"]["title"]).'</h1>').'
988'.($this->conf['text_in_top_of_preview']?'<div'.$this->caller->pi_classParam('preview-text').'>'.$this->cObj->stdWrap($this->conf['text_in_top_of_preview'],$this->conf['text_in_top_of_preview.']).'</div>':'').'
989<div'.$this->caller->pi_classParam('preview-wrap').'>
990<form name="'.$this->table.'_form" method="post" action="###FORM_URL###" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">
991'.$HTMLPreviewCreate.'
992<div'.$this->caller->pi_classParam('preview-row').'>
993    ###HIDDENFIELDS###
994    <input type="Submit" name="doNotSave" value="'.$this->getLL("create_preview_donotsave_label").'"'.$this->caller->pi_classParam('preview-donotsave').'>
995    <input type="Submit" name="submit" value="'.$this->getLL("create_preview_submit_label").'"'.$this->caller->pi_classParam('

Large files files are truncated, but you can click here to view the full file