凌雪
2018-11-08
来源 :网络
阅读 1315
评论 0
摘要:本文将带你了解WEBAPP开发教程yii 整合 ckeditor,ckfinder,希望本文对大家学WEBAPP有所帮助。
本文将带你了解WEBAPP开发教程yii 整合 ckeditor,ckfinder,希望本文对大家学WEBAPP有所帮助。
//目錄配置path\to\webapp\protected\extensions\ckeditor\CKEditorWidget.phppath\to\webapp\protected\extensions\ckeditor\views\CKEditorView.phppath\to\webapp\ckeditor\...path\to\webapp\ckfinder\...//CKEditorWidget.php<?php/* * Created on 10.10.2010 * * Copyright: Shahram Monshi Pouri * Based on Christian Kütbach's FCKEditorWidget * * GNU LESSER GENERAL PUBLIC LICENSE * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU lesser General Public License * along with this program. If not, see <//www.gnu.org/licenses/>. * * Requirements: * The CK-Editor have to be installed and configured. The Editor itself is * not includet to this extension. * * This extension have to be installed into: * <Yii-Application>/proected/extensions/ckeditor * */ /** * @author Sam * @example * for basic: * <?php $this->widget('ext.ckeditor.CKEditorWidget',array('model'=>$model, 'attribute'=>'content', 'value'=>$model->content)); ?> * @example * for single: in this case, textarea tag is not included * <?php $this->widget('ext.ckeditor.CKEditorWidget',array('htmlOptions'=>array('id'=>'textarea_id'))); ?> * @example * for name and value: in this case, value is not requried: * <?php $this->widget('ext.ckeditor.CKEditorWidget',array('htmlOptions'=>array('name'=>CHtml::activeName($model, 'content'))), 'value'=>$model->content); ?> * @example * for multiple: in this case, textarea tag is not included * <?php $this->widget('ext.ckeditor.CKEditorWidget',array('htmlOptions'=>array('class'=>'textarea_class')))); ?> */ class CKEditorWidget extends CInputWidget{ public $ckEditor; public $ckFinder; public $ckBasePath; public $config; public function init() { if(!isset($this->ckEditor)){ $this->ckEditor = Yii::getPathOfAlias('webroot').'/ckeditor/ckeditor.php'; } if(!isset($this->ckFinder)){ $this->ckFinder = Yii::getPathOfAlias('webroot').'/ckfinder/ckfinder.php'; } if(!isset($this->ckBasePath)){ $this->ckBasePath = Yii::app()->getBaseUrl().'/ckeditor/'; } if(!isset($this->value)){ $this->value = ''; } $controller=$this->controller; $action=$controller->action; if(!(isset($this->htmlOptions['class']) || isset($this->htmlOptions['id']) || isset($this->htmlOptions['name']))){ if(!isset($this->model)){ throw new CHttpException(500,'"model" have to be set!'); } if(!isset($this->attribute)){ throw new CHttpException(500,'"attribute" have to be set!'); } $this->htmlOptions['name']=CHtml::activeName($this->model, $this->attribute); } } public function run() { $this->render('CKEditorView',array( "ckBasePath"=>$this->ckBasePath, "ckEditor"=>$this->ckEditor, "ckFinder"=>$this->ckFinder, "htmlOptions"=>$this->htmlOptions, "value"=>$this->value, "config"=>$this->config, )); }}?>//CKEditorView.php<?php/* * Created on 10.10.2010 * * Copyright: Shahram Monshi Pouri * Based on Christian Kütbach's FCKEditorWidget * * GNU LESSER GENERAL PUBLIC LICENSE * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU lesser General Public License * along with this program. If not, see <//www.gnu.org/licenses/>. * * Requirements: * The CK-Editor have to be installed and configured. The Editor itself is * not includet to this extension. * * This extension have to be installed into: * <Yii-Application>/proected/extensions/ckeditor * * Usage: * see-> readme.txt */ require_once($ckEditor);require_once($ckFinder); $oCKeditor = new CKeditor();$oCKeditor->basePath = $ckBasePath; if(isset($config) && is_array($config)){ foreach($config as $key=>$value){ $oCKeditor->config[$key] = $value; }}CKFinder::SetupCKEditor($oCKeditor, Yii::app()->getBaseUrl().'/ckfinder/'); if(isset($htmlOptions['id'])){ $oCKeditor->replace($htmlOptions['id']);}else if(isset($htmlOptions['name'])){ $oCKeditor->editor($htmlOptions['name'],$value);}else if(isset($htmlOptions['class'])){ $oCKeditor->replaceAll($htmlOptions['class']);}?>
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之WebApp频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号