/** * Returns the current context * * @param boolean $locale True to add locale object to context, false if not (deprecated, use \Aimeos\Shop\Base\Locale) * @param string $type Configuration type, i.e. "frontend" or "backend" (deprecated, use \Aimeos\Shop\Base\Config) * @return \Aimeos\MShop\Context\Item\Iface Context object */ public function get($locale = true, $type = 'frontend') { $config = $this->config->get($type); if ($this->context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig($config); $this->addDataBaseManager($context); $this->addFilesystemManager($context); $this->addMessageQueueManager($context); $this->addLogger($context); $this->addCache($context); $this->addMailer($context); $this->addSession($context); $this->addUser($context); $this->addGroups($context); $this->context = $context; } $this->context->setConfig($config); if ($locale === true) { $localeItem = $this->locale->get($this->context); $this->context->setLocale($localeItem); $this->context->setI18n($this->i18n->get(array($localeItem->getLanguageId()))); } return $this->context; }
/** * Returns the current context. * * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object * @return \MShop_Context_Item_Interface */ public function get(\TYPO3\Flow\Mvc\RequestInterface $request = null) { if (self::$context === null) { $context = new \MShop_Context_Item_Default(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \MW_DB_Manager_PDO($config); $context->setDatabaseManager($dbm); $mail = new \MW_Mail_Swift($this->mailer); $context->setMail($mail); $logger = \MAdmin_Log_Manager_Factory::createManager($context); $context->setLogger($logger); $cache = $this->getCache($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($request !== null) { $localeItem = $this->getLocale($context, $request); $context->setLocale($localeItem); $i18n = $this->i18n->get(array($localeItem->getLanguageId())); $context->setI18n($i18n); } $session = new \MW_Session_Flow($this->session); $context->setSession($session); $this->addUser($context); return $context; }
/** * Returns the current context. * * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object * @return \Aimeos\MShop\Context\Item\Iface */ public function get(\TYPO3\Flow\Mvc\RequestInterface $request = null, $type = 'frontend') { $config = $this->config->get($type); if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig($config); $this->addDataBaseManager($context); $this->addFilesystemManager($context); $this->addMessageQueueManager($context); $this->addLogger($context); $this->addCache($context); $this->addMailer($context); self::$context = $context; } $context = self::$context; $context->setConfig($config); if ($request !== null) { $localeItem = $this->locale->get($context, $request); $context->setI18n($this->i18n->get(array($localeItem->getLanguageId()))); $context->setLocale($localeItem); } $this->addSession($context); $this->addUser($context); return $context; }
/** * Returns the resource controller * * @param string $sitecode Unique site code * @return \Aimeos\MShop\Context\Item\Iface Context item */ protected function createClient($sitecode, $resource) { $lang = $this->request->hasArgument('lang') ? $this->request->getArgument('lang') : 'en'; $templatePaths = $this->aimeos->get()->getCustomPaths('admin/jqadm/templates'); $context = $this->context->get(null, 'backend'); $context->setI18n($this->i18n->get(array($lang, 'en'))); $context->setLocale($this->locale->getBackend($context, $sitecode)); $context->setView($this->viewbase->create($context, $this->uriBuilder, $templatePaths, $this->request, $lang)); return \Aimeos\Admin\JQAdm\Factory::createClient($context, $templatePaths, $resource); }
/** * 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" * @return \Aimeos\MW\View\Iface Modified view object */ protected function addTranslate(\Aimeos\MW\View\Iface $view, $langid) { if ($langid !== null) { $i18n = $this->i18n->get(array($langid)); $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; }
/** * Creates the view object for the HTML client. * * @param \MShop_Context_Item_Interface $context Context object * @param \TYPO3\Flow\Mvc\Routing\UriBuilder $uriBuilder URL builder object * @param array $templatePaths List of base path names with relative template paths as key/value pairs * @param \TYPO3\Flow\Mvc\RequestInterface|null $request Request object * @param string|null $langid Language ID * @return \MW_View_Interface View object */ public function create(\MW_Config_Interface $config, \TYPO3\Flow\Mvc\Routing\UriBuilder $uriBuilder, array $templatePaths, \TYPO3\Flow\Mvc\RequestInterface $request = null, $langid = null) { $params = $fixed = array(); if ($request !== null && $langid !== null) { $params = $request->getArguments(); $fixed = $this->getFixedParams($request); // required for reloading to the current page // $params['target'] = $request->getArgument( '_route' ); $i18n = $this->i18n->get(array($langid)); $translation = $i18n[$langid]; } else { $translation = new \MW_Translation_None('en'); } $view = new \MW_View_Default(); $helper = new \MW_View_Helper_Translate_Default($view, $translation); $view->addHelper('translate', $helper); $helper = new \MW_View_Helper_Url_Flow($view, $uriBuilder, $fixed); $view->addHelper('url', $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()); $view->addHelper('formparam', $helper); $helper = new \MW_View_Helper_Encoder_Default($view); $view->addHelper('encoder', $helper); if ($request !== null) { $helper = new \MW_View_Helper_Request_Flow($view, $request->getHttpRequest()); $view->addHelper('request', $helper); } return $view; }