1. 让ckeditor的编辑界面更简单.
在ckeditor根目录中修改config.js
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
config.language = 'zh-cn';
// config.uiColor = '#AADC6E';
config.toolbar_Full = [
['Source'],
['Cut','Copy','Paste','PasteText','PasteFromWord',],
['Undo','Redo','-','Find','Replace']
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],'/',
['Format','Font','FontSize'],
['TextColor','BGColor'],
['Image','Flash','Link','HorizontalRule','Smiley','SpecialChar','PageBreak']
];
config.font_names='宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;微软雅黑/微软雅黑;'+ config.font_names;
};
2. php中配置ckfinder + editor
<?php
class Das_CKEditor {
protected $ckeditor_path ;
protected $ckfinder_path ;
protected $ckeditor_webpath;
protected $ckfinder_webpath;
protected $_content;
public function __construct(){
$this->ckeditor_path = APPLICATION_PATH . "/resources/scripts/ckeditor/";
$this->ckfinder_path = APPLICATION_PATH . "/resources/scripts/ckfinder/";
//echo $this->ckeditor_path;
//d:\xampp\htdocs\etc.....
$app_web_path = 'http://' .$_SERVER['SERVER_NAME'] . '' . $_SERVER['SCRIPT_NAME'];
$app_web_path = strtolower($app_web_path);
$app_web_path = str_replace( "index.php" , "" , $app_web_path);
$this->ckeditor_webpath = $app_web_path . "resources/scripts/ckeditor/";
$this->ckfinder_webpath = $app_web_path . "resources/scripts/ckfinder/";
}
public function init($content = null)
{
require_once $this->ckeditor_path . "ckeditor.php";
require_once $this->ckfinder_path . "ckfinder.php";
$ckeditor = new CKEditor();
$ckeditor->returnOutput = true;
$ckeditor->basePath = $this->ckeditor_webpath;
CKFinder::SetupCKEditor($ckeditor , $this->ckfinder_webpath);
//die($this->_content);
$contentarea = $ckeditor->editor("editor_content" ,$content);
return $contentarea;
}
}
3,配置ckfinder的真实地址与上传后的url的配置,在ckfinder的config.php中修改
function CheckAuthentication()
{
return true;
}
// LicenseKey : Paste your license key here. If left blank, CKFinder will be
// fully functional, in demo mode.
$config['LicenseName'] = '';
$config['LicenseKey'] = '';
//$baseUrl = '../../../uploads/';
$baseUrl = 'http://www.name.com/xinxibaosong/uploads/';
$baseDir = "d:/webphp/xinxibaosong/uploads/";
4.上传后修改文件的名为随机数字和字符
在ckfinder/core/connector/php/php5/CommandHandler/FileUpload.php中加入
public function mySetFileName() {
$gettime = explode(' ', microtime());
$string = 'abcdefghijklmnopgrstuvwxyz0123456789';
$rand = '';
for ($x = 0; $x < 5; $x++) {
$rand .= substr($string, mt_rand(0, strlen($string) - 1), 1);
}
return date("ymdHis") . substr($gettime[0], 2, 6) . $rand;
}
完后修改63行左右的
if ($sFileName != $sUnsafeFileName) {
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
}
修改为:
if ($sFileName != $sUnsafeFileName) {
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
}
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
$sFileName = $this->mySetFileName() . '.' . $sExtension;