Project

General

Profile

Feature #23085 » saveAndView.patch

Administrator Admin, 2010-07-03 12:43

View differences:

typo3/alt_doc.php (working copy)
// CLEANSE SETTINGS
$this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_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 (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['init'])) {
$parameters = array(
'editcont' => $this->editconf,
'popViewId_addParams' => &$this->popViewId_addParams,
'popViewId' => &$this->popViewId,
'viewUrl' => &$this->viewUrl,
);
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['init'] as $classReference) {
$hook = t3lib_div::getUserObj($classReference);
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 = $BACK_PATH;
......
$CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid'])); // Fetching pid-record first.
$hasAccess = $CALC_PERMS&16 ? 1 : 0;
$deleteAccess = $CALC_PERMS&16 ? 1 : 0;
$this->viewId = $calcPRec['pid'];
$pagesTSC = t3lib_BEfunc::getPagesTSconfig($calcPRec['pid']);
if (is_array($pagesTSC['common.']['table.'][$table.'.']) && is_int($pagesTSC['options.']['table.'][$table.'.']['FePreviewPid'])) {
$this->viewId = $pagesTSC['common.']['table.'][$table.'.']['FePreviewPid'];
}else{
$this->viewId = $calcPRec['pid'];
}
// Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']]>0) {
$this->viewId_addParams = '&L='.$calcPRec[$TCA[$table]['ctrl']['languageField']];
tests/typo3/alt_docTest.php (revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Ingo Schmitt <is@marketing-factory.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for the "SC_alt_doc" in the TYPO3 Core.
*
* @package TYPO3
*
* @author Ingo Schmitt <is@marketing-factory.de>
* @thanks to Christian Kuhn and Oliver Klee for helping me on this
*
*/
// Since at_doc.php actually is outputting data, we have to start output
// buffering and have to discard the output after executing the file.
ob_start();
require_once(PATH_site . 'typo3/alt_doc.php');
ob_end_clean();
class alt_docTest extends tx_phpunit_testcase {
/**
* @var array backup for global arrays
*/
private $backupGlobalVariables = array();
public function setUp() {
$this->backupGloablsVariables = array(
'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS'],
'T3_VAR' => $GLOBALS['T3VAR'],
);
}
public function tearDown() {
foreach ($this->backupGlobalsVariables as $key => $value) {
$GLOBALS[$key] = $value;
}
}
/**
* @test
*/
public function initHookGetsCalled() {
$hookClassName = uniqid('tx_coretest');
$hookMock = $this->getMock(
$hookClassName,
array('processPreviewLink')
);
$hookMock->expects($this->once())->method('processPreviewLink');
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['init'][] = $hookClassName;
$GLOBALS['T3_VAR']['getUserObj'][$hookClassName] = $hookMock;
$fixture = t3lib_div::makeInstance('SC_alt_doc');
$fixture->init();
}
}
?>
(1-1/2)