Loading [MathJax]/jax/element/mml/optable/BasicLatin.js
XXXXX
C/C++
XXXXX
C#/.net
XXXXX
js
java
java
开发导航 开发导航 www.endv.cn
天云

knowledgeroot 配置

首先下载 KnowledgeRoot 的安装包,就是一个压缩文件,解压缩后放到 WebRoot 下面

在浏览器中打开网站,自动提示进行安装,安装的过程很简单,安装结束后即可以使用。

安装包创建的数据库默认使用瑞典语,这个很不好,可以打开 dumps/mysql.sql 文件进行修改,将 

ENGINE=MyISAM AUTO_INCREMENT=1

全部替换为

ENGINE=MyISAM AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci

即可保证所有的表创建为 UTF-8 格式的。

如果需要修改 admin 账号的密码,也可以在脚本中直接修改,如下所示:

INSERT INTO `users` ( `id` , `name` , `password` , `enabled` , `defaultgroup` , `defaultrights` , `admin` , `rightedit` , `treecache` )
VALUES ( '1', 'Admin', MD5('1qA2wS3eD$'), '1', '1', '210', '1', '1', '' );

默认的登录界面是英文的(en_US.UTF8),可以在 config/app.ini 文件中修改

复制代码
复制代码
[base]
version = "1.0.3"
title = "知识库"
cryptkey = "yourcryptkeyhere"
base_path = "D:\Web\Domains\knowledge/"
base_url = "http://localhost/"
charset = "UTF-8"
locale = "zh_CN"
showlogo = "1"
theme = "green"
复制代码
复制代码

如上文所示,将 local 修改为 zh_CN 则默认的语言就是中文的了,另外网站的标题也可以修改,如果修改为中文记得将文件编码设置为 UTF8

showlogo 为 1 则在页面左上方显示 logo , 为 0 则显示title 的内容

在内容标题的下方有一排菜单,鼠标移动到菜单项上时会出现菜单项超出菜单条的问题,这是因为直接设置了菜单条的高度,去掉元素的高度,让 dojo 自动计算高度就不会有这个问题,找到 include/class-default-menu.php,定位到 201 行(针对 1.0.3 版本),去掉 height: 24px; 这个属性,就可以了

$this->defaultmenu['content']['config']['wrap'] = '<div style="border-left:0px; border-right:0px;" dojoType="dijit.MenuBar" region="top">|</div>';

首页的

D:\wwwroot\WWWW\index.php
knowledgeroot_logo.png
1 <div class="pagetitle">
2     <?php echo ($CLASS['config']->base->showlogo) ? "<img src=\"images/knowledgeroot_logo.png\" alt=\"".$CLASS['config']->base->title."\" title=\"".$CLASS['config']->base->title."\" />" : $CLASS['config']->base->title; ?>
3 </div>
1 <div class="version">
2   <a href="http://www.knowledgeroot.org">Knowledgeroot</a> - <?php echo $CLASS['translate']->_('version') . ":&nbsp;" . $CLASS['config']->base->version; ?>
3  </div>

换成自己的标识

 

 

如果觉得内置的编辑器功能太弱,可以到KNOWLEDGEROOT官方网址上下载 CKEditor 插件(或者 FCKEditor 插件),在后台管理界面中导入 ckeditor.krx ,然后在扩展里面安装(install)并启用(enable)这个插件就可以了,该编辑插件在 FireFox 中可以直接从计算机里面拖图片到编辑框中,非常方便(该功能在 Chrome 和 IE 不好用,因为这些浏览器会打开你拖进来的图片,而不是放到编辑区里面)

最后如果觉得字体和文字的大小不合适那么可以修改 css 来进行调整,例如把 system/themes/green/green.css 中字体调整为

font-family: "微软雅黑", "新宋体", "宋体", Arial;
font-size: 10pt;
    .pagetitle {
        color:#ffffff;
        font-family: Georgia, "Trebuchet MS";
        font-size:32.5px;
        font-weight:bold;
        padding: 5px;
        letter-spacing: -2px;
    }

 

.pagetitle {
        color:#ffffff;
        font-family: 微软雅黑, "Microsoft YaHei UI";
        font-size:32.5px;
        font-weight:bold;
        padding: 5px;
        letter-spacing: -2px;
    }

 

字体大小在不同的地方需要根据原来的大小等比例的调整,目录树、菜单、正文等系统默认 12px,对中文来说太小不方便阅读,所以统一调整为 10pt,就美观多了。

 

默认语言

\include\class-language.php

var $default_lang = "zh_CN.UTF8";

以下是建好的效果:

 


1.基于php开发,支持linux ,windows.
2.支持mysql ,sqlite, postgreSQL
3.支持任意类型附件(目前版本使用数据库base64后保存文件,需要调整mysql 参数max_allowed_packet,否则大于1M文件不能保存),使用数据库保存附件这个特性,如果附件很多,很大的情况,会是个问题。需要改造。
4.支持插件功能,官方网站下载插件,后台管理import,然后install, enable。
5.官方插件CKEditor (当前版本 2.6.2) 可与KCFinder 2.5.1 配合实现文件上传(已经支持中文)
6.官方插件ContentHistory 实现版本历史功能,类似diff查看版本,以及系统全部 last changes
7.支持中文,如需要修改原始翻译,可使用 msgfmt 可自主转换 po to mo.
8.tips:针对每个page.可以在edit page时设定content是否在点击page时自动展开还是只列title。创建时不能指定?
9.编辑冲突问题解决:原始版本编辑content时,首先在content_open表插入数据。然后打开content内容。第二个用户编辑时,也是先写入到content_open表,然后检查是否有其他用户打开数据,如果有,在打开内容上方显示警告。如果强制编辑,会出现一方修改信息被另一方覆盖的问题。
解决方法是采用排他编辑模式,如果内容被编辑中,其他人再试图编辑,直接提示有其他人编辑,返回。不能进入编辑。提示信息中有正在编辑此内容的user id。以方便协调。
主要修改2个文件:
  class-knowledgeroot-content.php 
    function edit_content
 class-knowledgeroot.php
    function openContent

10.注意插件多不支持中文,修改插件的language.php参照 en_US 增加zh_CN配置,(UTF-8 no bom )
11. 使用CKEditor 时,配合KCFinder支持文件上传
修改CKEditor目录下config.js  指向KCFinder
CKEDITOR.editorConfig = function( config )
{
        // Define changes to default configuration here. For example:
        // config.language = 'fr';
        // config.uiColor = '#AADC6E';

      config.filebrowserBrowseUrl = '/kcfinder/browse.php?type=files';
      config.filebrowserImageBrowseUrl = '/kcfinder/browse.php?type=images';
      config.filebrowserFlashBrowseUrl = '/kcfinder/browse.php?type=flash';
      config.filebrowserUploadUrl = '/kcfinder/upload.php?type=files';
      config.filebrowserImageUploadUrl = '/kcfinder/upload.php?type=images';
      config.filebrowserFlashUploadUrl = '/kcfinder/upload.php?type=flash';
};

修改kcfinder 中config.php ,加入:
$_SESSION['KCFINDER']['disabled'] = false, 
完成。
注意如果在linux系统中使用了软链接www root,需要配置kcfinder的uploadurl地址。
12. 升级CKEditor .
出于安全考虑, CKEditor使用 新版本  3.6.6.1替换原始版本3.6.2。
直接替换原始extension/ckeditor/ckeditor,然后修改config.js 同11.

13.修改email 发送为异步发送方式方法:
需求:由于远程邮件服务器访问缓慢,打开邮件提醒功能后,操作缓慢,影响用户体验。
数据库增加表:
DROP TABLE IF EXISTS mail_queue;
CREATE TABLE mail_queue (
  id int(11) unsigned NOT NULL auto_increment,
  subject varchar(255) NOT NULL,
  bodytext text ,
  bodyhtml text ,
  emailto  varchar(255) not null,
  createtime timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (id)
 
  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8
 
修改:class-email-notification.php 文件的函数:
 function sendEmail(config,subject, bodyText,bodyHtml = null) {
             
                  emailto=config->to;      
             sql =  sprintf("INSERT into mail_queue (subject, bodytext,bodyhtml,emailto) VALUES( '%s', '%s', '%s', '%s')",                                addslashes(subject),addslashes(bodyText),addslashes(bodyHtml),emailto);                   this->CLASS['db']->query($sql );
           return true;       
       }
 
建立一个读取mail_queue表中数据然后通过SMTP发送邮件的php文件。
mailqueue_send_job.php
<?php
// mailqueue_send_job.php
// tank add 2013.
timer = microtime(); starttime = ((double)strstr(timer, ' ') + (double)substr(timer,0,strpos(timer,' '))); if (!is_file("config/app.ini")) {     echo "No configuration file found! ";     exit(); } // load requiered files require_once ('include/init.php'); config = CLASS['config']->email; res = CLASS['db']->query("SELECT id, subject,bodytext,bodyhtml,emailto  FROM mail_queue order by id "); cnt = CLASS['db']->num_rows(res);
while(row = CLASS['db']->fetch_assoc(res)) {    $id =  $row['id'];    $res2 = $CLASS['db']->query(sprintf("delete  FROM mail_queue where id = %d ",$id));   sendEmail($config,$row['emailto'], $row['subject'], $row['bodytext'], $row['bodyhtml']) ; } function sendEmail(config, emailto,subject, bodyText, bodyHtml = null) {
        try {
            transport = null;             if(config->host != '') {
                smtpConfig = array();                 if(config->auth != '') {
                    smtpConfig['auth'] = config->auth;
                    smtpConfig['username'] = config->username;
                    smtpConfig['password'] = config->password;
                }

                if(config->port != '') {                     $smtpConfig['port'] = $config->port;                 }                 if(config->ssl != '') {
                    smtpConfig['ssl'] = config->ssl;
                }

                transport = new Zend_Mail_Transport_Smtp(config->host, smtpConfig);             }             mail = new Zend_Mail('UTF-8');                     
                        mail->addHeader('X-MailGenerator', 'Knowledgeroot');             mail->setBodyText(bodyText);             if(bodyHtml != null) mail->setBodyHtml(bodyHtml);
            mail->setFrom(config->from, config->from_name);             foreach(explode(",", emailto) as value) {                 if(trim($value) != "") {                     $mail->addTo($value);                 }             }             mail->setSubject(config->subject_prefix . subject);
            mail->send(transport);
                        echo  'Sent OK\n';
            return true;
        } catch(Zend_Mail_Transport_Exception e) {                $ErrorMsg = $e->getMessage();                            echo  '\nError 1:' .$ErrorMsg;             return false;         } catch(Exception e) {
                         ErrorMsg = e->getMessage();
                           echo '\nsError 2:' . $ErrorMsg;          
            return false;
        }
    } 
?>

 
 此php脚本只能使用wget访问执行,在cron 中增加执行shell
#!/bin/sh
wget -O result http://localhost/mailqueue_send_job.php >> log.txt


14.官方插件CKEditor  对于尖括号 <> 不兼容问题修复
 修改 class-ckeditor.php  :
function show($text="") {
            texthtml = htmlspecialchars(text);
            texthtml = text;
        return "<textarea class="ckeditor" id="content" name="content">".$texthtml."</textarea>";
    }
 
15. 增加首页显示last changes功能:
 
a. 在include目录中创建类:class-lastchanges.php
   var CLASS;     function start(&CLASS) {
        this->CLASS =& CLASS;
    }

    function  getlastchanges() {
...  参考class-history.php类中:function showLastChanges() 方法。
}
-----------------------------------------------------------
b.修改init.php
在最后增加:
require_once($base_path."include/class-lastchanges.php");
//
CLASS['lastchanges'] = new lastchanges(); CLASS['lastchanges']->start($CLASS);
------------------------------------------------------------
 
c.修改:class-knowledgeroot_content.php
1650行附近:
 
 
 
posted @   Endv  阅读(1263)  评论(0)    收藏  举报
编辑推荐:
· 日常问题排查-空闲一段时间再请求就超时
· Java虚拟机代码是如何一步一步变复杂且难以理解的?
· 领域驱动的事实与谬误 一 DDD 与 MVC
· SQL Server 2025 中的改进
· 当数据爆炸遇上SQL Server:优化策略全链路解析
阅读排行:
· 日常问题排查-空闲一段时间再请求就超时
· 揭秘 AI 工具的系统提示词「GitHub 热点速览」
· C# 14 新增功能一览,你觉得实用吗?
· MySQL同步ES的6种方案!
· 解密AI知识库
点击右上角即可分享
微信分享提示