コード例 #1
0
ファイル: site.php プロジェクト: narrenfrei/kirbycms
 function siteInfo()
 {
     $file = c::get('root.content') . '/site.txt';
     $info = variables::fetch($file);
     // merge the current site info with the additional
     // info from the info file(s)
     $this->variables = $info;
     $this->_ = array_merge($this->_, $info);
 }
コード例 #2
0
ファイル: site.php プロジェクト: robeam/kirbycms
 function siteInfo()
 {
     $file = c::get('root.content') . '/site.txt';
     $info = variables::fetch($file);
     $this->_ = array_merge($this->_, $info);
 }
コード例 #3
0
 function info($lang = false)
 {
     // first run: fetch all the things we need
     if (!$this->info) {
         $root = c::get('root.content');
         if (c::get('lang.support')) {
             $defaultLang = c::get('lang.default');
             $currentLang = c::get('lang.current');
             foreach (c::get('lang.available') as $lang) {
                 $file = $root . '/site.' . $lang . '.' . c::get('content.file.extension', 'txt');
                 if (!file_exists($file)) {
                     continue;
                 }
                 // fetch the site info from the defaulf file.
                 $fetched = variables::fetch($file);
                 $data = $fetched['data'];
                 $data['filecontent'] = $fetched['raw'];
                 $this->_['info'][$lang] = $data;
             }
             // if there's no default language
             if (!isset($this->_['info'][$defaultLang])) {
                 $file = $root . '/site.' . c::get('content.file.extension', 'txt');
                 if (file_exists($file)) {
                     // fetch the site info from the defaulf file.
                     $fetched = variables::fetch($file);
                     $data = $fetched['data'];
                     $data['filecontent'] = $fetched['raw'];
                     $this->_['info'][$defaultLang] = $data;
                 } else {
                     $this->_['info'][$defaultLang] = array();
                 }
             }
             foreach ($this->_['info'] as $key => $value) {
                 if ($key == $defaultLang) {
                     continue;
                 }
                 $merged = array_merge($this->_['info'][$defaultLang], $value);
                 $this->_['info'][$key] = new siteinfo($merged);
             }
             // bake the default language stuff into an object finally
             $this->_['info'][$defaultLang] = new siteinfo($this->_['info'][$defaultLang]);
             // get the current variables
             $current = isset($this->_['info'][$currentLang]) ? $this->_['info'][$currentLang] : $this->_['info'][$defaultLang];
         } else {
             $file = $root . '/site.' . c::get('content.file.extension', 'txt');
             if (file_exists($file)) {
                 // fetch the site info from the defaulf file.
                 $fetched = variables::fetch($file);
                 $data = $fetched['data'];
                 $data['filecontent'] = $fetched['raw'];
                 $this->_['info'] = new siteinfo($data);
             } else {
                 $this->_['info'] = new siteinfo(array());
             }
             $current = $this->_['info'];
         }
         // add all variables
         $vars = $current->_;
         // don't add the filecontent var,
         // because this is not a custom var
         unset($vars['filecontent']);
         $this->variables = $vars;
         // merge the current site info with the additional
         // info from the info file(s)
         $this->_ = array_merge($this->_, $current->_);
     }
     // now get the stuff the user wants
     if (c::get('lang.support')) {
         $currentLang = c::get('lang.current');
         $defaultLang = c::get('lang.default');
         if ($lang && in_array($lang, c::get('lang.available'))) {
             return isset($this->info[$lang]) ? $this->info[$lang] : $this->info[$defaultLang];
         }
         return isset($this->info[$currentLang]) ? $this->info[$currentLang] : $this->info[$defaultLang];
     } else {
         return $this->info;
     }
 }