opengoo--安装配置以及智能汉化

安装需求套件

yum install httpd mysql-server php php-mysql php-gd

/etc/init.d/mysqld start

mysqladmin -u root password roots_password

mysql -u root -p -A mysql

mysql> create database opengoo;
mysql> grant all privileges on opengoo.* to opengoo@localhost identified by 'password';
mysql> flush privileges;
mysql> exit

/etc/init.d/httpd start

安�b OpenGoo

下载 OpenGoo

cd /var/www/html

unzip /path/to/opengoo*.zip

cd /var/www/html/opengoo

chmod a+w config cache upload tmp

打开浏览器键入 http://服务器地址/opengoo(如http://localhost:8080/opengoo)即可进入初始化界面

Step 3: System settings

  • Database type: MySQL
  • Host name: localhost
  • Username: opengoo
  • Password: password
  • Database name: opengoo
  • Table prefix: og_
  • Database engine: InnoDB
  • Absolute script URL: http://服务器地址/opengoo

智能汉化 OpenGoo

进入页面点击选择 "Options" 可选择语系: 中文 (简体)

页面中未翻译的部分会呈现 Missing lang.js: xxxx, 可修改源码:

vi /var/www/html/opengoo/public/assets/javascript/og/app.js

function lang(name) {
    var value = _lang[name];
    if (!value) {
        //return "Missing lang.js: " + name; //注解此行
        value = name; //加入此行
    }

刷新页面, Missing lang.js 消失, 未翻译的部分以英文呈现。

若要补充或修改翻译内容,将语言包改为可写入,就能透过opengoo内嵌的工具界面编辑翻译网页内容:

cd /var/www/html/opengoo/language

chmod -R a+w zh_cn

浏览器键入地址 http://your.opengoo.host/opengoo/public/tools/

  • 点击 Check lang → zh_cn 可查看尚未翻译成中文的所有�热�
  • 点击 Translate OpenGoo → Choose a locale: zh_cn → Choose a file: 任一个档案 → View: Missing 可编辑尚未翻译成中文的内容
    例如: 想将主选单里的 "email tab" 翻译成中文, Choose a file: lang.js, View: Missing, 翻页直到 en_us 栏位出现 "email tab", 于 zh_cn 输入 "邮件" (不包含双引号), 按 Save, 重新整理 OpenGoo 主画面, 主选单原本 "email tab" 就会变成中文的 "邮件"

 

关于1.6版本中下载文档中文件名变成乱码问题的解决(转):

      Opengoo是一个不错的开源软件而且对中文支持不错,但是使用中发现当上传中文文件名的文件时,发现文件下载时名称是乱码,网上找了很长时间没有找到 解决方法,只好自己改代码了。发现是IE浏览器对于UTF-8的支持不太好要把下载文件名转换成GBK编码。

 

需要修改files.php文件(路径: /opengoo/environment/functions/files.php)

 

代码如下:

 

<?php


function folder_is_writable($path) {
 if(!is_dir($path)) {
  return false;
 } // if

 do {
  $test_file = with_slash($path) . sha1(uniqid(rand(), true));
 } while(is_file($test_file));

 $put = @file_put_contents($test_file, 'test');
 if($put === false) {
  return false;
 } // if

 @unlink($test_file);
 return true;
} // folder_is_writable


function file_is_writable($path) {
 if(!is_file($path)) {
  return false;
 } // if

 $open = @fopen($path, 'a+');
 if($open === false) {
  return false;
 } // if

 @fclose($open);
 return true;
} // file_is_writable


function get_file_line($file, $line, $default = null) {
 if(is_file($file)) {
  $lines = file($file);
  return isset($file[$line]) ? $file[$line] : $default;
 } else {
  return $default;
 } // if
} // get_file_line


function get_files($dir, $extension = null, $base_name_only = false) {
 
 // Check dir...
 if(!is_dir($dir)) return false;

 // Prepare input data...
 $dir = with_slash($dir);
 if(!is_null($extension)) {
  if(is_array($extension)) {
   foreach($extension as $k => $v) $extension[$k] = strtolower($v);
  } else {
   $extension = strtolower($extension);
  } // if
 } // if
 
 // We have a dir...
 if(!is_dir($dir)) return null;
 
 // Open dir and prepare result
 $d = dir($dir);
 if (!is_object($d)) throw new Error($dir);
 $files = array();

 // Loop dir entries
 while(false !== ($entry = $d->read())) {
   
  // Valid entry?
  if(($entry <> '.') && ($entry <> '..')) {
   
   // Get file path...
   $path = $dir . $entry;

   // If we have valid file that do the checks
   if(is_file($path)) {
    
    if(is_null($extension)) {
     $files[] = $base_name_only ? basename($path) : $path;
    } else {
     
     // Match multiple extensions?
     if(is_array($extension)) {
      
      // If in array add...
      if(in_array( strtolower(get_file_extension($path)), $extension )) {
       $files[] = $base_name_only ? basename($path) : $path;
      } // if

      // Match single extension
     } else {
      
      // If extensions match add...
      if(strtolower(get_file_extension($path)) == $extension) {
       $files[] = $base_name_only ? basename($path) : $path;
      } // if

     } // if

    } // if

   } // if

  } // if

 } // while

 // Done... close dir...
 $d->close();

 // And return...
 return count($files) > 0 ? $files : null;

} // get_files


function get_file_extension($path, $leading_dot = false) {
 $filename = basename($path);
 $dot_offset = (boolean) $leading_dot ? 0 : 1;
 
 if( ($pos = strrpos($filename, '.')) !== false ) {
  return substr($filename, $pos + $dot_offset, strlen($filename));
 } // if

 return '';
} // get_file_extension


function dir_size($dir) {
 $totalsize = 0;
 
 if ($dirstream = @opendir($dir)) {
  while (false !== ($filename = readdir($dirstream))) {
   if (($filename != ".") && ($filename != "..")) {
    $path = with_slash($dir) . $filename;
    if (is_file($path)) $totalsize += filesize($path);
    if (is_dir($path)) $totalsize += dir_size($path);
   } // if
  } // while
 } // if
 
 closedir($dirstream);
 return $totalsize;
} // end func dir_size

function file_is_zip($mime_type, $extension = '') {
 return ($mime_type == 'application/zip' || $mime_type == 'application/x-zip-compressed' ||
   ($mime_type == 'application/x-compressed' && $extension == 'zip'));
}


function delete_dir($dir) {
 $dh = opendir($dir);
 while($file = readdir($dh)) {
  if(($file != ".") && ($file != "..")) {
   $fullpath = $dir . "/" . $file;
    
   if(!is_dir($fullpath)) {
    unlink($fullpath);
   } else {
    delete_dir($fullpath);
   } // if
  } // if
 } // while

 closedir($dh);
 return rmdir($dir) ? true : false;
} // end func delete_dir


function force_mkdir($path, $chmod = null) {
 return mkdir($path, $chmod, true);
} // force_mkdir

function force_mkdir_from_base($base, $path, $chmod = null) {
 if(is_dir(with_slash($base).$path)) return true;
 $real_path = str_replace('//', '/', $path);
 $parts = explode('/', $real_path);
 
 $forced_path = '';
 foreach($parts as $part) {
  if($part !='')
  {
   // Skip first on windows
   if($forced_path == '') {
    $forced_path = with_slash($base) . $part;
   } else {
    $forced_path .= '/' . $part;
   } // if
   if(!is_dir($forced_path)) {
    if(!is_null($chmod)) {
     if(!mkdir($forced_path)) return false;
    } else {
     if(!mkdir($forced_path, $chmod)) return false;
    } // if
   } // if
  } // if
 } // foreach
 
 return true;
} // force_mkdir


function is_dir_empty($dir_path) {
 $d = dir($dir_path);
 if($d) {
  while(false !== ($entry = $d->read())) {
   if(($entry == '.') || ($entry == '..')) continue;
   return false;
  } // while
 } // if
 return true;
} // is_dir_empty


function get_unique_filename($in, $desired_filename) {

 if(!is_dir($in)) false;

 $file_path = $in . '/' . $desired_filename;
 $counter = 0;
 while(is_file($file_path)) {
  $counter++;
  $file_path = insert_before_file_extension($file_path, '(' . $counter . ')');
 } // if

 return $file_path;

} // get_unique_filename


function insert_before_file_extension($filename, $insert) {
 if (strpos($filename,'.') > 0)
 return str_replace_first('.', $insert . '.', $filename);
 else
 return $filename . $insert;
} // insert_before_file_extension


function download_file($path, $type = 'application/octet-stream', $name = '', $force_download = false) {
 if (!function_exists('readfile')) {
  $contents = file_get_contents($path);
  return download_contents($contents, $type, $name, $force_download);
 }
 if (!is_readable($path)) return false;

 $name = trim($name) == '' ? basename($path) : trim($name);
 $size = filesize($path);
 
 if(connection_status() != 0) return false; // check connection

 if($force_download) {
  header("Cache-Control: public");
 } else {
  header("Cache-Control: no-store, no-cache, must-ridate");
  header("Cache-Control: post-check=0, pre-check=0", false);
  header("Pragma: no-cache");
 } // if
 header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT");
 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
 header("Content-Type: $type");
 header("Content-Length: " . (string) $size);

 // Prepare disposition
 $disposition = $force_download ? 'attachment' : 'inline';
 $name1 = iconv("UTF-8","GBK",$name); //wangzhaoliang
 header("Content-Disposition: $disposition; filename=/"" . $name1 . "/""); //wangzhaoliang
 header("Content-Transfer-Encoding: binary");
 readfile($path);

 return((connection_status() == 0) && !connection_aborted());
} // download_file


function download_contents($content, $type, $name, $size, $force_download = false) {
 if(connection_status() != 0) return false; // check connection

 if($force_download) {
  header("Cache-Control: public");
 } else {
  header("Cache-Control: no-store, no-cache, must-ridate");
  header("Cache-Control: post-check=0, pre-check=0", false);
  header("Pragma: no-cache");
 } // if
 header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT");
 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
 header("Content-Type: $type");
 header("Content-Length: " . (string) $size);

 // Prepare disposition
 $disposition = $force_download ? 'attachment' : 'inline';
 $name1 = iconv("UTF-8","GBK",$name);  //wangzhaoliang
 header("Content-Disposition: $disposition; filename=/"" . $name1 . "/""); //wangzhaoliang

 header("Content-Transfer-Encoding: binary");
 print $content;

 return((connection_status() == 0) && !connection_aborted());
} // download_contents


function sort_files($files, $extractor, $sort_with = 'array_ksort', $sort_method = null) {

 // Prepare...
 $extractor = trim($extractor);
 $sort_with = trim($sort_with);

 // Check the input data...
 if(!is_array($files)) return false;
 if(!function_exists($extractor)) return false;
 if(!function_exists($sort_with)) return false;

 // Prepare the tmp array...
 $tmp = array();

 // OK, now get the files...
 foreach($files as $file) {

  // Pass this one?
  if(!is_file($file)) continue;

  // Get data...
  $data = call_user_func($extractor, $file);

  // Prepare array...
  if(!isset($tmp[$data])) $tmp[$data] = array();

  // Add filename to the extracted param...
  $tmp[$data][] = $file;

 } // foreach

 // OK, now sort subarrays
 foreach($tmp as &$subarray) {
  if(count($subarray) > 0) sort($subarray);
 } // if

 // OK, do the sort thing...
 if(is_null($sort_method)) {
  $sorted = call_user_func($sort_with, $tmp);
 } else {
  $sorted = call_user_func_array($sort_with, array($tmp, $sort_method));
 } // if

 // Check sorted array
 if(!is_array($sorted)) return false;

 // OK, flatten...
 $result = array();
 foreach($sorted as &$subarray) {
  $result = array_merge($result, $subarray);
 } // foreach

 // And done...
 return $result;

} // sort_files

// ================================================================
//  SORT FUNC REPLACEMENTS
//
//  These function RETURN sorted array, don't use side effect. They
//  are used by the sort_files() function in the
//  environment/functions/files.php
// ================================================================


function array_sort($array, $flag = SORT_REGULAR) {
 sort($array, $flag);
 return $array;
} // end func


function array_rsort($array, $flag = SORT_REGULAR) {
 rsort($array, $flag);
 return $array;
} // end func array_rsort


function array_ksort($array, $flag = SORT_REGULAR) {
 ksort($array, $flag);
 return $array;
} // end func array_ksort


function array_krsort($array, $flag = SORT_REGULAR) {
 krsort($array, $flag);
 return $array;
} // end func array_krsort

 

?>

你可能感兴趣的:(职场,休闲,opengoo)