Exemplo n.º 1
0
 /**
  * Creates the view object for the HTML client.
  *
  * @param \MW_Config_Interface $config Configuration object
  * @param array $templatePaths List of base path names with relative template paths as key/value pairs
  * @param string|null $locale Code of the current language or null for no translation
  * @return \MW_View_Interface View object
  */
 public function create(\MW_Config_Interface $config, array $templatePaths, $locale = null)
 {
     $params = $fixed = array();
     if ($locale !== null) {
         $params = \Route::current()->parameters() + \Input::all();
         $params['target'] = \Route::currentRouteName();
         $fixed = $this->getFixedParams();
         $i18n = app('\\Aimeos\\Shop\\Base\\I18n')->get(array($locale));
         $translation = $i18n[$locale];
     } 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_Laravel5($view, app('url'), $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);
     $helper = new \MW_View_Helper_Csrf_Default($view, '_token', csrf_token());
     $view->addHelper('csrf', $helper);
     return $view;
 }
Exemplo n.º 2
0
 protected static function _createView(MW_Config_Interface $config)
 {
     $view = new MW_View_Default();
     $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_Encoder_Default($view);
     $view->addHelper('encoder', $helper);
     return $view;
 }
Exemplo n.º 3
0
 /**
  * Creates the view object for the HTML client.
  *
  * @param \MW_Config_Interface $config Configuration object
  * @param array $templatePaths List of base path names with relative template paths as key/value pairs
  * @param string|null $locale Code of the current language or null for no translation
  * @return \MW_View_Interface View object
  */
 public function create(\MW_Config_Interface $config, array $templatePaths, $locale = null)
 {
     $params = $fixed = array();
     $request = $this->requestStack->getMasterRequest();
     if ($locale !== null) {
         $fixed = $this->getFixedParams();
         $params = $request->request->all() + $request->query->all() + $request->attributes->get('_route_params');
         // required for reloading to the current page
         $params['target'] = $request->get('_route');
         $i18n = $this->container->get('aimeos_i18n')->get(array($locale));
         $translation = $i18n[$locale];
     } 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_Symfony2($view, $this->container->get('router'), $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_Symfony2($view, $request);
         $view->addHelper('request', $helper);
     }
     $token = $this->container->get('security.csrf.token_manager')->getToken('_token');
     $helper = new \MW_View_Helper_Csrf_Default($view, '_token', $token->getValue());
     $view->addHelper('csrf', $helper);
     return $view;
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 5
0
 /**
  * Returns the fixed parameters that should be included in every URL
  *
  * @param \MW_Config_Interface $config Config object
  * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface $request Request object
  * @return array Associative list of site, language and currency if available
  */
 protected static function getFixedParams(\MW_Config_Interface $config, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request)
 {
     $fixed = array();
     $name = $config->get('typo3/param/name/site', 'loc-site');
     if ($request->hasArgument($name) === true) {
         $fixed[$name] = $request->getArgument($name);
     }
     $name = $config->get('typo3/param/name/language', 'loc-language');
     if ($request->hasArgument($name) === true) {
         $fixed[$name] = $request->getArgument($name);
     }
     $name = $config->get('typo3/param/name/currency', 'loc-currency');
     if ($request->hasArgument($name) === true) {
         $fixed[$name] = $request->getArgument($name);
     }
     return $fixed;
 }
Exemplo n.º 6
0
 /**
  * Extracts the configuration options from the input object and updates the configuration values in the config object.
  *
  * @param \MW_Config_Interface $conf Configuration object
  * @param array Associative list of database configurations
  * @throws \RuntimeException If the format of the options is invalid
  */
 protected function setOptions(\MW_Config_Interface $conf)
 {
     foreach ((array) $this->option('option') as $option) {
         list($name, $value) = explode(':', $option);
         $conf->set($name, $value);
     }
 }
Exemplo n.º 7
0
 /**
  * Extracts the configuration options from the input object and updates the configuration values in the config object.
  *
  * @param \MW_Config_Interface $conf Configuration object
  * @param array $options List of option key/value pairs
  * @param array Associative list of database configurations
  */
 protected function setOptions(\MW_Config_Interface $conf, array $options)
 {
     foreach ($options as $option) {
         list($name, $value) = explode(':', $option);
         $conf->set($name, $value);
     }
 }