示例#1
0
 public function lang()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.config.lang', true, '/configuration');
     $xmlLangs = \Rebond\Util\File::getFiles(\Rebond\Config::getPath('lang'));
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::SITE, ['admin', 'configuration']);
     $tplMain->set('xmlLangs', $xmlLangs);
     $tplMain->set('langs', \Rebond\Config::getLang());
     $tplMain->set('current', $this->app->lang());
     // layout
     $this->tplLayout->set('column1', $tplMain->render('lang'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     return $this->tplMaster->render('tpl-default');
 }
示例#2
0
 public function locale()
 {
     $tpl = new Util\Template(Util\Template::MODULE, ['app', 'plugin']);
     $tpl->set('langs', \Rebond\Config::getLang());
     return $tpl->render('locale');
 }
示例#3
0
 private function generateJavascript(array $xmlLangs)
 {
     foreach (\Rebond\Config::getLang() as $lang => $locale) {
         $adminList = [];
         $siteList = [];
         $langTpl = new Template(Template::SITE, ['generator', 'lang']);
         $langTpl->set('lang', $lang);
         foreach ($xmlLangs as $xmlLang) {
             $valueList = $xmlLang->getElementsByTagName('language')->item(0);
             if (isset($valueList) && $valueList->hasChildNodes()) {
                 foreach ($valueList->childNodes as $node) {
                     if (in_array($node->nodeType, [XML_COMMENT_NODE, XML_TEXT_NODE])) {
                         continue;
                     }
                     if ($node->getAttribute('js') == 'both' || $node->getAttribute('js') == 'admin') {
                         $message = $node->getElementsByTagName($lang)->item(0)->nodeValue;
                         $adminList[] = str_repeat(' ', 4) . $node->nodeName . ' : "' . addslashes(ucfirst($message)) . '",' . chr(10);
                     }
                     if ($node->getAttribute('js') == 'both' || $node->getAttribute('js') == 'site') {
                         $message = $node->getElementsByTagName($lang)->item(0)->nodeValue;
                         $siteList[] = str_repeat(' ', 4) . $node->nodeName . ' : "' . addslashes(ucfirst($message)) . '",' . chr(10);
                     }
                 }
             }
         }
         $langTpl->set('list', implode('', $adminList));
         $adminLangPath = \Rebond\Config::getPath('admin') . 'js/lang-' . $lang . '.js';
         File::save($adminLangPath, 'w', $langTpl->render('js'));
         $langTpl->set('list', implode('', $siteList));
         $siteLangPath = \Rebond\Config::getPath('site') . 'js/lang-' . $lang . '.js';
         File::save($siteLangPath, 'w', $langTpl->render('js'));
     }
 }