首先,去官网下载最新版的kindeditor,然后把里面asp,jsp,net,example的全删除,然后改名为editor放进public(最外层目录的public)文件夹里面

在目录lib目录建立ORG文件夹(个人习惯用ORG存储公用类),建立一个共用类,editor.class.php

下面是这个类的具体代码

<?php

/*编辑器调用的初始化类

*

*/

class editor {

var $Width;

var $Height;

var $Value;

/* 此方法是编辑器的构造方法

*第一个参数,$Height是高度,不填默认是500px

*第二个参数,$Width是宽度,不填默认是700px

*第三个参数,$Value是编辑器默认内容,不填默认是“<h2>欢迎使用编辑器</h2><br>”

*

*/

function editor($Height="500px",$Width="700px",$Value="<h2>欢迎使用编辑器</h2><br>") {

$this->Value = $Value;

$this->Height = $Height;

$this->Width = $Width;

}

/*此方法是在线编辑器的调用

* 在需要编辑器的地方调用此函数

*/

function createEditor(){

return "<textarea name='content1' style='width:$this->Width;height:$this->Height;visibility:hidden;'>$this->Value</textarea>";

}

/*使用在线编辑器必须在html<head></head>之间调用此方法,才能正确调用,

* 内容主要都是script

*/

function usejs(){

$str=<<<eot

<link rel="stylesheet" href="__PUBLIC__/editor/themes/default/default.css" />

<link rel="stylesheet" href="__PUBLIC__/editor/plugins/code/prettify.css" />

<script charset="utf-8" src="__PUBLIC__/editor/kindeditor.js"></script>

<script charset="utf-8" src="__PUBLIC__/editor/lang/zh_CN.js"></script>

<script charset="utf-8" src="__PUBLIC__/editor/plugins/code/prettify.js"></script>

<script>

KindEditor.ready(function(K) {

var editor1 = K.create('textarea[name="content1"]', {

cssPath : '__PUBLIC__/editor/plugins/code/prettify.css',

uploadJson : '__PUBLIC__/editor/php/upload_json.php',

fileManagerJson : '__PUBLIC__/editor/php/file_manager_json.php',

allowFileManager : true,

afterCreate : function() {

var self = this;

K.ctrl(document, 13, function() {

self.sync();

K('form[name=example]')[0].submit();

});

K.ctrl(self.edit.doc, 13, function() {

self.sync();

K('form[name=example]')[0].submit();

});

}

});

prettyPrint();

});

</script>

eot;

return $str;

}

/*取得在线编辑器的值并返回

*/

function getEditorContent(){

$htmlData = '';

if (!empty($_POST['content1'])) {

if (get_magic_quotes_gpc()) {

$htmlData = stripslashes($_POST['content1']);

} else {

$htmlData = $_POST['content1'];

}

return $htmlData;

}

}

}

代码注释都写的比较清楚了,然后在action建立个文件,是IndexAction.class.php

<?php

class IndexAction extends Action {

public function _initialize() {

header("Content-Type:text/html; charset=utf-8");

}

public function index(){

import("@.ORG.editor");  //导入类

$editor=new editor();     //创建一个对象

$a=$editor->createEditor();   //返回编辑器

$b=$editor->usejs();             //js代码

$this->assign('usejs',$b);     //输出到html

$this->assign('editor',$a);

$this->display();

}

public function php(){

import("@.ORG.editor");

$editor=new editor();

$a=$editor->getEditorContent();   //获取编辑器的内容

$this->assign('a',$a);

$this->display();

// $this->success('数据添加成功!');

}

}

然后在tpl建立index文件夹,在里面建立2个html文件,

index.html    //使用编辑器

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

{$usejs}

</head>

<body>

<form name="example" method="post" action="__URL__/php">

<?php //<textarea name="content1" style="width:700px;height:200px;visibility:hidden;"></textarea>   ?>

{$editor}

<br />

<input type="submit" name="button" value="提交内容" /> (提交快捷键: Ctrl + Enter)

</form>

</body>

</html>

php.html    //获取编辑器的内容

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>

{$a}

</body>

</html>

thinkphp 编辑器kindeditor的更多相关文章

  1. 富文本编辑器kindeditor配置

    <!--富文本编辑器kindeditor配置↓ --> <link type="text/css" rel="stylesheet" href ...

  2. easyUI整合富文本编辑器KindEditor详细教程(附源码)

    原因 在今年4月份的时候写过一篇关于easyui整合UEditor的文章Spring+SpringMVC+MyBatis+easyUI整合优化篇(六)easyUI与富文本编辑器UEditor整合,从那 ...

  3. 后台文本编辑器KindEditor介绍

    后台文本编辑器KindEditor介绍 我们在自己的个人主页添加文章内容的时候,需要对文章内容进行修饰,此时就需要文本编辑器助阵了! 功能预览 KindEditor文本编辑器 KindEditor文本 ...

  4. python 全栈开发,Day83(博客系统子评论,后台管理,富文本编辑器kindeditor,bs4模块)

    一.子评论 必须点击回复,才是子评论!否则是根评论点击回复之后,定位到输入框,同时加入@评论者的用户名 定位输入框 focus focus:获取对象焦点触发事件 先做样式.点击回复之后,定位到输入框, ...

  5. 使用富文本编辑器Kindeditor

    今天在做需求的时候,遇到有一个字段,需要保存带有格式的内容,决定使用富文本框编辑器Kindeditor来实现,解决方法如下: 登录官网下载控件包: http://kindeditor.net/down ...

  6. 富文本编辑器 KindEditor 的基本使用 文件上传 图片上传

    富文本编辑器 KindEditor 富文本编辑器,Rich Text Editor , 简称 RTE , 它提供类似于 Microsoft Word 的编辑功能. 常用的富文本编辑器: KindEdi ...

  7. Thinkphp编辑器扩展类kindeditor用法

    一, 使用前的准备. 使用前请确认你已经建立好了一个Thinkphp站点项目. 1,Keditor.class.php和JSON.class.php 是编辑器扩展类文件,将他们拷贝到你的站点项目的Th ...

  8. 纯JS文本在线HTML编辑器KindEditor

    KindEditor(http://www.kindsoft.net)是一款比较专业,主流,好用的在线HTML编辑器. 它除了可以将文本进行编辑.将Word中的内容复制进来外,本身还可以拖动缩放(右下 ...

  9. HTML编辑器KindEditor

    KindEditor 是一套开源的在线HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,开发人员可以用 KindEditor 把传统的多行文本输入框(textarea)替换为可视化的富文本 ...

随机推荐

  1. 【最短路】【spfa】CDOJ1647 酌贪泉而觉爽, 处涸辙以犹欢。

    题意: 给你一个全为0的01串,问你能否通过一系列的变换,得到全为1的01串. 分析: 将每个01串看作一个点,每一个变换可以看作是一条有向边,现在问题可以转化 为找从“00..0”这个点到“11.. ...

  2. 【搜索】【约数个数定理】[HAOI2007]反素数ant

    对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4.如果某个正整数x满足:g(x)>g(i) 0<i<x,则称x为反质数. 所以,n以内的反质数即为不超过n的 ...

  3. 【深度优先搜索】mr353-取奶

    应该是USACO的题目,暂时没有找到对应出处. [题目大意] 农夫约翰要量取 Q(1 <= Q <= 20,000)夸脱(夸脱,quarts,容积单位——译者注) 他的最好的牛奶,并把它装 ...

  4. 1.4(SQL学习笔记)分组、子查询、联结、组合查询

    一.分组 建表及数据填充语句下载:链接: https://pan.baidu.com/s/1WHYafwqKJEKq1kDwCH_Zlg 提取码: 3wy4 1.1初识分组 分组是按照某一列,将该列中 ...

  5. 微软笔试Highway问题解析

      High way   时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 In the city, there is a one-way straight highway ...

  6. C#-java RSA加密解密

    using Org.BouncyCastle.Math; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Securi ...

  7. 前端工业化工具Gulp初体验

    1. 全局安装 gulp: npm install --global gulp 2.在项目目录下,用以下命令创建一个基本的package.json文件 npm init 3.安装Gulp npm in ...

  8. MyBatis 显示日志

    <!-- 全局配置 --> <settings> <setting name="cacheEnabled" value="false&quo ...

  9. [java] 简单的ConcurrentHashMap

    ConcurrentMap和Guava的LocalCache实现原理相近,底层的存储方式使用的时table方式来存储.这里使用最简单且最暴力的方式,在每次访问的时候均加锁. ConcurrentHas ...

  10. iOS:分页控件UIPageControl的使用

    分页控件:UIPageControl   功能:通常搭配滚动视图一起使用,设置pagingEnabled=YES即可,UIScrollView会被分割成多个独立页面,用户的滚动体验则变成了页面翻转,一 ...