Fixed bug #9994: ereg* is deprecated in PHP 5.3 alpha3
[Packages/TYPO3.CMS.git] / typo3 / sysext / fe_edit / view / class.tx_feedit_editpanel.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008-2009 Jeff Segars <jeff@webempoweredchurch.org>
6 * (c) 2008-2009 David Slayback <dave@webempoweredchurch.org>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * View class for the edit panels in frontend editing.
30 *
31 * $Id$
32 *
33 * @author Jeff Segars <jeff@webempoweredchurch.org>
34 * @author David Slayback <dave@webempoweredchurch.org>
35 * @package TYPO3
36 * @subpackage fe_edit
37 */
38 class tx_feedit_editpanel {
39
40 /**
41 * Local instance of tslib_cObj.
42 *
43 * @var tslib_cObj
44 */
45 protected $cObj;
46
47 /**
48 * Constructor for the edit panel. Creates a new cObject instance to be used in wrapping, etc.
49 *
50 * @return void
51 */
52 public function __construct() {
53 require_once (PATH_tslib . '/class.tslib_content.php');
54 $this->cObj = t3lib_div::makeInstance('tslib_cObj');
55 $this->cObj->start(array());
56 }
57
58 /**
59 * Generates the "edit panels" which can be shown for a page or records on a page when the Admin Panel is enabled for a backend users surfing the frontend.
60 * With the "edit panel" the user will see buttons with links to editing, moving, hiding, deleting the element
61 * This function is used for the cObject EDITPANEL and the stdWrap property ".editPanel"
62 *
63 * @param string A content string containing the content related to the edit panel. For cObject "EDITPANEL" this is empty but not so for the stdWrap property. The edit panel is appended to this string and returned.
64 * @param array TypoScript configuration properties for the editPanel
65 * @param string The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW"
66 * @param array Alternative data array to use. Default is $this->data
67 * @return string The input content string with the editPanel appended. This function returns only an edit panel appended to the content string if a backend user is logged in (and has the correct permissions). Otherwise the content string is directly returned.
68 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=375&cHash=7d8915d508
69 */
70 public function editPanel($content, array $conf, $currentRecord='', array $dataArr=array(), $table='', $allow='', $newUID=0, array $hiddenFields=array()) {
71 // Special content is about to be shown, so the cache must be disabled.
72 $GLOBALS['TSFE']->set_no_cache();
73 $formName = 'TSFE_EDIT_FORM_' . substr($GLOBALS['TSFE']->uniqueHash(), 0, 4);
74 $formTag = '<form name="' . $formName . '" id ="' . $formName . '" action="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" onsubmit="return TBE_EDITOR.checkSubmit(1);" style="margin: 0 0 0 0;">';
75 $sortField = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
76 $labelField = $GLOBALS['TCA'][$table]['ctrl']['label'];
77 $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
78 $blackLine = $conf['line'] ? '<img src="clear.gif" width="1" height="' . intval($conf['line']) . '" alt="" title="" /><br /><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="black" style="border: 0px;" summary=""><tr style="border: 0px;"><td style="border: 0px;"><img src="clear.gif" width="1" height="1" alt="" title="" /></td></tr></table><br />' : '';
79
80 $theCmd='';
81 $TSFE_EDIT = $GLOBALS['BE_USER']->frontendEdit->TSFE_EDIT;
82 if (is_array($TSFE_EDIT) && $TSFE_EDIT['record'] == $currentRecord && !$TSFE_EDIT['update_close']) {
83 $theCmd =$TSFE_EDIT['cmd'];
84 }
85
86 switch($theCmd) {
87 case 'edit':
88 case 'new':
89 $finalOut = $this->editContent($formTag, $formName, $theCmd, $newUID, $dataArr, $table, $currentRecord, $blackLine);
90 break;
91 default:
92 $panel = '';
93 if (isset($allow['toolbar'])) {
94 $adminClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['admin'];
95 $admin = &t3lib_div::getUserObj($adminClass);
96 $panel .= $admin->ext_makeToolBar() . '<img src="clear.gif" width="2" height="1" alt="" title="" />';
97 }
98 if (isset($allow['edit'])) {
99 $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_editRecord').'" align="top" alt="" />', $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord);
100 }
101 // Hiding in workspaces because implementation is incomplete
102 if (isset($allow['move']) && $sortField && $GLOBALS['BE_USER']->workspace === 0) {
103 $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/button_up.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_moveUp') . '" align="top" alt="" />', $formName, 'up');
104 $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/button_down.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_moveDown') . '" align="top" alt="" />', $formName, 'down');
105 }
106 // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
107 if (isset($allow['hide']) && $hideField && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
108 if ($dataArr[$hideField]) {
109 $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/button_unhide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_unhide') . '" align="top" alt="" />', $formName, 'unhide');
110 } else {
111 $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/button_hide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_hide') . '" align="top" alt="" />', $formName, 'hide', '', $GLOBALS['BE_USER']->extGetLL('p_hideConfirm'));
112 }
113 }
114 if (isset($allow['new'])) {
115 if ($table == 'pages') {
116 $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/new_page.gif" width="13" height="12" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_newSubpage') . '" align="top" alt="" />', $formName, 'new', $currentRecord, '', $nPid);
117 } else {
118 $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/new_record.gif" width="16" height="12" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_newRecordAfter') . '" align="top" alt="" />', $formName, 'new', $currentRecord, '', $nPid);
119 }
120 }
121 // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
122 if (isset($allow['delete']) && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
123 $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/delete_record.gif" width="12" height="12" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_delete').'" align="top" alt="" />', $formName, 'delete', '', $GLOBALS['BE_USER']->extGetLL('p_deleteConfirm'));
124 }
125 // Final
126 $labelTxt = $this->cObj->stdWrap($conf['label'],$conf['label.']);
127
128 foreach((array) $hiddenFields as $name => $value) {
129 $hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . $name . ']" value="' . $value . '"/>' . chr(10);
130 }
131
132 $panel='
133
134 <!-- BE_USER Edit Panel: -->
135 ' . $formTag .
136 $hiddenFieldString . '
137 <input type="hidden" name="TSFE_EDIT[cmd]" value="" />
138 <input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord . '" />
139 <table border="0" cellpadding="0" cellspacing="0" class="typo3-editPanel" summary="">
140 <tr>
141 <td nowrap="nowrap" bgcolor="#ABBBB4" class="typo3-editPanel-controls">' . $panel . '</td>' .
142 ($labelTxt ? '<td nowrap="nowrap" bgcolor="#F6F2E6" class="typo3-editPanel-label"><font face="verdana" size="1" color="black">&nbsp;' . sprintf($labelTxt, htmlspecialchars(t3lib_div::fixed_lgd_cs($dataArr[$labelField], 50))) . '&nbsp;</font></td>' : '') . '
143 </tr>
144 </table>
145 </form>';
146 // wrap the panel
147 if ($conf['innerWrap']) {
148 $panel = $this->cObj->wrap($panel, $conf['innerWrap']);
149 }
150 if ($conf['innerWrap.']) {
151 $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']);
152 }
153
154 // add black line:
155 $panel .= $blackLine;
156
157 // wrap the complete panel
158 if ($conf['outerWrap']) {
159 $panel = $this->cObj->wrap($panel, $conf['outerWrap']);
160 }
161 if ($conf['outerWrap.']) {
162 $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']);
163 }
164 if ($conf['printBeforeContent']) {
165 $finalOut = $panel . $content;
166 } else {
167 $finalOut = $content . $panel;
168 }
169 break;
170 }
171
172 if ($conf['previewBorder']) {
173 if (!is_array($conf['previewBorder.'])) {
174 $conf['previewBorder.'] = array();
175 }
176 $finalOut = $this->editPanelPreviewBorder($table, $dataArr, $finalOut, $conf['previewBorder'], $conf['previewBorder.']);
177 }
178
179 return $finalOut;
180 }
181
182 /**
183 * Adds an edit icon to the content string. The edit icon links to alt_doc.php with proper parameters for editing the table/fields of the context.
184 * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
185 *
186 * @param string The content to which the edit icons should be appended
187 * @param string The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to alt_doc.php
188 * @param array TypoScript properties for configuring the edit icons.
189 * @param string The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW"
190 * @param array Alternative data array to use. Default is $this->data
191 * @param string Additional URL parameters for the link pointing to alt_doc.php
192 * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
193 */
194 public function editIcons($content, $params, array $conf=array(), $currentRecord='', array $dataArr=array(), $addUrlParamStr='', $table, $editUid, $fieldList) {
195 // Special content is about to be shown, so the cache must be disabled.
196 $GLOBALS['TSFE']->set_no_cache();
197 $style = $conf['styleAttribute'] ? ' style="' . htmlspecialchars($conf['styleAttribute']) . '"' : '';
198 $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']);
199 $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img src="' . TYPO3_mainDir . 'gfx/edit_fe.gif" width="11" height="12" border="0" align="top" title="' . t3lib_div::deHSCentities(htmlspecialchars($iconTitle)) . '"' . $style . ' class="frontEndEditIcons" alt="" />';
200 $nV=t3lib_div::_GP('ADMCMD_view') ? 1 : 0;
201 $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
202 $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL . 'alt_doc.php?edit[' . $table . '][' . $editUid . ']=edit&columnsOnly=' . rawurlencode($fieldList) . '&noView=' . $nV . $addUrlParamStr, $currentRecord);
203
204 if ($conf['beforeLastTag'] < 0) {
205 $content = $icon . $content;
206 } elseif ($conf['beforeLastTag'] > 0) {
207 $cBuf = rtrim($content);
208 $securCount = 30;
209 while($securCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') {
210 $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf));
211 $securCount--;
212 }
213 $content = (strlen($cBuf) && $securCount) ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : $content = $icon . $content;
214 } else {
215 $content .= $icon;
216 }
217
218 return $content;
219 }
220
221 /**
222 * Helper function for editPanel() which wraps icons in the panel in a link with the action of the panel.
223 * The links are for some of them not simple hyperlinks but onclick-actions which submits a little form which the panel is wrapped in.
224 *
225 * @param string The string to wrap in a link, typ. and image used as button in the edit panel.
226 * @param string The name of the form wrapping the edit panel.
227 * @param string The command of the link. There is a predefined list available: edit, new, up, down etc.
228 * @param string The "table:uid" of the record being processed by the panel.
229 * @param string Text string with confirmation message; If set a confirm box will be displayed before carrying out the action (if Yes is pressed)
230 * @param integer "New pid" - for new records
231 * @return string A <a> tag wrapped string.
232 * @see editPanel(), editIcons(), t3lib_tsfeBeUserAuth::extEditAction()
233 */
234 protected function editPanelLinkWrap($string, $formName, $cmd, $currentRecord='', $confirm='', $nPid='') {
235 // Editing forms on page only supported in Live workspace (because of incomplete implementation)
236 $editFormsOnPage = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] && $GLOBALS['BE_USER']->workspace === 0;
237 $nV=t3lib_div::_GP('ADMCMD_view') ? 1 : 0;
238 $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
239
240 if ($cmd == 'edit' && !$editFormsOnPage) {
241 $rParts = explode(':', $currentRecord);
242 $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'alt_doc.php?edit[' . $rParts[0] . '][' . $rParts[1] . ']=edit&noView=' . $nV, $currentRecord);
243 } elseif ($cmd == 'new' && !$editFormsOnPage) {
244 $rParts = explode(':', $currentRecord);
245 if ($rParts[0] == 'pages') {
246 $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'db_new.php?id=' . $rParts[1] . '&pagesOnly=1', $currentRecord);
247 } else {
248 if (!intval($nPid)) {
249 $nPid = t3lib_div::testInt($rParts[1]) ? -$rParts[1] : $GLOBALS['TSFE']->id;
250 }
251 $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'alt_doc.php?edit[' . $rParts[0] . '][' . $nPid . ']=new&noView=' . $nV, $currentRecord);
252 }
253 } else {
254 if ($confirm && $GLOBALS['BE_USER']->jsConfirmation(8)) {
255 // Gets htmlspecialchared later
256 $cf1 = 'if (confirm(' . t3lib_div::quoteJSvalue($confirm, true) . ')) {';
257 $cf2 = '}';
258 } else {
259 $cf1 = $cf2 = '';
260 }
261 $out = '<a href="#" onclick="' .
262 htmlspecialchars($cf1 . 'document.' . $formName . '[\'TSFE_EDIT[cmd]\'].value=\'' . $cmd . '\'; document.' . $formName . '.submit();' . $cf2 . ' return false;') .
263 '">' . $string . '</a>';
264 }
265
266 return $out;
267 }
268
269 /**
270 * Creates a link to a script (eg. typo3/alt_doc.php or typo3/db_new.php) which either opens in the current frame OR in a pop-up window.
271 *
272 * @param string The string to wrap in a link, typ. and image used as button in the edit panel.
273 * @param string The URL of the link. Should be absolute if supposed to work with <base> path set.
274 * @param string The "table:uid" of the record being processed by the panel.
275 * @return string A <a> tag wrapped string.
276 * @see editPanelLinkWrap()
277 */
278 protected function editPanelLinkWrap_doWrap($string, $url, $currentRecord) {
279 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] || $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceNoPopup']) {
280 $retUrl = t3lib_div::getIndpEnv('REQUEST_URI');
281 $rParts = explode(':', $currentRecord);
282 // This parentRecordNumber is used to make sure that only elements 3- of ordinary content elements makes a 'anchor' jump down the page.
283 if ($rParts[0] == 'tt_content' && $this->parentRecordNumber > 2) {
284 $retUrl .= '#' . $rParts[1];
285 }
286 return '<a href="' . htmlspecialchars($url . '&returnUrl=' . rawurlencode($retUrl)) . '" class="frontEndEditIconLinks">' . $string . '</a>';
287 } else {
288 return '<a href="#" onclick="' .
289 htmlspecialchars('vHWin=window.open(\'' . $url . '&returnUrl=close.html\',\'FEquickEditWindow\',\'' . ($GLOBALS['BE_USER']->uc['edit_wideDocument'] ? 'width=690,height=500' : 'width=540,height=400') . ',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;') .
290 '" class="frontEndEditIconLinks">' . $string . '</a>';
291 }
292 }
293
294 /**
295 * Wraps the input content string in a table with a gray border if the table/row combination evaluates to being disabled/hidden.
296 * Used for marking previewed records in the frontend.
297 *
298 * @param string The table name
299 * @param array The data record from $table
300 * @param string The content string to wrap
301 * @param integer The thickness of the border
302 * @param array The array with TypoScript properties for the content object
303 * @return string The input string wrapped in a table with a border color of #cccccc and thickness = $thick
304 * @see editPanel()
305 */
306 protected function editPanelPreviewBorder($table, array $row, $content, $thick, array $conf = array()) {
307 if ($this->isDisabled($table, $row)) {
308 $thick = t3lib_div::intInRange($thick, 1, 100);
309 $color = $conf['color'] ? $conf['color'] : '#cccccc';
310 if ($conf['innerWrap']) {
311 $content = $this->wrap($content,$conf['innerWrap']);
312 }
313 if ($conf['innerWrap.']) {
314 $content = $this->stdWrap($content,$conf['innerWrap.']);
315 }
316 $content = '<table class="typo3-editPanel-previewBorder" border="' . $thick . '" cellpadding="0" cellspacing="0" bordercolor="' . $color . '" width="100%" summary=""><tr><td>' . $content . '</td></tr></table>';
317 if ($conf['outerWrap']) {
318 $content = $this->wrap($content,$conf['outerWrap']);
319 }
320 if ($conf['outerWrap.']) {
321 $content = $this->stdWrap($panel,$conf['outerWrap.']);
322 }
323 }
324
325 return $content;
326 }
327
328 /**
329 * Returns true if the input table/row would be hidden in the frontend (according nto the current time and simulate user group)
330 *
331 * @param string The table name
332 * @param array The data record
333 * @return boolean
334 * @see editPanelPreviewBorder()
335 */
336 protected function isDisabled($table, $row) {
337 if (($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']]) ||
338 ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group'] && $GLOBALS['TSFE']->simUserGroup && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group']] == $GLOBALS['TSFE']->simUserGroup) ||
339 ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > time() ) ||
340 ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < time())) {
341 return true;
342 }
343 }
344
345 /**
346 * Returns the editing form for a content element.
347 *
348 * @param string Form tag
349 * @param string Form name
350 * @param string the command
351 * @param integer newUID
352 * @param array dataArray for element
353 * @param string Table name of element
354 * @param string Current record
355 * @param string Blackline
356 * @return string
357 */
358 protected function editContent($formTag, $formName, $theCmd, $newUID, array $dataArray, $table, $currentRecord, $blackLine) {
359 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms_FE');
360 $tceforms->prependFormFieldNames = 'TSFE_EDIT[data]';
361 $tceforms->prependFormFieldNames_file = 'TSFE_EDIT_file';
362 $tceforms->doSaveFieldName = 'TSFE_EDIT[doSave]';
363 $tceforms->formName = $formName;
364 $tceforms->backPath = TYPO3_mainDir;
365 $tceforms->setFancyDesign();
366 $tceforms->defStyle = 'font-family:Verdana;font-size:10px;';
367 $tceforms->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp'];
368
369 // Icon only mode for CSH destroys the layout for frontend editing so force full text mode instead.
370 // @todo Make sure the necessary Javascript and CSS are included so that CSH can work properly in all modes.
371 if($tceforms->edit_showFieldHelp == 'icon') {
372 $tceforms->edit_showFieldHelp = 'text';
373 }
374
375 $tceforms->helpTextFontTag = '<font face="verdana,sans-serif" color="#333333" size="1">';
376
377 $trData = t3lib_div::makeInstance('t3lib_transferData');
378 $trData->addRawData = true;
379 $trData->lockRecords = 1;
380 // Added without testing - should provide ability to submit default values in frontend editing, in-page.
381 $trData->defVals = t3lib_div::_GP('defVals');
382 $trData->fetchRecord($table, ($theCmd == 'new' ? $newUID : $dataArray['uid']), ($theCmd == 'new' ? 'new' : '') );
383 reset($trData->regTableItems_data);
384 $processedDataArr = current($trData->regTableItems_data);
385 $processedDataArr['uid'] = $theCmd == 'new' ? 'NEW' : $dataArray['uid'];
386 $processedDataArr['pid'] = $theCmd == 'new' ? $newUID : $dataArray['pid'];
387
388 $panel = '';
389 $buttons = '<input type="image" border="0" name="TSFE_EDIT[update]" src="' . $tceforms->backPath . 'gfx/savedok.gif" hspace="2" width="21" height="16" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" />';
390 $buttons .= '<input type="image" border="0" name="TSFE_EDIT[update_close]" src="' . $tceforms->backPath . 'gfx/saveandclosedok.gif" hspace="2" width="21" height="16" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc', 1) . '" />';
391 $buttons .= '<input type="image" border="0" name="TSFE_EDIT[cancel]" onclick="' .
392 htmlspecialchars('window.location.href=\'' . t3lib_div::getIndpEnv('REQUEST_URI') . '\';return false;') .
393 '" src="' . $tceforms->backPath . 'gfx/closedok.gif" hspace="2" width="21" height="16" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', 1) . '" />';
394 // Buttons top
395 $panel .= $tceforms->intoTemplate(array('ITEM' => $buttons));
396 $panel .= $tceforms->getMainFields($table, $processedDataArr);
397
398 $hiddenF = "";
399 if ($theCmd == 'new') {
400 $hiddenF .= '<input type="hidden" name="TSFE_EDIT[data][' . $table . '][NEW][pid]" value="' . $newUID . '" />';
401 if ($table == 'pages') {
402 // If a new page is created in front-end, then show it by default!
403 $hiddenF .= '<input type="hidden" name="TSFE_EDIT[data][' . $table . '][NEW][hidden]" value="0" />';
404 } else {
405 $hiddenF .= '<input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord . '" />';
406 $hiddenF .= '<input type="hidden" name="TSFE_EDIT[cmd]" value="edit" />';
407 }
408 }
409 $hiddenF .= '<input type="hidden" name="TSFE_EDIT[doSave]" value="0" />';
410 // Buttons AND hidden fields bottom.
411 $panel .= $tceforms->intoTemplate(array('ITEM' => $buttons . $hiddenF));
412
413 $panel = $formTag . $tceforms->wrapTotal($panel, $dataArray, $table) . '</form>' . ($theCmd != 'new' ? $blackLine : '');
414
415 $finalOut = $tceforms->printNeededJSFunctions_top() . ($conf['edit.']['displayRecord'] ? $content : '') . $panel . ($theCmd=='new' ? $blackLine : '') . $tceforms->printNeededJSFunctions();
416
417 return $finalOut;
418 }
419
420 }
421
422 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/fe_edit/view/class.tx_feedit_editpanel.php']) {
423 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/fe_edit/view/class.tx_feedit_editpanel.php']);
424 }
425
426 ?>