PageRenderTime 751ms CodeModel.GetById 99ms RepoModel.GetById 1ms app.codeStats 1ms

/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
Possible License(s): LGPL-2.1

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