Author: Dmitry Dulepov (dmitry.dulepov@gmail.com)
Example #1
0
 /**
  * Test if whitespace is trimmed and spaces are treated the same as tabs and nbsp
  *
  * @test
  * @see https://github.com/dmitryd/typo3-realurl/issues/218
  */
 public function convertToSafeStringWithWhitespace()
 {
     // the string should be trimmed
     $this->assertEquals('trim', $this->utility->convertToSafeString("  trim  "));
     // the next line contains a non-breaking-sapce (\x20)
     $this->assertEquals('non-breaking-space-split', $this->utility->convertToSafeString("non-breaking-space split"), 'Non-breaking-spaces should be treated as whitespace');
     // tabs should be treated the same as white-space
     $this->assertEquals('tab-split', $this->utility->convertToSafeString("tab\tsplit"), 'tabs should be treated the same as white-space');
 }
 /**
  * Initializes the class.
  */
 public function __construct()
 {
     $this->databaseConnection = $GLOBALS['TYPO3_DB'];
     $this->tsfe = $GLOBALS['TSFE'];
     $this->configuration = ConfigurationReader::getInstance();
     $this->emptySegmentValue = $this->configuration->get('init/emptySegmentValue');
     $this->rootPageId = (int) $this->configuration->get('pagePath/rootpage_id');
     $this->utility = Utility::getInstance();
     $this->cache = $this->utility->getCache();
     $this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
     $this->pageRepository->init(FALSE);
 }
Example #3
0
 /**
  * Initializes the instance.
  *
  * @throws \Exception
  */
 protected function initialize()
 {
     $this->initializeConfiguration();
     $this->emptySegmentValue = $this->configuration->get('init/emptySegmentValue');
     $this->rootPageId = (int) $this->configuration->get('pagePath/rootpage_id');
     $this->utility = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Utility', $this->configuration);
     $this->cache = $this->utility->getCache();
     $this->separatorCharacter = $this->configuration->get('pagePath/spaceCharacter');
 }
Example #4
0
 /**
  * Initializes the class.
  */
 public function __construct()
 {
     Utility::checkAndPerformRequiredUpdates();
     $this->databaseConnection = $GLOBALS['TYPO3_DB'];
     $this->tsfe = $GLOBALS['TSFE'];
     // Warning! It is important to init the new object and not reuse any existing object
     // $this->pageRepository->sys_language_uid must stay 0 because we will do overlays manually
     $this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
     $this->pageRepository->init(FALSE);
 }
Example #5
0
 /**
  * Sets the root page id from the top level pages.
  *
  * @return bool
  * @throws \Exception
  */
 protected function setRootPageIdFromTopLevelPages()
 {
     /** @noinspection PhpUndefinedMethodInspection */
     $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages', 'pid=0 AND doktype IN (1,2,4) AND deleted=0 AND hidden=0');
     if (count($rows) !== 1) {
         // Cannot be done: too many of them!
         throw new \Exception('RealURL was not able to find the root page id for the domain "' . $this->utility->getCurrentHost() . '"', 1420480982);
     }
     $this->configuration['pagePath']['rootpage_id'] = (int) $rows[0]['uid'];
     return TRUE;
 }
 /**
  * Initializes all actions.
  *
  * @return void
  */
 protected function initializeAction()
 {
     Utility::checkAndPerformRequiredUpdates();
     $this->currentPageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id');
     $this->databaseConnection = $GLOBALS['TYPO3_DB'];
     // Fix pagers
     $arguments = GeneralUtility::_GPmerged('tx_realurl_web_realurlrealurl');
     if ($arguments && is_array($arguments)) {
         foreach ($arguments as $argumentKey => $argumentValue) {
             if ($argumentValue) {
                 if (!in_array($argumentKey, $this->excludedArgments)) {
                     GeneralUtility::_GETset($argumentValue, 'tx_realurl_web_realurlrealurl|' . $argumentKey);
                 } else {
                     GeneralUtility::_GETset('', 'tx_realurl_web_realurlrealurl|' . $argumentKey);
                 }
             }
         }
     } else {
         $this->forwardToLastModule();
     }
     parent::initializeAction();
 }