Пример #1
0
 /**
  * Creates the view object for the HTML client.
  *
  * @param \Aimeos\MW\Config\Iface $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 \Aimeos\MW\View\Iface View object
  */
 public function create(\Aimeos\MW\Config\Iface $config, array $templatePaths, $locale = null)
 {
     $params = $fixed = array();
     if ($locale !== null) {
         $params = Route::current()->parameters() + Input::all();
         $fixed = $this->getFixedParams();
         $i18n = app('\\Aimeos\\Shop\\Base\\I18n')->get(array($locale));
         $translation = $i18n[$locale];
     } else {
         $translation = new \Aimeos\MW\Translation\None('en');
     }
     $view = new \Aimeos\MW\View\Standard($templatePaths);
     $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
     $view->addHelper('translate', $helper);
     $helper = new \Aimeos\MW\View\Helper\Url\Laravel5($view, app('url'), $fixed);
     $view->addHelper('url', $helper);
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params);
     $view->addHelper('param', $helper);
     $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
     $view->addHelper('config', $helper);
     $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
     $sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
     $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000);
     $view->addHelper('number', $helper);
     $helper = new \Aimeos\MW\View\Helper\Request\Laravel5($view, Request::instance());
     $view->addHelper('request', $helper);
     $helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_token', csrf_token());
     $view->addHelper('csrf', $helper);
     return $view;
 }
Пример #2
0
 /**
  * Creates the view object for the HTML client.
  *
  * @param \Aimeos\MW\Config\Iface $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 \Aimeos\MW\View\Iface View object
  */
 public function create(\Aimeos\MW\Config\Iface $config, array $templatePaths, $locale = null)
 {
     $params = $fixed = array();
     $request = $this->requestStack->getMasterRequest();
     if ($locale !== null) {
         $params = $request->request->all() + $request->query->all() + $request->attributes->get('_route_params');
         $fixed = $this->getFixedParams();
         $i18n = $this->container->get('aimeos_i18n')->get(array($locale));
         $translation = $i18n[$locale];
     } else {
         $translation = new \Aimeos\MW\Translation\None('en');
     }
     $view = new \Aimeos\MW\View\Standard($templatePaths);
     $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
     $view->addHelper('translate', $helper);
     $helper = new \Aimeos\MW\View\Helper\Url\Symfony2($view, $this->container->get('router'), $fixed);
     $view->addHelper('url', $helper);
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params);
     $view->addHelper('param', $helper);
     $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
     $view->addHelper('config', $helper);
     $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
     $sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
     $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000);
     $view->addHelper('number', $helper);
     if ($request !== null) {
         $helper = new \Aimeos\MW\View\Helper\Request\Symfony2($view, $request);
         $view->addHelper('request', $helper);
     }
     $token = $this->container->get('security.csrf.token_manager')->getToken('_token');
     $helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_token', $token->getValue());
     $view->addHelper('csrf', $helper);
     return $view;
 }
Пример #3
0
 protected static function createView(\Aimeos\MW\Config\Iface $config)
 {
     $view = new \Aimeos\MW\View\Standard(self::getTemplatePaths());
     $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
     $view->addHelper('config', $helper);
     $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
     $sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
     $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000);
     $view->addHelper('number', $helper);
     return $view;
 }
Пример #4
0
 /**
  * Creates the view object for the HTML client.
  *
  * @param \Aimeos\MW\Config\Iface $config Config object
  * @param \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder URL builder object
  * @param array $templatePaths List of base path names with relative template paths as key/value pairs
  * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface|null $request Request object
  * @param string|null $locale Code of the current language or null for no translation
  * @param boolean $frontend True if the view is for the frontend, false for the backend
  * @return \Aimeos\MW\View\Iface View object
  */
 public static function get(\Aimeos\MW\Config\Iface $config, \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder, array $templatePaths, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null, $locale = null)
 {
     $view = new \Aimeos\MW\View\Standard($templatePaths);
     self::addTranslate($view, $locale, $config->get('i18n', array()));
     self::addParam($view, $request);
     self::addConfig($view, $config);
     self::addNumber($view, $config);
     self::addFormparam($view, array($uriBuilder->getArgumentPrefix()));
     self::addUrl($view, $config, $uriBuilder, $request);
     self::addRequest($view, $request);
     self::addResponse($view);
     self::addAccess($view);
     return $view;
 }
Пример #5
0
 /**
  * Returns the fixed parameters that should be included in every URL
  *
  * @param \Aimeos\MW\Config\Iface $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(\Aimeos\MW\Config\Iface $config, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request)
 {
     $fixed = array();
     $name = $config->get('typo3/param/name/site', 'site');
     if ($request->hasArgument($name) === true) {
         $fixed[$name] = $request->getArgument($name);
     }
     $name = $config->get('typo3/param/name/language', 'locale');
     if ($request->hasArgument($name) === true) {
         $fixed[$name] = $request->getArgument($name);
     }
     $name = $config->get('typo3/param/name/currency', 'currency');
     if ($request->hasArgument($name) === true) {
         $fixed[$name] = $request->getArgument($name);
     }
     return $fixed;
 }
Пример #6
0
 /**
  * Extracts the configuration options from the input object and updates the configuration values in the config object.
  *
  * @param \Aimeos\MW\Config\Iface $conf Configuration object
  * @param array Associative list of database configurations
  * @throws \RuntimeException If the format of the options is invalid
  */
 protected function setOptions(\Aimeos\MW\Config\Iface $conf)
 {
     foreach ((array) $this->option('option') as $option) {
         list($name, $value) = explode(':', $option);
         $conf->set($name, $value);
     }
 }
Пример #7
0
 /**
  * Extracts the configuration options from the input object and updates the configuration values in the config object.
  *
  * @param \Aimeos\MW\Config\Iface $conf Configuration object
  * @param InputInterface $input Input object
  * @param array Associative list of database configurations
  * @throws \RuntimeException If the format of the options is invalid
  */
 protected function setOptions(\Aimeos\MW\Config\Iface $conf, InputInterface $input)
 {
     foreach ((array) $input->getOption('option') as $option) {
         list($name, $value) = explode(':', $option);
         $conf->set(str_replace('\\', '/', $name), $value);
     }
 }
Пример #8
0
 /**
  * Adds the "number" helper to the view object
  *
  * @param \Aimeos\MW\View\Iface $view View object
  * @param \Aimeos\MW\Config\Iface $config Configuration object
  * @return \Aimeos\MW\View\Iface Modified view object
  */
 protected function addNumber(\Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config)
 {
     $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
     $sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
     $decimals = $config->get('client/html/common/format/decimals', 2);
     $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000, $decimals);
     $view->addHelper('number', $helper);
     return $view;
 }
 /**
  * Extracts the configuration options from the input object and updates the configuration values in the config object.
  *
  * @param \Aimeos\MW\Config\Iface $conf Configuration object
  * @param array $options List of option key/value pairs
  * @param array Associative list of database configurations
  */
 protected function setOptions(\Aimeos\MW\Config\Iface $conf, array $options)
 {
     foreach ($options as $option) {
         list($name, $value) = explode(':', $option);
         $conf->set(str_replace('\\', '/', $name), $value);
     }
 }
Пример #10
0
/**
 * Returns the fixed and cleaned up database configuration
 *
 * @param \Aimeos\MW\Config\Iface $conf Configuration object
 * @return array Updated database configuration
 */
function getDbConfig(\Aimeos\MW\Config\Iface $conf)
{
    $dbconfig = $conf->get('resource', array());
    foreach ($dbconfig as $rname => $dbconf) {
        if (strncmp($rname, 'db', 2) !== 0) {
            unset($dbconfig[$rname]);
        } else {
            $conf->set('resource/' . $rname . '/limit', 2);
        }
    }
    return $dbconfig;
}