Example #1
0
File: Asset.php Project: acp3/setup
 /**
  * @param string $template
  *
  * @return string
  */
 protected function resolveTemplatePath($template)
 {
     // If an template with directory is given, uppercase the first letter
     if (strpos($template, '/') !== false) {
         $template = ucfirst($template);
         // Pfad zerlegen
         $fragments = explode('/', $template);
         if (count($fragments) === 3) {
             $path = $fragments[0] . '/Resources/View/' . $fragments[1] . '/' . $fragments[2];
         } else {
             $path = $fragments[0] . '/Resources/View/' . $fragments[1];
         }
         return $this->appPath->getInstallerModulesDir() . $path;
     }
     return $this->appPath->getDesignPathInternal() . $template;
 }
Example #2
0
 /**
  * Cacht die Sprachfiles, um diese schneller verarbeiten zu können
  *
  * @param string $language
  *
  * @return array
  */
 public function setLanguageCache($language)
 {
     $data = [];
     foreach (Filesystem::scandir($this->appPath->getInstallerModulesDir()) as $module) {
         $path = $this->appPath->getInstallerModulesDir() . $module . '/Resources/i18n/' . $language . '.xml';
         if (is_file($path) === true) {
             $xml = simplexml_load_file($path);
             if (isset($data['info']['direction']) === false) {
                 $data['info']['direction'] = (string) $xml->info->direction;
             }
             // Über die einzelnen Sprachstrings iterieren
             foreach ($xml->keys->item as $item) {
                 $data['keys'][strtolower($module . (string) $item['key'])] = trim((string) $item);
             }
         }
     }
     return $data;
 }
Example #3
0
 private function setLanguage()
 {
     $cookieLocale = $this->request->getCookies()->get('ACP3_INSTALLER_LANG', '');
     if (!preg_match('=/=', $cookieLocale) && is_file($this->appPath->getInstallerModulesDir() . 'Install/Resources/i18n/' . $cookieLocale . '.xml') === true) {
         $language = $cookieLocale;
     } else {
         $language = 'en_US';
         // Fallback language
         foreach ($this->request->getUserAgent()->parseAcceptLanguage() as $locale => $val) {
             $locale = str_replace('-', '_', $locale);
             if ($this->translator->languagePackExists($locale) === true) {
                 $language = $locale;
                 break;
             }
         }
     }
     $this->translator->setLocale($language);
 }