/** * 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 list of categories with their ID. * * @param array $config Associative array of existing configurations * @param \TYPO3\CMS\Backend\Form\FormEngine|\TYPO3\CMS\Backend\Form\DataPreprocessor $tceForms TCE forms object * @param string $sitecode Unique code of the site to retrieve the categories for * @return array Associative array with existing and new entries */ public function getCategories(array $config, $tceForms = null, $sitecode = 'default') { if (isset($config['row']) && isset($config['row']['pid'])) { $pageTSConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($config['row']['pid'], 'tx_aimeos'); if (isset($pageTSConfig['properties']['mshop.']['locale.']['site'])) { $sitecode = $pageTSConfig['properties']['mshop.']['locale.']['site']; } } try { $context = Base::getContext(Base::getConfig()); $context->setEditor('flexform'); $localeManager = \MShop_Locale_Manager_Factory::createManager($context); $context->setLocale($localeManager->bootstrap($sitecode, '', '', false)); $manager = \MShop_Catalog_Manager_Factory::createManager($context); $item = $manager->getTree(null, array(), \MW_Tree_Manager_Abstract::LEVEL_TREE); $config['items'] = array_merge($config['items'], $this->getCategoryList($item, 0)); } catch (Exception $e) { error_log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); } return $config; }
/** * 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; }
/** * Returns the list of categories with their ID. * * @param array $config Associative array of existing configurations * @param \TYPO3\CMS\Backend\Form\FormEngine|\TYPO3\CMS\Backend\Form\DataPreprocessor $tceForms TCE forms object * @param string $sitecode Unique code of the site to retrieve the categories for * @return array Associative array with existing and new entries */ public function getCategories(array $config, $tceForms = null, $sitecode = 'default') { if (isset($config['flexParentDatabaseRow']['pid'])) { // TYPO3 7+ $pid = $config['flexParentDatabaseRow']['pid']; } elseif (isset($config['row']['pid'])) { // TYPO3 6.2 $pid = $config['row']['pid']; } $pageTSConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($pid, 'tx_aimeos'); if (isset($pageTSConfig['properties']['mshop.']['locale.']['site'])) { $sitecode = $pageTSConfig['properties']['mshop.']['locale.']['site']; } try { $context = Base::getContext(Base::getConfig()); $context->setEditor('flexform'); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); $context->setLocale($localeManager->bootstrap($sitecode, '', '', false)); $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($context); $item = $manager->getTree(null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE); $config['items'] = array_merge($config['items'], $this->getCategoryList($item, $item->getName())); } catch (\Exception $e) { error_log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); } return $config; }