Ejemplo n.º 1
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     // themeswitching must is enabled in configuration
     if ($this->config['themeswitch_via_url'] == 1) {
         return;
     }
     // check for "?theme=mytheme" URL parameter
     if (false === $request->issetParameter('theme', 'GET')) {
         return;
     }
     $theme = '';
     $theme = $request->getParameterFromGet('theme');
     /**
      * Inputfilter for $_GET['theme']. Allowed Chars are: az, 0-9, underscore.
      *
      */
     if (false === $this->input->check($theme, 'is_abc|is_int|is_custom', '_')) {
         throw new InvalidArgumentException('Please provide a proper theme name.');
     }
     $themedir = '';
     $themedir = ROOT_THEMES_FRONTEND . $theme . DIRECTORY_SEPARATOR;
     // theme exists, set it as session-user-theme
     if (is_dir($themedir) and is_file($themedir . 'theme_info.xml')) {
         $_SESSION['user']['frontend_theme'] = $theme;
     }
     unset($theme, $themedir);
 }
Ejemplo n.º 2
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     // theme switching must be enabled in configuration
     if ($this->config['theme_via_get'] === 0) {
         return;
     }
     // check for "?theme=mytheme" URL parameter
     if (false === $request->issetParameter('theme', 'GET')) {
         return;
     }
     // get parameter
     $theme = '';
     $theme = $request->getParameterFromGet('theme');
     // Inputfilter for $_GET['theme']. Allowed Chars are: az, 0-9, underscore.
     if (false === $this->input->check($theme, 'is_abc|is_int|is_custom', '_')) {
         throw new \InvalidArgumentException('Please provide a proper theme name.');
     }
     // compose theme dir
     $themedir = '';
     $themedir = APPLICATION_PATH . 'themes/frontend/' . $theme . DIRECTORY_SEPARATOR;
     // if theme exists, set it as frontend theme to the session
     if (is_dir($themedir) and is_file($themedir . 'theme_info.xml')) {
         $_SESSION['user']['frontend_theme'] = $theme;
     }
     unset($theme, $themedir);
 }
Ejemplo n.º 3
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     /*
      * take the initiative of filtering, if language switching is enabled in CONFIG
      * or pass through (do nothing) if disabled
      */
     if (true === (bool) $this->config['language_via_get']) {
         return;
     }
     // fetch URL parameter "&lang=" from $_GET['lang']
     $language = $request->getParameterFromGet('lang');
     if (isset($language) && mb_strlen($language) === 2) {
         /*
          * memorize in the user session
          * a) the selected language
          * b) that the language was set via $_GET parameter
          */
         $_SESSION['user']['language'] = mb_strtolower($language);
         $_SESSION['user']['language_via_get'] = 1;
     }
 }