/** * Adds the "translate" helper to the view object * * @param \Aimeos\MW\View\Iface $view View object * @param string|null $langid ISO language code, e.g. "de" or "de_CH" * @param array $local Local translations * @return \Aimeos\MW\View\Iface Modified view object */ protected static function addTranslate(\Aimeos\MW\View\Iface $view, $langid, array $local) { if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view_translate']) && is_callable($fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view_translate'])) { return $fcn($view, $langid, $local); } if ($langid) { $i18n = \Aimeos\Aimeos\Base::getI18n(array($langid), $local); $translation = $i18n[$langid]; } else { $translation = new \Aimeos\MW\Translation\None('en'); } $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation); $view->addHelper('translate', $helper); return $view; }
/** * Sets the locale item in the given context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object * @param string $sitecode Unique site code * @param string $lang ISO language code, e.g. "en" or "en_GB" * @return \Aimeos\MShop\Context\Item\Iface Modified context object */ protected function getContext($sitecode, $lang) { if (!isset($this->context)) { $config = $this->getConfig($this->settings); $context = Base::getContext($config); $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); try { $localeItem = $localeManager->bootstrap($sitecode, '', '', false); $localeItem->setLanguageId(null); $localeItem->setCurrencyId(null); } catch (\Aimeos\MShop\Locale\Exception $e) { $localeItem = $localeManager->createItem(); } $context->setLocale($localeItem); $context->setI18n(Base::getI18n(array($lang))); $context->setEditor($GLOBALS['BE_USER']->user['username']); $this->context = $context; } return $this->context; }
/** * Returns the context item for backend operations * * @param array $templatePaths List of paths to the view templates * @return \Aimeos\MShop\Context\Item\Iface Context item */ protected function getContextBackend(array $templatePaths = array(), $withView = true) { if (!isset($this->contextBE)) { $lang = 'en'; $site = 'default'; if (isset($GLOBALS['BE_USER']->uc['lang']) && $GLOBALS['BE_USER']->uc['lang'] != '') { $lang = $GLOBALS['BE_USER']->uc['lang']; } if ($this->request->hasArgument('lang')) { $lang = $this->request->getArgument('lang'); } if ($this->request->hasArgument('site')) { $site = $this->request->getArgument('site'); } $config = Base::getConfig((array) $this->settings); $context = Base::getContext($config); $locale = Base::getLocaleBackend($context, $site); $context->setLocale($locale); $i18n = Base::getI18n(array($lang, 'en'), $config->get('i18n', array())); $context->setI18n($i18n); if ($withView) { $view = Base::getView($config, $this->uriBuilder, $templatePaths, $this->request, $lang, false); $context->setView($view); } $this->contextBE = $context; } return $this->contextBE; }
/** * Returns the current context. * * @param array Multi-dimensional associative list of key/value pairs * @return MShop_Context_Item_Interface Context object */ public static function getContext(array $conf = array()) { $aimeos = Aimeos\Base::getAimeos(); $tmplPaths = $aimeos->getCustomPaths('controller/jobs/templates'); $tmplPaths = array_merge($tmplPaths, $aimeos->getCustomPaths('client/html')); $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $uriBuilder = $objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder'); $uriBuilder->setArgumentPrefix('ai'); $config = Aimeos\Base::getConfig($conf); $context = Aimeos\Base::getContext($config); $langManager = \Aimeos\MShop\Factory::createManager($context, 'locale/language'); $search = $langManager->createSearch(true); $expr = array(); $expr[] = $search->getConditions(); $expr[] = $search->compare('==', 'locale.language.id', 'en'); // default language if (isset($GLOBALS['BE_USER']->uc['lang']) && $GLOBALS['BE_USER']->uc['lang'] != '') { // BE language $expr[] = $search->compare('==', 'locale.language.id', $GLOBALS['BE_USER']->uc['lang']); } $search->setConditions($search->combine('||', $expr)); $langids = array_keys($langManager->searchItems($search)); $i18n = Aimeos\Base::getI18n($langids, isset($conf['i18n']) ? (array) $conf['i18n'] : array()); $context->setI18n($i18n); $view = Aimeos\Base::getView($config, $uriBuilder, $tmplPaths); $context->setView($view); $context->setEditor('scheduler'); return $context; }
/** * Returns the context item * * @return \MShop_Context_Item_Interface Context item */ protected function getContext() { if (!isset($this->context)) { $templatePaths = Base::getAimeos()->getCustomPaths('client/html'); $config = $this->getConfig($this->settings); $context = Base::getContext($config); $localI18n = isset($this->settings['i18n']) ? $this->settings['i18n'] : array(); $locale = $this->getLocale($context); $langid = $locale->getLanguageId(); $context->setLocale($locale); $context->setI18n(Base::getI18n(array($langid), $localI18n)); $context->setView(Base::getView($config, $this->uriBuilder, $templatePaths, $this->request, $langid)); if (TYPO3_MODE === 'FE' && $GLOBALS['TSFE']->loginUser == 1) { $context->setEditor($GLOBALS['TSFE']->fe_user->user['username']); $context->setUserId($GLOBALS['TSFE']->fe_user->user[$GLOBALS['TSFE']->fe_user->userid_column]); } $this->context = $context; } return $this->context; }
/** * Returns the context item * * @return \Aimeos\MShop\Context\Item\Iface Context item */ protected function getContext() { if (!isset($this->context)) { $config = $this->getConfig($this->settings); $context = Base::getContext($config); $localeItem = $this->getLocale($context); $context->setLocale($localeItem); $localI18n = isset($this->settings['i18n']) ? $this->settings['i18n'] : array(); $i18n = Base::getI18n(array($localeItem->getLanguageId()), $localI18n); $context->setI18n($i18n); $context->setEditor($GLOBALS['BE_USER']->user['username']); $this->context = $context; } return $this->context; }