您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

phpcms v9编辑器ckeditor数据恢复效能

2026/2/2 17:15:08发布16次查看
phpcms v9编辑器ckeditor数据恢复功能
为phpcms v9的ckeditor编辑器开发的数据恢复功能.下面直接上步骤说明吧.
1.\statics\js\ckeditor\config.js文件最后增加以下代码:
//化蝶自在飞 add 2011-11-12 自动保存数据var timer = counttimer = '30';//每?秒保存一次var delays = 10;//延迟多少秒执行,因为firefox下无法显示,建议设置为10000var editorid = 'content';var fromid = 'myform';$(function(){var str = '恢复数据'+timer+'秒后自动保存';settimeout('$(.cke_footer).append(\''+str+'\')',delays*1000);setinterval('tuzwu_posts()',timer*1000);setinterval('tuzwu_timer()',1000);});function tuzwu_posts(){ //post提交数据var editor = ckeditor.instances[editorid];data = editor.getdata();$('#'+editorid).val(data);$.post(api.php?op=editor_data, $(#+fromid).serializearray(),function(data){$('#'+editorid).val();});}function tuzwu_timer(){ //每秒执行1次,倒数计时if(timer
2.建数据表用于保存数据:
create table `v9_editor_data` ( `id` mediumint(8) not null auto_increment, `data` mediumtext character set gbk not null comment '数据', `time` int(10) not null, `userid` mediumint(8) not null, primary key (`id`)) engine=myisam default charset=latin1 auto_increment=1 ;
注意:表前缀和数据库编码,推荐自己手工用phpmyadmin建表;
3.\phpcms\model\editor_data_model.class.php新建该文件,用以下代码填充文件:
db_config = pc_base::load_config('database'); $this->db_setting = 'default'; $this->table_name = 'editor_data'; parent::__construct(); }}?>
4.\api\editor_data.php新建改文件,用以下代码填充该文件:
$postdata,'userid'=>$_userid,'time'=>sys_time);$r = $db->get_one( array('userid'=>$_userid,'data'=>$postdata),'id' );//如果没有改变就不用备份if($r) exit('0');$db->insert($posts);exit('1');?>
5.\phpcms\modules\content\databak.php新建该文件,代码如下:
db = pc_base::load_model('editor_data_model'); $this->_userid = param::get_cookie('userid')?param::get_cookie('userid'):param::get_cookie('admin_userid'); $this->_username = param::get_cookie('_username'); $this->_groupid = param::get_cookie('_groupid'); } public function init() { if(!$this->_userid) exit('用户id校验失败'); $page = $_get['page']?$_get['page']:1; $infos = $this->db->listinfo( array('userid'=>$this->_userid),'time desc',$page,20,'',10 ); $pages = $this->db->pages; $target = $_get['target']; include $this->admin_tpl('databak'); }}?>
6.\phpcms\modules\content\templates\databak.tpl.php新建改文件,代码如下:
class=addbg>备份生成时间 标题
by 化蝶自在飞

完毕.2011-11-12 for http://www.xiaojudeng.com,转载请注明出处,谢谢.
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product