phpcms v9編輯器ckeditor資料恢複效能

來源:互聯網
上載者:User
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<=0) timer = counttimer;$('#tuzwu_timer').html(--timer);}function open_databak(){omnipotent('databak_area','?m=content&c=databak&a=init&target=dialog','恢複資料',1,600,400);}


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"><?php echo L('website_manage');?>    備份產生時間標題by 化蝶自在飛


完畢.2011-11-12 for http://www.xiaojudeng.com,轉載請註明出處,謝謝.
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.