diff --git a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php index 3d30655..dab8c06 100644 --- a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php +++ b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php @@ -580,6 +580,23 @@ class EditDocumentController { $this->MCONF['name'] = 'xMOD_alt_doc.php'; // CLEANSE SETTINGS $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name']); + + // Hook for processing preview popViewId_addParams, popViewId and viewUrl + // could be used to modify the save and view preview URL + if(sizeof($this->getHookObjects())) { + $parameters = array( + 'editcont' => $this->editconf, + 'popViewId_addParams' => &$this->popViewId_addParams, + 'popViewId' => &$this->popViewId, + 'viewUrl' => &$this->viewUrl, + ); + foreach ($this->getHookObjects() as $hook) { + if ((method_exists($hook, 'processPreviewLink'))) { + $hook->processPreviewLink($parameters, $this); + } + } + } + // Create an instance of the document template object $this->doc = $GLOBALS['TBE_TEMPLATE']; $this->doc->backPath = $GLOBALS['BACK_PATH']; @@ -629,6 +646,27 @@ class EditDocumentController { } /** + * Get the pre created hook objects for the EditDocumentController + * + * @return array + */ + protected function getHookObjects(){ + static $hookObjects = NULL; + if($hookObjects === NULL) { + $hookObjects = array(); + if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['hookObject'])) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['hookObject'] as $classReference) { + $hook = GeneralUtility::getUserObj($classReference); + if (is_object($hook)) { + $hookObjects[] = $hook; + } + } + } + } + return $hookObjects; + } + + /** * Main module operation * * @return void @@ -794,6 +832,14 @@ class EditDocumentController { if ($GLOBALS['TCA'][$table]['ctrl']['languageField'] && $calcPRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) { $this->viewId_addParams = '&L=' . $calcPRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']]; } + + $pagesTSC = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($calcPRec['pid']); + if (is_array($pagesTSC['common.']['table.'][$table.'.']) && is_numeric($pagesTSC['common.']['table.'][$table.'.']['FePreviewPid'])) { + $this->viewId = $pagesTSC['common.']['table.'][$table.'.']['FePreviewPid']; + if(isset($pagesTSC['common.']['table.'][$table.'.']['additionalParams'])) { + $this->viewId_addParams .= '&' . str_replace('###UID###', $theUid, trim($pagesTSC['common.']['table.'][$table.'.']['additionalParams'], '& ')); + } + } } // Check internals regarding access: $isRootLevelRestrictionIgnored = BackendUtility::isRootLevelRestrictionIgnored($table); @@ -924,7 +970,17 @@ class EditDocumentController { $buttons['save'] = IconUtility::getSpriteIcon('actions-document-save', array('html' => '')); // SAVE / VIEW button: if ($this->viewId && !$this->noView && ExtensionManagementUtility::isLoaded('cms') && $this->getNewIconMode($this->firstEl['table'], 'saveDocView')) { - $buttons['save_view'] = IconUtility::getSpriteIcon('actions-document-save-view', array('html' => '')); + + $pagesTSC = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($this->pageinfo['uid']); + if (isset($pagesTSC['properties']['excludeDokTypes'])) { + $excludeDokTypes = GeneralUtility::intExplode(',', $pagesTSC['properties']['excludeDokTypes'], TRUE); + } else { + // exclude sysfolders and recycler by default + $excludeDokTypes = array(254, 255); + } + if (!in_array($this->pageinfo['doktype'], $excludeDokTypes) || isset($pagesTSC['common.']['table.'][$table.'.']['FePreviewPid'])) { + $buttons['save_view'] = IconUtility::getSpriteIcon('actions-document-save-view', array('html' => '')); + } } // SAVE / NEW button: if (count($this->elementsData) == 1 && $this->getNewIconMode($this->firstEl['table'])) { @@ -968,6 +1024,19 @@ class EditDocumentController { $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'], '', TRUE); $buttons['shortcut'] = $this->shortCutLink(); $buttons['open_in_new_window'] = $this->openInNewWindowLink(); + + // Hook for change the behavior of the button generation + if(sizeof($this->getHookObjects())) { + $parameters = array( + 'buttons' => &$buttons + ); + foreach ($this->getHookObjects() as $hook) { + if ((method_exists($hook, 'manipulateButtons'))) { + $hook->manipulateButtons($parameters, $this); + } + } + } + return $buttons; }