Пример #1
0
 public function setUp()
 {
     $GLOBALS['TCA'] = array();
     $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
     $this->backEndUser = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
     $this->subject = new \TYPO3\CMS\Core\DataHandling\DataHandler();
     $this->subject->start(array(), '', $this->backEndUser);
 }
Пример #2
0
 /**
  * @param int $id
  */
 public function deleteAction($id)
 {
     $GLOBALS['TYPO3_DB']->exec_DELETEquery('link_cache', 'id = ' . (int) $id);
     $this->dataHandler->start(NULL, NULL);
     $this->dataHandler->clear_cacheCmd('all');
     $this->addFlashMessage('A link has been removed from cache, please reload page where the link is present (not the page itself, but e.g. parent page with this link in menu) in order to generate it again.');
     $this->redirect('list');
 }
Пример #3
0
 public function setUp()
 {
     $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
     $this->databaseBackup = $GLOBALS['TYPO3_DB'];
     $this->backEndUser = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
     $this->fixture = new \TYPO3\CMS\Core\DataHandling\DataHandler();
     $this->fixture->start(array(), '', $this->backEndUser);
 }
Пример #4
0
 /**
  * Set up the tests
  */
 protected function setUp()
 {
     $GLOBALS['TCA'] = array();
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     $this->backEndUser = $this->getMock(BackendUserAuthentication::class);
     $this->mockDatabaseConnection = $this->getMock(DatabaseConnection::class, array(), array(), '', FALSE);
     $GLOBALS['TYPO3_DB'] = $this->mockDatabaseConnection;
     $this->subject = $this->getAccessibleMock(DataHandler::class, ['dummy']);
     $this->subject->start(array(), '', $this->backEndUser);
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->dataHandler = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
     $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->installToolClearCacheService = GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\Service\\ClearCacheService');
     // Create a fake admin user
     $adminUser = $this->objectManager->get('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
     $adminUser->user['uid'] = $GLOBALS['BE_USER']->user['uid'];
     $adminUser->user['username'] = '******';
     $adminUser->user['admin'] = 1;
     $adminUser->workspace = 0;
     $this->dataHandler->start(array(), array(), $adminUser);
 }
Пример #6
0
 /**
  * Create a new record under the given PID.
  *
  * @param  int  $pid
  * @param  array  $attrs  Set of attributes to add to the record
  * @return  int|null  UID of created record, or null if creation failed
  */
 public function create($pid, $attrs = [])
 {
     $table = $this->getTable();
     $newUid = 'NEW_' . uniqid($table);
     $this->dh->stripslashes_values = 0;
     $this->dh->start([$table => [$newUid => array_merge($attrs, ['pid' => $pid])]], null);
     $this->dh->process_datamap();
     if (isset($this->dh->substNEWwithIDs[$newUid])) {
         return $this->dh->substNEWwithIDs[$newUid];
     } else {
         return null;
     }
 }
 /**
  * @param int $workspaceId
  */
 public function swapWorkspace($workspaceId)
 {
     $commandMap = $this->getWorkspaceService()->getCmdArrayForPublishWS($workspaceId, TRUE);
     $this->createDataHandler();
     $this->dataHandler->start(array(), $commandMap);
     $this->dataHandler->process_cmdmap();
 }
 /**
  * Executing the posted actions ...
  *
  * @return void
  * @todo Define visibility
  */
 public function main()
 {
     // LOAD TCEmain with data and cmd arrays:
     $this->tce->start($this->data, $this->cmd);
     if (is_array($this->mirror)) {
         $this->tce->setMirror($this->mirror);
     }
     // Checking referer / executing
     $refInfo = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_REFERER'));
     $httpHost = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
     if ($httpHost != $refInfo['host'] && $this->vC != $GLOBALS['BE_USER']->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
         $this->tce->log('', 0, 0, 0, 1, 'Referer host "%s" and server host "%s" did not match and veriCode was not valid either!', 1, array($refInfo['host'], $httpHost));
     } else {
         // Register uploaded files
         $this->tce->process_uploads($_FILES);
         // Execute actions:
         $this->tce->process_datamap();
         $this->tce->process_cmdmap();
         // Clearing cache:
         $this->tce->clear_cacheCmd($this->cacheCmd);
         // Update page tree?
         if ($this->uPT && (isset($this->data['pages']) || isset($this->cmd['pages']))) {
             \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
         }
     }
 }
Пример #9
0
 /**
  * @return \TYPO3\CMS\Core\DataHandling\DataHandler
  */
 public function getDataHandler()
 {
     if (!isset($this->dataHandler)) {
         $this->dataHandler = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
         $this->dataHandler->start(null, null);
     }
     return $this->dataHandler;
 }
Пример #10
0
 /**
  * Create an (cached) instance of t3lib_TCEmain
  *
  * @return \TYPO3\CMS\Core\DataHandling\DataHandler
  */
 protected function _tce()
 {
     if ($this->_tce === NULL) {
         $this->_tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
         $this->_tce->start(null, null);
     }
     return $this->_tce;
 }
Пример #11
0
 /**
  * Initialize the object.
  *
  * @return void
  */
 public function initializeObject()
 {
     // Create a fake admin user
     $adminUser = $this->objectManager->get('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
     $adminUser->user['uid'] = $GLOBALS['BE_USER']->user['uid'];
     $adminUser->user['username'] = '******';
     $adminUser->user['admin'] = 1;
     $adminUser->workspace = 0;
     $this->dataHandler->start(array(), array(), $adminUser);
 }
 /**
  * Saves a record based on its data array.
  *
  * @param string $table The table name for the record to save.
  * @param integer $uid The UID for the record to save.
  * @return void
  */
 public function doSave($table, $uid)
 {
     $data = $this->TSFE_EDIT['data'];
     if (!empty($data)) {
         $this->initializeTceMain();
         $this->tce->start($data, array());
         $this->tce->process_uploads($_FILES);
         $this->tce->process_datamap();
         // Save the new UID back into TSFE_EDIT
         $newUID = $this->tce->substNEWwithIDs['NEW'];
         if ($newUID) {
             $GLOBALS['BE_USER']->frontendEdit->TSFE_EDIT['newUID'] = $newUID;
         }
     }
 }
 /**
  * @test
  */
 public function copyingNewContentFromLanguageIntoExistingLocalizationHasSameOrdering()
 {
     $params = ['pageId' => 1, 'srcLanguageId' => 0, 'destLanguageId' => 1, 'uidList' => [1, 2, 3], 'action' => LocalizationController::ACTION_COPY];
     $this->callInaccessibleMethod($this->subject, 'process', $params);
     // Create another content element in default language
     $data = ['tt_content' => ['NEW123456' => ['sys_language_uid' => 0, 'header' => 'Test content 2.5', 'pid' => -2]]];
     $dataHandler = new DataHandler();
     $dataHandler->start($data, []);
     $dataHandler->process_datamap();
     $dataHandler->process_cmdmap();
     $newContentElementUid = $dataHandler->substNEWwithIDs['NEW123456'];
     // Copy the new content element
     $params = ['pageId' => 1, 'srcLanguageId' => 0, 'destLanguageId' => 1, 'uidList' => [$newContentElementUid], 'action' => LocalizationController::ACTION_COPY];
     $this->callInaccessibleMethod($this->subject, 'process', $params);
     $expectedResults = [['pid' => '1', 'sys_language_uid' => '1', 'l18n_parent' => '0', 'header' => 'Test content 1 (copy 1)'], ['pid' => '1', 'sys_language_uid' => '1', 'l18n_parent' => '0', 'header' => 'Test content 2 (copy 1)'], ['pid' => '1', 'sys_language_uid' => '1', 'l18n_parent' => '0', 'header' => 'Test content 2.5 (copy 1)'], ['pid' => '1', 'sys_language_uid' => '1', 'l18n_parent' => '0', 'header' => 'Test content 3 (copy 1)']];
     $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 1', '', 'sorting ASC');
     $this->assertSame($expectedResults, $results);
 }