/** * Initializes the URL view helper. * * @param \Aimeos\MW\View\Iface $view View instance with registered view helpers * @param \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder TYPO3 URI builder * @param array $fixed Fixed parameters that should be added to each URL */ public function __construct(\Aimeos\MW\View\Iface $view, \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder, array $fixed) { parent::__construct($view); $this->prefix = $uriBuilder->getArgumentPrefix(); $this->uriBuilder = $uriBuilder; $this->fixed = $fixed; }
/** * Initializes the URL view helper. * * @param MW_View_Interface $view View instance with registered view helpers * @param TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder TYPO3 URI builder * @param array $fixed Fixed parameters that should be added to each URL */ public function __construct(MW_View_Interface $view, \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder, array $fixed) { parent::__construct($view); $this->_prefix = $uriBuilder->getArgumentPrefix(); $this->_uriBuilder = $uriBuilder; $this->_fixed = $fixed; }
/** * Creates the view object for the HTML client. * * @param \Aimeos\MW\Config\Iface $config Config object * @param \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder URL builder object * @param array $templatePaths List of base path names with relative template paths as key/value pairs * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface|null $request Request object * @param string|null $locale Code of the current language or null for no translation * @param boolean $frontend True if the view is for the frontend, false for the backend * @return \Aimeos\MW\View\Iface View object */ public static function get(\Aimeos\MW\Config\Iface $config, \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder, array $templatePaths, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null, $locale = null) { $view = new \Aimeos\MW\View\Standard($templatePaths); self::addTranslate($view, $locale, $config->get('i18n', array())); self::addParam($view, $request); self::addConfig($view, $config); self::addNumber($view, $config); self::addFormparam($view, array($uriBuilder->getArgumentPrefix())); self::addUrl($view, $config, $uriBuilder, $request); self::addRequest($view, $request); self::addResponse($view); self::addAccess($view); return $view; }
/** * @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()); }
/** * Creates the view object for the HTML client. * * @param \MW_Config_Interface $config Configuration object * @param \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder URL builder object * @param array $templatePaths List of base path names with relative template paths as key/value pairs * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface|null $request Request object * @param string|null $locale Code of the current language or null for no translation * @return MW_View_Interface View object */ public static function getView(\MW_Config_Interface $config, \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder, array $templatePaths, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null, $locale = null) { $params = $fixed = array(); if ($request !== null && $locale !== null) { $fixed = self::getFixedParams($config, $request); // required for reloading to the current page $params = $request->getArguments(); $params['target'] = $GLOBALS["TSFE"]->id; $i18n = Base::getI18n(array($locale), $config->get('i18n', array())); $translation = $i18n[$locale]; } else { $translation = new \MW_Translation_None('en'); } $view = new \MW_View_Default(); // workaround for TYPO3 6.2 bug (UriBuilder is incomplete) if ($request !== null || \TYPO3\CMS\Core\Utility\VersionNumberUtility::getNumericTypo3Version() >= '7.0.0') { $helper = new \MW_View_Helper_Url_Typo3($view, $uriBuilder, $fixed); } else { $helper = new \MW_View_Helper_Url_None($view); } $view->addHelper('url', $helper); $helper = new \MW_View_Helper_Translate_Default($view, $translation); $view->addHelper('translate', $helper); $helper = new \MW_View_Helper_Partial_Default($view, $config, $templatePaths); $view->addHelper('partial', $helper); $helper = new \MW_View_Helper_Parameter_Default($view, $params); $view->addHelper('param', $helper); $helper = new \MW_View_Helper_Config_Default($view, $config); $view->addHelper('config', $helper); $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.'); $sep1000 = $config->get('client/html/common/format/seperator1000', ' '); $helper = new \MW_View_Helper_Number_Default($view, $sepDec, $sep1000); $view->addHelper('number', $helper); $helper = new \MW_View_Helper_FormParam_Default($view, array($uriBuilder->getArgumentPrefix())); $view->addHelper('formparam', $helper); $helper = new \MW_View_Helper_Encoder_Default($view); $view->addHelper('encoder', $helper); $helper = new \MW_View_Helper_Csrf_Default($view); $view->addHelper('csrf', $helper); $body = @file_get_contents('php://input'); $helper = new \MW_View_Helper_Request_Default($view, $body, $_SERVER['REMOTE_ADDR']); $view->addHelper('request', $helper); return $view; }
/** * Creates the view object for the HTML client. * * @param \Aimeos\MW\Config\Iface $config Configuration object * @param \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder URL builder object * @param array $templatePaths List of base path names with relative template paths as key/value pairs * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface|null $request Request object * @param string|null $locale Code of the current language or null for no translation * @return MW_View_Interface View object */ public static function getView(\Aimeos\MW\Config\Iface $config, \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder, array $templatePaths, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null, $locale = null) { $params = $fixed = array(); if ($request !== null && $locale !== null) { $params = $request->getArguments(); $fixed = self::getFixedParams($config, $request); $i18n = Base::getI18n(array($locale), $config->get('i18n', array())); $translation = $i18n[$locale]; } else { $translation = new \Aimeos\MW\Translation\None('en'); } $view = new \Aimeos\MW\View\Standard($templatePaths); // workaround for TYPO3 bug (UriBuilder is incomplete in CLI environment) if ($request !== null) { $helper = new \Aimeos\MW\View\Helper\Url\Typo3($view, $uriBuilder, $fixed); } else { $helper = new \Aimeos\MW\View\Helper\Url\None($view); } $view->addHelper('url', $helper); $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation); $view->addHelper('translate', $helper); $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params); $view->addHelper('param', $helper); $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); $view->addHelper('config', $helper); $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.'); $sep1000 = $config->get('client/html/common/format/seperator1000', ' '); $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000); $view->addHelper('number', $helper); $helper = new \Aimeos\MW\View\Helper\Formparam\Standard($view, array($uriBuilder->getArgumentPrefix())); $view->addHelper('formparam', $helper); $ip = $_SERVER['REMOTE_ADDR']; $target = $GLOBALS["TSFE"]->id; $body = @file_get_contents('php://input'); $files = is_array($_FILES) ? $_FILES : array(); $helper = new \Aimeos\MW\View\Helper\Request\Standard($view, $body, $ip, $target, $files); $view->addHelper('request', $helper); return $view; }