/** * 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 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 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 resource controller * * @param string $sitecode Unique site code * @param string Resource location, e.g. "product/stock/wareshouse" * @param string $lang Language code * @return \Aimeos\MShop\Context\Item\Iface Context item */ protected function createController($sitecode, $resource, $lang) { $lang = $lang ? $lang : 'en'; $context = $this->getContext($sitecode, $lang); $templatePaths = Base::getAimeos()->getCustomPaths('controller/jsonadm/templates'); $view = Base::getView($context->getConfig(), $this->uriBuilder, $templatePaths, $this->request, $lang); $context->setView($view); return \Aimeos\Controller\JsonAdm\Factory::createController($context, $templatePaths, $resource); }