示例#1
0
文件: I18nUnit.php 项目: jivoo/jivoo
 /**
  * {@inheritdoc}
  */
 public function run(App $app, Document $config)
 {
     I18n::setCache($app->m->cache->i18n);
     if (isset($app->config['i18n']['language'])) {
         I18n::setLanguage($app->config['i18n']['language']);
     }
     I18n::loadFrom($this->p('Core/languages'));
     I18n::loadFrom($this->p('app/languages'));
 }
示例#2
0
文件: Themes.php 项目: jivoo/jivoo
 /**
  * Load the templates and assets of a theme.
  * @param string $theme Theme name.
  * @param int $priority Priority of templates, if the theme has one or more
  * parent themes, those themes will be loaded with a lower priority.
  * @throws InvalidThemeException If the theme was not found or invalid.
  */
 public function load($theme, $priority = 10)
 {
     $info = $this->getInfo($theme);
     if (!isset($info)) {
         throw new InvalidThemeException(tr('Theme not found or invalid: "%1"', $theme));
     }
     foreach ($info->extend as $parent) {
         $this->load($parent, $priority - 1);
     }
     foreach ($info->loadAfter as $dependency) {
         $this->m->Extensions->import($dependency);
         $this->m->Extensions->getInfo($dependency)->requiredBy($theme);
     }
     list($key, $path) = $info->getKeyPath('templates');
     $this->view->addTemplateDir($key, $path, $priority);
     $info->addAssetDir($this->m->Assets, 'assets');
     if (is_dir($info->p($this->app, 'languages'))) {
         I18n::loadFrom($info->p($this->app, 'languages'));
     }
 }
示例#3
0
 /**
  * Import a single extension.
  * @param string $extension Extension name.
  */
 public function import($extension)
 {
     if (isset($this->imported[$extension])) {
         if (!$this->imported[$extension]) {
             throw new InvalidExtensionException(tr('Extension not found or invalid: "%1"', $extension));
         }
         return;
     }
     $this->imported[$extension] = false;
     $extensionInfo = $this->getInfo($extension);
     if (!isset($extensionInfo)) {
         throw new InvalidExtensionException(tr('Extension not found or invalid: "%1"', $extension));
     }
     if (isset($extensionInfo->namespace)) {
         Autoloader::getInstance()->addPath($extensionInfo->namespace, $extensionInfo->p($this->app, ''));
     } else {
         Autoloader::getInstance()->addPath('', $extensionInfo->p($this->app, ''));
     }
     $extensionInfo->imported = true;
     if (is_dir($extensionInfo->p($this->app, 'languages'))) {
         I18n::loadFrom($extensionInfo->p($this->app, 'languages'));
     }
     foreach ($extensionInfo->loadAfter as $dependency) {
         $this->import($dependency);
         $this->getInfo($dependency)->requiredBy($extension);
     }
     foreach ($this->featureHandlers as $tuple) {
         list($feature, $handler) = $tuple;
         if (isset($extensionInfo->{$feature})) {
             call_user_func($handler, $extensionInfo);
         }
     }
     $this->imported[$extension] = true;
 }