/**
  * @test
  */
 public function getTriggerSelfChangedEventWhenTitleOfPageWasChanged()
 {
     $eventWasFired = false;
     $this->dispatcher->subscribe('Page::Changed::Self', function ($event) use(&$eventWasFired) {
         if ($event instanceof SelfChangedEvent) {
             $eventWasFired = true;
         }
         $eventWasFired = false;
     });
     $this->dataHandler->updateDB();
     $this->dataHandler->process_datamap();
     $this->assertTrue($eventWasFired);
 }
Пример #2
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 string $tableName
  * @param integer $uid
  * @param string $fieldName
  * @param array $referenceIds
  */
 public function modifyReferences($tableName, $uid, $fieldName, array $referenceIds)
 {
     $dataMap = array($tableName => array($uid => array($fieldName => implode(',', $referenceIds))));
     $this->createDataHandler();
     $this->dataHandler->start($dataMap, array());
     $this->dataHandler->process_datamap();
 }
 /**
  * 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');
         }
     }
 }
 /**
  * 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);
 }