コード例 #1
0
 public function actionIndex()
 {
     $files = [];
     $dir = \Gbox::$components->debug->getPath();
     if ($handle = opendir($dir)) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != '.' && $entry != '..' && strpos($entry, 'debug') === 0) {
                 $data = Json::decode(file_get_contents(\Gbox::$components->debug->getFile($entry)));
                 if ($data[0]['session'] == session_id()) {
                     // $files[] = $entry;
                     $files[filemtime($dir . $entry)] = $entry;
                 }
             }
         }
         closedir($handle);
         krsort($files);
     }
     Session::set('files-debug', $files);
     if (!($current = \Gbox::getRequest()->get('id'))) {
         reset($files);
         $current = current($files);
         Session::set('files-debug-current', $current);
     }
     Session::set('files-debug-current', $current);
     return $this->render('index', ['files' => $files]);
 }
コード例 #2
0
 public function format($response)
 {
     $response->getHeaders()->set('Content-Type', 'application/json; charset=UTF-8');
     if ($response->data !== null) {
         $response->content = Json::encode($response->data);
     }
 }
コード例 #3
0
 public function init()
 {
     $this->langs = $this->params['langs'];
     $lang = Request::get('lang');
     $lang_cookie = Gbox::getRequest()->getCookies('lang');
     if ($lang && in_array($lang, $this->langs)) {
         $this->setLang($lang);
     } else {
         if (isset($lang_cookie) && in_array($lang_cookie, $this->langs)) {
             $this->setLang($lang);
         } else {
             $this->setLang(self::LANG_DEFAULT);
         }
     }
     $name_file = 'strings-' . $this->lang . '.json';
     $url = Url::to(['@components', 'ConfigLanguages', $name_file]);
     $json = file_get_contents($url);
     $this->strings = Json::decode($json, true);
     if (self::LANG_DEFAULT == $this->lang) {
         $this->strings_default = Json::decode($json, true);
     } else {
         $name_file = 'strings-' . self::LANG_DEFAULT . '.json';
         $url = Url::to(['@components', 'ConfigLanguages', $name_file]);
         $json = file_get_contents($url);
         $this->strings_default = Json::decode($json, true);
     }
 }
コード例 #4
0
 public function getData($file = null)
 {
     if ($file) {
         return Json::decode(file_get_contents($this->getFile($file)));
     } else {
         return Json::decode(file_get_contents($this->file));
     }
 }