CI集成FCKeditor
分享下CI集成FCKeditor1、把FCKeditor复制到system/application/libraries/下
并建立一个FCKeditor.php的文件(继承FCKeditor的类)
代码如下:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once('FCKeditor/fckeditor.php');
/**
* DK_FCKeditor extends FCKeditor
* Author: Daker.W
* Create Time: 2010/08/13
**/
class DK_FCKeditor extends FCKeditor
{
function DK_FCKeditor($config = array('InstanceName'=>''))
{
$this->CI =& get_instance();
if ( ! in_array('fckeditor_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
{
$this->CI->lang->load('fckeditor');
}
$this->local_time = time();
if (count($config) > 0)
{
$this->initialize($config);
}
parent::__construct($this->InstanceName);
$this->BasePath = $this->CI->config->item('fck_base_path');//配置文件中配置的FCK的路径
$this->ToolbarSet = $this->CI->config->item('fck_toolbarset_default');//配置的默认样式
log_message('debug', "FCKeditor Class Initialized");
}
function initialize($config = array())
{
foreach ($config as $key => $val)
{
if (isset($this->$key))
{
$this->$key = $val;
}
}
}
}//End Class
?>
2.配置文件中增加两项配置
/**
* 配置fckeditor的路径
*/
$config['fck_base_path'] = $config['base_url']."libraries/FCKeditor/";
$config['fck_toolbarset_default'] = 'Default';
控制器重调用CODE:
<?php
class testfckeditor extends DK_Controller {
function testfckeditor()
{
parent::DK_Controller();
}
function index()
{
$this->load->library('fckeditor', array('InstanceName' => 'content'));
$this->load->library('smarty');
$this->fckeditor->Width = 600;
$this->fckeditor->Height = 600;
$this->fckeditor->Value = '555555555';
$sFCKeditor = $this->fckeditor->CreateHtml();
$this->smarty->assign('test',$sFCKeditor);
$this->smarty->display('test/testsmarty.html');
}
}
谢谢了!![ 我一般都是直接用JS引入的 太复杂了,还是JS版吧。放之四海而皆准。 是的 支持 JS 这样有点麻烦,修改不是很方便呢。还是js好 不错蛮详细的 顶.......... 这个编辑器挺不错 我也是这么做的。。。
页:
[1]
2