Пример #1
0
 /**
  * @test
  */
 public function frontendUriBuilderParametersArePassedOnIfConfigured()
 {
     $this->typoScriptFrontendController->tmpl->setup['plugin.']['tx_linkhandler.']['tx_news_news.']['overrideParentTypolinkConfiguration'] = 1;
     $this->typoScriptFrontendController->tmpl->setup['plugin.']['tx_linkhandler.']['tx_news_news.']['typolink.']['useCacheHash'] = 0;
     $this->uriBuilder->reset()->setTargetPageUid('record:tx_news_news:tx_news_domain_model_news:1')->setNoCache(TRUE);
     $generatedUrl = $this->uriBuilder->buildFrontendUri();
     $this->assertEquals('index.php?id=1&no_cache=1&tx_news_pi1%5Bnews%5D=1&tx_news_pi1%5Bcontroller%5D=News&tx_news_pi1%5Baction%5D=detail', $generatedUrl);
 }
Пример #2
0
 /**
  * Returns a frontend URI independently of current context, with or without extbase, and with or without TSFE
  * @param string $actionName
  * @param array $controllerArguments
  * @param string $controllerName
  * @param string $extensionName
  * @param string $pluginName
  * @return string absolute URI
  */
 public static function buildFrontendUri($actionName, array $controllerArguments, $controllerName, $extensionName = 'newsletter', $pluginName = 'p')
 {
     if (!self::$uriBuilder) {
         self::$uriBuilder = self::buildUriBuilder($extensionName, $pluginName);
     }
     $controllerArguments['action'] = $actionName;
     $controllerArguments['controller'] = $controllerName;
     $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $extensionService = $objectManager->get('TYPO3\\CMS\\Extbase\\Service\\ExtensionService');
     $pluginNamespace = $extensionService->getPluginNamespace($extensionName, $pluginName);
     $arguments = array($pluginNamespace => $controllerArguments);
     self::$uriBuilder->reset()->setUseCacheHash(false)->setCreateAbsoluteUri(true)->setArguments($arguments);
     return self::$uriBuilder->buildFrontendUri() . '&type=1342671779';
 }
Пример #3
0
 /**
  * Create doc header drop down
  *
  * @return void
  */
 protected function createMenu()
 {
     $this->uriBuilder->setRequest($this->request);
     $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
     $menu->setIdentifier('cadabra');
     $actions = [['action' => 'index', 'label' => 'listProducts'], ['action' => 'listArticles', 'label' => 'listArticles']];
     foreach ($actions as $action) {
         $item = $menu->makeMenuItem()->setTitle($this->getLanguageService()->sL($this->settings['LLL']['productadministration'] . ':module.' . $action['label']))->setHref($this->uriBuilder->reset()->uriFor($action['action'], [], 'Backend\\Product'))->setActive($this->request->getControllerActionName() === $action['action']);
         $menu->addMenuItem($item);
     }
     $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
     $pageInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->pageUid, '');
     $this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageInfo);
 }
Пример #4
0
 /**
  * Redirects the request to another action and / or controller.
  *
  * Redirect will be sent to the client which then performs another request to the new URI.
  *
  * NOTE: This method only supports web requests and will thrown an exception
  * if used with other request types.
  *
  * @param string $actionName Name of the action to forward to
  * @param string $controllerName Unqualified object name of the controller to forward to. If not specified, the current controller is used.
  * @param string $extensionName Name of the extension containing the controller to forward to. If not specified, the current extension is assumed.
  * @param array $arguments Arguments to pass to the target action
  * @param int $pageUid Target page uid. If NULL, the current page uid is used
  * @param int $delay (optional) The delay in seconds. Default is no delay.
  * @param int $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other
  * @return void
  * @throws UnsupportedRequestTypeException If the request is not a web request
  * @throws StopActionException
  * @see forward()
  * @api
  */
 protected function redirect($actionName, $controllerName = null, $extensionName = null, array $arguments = null, $pageUid = null, $delay = 0, $statusCode = 303)
 {
     if (!$this->request instanceof WebRequest) {
         throw new UnsupportedRequestTypeException('redirect() only supports web requests.', 1220539734);
     }
     if ($controllerName === null) {
         $controllerName = $this->request->getControllerName();
     }
     $this->uriBuilder->reset()->setTargetPageUid($pageUid)->setCreateAbsoluteUri(true);
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
         $this->uriBuilder->setAbsoluteUriScheme('https');
     }
     $uri = $this->uriBuilder->uriFor($actionName, $arguments, $controllerName, $extensionName);
     $this->redirectToUri($uri, $delay, $statusCode);
 }
Пример #5
0
 /**
  * @test
  */
 public function resetSetsAllOptionsToTheirDefaultValue()
 {
     $this->uriBuilder->setArguments(array('test' => 'arguments'))->setSection('testSection')->setFormat('someFormat')->setCreateAbsoluteUri(true)->setAddQueryString(true)->setArgumentsToBeExcludedFromQueryString(array('test' => 'addQueryStringExcludeArguments'))->setAddQueryStringMethod(null)->setArgumentPrefix('testArgumentPrefix')->setLinkAccessRestrictedPages(true)->setTargetPageUid(123)->setTargetPageType(321)->setNoCache(true)->setUseCacheHash(false);
     $this->uriBuilder->reset();
     $this->assertEquals(array(), $this->uriBuilder->getArguments());
     $this->assertEquals('', $this->uriBuilder->getSection());
     $this->assertEquals('', $this->uriBuilder->getFormat());
     $this->assertEquals(false, $this->uriBuilder->getCreateAbsoluteUri());
     $this->assertEquals(false, $this->uriBuilder->getAddQueryString());
     $this->assertEquals(array(), $this->uriBuilder->getArgumentsToBeExcludedFromQueryString());
     $this->assertEquals(null, $this->uriBuilder->getAddQueryStringMethod());
     $this->assertEquals(null, $this->uriBuilder->getArgumentPrefix());
     $this->assertEquals(false, $this->uriBuilder->getLinkAccessRestrictedPages());
     $this->assertEquals(null, $this->uriBuilder->getTargetPageUid());
     $this->assertEquals(0, $this->uriBuilder->getTargetPageType());
     $this->assertEquals(false, $this->uriBuilder->getNoCache());
     $this->assertEquals(true, $this->uriBuilder->getUseCacheHash());
 }
 /**
  * @param $pages
  * @return array
  */
 public function getEntriesFromPages($pages)
 {
     $urlEntries = [];
     foreach ($pages as $page) {
         if ($page['doktype'] == 1) {
             $urlEntry = new UrlEntry();
             $uri = $this->uriBuilder->reset()->setTargetPageUid($page['uid'])->setCreateAbsoluteUri(true)->build();
             $urlEntry->setLoc($uri);
             $urlEntry->setLastmod(date('Y-m-d', $page['tstamp']));
             if (isset($page['sitemap_priority'])) {
                 $urlEntry->setPriority(sprintf('%01.1f', $page['sitemap_priority'] / 10));
             }
             if (isset($page['sitemap_changefreq'])) {
                 $urlEntry->setChangefreq($page['sitemap_changefreq']);
             }
             $urlEntries[] = $urlEntry;
         }
     }
     return $urlEntries;
 }
Пример #7
0
 /**
  * Page not found handling
  *
  * @param array $params
  * @param TypoScriptFrontendController $ref
  * @throws PageNotFoundException
  * @return void
  */
 public function pageNotFound(array $params, TypoScriptFrontendController $ref = NULL)
 {
     $domain = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
     $domainInformation = parse_url($domain);
     $errorPageUid = (int) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['theme']['errorPages']['_DEFAULT'];
     if (!empty($domainInformation['host'])) {
         $tmpErrorPageUid = (int) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['theme']['errorPages'][$domainInformation['host']];
         if ($tmpErrorPageUid > 0) {
             $errorPageUid = $tmpErrorPageUid;
         }
     }
     if ($errorPageUid > 0) {
         $sysLanguageUid = $this->getSysLanguage($ref);
         $this->uriBuilder->reset()->setTargetPageUid($errorPageUid)->setCreateAbsoluteUri(TRUE);
         if ($sysLanguageUid > 0) {
             $this->uriBuilder->setArguments(array('L' => $sysLanguageUid));
         }
         HttpUtility::redirect($this->uriBuilder->buildFrontendUri(), HttpUtility::HTTP_STATUS_404);
     }
     $message = 'The page not found handling could not handle the request. The original message was: "' . $params['reasonText'] . '" with URL "' . $params['currentUrl'] . '"';
     throw new PageNotFoundException($message, 1301648780);
 }
Пример #8
0
 /**
  * Gets the pageUrl
  *
  * @param integer $pageUid
  * @return string
  */
 protected function getPageUrl($pageUid)
 {
     return $this->uriBuilder->reset()->setTargetPageUid((int) $pageUid)->setCreateAbsoluteUri(true)->buildFrontendUri();
 }