2 namespace TYPO3\CMS\Core\FrontendEditing;
47 if (
$GLOBALS[
'BE_USER']->isFrontendEditingActive()) {
65 public function displayEditPanel($content, array $conf, $currentRecord, array $dataArray)
67 if ($conf[
'newRecordFromTable']) {
68 $currentRecord = $conf[
'newRecordFromTable'] .
':NEW';
69 $conf[
'allow'] =
'new';
70 $checkEditAccessInternals =
false;
72 $checkEditAccessInternals =
true;
74 list($table, $uid) = explode(
':', $currentRecord);
76 $newRecordPid = (int)$conf[
'newRecordInPid'];
77 if (!$conf[
'onlyCurrentPid'] || $dataArray[
'pid'] ==
$GLOBALS[
'TSFE']->
id) {
78 if ($table ==
'pages') {
81 if ($conf[
'newRecordFromTable']) {
84 $newUid = $newRecordPid;
92 $editClass =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'typo3/classes/class.frontendedit.php'][
'edit'];
95 if (is_object($edit)) {
97 $content = $edit->editPanel($content, $conf, $currentRecord, $dataArray, $table, $allowedActions, $newUid, $this->
getHiddenFields($dataArray));
116 public function displayEditIcons($content, $params, array $conf = array(), $currentRecord =
'', array $dataArray = array(), $addUrlParamStr =
'')
119 list($currentRecordTable, $currentRecordUID) = explode(
':', $currentRecord);
123 $table = $currentRecordTable;
124 }
elseif ($table != $currentRecordTable) {
128 $editUid = $dataArray[
'_LOCALIZED_UID'] ?: $currentRecordUID;
130 if (!array_key_exists(
'allow', $conf)) {
131 $conf[
'allow'] =
'edit';
134 $editClass =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'typo3/classes/class.frontendedit.php'][
'edit'];
137 if (is_object($edit)) {
138 $content = $edit->editIcons($content, $params, $conf, $currentRecord, $dataArray, $addUrlParamStr, $table, $editUid, $fieldList);
158 if (is_array($this->TSFE_EDIT)) {
159 if ($this->TSFE_EDIT[
'cancel']) {
160 unset($this->TSFE_EDIT[
'cmd']);
162 $cmd = (string)$this->TSFE_EDIT[
'cmd'];
163 if (($cmd !=
'edit' || is_array($this->TSFE_EDIT[
'data']) && ($this->TSFE_EDIT[
'doSave'] || $this->TSFE_EDIT[
'update'] || $this->TSFE_EDIT[
'update_close'])) && $cmd !=
'new') {
181 if (is_array($this->TSFE_EDIT)) {
182 $cmd = (string)$this->TSFE_EDIT[
'cmd'];
183 if ($cmd ==
'edit' || $cmd ==
'new') {
200 list($table, $uid) = explode(
':', $this->TSFE_EDIT[
'record']);
202 $cmd = $this->TSFE_EDIT[
'cmd'];
204 if (($this->TSFE_EDIT[
'doSave'] || $this->TSFE_EDIT[
'update'] || $this->TSFE_EDIT[
'update_close']) && is_array($this->TSFE_EDIT[
'data'])) {
207 if ($cmd ==
'save' || $cmd && $table && $uid && isset(
$GLOBALS[
'TCA'][$table])) {
209 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tsfebeuserauth.php'][
'extEditAction'])) {
211 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tsfebeuserauth.php'][
'extEditAction'] as $_funcRef) {
216 $cmdAction =
'do' . ucwords($cmd);
217 if (is_callable(array($this, $cmdAction))) {
218 $this->{$cmdAction}($table, $uid);
220 throw new \UnexpectedValueException(
'The specified frontend edit command (' . $cmd .
') is not valid.', 1225818120);
234 $hideField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'];
237 $recData[$table][$uid][$hideField] = 1;
239 $this->tce->start($recData, array());
240 $this->tce->process_datamap();
253 $hideField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'];
256 $recData[$table][$uid][$hideField] = 0;
258 $this->tce->start($recData, array());
259 $this->tce->process_datamap();
270 public function doUp($table, $uid)
272 $this->
move($table, $uid,
'up');
284 $this->
move($table, $uid,
'down');
296 $afterUID =
$GLOBALS[
'BE_USER']->frontendEdit->TSFE_EDIT[
'moveAfter'];
297 $this->
move($table, $uid,
'', $afterUID);
309 protected function move($table, $uid, $direction =
'', $afterUID = 0)
312 $sortField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
316 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(implode(
',', $fields), $table,
'uid=' . $uid);
317 if ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
319 if (
$GLOBALS[
'BE_USER']->adminPanel instanceof \TYPO3\CMS\Frontend\View\AdminPanelView &&
$GLOBALS[
'BE_USER']->adminPanel->extGetFeAdminValue(
'preview')) {
320 $ignore = array(
'starttime' => 1,
'endtime' => 1,
'disabled' => 1,
'fe_group' => 1);
322 $copyAfterFieldsQuery =
'';
323 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'copyAfterDuplFields']) {
325 foreach ($cAFields as $fieldName) {
326 $copyAfterFieldsQuery .=
' AND ' . $fieldName .
'="' . $row[$fieldName] .
'"';
329 if (!empty($direction)) {
330 if ($direction ==
'up') {
337 $sortCheck =
' AND ' . $sortField . $operator . (int)$row[$sortField];
339 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
340 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid,pid', $table,
'pid=' . (
int)$row[
'pid'] . $sortCheck . $copyAfterFieldsQuery .
$GLOBALS[
'TSFE']->sys_page->enableFields($table,
'', $ignore),
'', $sortField .
' ' . $order,
'2');
341 if ($row2 =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
343 $cmdData[$table][$uid][
'move'] = -$afterUID;
344 }
elseif ($direction ==
'down') {
345 $cmdData[$table][$uid][
'move'] = -$row2[
'uid'];
348 $cmdData[$table][$uid][
'move'] = -$row3[
'uid'];
351 $cmdData[$table][$uid][
'move'] = $row[
'pid'];
353 }
elseif ($direction ==
'up') {
354 $cmdData[$table][$uid][
'move'] = $row[
'pid'];
356 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
358 if (!empty($cmdData)) {
360 $this->tce->start(array(), $cmdData);
361 $this->tce->process_cmdmap();
375 $cmdData[$table][$uid][
'delete'] = 1;
376 if (!empty($cmdData)) {
378 $this->tce->start(array(), $cmdData);
379 $this->tce->process_cmdmap();
392 $data = $this->TSFE_EDIT[
'data'];
395 $this->tce->start($data, array());
396 $this->tce->process_uploads($_FILES);
397 $this->tce->process_datamap();
399 $newUID = $this->tce->substNEWwithIDs[
'NEW'];
401 $GLOBALS[
'BE_USER']->frontendEdit->TSFE_EDIT[
'newUID'] = $newUID;
416 $this->
doSave($table, $uid);
442 if ($table ===
'pages') {
444 }
elseif ($table ===
'tt_content') {
447 $lang = $currentRecord[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']];
452 $languageAccess =
true;
454 $languageAccess =
false;
456 return $languageAccess;
468 protected function allowedToEdit($table, array $dataArray, array $conf, $checkEditAccessInternals =
true)
472 if ($checkEditAccessInternals) {
473 $editAccessInternals =
$GLOBALS[
'BE_USER']->recordEditAccessInternals($table, $dataArray,
false,
false);
475 $editAccessInternals =
true;
477 if ($editAccessInternals) {
478 if ($table ==
'pages') {
480 if (
$GLOBALS[
'BE_USER']->isAdmin() ||
$GLOBALS[
'BE_USER']->doesUserHaveAccess($dataArray, 2)) {
485 if (
$GLOBALS[
'BE_USER']->isAdmin() ||
$GLOBALS[
'BE_USER']->doesUserHaveAccess(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecord(
'pages', $dataArray[
'pid']), 16)) {
489 if (!$conf[
'onlyCurrentPid'] || $dataArray[
'pid'] ==
$GLOBALS[
'TSFE']->
id) {
492 $allow = array_flip($types);
494 if ($table ==
'pages') {
497 if (!empty($allow)) {
521 $allow = array_flip($types);
523 if (!$conf[
'onlyCurrentPid'] || $pid ==
$GLOBALS[
'TSFE']->
id) {
526 $allow = array_flip($types);
528 if ($table ==
'pages') {
530 if (count(
$GLOBALS[
'TSFE']->config[
'rootLine']) === 1) {
531 unset($allow[
'move']);
532 unset($allow[
'hide']);
533 unset($allow[
'delete']);
536 unset($allow[
'edit']);
537 unset($allow[
'move']);
538 unset($allow[
'hide']);
541 unset($allow[
'delete']);
544 unset($allow[
'new']);
582 if (!isset($this->tce)) {
584 $this->tce->stripslashes_values = 0;