Ejemplo n.º 1
0
 /**
  * 获得对应多语言数组
  * @param string $lang 语言类型
  * @return array
  *
  */
 public function getLanguage($lang)
 {
     $i18n = array();
     $dir = Wave::app()->projectPath . 'data/caches/';
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $filepath = $dir . 'language_' . $lang . '.php';
     if (!is_file($filepath)) {
         $zhnew = array();
         $zh = $this->where(array('lang_code' => 'zh-cn'))->getAll('lang_key,lang_value');
         foreach ($zh as $key => $val) {
             $zhnew[$val['lang_key']] = $val['lang_value'];
         }
         $foreign = $this->where(array('lang_code' => $lang))->getAll('lang_key,lang_value');
         foreach ($foreign as $key => $val) {
             $zhcn = $zhnew[$val['lang_key']];
             $i18n[$zhcn] = $val['lang_value'];
         }
         $cache = var_export($i18n, true);
         $content = "<?php defined('Application')";
         $content .= "or die('No direct script access.');\n";
         $content .= "return {$cache} ?>";
         Wave::writeCache($filepath, $content);
     } else {
         $i18n = (require $filepath);
     }
     return $i18n;
 }
Ejemplo n.º 2
0
 /**
  * 编辑结果
  */
 public function actionModified()
 {
     if (isset($_POST['submit'])) {
         $filePath = ROOT_PATH . '/data/md/' . $_POST['fileName'];
         $markText = $_POST["test-editormd-markdown-doc"];
         Wave::writeCache($filePath, $markText);
         $FileClass = new FileClass();
         $FileClass->rmdirs(ROOT_PATH . '/data/caches');
         $this->jumpBox('编辑成功!', Wave::app()->homeUrl, 1);
     }
 }
Ejemplo n.º 3
0
 /**
  * 数据库执行语句
  *
  * @return blooean
  *
  */
 protected function _query($sql, $conn, $is_rw = false)
 {
     $start_time = microtime(TRUE);
     $result = $conn->query($sql);
     if ($result) {
         if (Wave::app()->config['debuger']) {
             Wave::debug_log('database', microtime(TRUE) - $start_time, $sql);
         }
         if (isset(Wave::app()->config['write_sql_log']) && Wave::app()->config['write_sql_log']) {
             $data = array('op' => 'sql_log', 'time' => time(), 'sql' => $sql, 'execute_time' => microtime(TRUE) - $start_time);
             $content = json_encode($data);
             $file = Wave::app()->config['write_sql_dir'] . 'sql_log_' . date('Y-m-d') . '.txt';
             Wave::writeCache($file, $content . "\n", 'a+');
         }
     } else {
         // 有错误发生
         $this->errno = $conn->error;
         // 强制报错并且die
         $this->msg();
     }
     return $result;
 }
Ejemplo n.º 4
0
 private function gbWriteCache($key, $objdata)
 {
     if ($this->enableCache && !empty($objdata)) {
         Wave::writeCache($this->cacheDir . $key, serialize($objdata));
     }
 }