From 13474e3455d11b553e3165a878b07fc8cd5985e7 Mon Sep 17 00:00:00 2001 From: Wouter Wolters Date: Sun, 3 Feb 2013 19:53:04 +0100 Subject: [PATCH] [TASK] Cleanup feedit Change-Id: I8eca6524c69ee71973411b4b791ee7b33bdcda82 Resolves: #45116 Releases: 6.1 Reviewed-on: https://review.typo3.org/17985 Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn --- Classes/FrontendEditPanel.php | 167 ++++++++++++++++++---------------- ext_localconf.php | 4 +- 2 files changed, 91 insertions(+), 80 deletions(-) diff --git a/Classes/FrontendEditPanel.php b/Classes/FrontendEditPanel.php index d6a7035..2a7c0c7 100644 --- a/Classes/FrontendEditPanel.php +++ b/Classes/FrontendEditPanel.php @@ -27,6 +27,7 @@ namespace TYPO3\CMS\Feedit; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** * View class for the edit panels in frontend editing. * @@ -82,82 +83,82 @@ class FrontendEditPanel { $theCmd = $TSFE_EDIT['cmd']; } switch ($theCmd) { - case 'edit': + case 'edit': - case 'new': - $finalOut = $this->editContent($formTag, $formName, $theCmd, $newUID, $dataArr, $table, $currentRecord, $blackLine); - break; - default: - $panel = ''; - if (isset($allow['toolbar']) && $GLOBALS['BE_USER']->adminPanel instanceof \TYPO3\CMS\Frontend\View\AdminPanelView) { - $panel .= $GLOBALS['BE_USER']->adminPanel->ext_makeToolBar() . ''; - } - if (isset($allow['edit'])) { - $panel .= $this->editPanelLinkWrap('', $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord); - } - // Hiding in workspaces because implementation is incomplete - if (isset($allow['move']) && $sortField && $GLOBALS['BE_USER']->workspace === 0) { - $panel .= $this->editPanelLinkWrap('', $formName, 'up'); - $panel .= $this->editPanelLinkWrap('', $formName, 'down'); - } - // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case - if (isset($allow['hide']) && $hideField && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) { - if ($dataArr[$hideField]) { - $panel .= $this->editPanelLinkWrap('', $formName, 'unhide'); - } else { - $panel .= $this->editPanelLinkWrap('', $formName, 'hide', '', $GLOBALS['BE_USER']->extGetLL('p_hideConfirm')); + case 'new': + $finalOut = $this->editContent($formTag, $formName, $theCmd, $newUID, $dataArr, $table, $currentRecord, $blackLine); + break; + default: + $panel = ''; + if (isset($allow['toolbar']) && $GLOBALS['BE_USER']->adminPanel instanceof \TYPO3\CMS\Frontend\View\AdminPanelView) { + $panel .= $GLOBALS['BE_USER']->adminPanel->ext_makeToolBar() . ''; } - } - if (isset($allow['new'])) { - if ($table == 'pages') { - $panel .= $this->editPanelLinkWrap('', $formName, 'new', $currentRecord, ''); - } else { - $panel .= $this->editPanelLinkWrap('', $formName, 'new', $currentRecord, '', $newUID); + if (isset($allow['edit'])) { + $panel .= $this->editPanelLinkWrap('', $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord); } - } - // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case - if (isset($allow['delete']) && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) { - $panel .= $this->editPanelLinkWrap('', $formName, 'delete', '', $GLOBALS['BE_USER']->extGetLL('p_deleteConfirm')); - } - // Final - $labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']); - foreach ((array) $hiddenFields as $name => $value) { - $hiddenFieldString .= '' . LF; - } - $panel = ' + // Hiding in workspaces because implementation is incomplete + if (isset($allow['move']) && $sortField && $GLOBALS['BE_USER']->workspace === 0) { + $panel .= $this->editPanelLinkWrap('', $formName, 'up'); + $panel .= $this->editPanelLinkWrap('', $formName, 'down'); + } + // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case + if (isset($allow['hide']) && $hideField && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) { + if ($dataArr[$hideField]) { + $panel .= $this->editPanelLinkWrap('', $formName, 'unhide'); + } else { + $panel .= $this->editPanelLinkWrap('', $formName, 'hide', '', $GLOBALS['BE_USER']->extGetLL('p_hideConfirm')); + } + } + if (isset($allow['new'])) { + if ($table == 'pages') { + $panel .= $this->editPanelLinkWrap('', $formName, 'new', $currentRecord, ''); + } else { + $panel .= $this->editPanelLinkWrap('', $formName, 'new', $currentRecord, '', $newUID); + } + } + // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case + if (isset($allow['delete']) && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) { + $panel .= $this->editPanelLinkWrap('', $formName, 'delete', '', $GLOBALS['BE_USER']->extGetLL('p_deleteConfirm')); + } + // Final + $labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']); + foreach ((array) $hiddenFields as $name => $value) { + $hiddenFieldString .= '' . LF; + } + $panel = ' - - ' . $formTag . $hiddenFieldString . ' - - - - - ' . ($labelTxt ? '' : '') . ' - -
' . $panel . ' ' . sprintf($labelTxt, htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($dataArr[$labelField], 50))) . ' 
- '; - // Wrap the panel - if ($conf['innerWrap']) { - $panel = $this->cObj->wrap($panel, $conf['innerWrap']); - } - if ($conf['innerWrap.']) { - $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']); - } - // Add black line: - $panel .= $blackLine; - // Wrap the complete panel - if ($conf['outerWrap']) { - $panel = $this->cObj->wrap($panel, $conf['outerWrap']); - } - if ($conf['outerWrap.']) { - $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']); - } - if ($conf['printBeforeContent']) { - $finalOut = $panel . $content; - } else { - $finalOut = $content . $panel; - } - break; + + ' . $formTag . $hiddenFieldString . ' + + + + + ' . ($labelTxt ? '' : '') . ' + +
' . $panel . ' ' . sprintf($labelTxt, htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($dataArr[$labelField], 50))) . ' 
+ '; + // Wrap the panel + if ($conf['innerWrap']) { + $panel = $this->cObj->wrap($panel, $conf['innerWrap']); + } + if ($conf['innerWrap.']) { + $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']); + } + // Add black line: + $panel .= $blackLine; + // Wrap the complete panel + if ($conf['outerWrap']) { + $panel = $this->cObj->wrap($panel, $conf['outerWrap']); + } + if ($conf['outerWrap.']) { + $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']); + } + if ($conf['printBeforeContent']) { + $finalOut = $panel . $content; + } else { + $finalOut = $content . $panel; + } + break; } if ($conf['previewBorder']) { if (!is_array($conf['previewBorder.'])) { @@ -184,7 +185,7 @@ class FrontendEditPanel { * @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. */ public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList) { - // Special content is about to be shown, so the cache must be disabled. + // Special content is about to be shown, so the cache must be disabled. $GLOBALS['TSFE']->set_no_cache('Display frontend edit icons'); $style = $conf['styleAttribute'] ? ' style="' . htmlspecialchars($conf['styleAttribute']) . '"' : ''; $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']); @@ -219,7 +220,7 @@ class FrontendEditPanel { * @param string $confirm Text string with confirmation message; If set a confirm box will be displayed before carrying out the action (if Yes is pressed) * @param integer $nPid "New pid" - for new records * @return string A tag wrapped string. - * @see editPanel(), editIcons(), t3lib_tsfeBeUserAuth::extEditAction() + * @see editPanel(), editIcons(), t3lib_tsfeBeUserAuth::extEditAction() */ protected function editPanelLinkWrap($string, $formName, $cmd, $currentRecord = '', $confirm = '', $nPid = '') { // Editing forms on page only supported in Live workspace (because of incomplete implementation) @@ -285,7 +286,7 @@ class FrontendEditPanel { * @param integer $thick The thickness of the border * @param array $conf The array with TypoScript properties for the content object * @return string The input string wrapped in a table with a border color of #cccccc and thickness = $thick - * @see editPanel() + * @see editPanel() */ protected function editPanelPreviewBorder($table, array $row, $content, $thick, array $conf = array()) { if ($this->isDisabled($table, $row)) { @@ -314,10 +315,21 @@ class FrontendEditPanel { * @param string $table The table name * @param array $row The data record * @return boolean - * @see editPanelPreviewBorder() + * @see editPanelPreviewBorder() */ protected function isDisabled($table, $row) { - if ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']] || $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group'] && $GLOBALS['TSFE']->simUserGroup && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group']] == $GLOBALS['TSFE']->simUserGroup || $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME'] || $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME']) { + if ( + $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] && + $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']] || + $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group'] && + $GLOBALS['TSFE']->simUserGroup && + $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group']] == $GLOBALS['TSFE']->simUserGroup || + $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime'] && + $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME'] || + $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime'] && + $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] && + $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME'] + ) { return TRUE; } } @@ -386,5 +398,4 @@ class FrontendEditPanel { } - ?> \ No newline at end of file diff --git a/ext_localconf.php b/ext_localconf.php index e50b129..26cfcf0 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,6 +2,6 @@ if (!defined('TYPO3_MODE')) { die('Access denied.'); } - // Register the edit panel view. -$TYPO3_CONF_VARS['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = 'EXT:feedit/Classes/FrontendEditPanel.php:TYPO3\\CMS\\Feedit\\FrontendEditPanel'; +// Register the edit panel view. +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = 'EXT:feedit/Classes/FrontendEditPanel.php:TYPO3\\CMS\\Feedit\\FrontendEditPanel'; ?> \ No newline at end of file