Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial thinkphp3.0 中的thinkeditor怎么用

thinkphp3.0 中的thinkeditor怎么用

Jun 23, 2016 pm 02:09 PM

一直纠结于thinkphp中怎么加载编辑器,最新我看就thinkphp3.0中tool工具中带了一个thinkeditor。但是一直的不知道怎么配置,那个高手能给详细的给我配置下吗?谢谢了


回复讨论(解决方案)

他不是有说明文档吗?

首先,介绍下本编辑器:
  本编辑器是thinkphp(简称tp)官方2010年某位大侠所创架构、用jquery写的,后又经历成立夫之手完成,我只是写了标签库、及本日志,本人接手后,水平有限、又没 有时间,尚未搞懂它的具体流程,今后将由左家梓(网名麦当苗儿)这位曾经和kindeditor官方人员接触的js大侠完善,当然网友也可以贡献力量,提 出建议,和贡献插件。

其次,使用thinkeditor必须注意三个地方:
  1.本编辑器只适用于tp(上传的地方TP写法,其他框架使用自行修改)。js部分的引用写成了标签库。
  2.使用本编辑器的人都要有大无畏的冒险精神,爱折腾,因为本编辑器尚未完善,不能称的上专业。
  3.本编辑器只提供大部分网站基本的编辑器的功能,排版、文章中能显示图片flash;插入视频插件未开发。有待广大网友的鼎力帮助。

如何使用本编辑器?
  首先,下载整个编辑器的压缩包。
  然后,解压,将thinkeditor文件夹放入你的项目公共资源目录/Public下。
并将其中的标签TagLibTp.class.php放入项目的Lib\TagLib\下,并根据框架版本在配置中配置引入的插件路径。(2.2和3.0使用方式会有不同)。
  再然后,在模板引用的地方加上
在head位置加上

这里先说几个参数id是你要替换的textarea的id,uploadURL是上传处理的方法,width是编辑器的宽,可以以px表示,也可以用百分表表示 如width = "100%",因此要单位,其他的参数不需要写单位的。
其他参数的话,参考标签库和说明文档。
然后给项目添加编辑器的上传方法。
如blog中的PublicAction.class.php中的写法
public function editor_up(){
        //$savePath 为项目下的上传目录名 如 uploads 会是 上传到__ROOR__/uploads下,为空则上传到__ROOT__/uploads/thinkeditor下 
// $saveRule为上传文件命名规则,例如可以是 time uniqid com_create_guid 等,例如可以是 time uniqid com_create_guid 等 默认为time参考tp的上传类
// 例如可以是 time uniqid com_create_guid 等
        $savePath = 'uploads';
        $saveRule = 'time';
        import("@.ORG.UploadFile");
        $savePath = ($savePath)? './'.$savePath : './Uploads/thinkeditor';
        $savePath = (substr($savePath,-1)!='/')?$savePath.'/':$savePath;
        $maxSize = ($_POST['temaxsize'])? $_POST['temaxsize'] : -1;
        $upload = new UploadFile($maxSize,'','',$savePath,$saveRule);
        
        //传给js的参数 $savepath是上传的文件的生成路径,$isupload是上传是否成功的布尔值
        $savepath = '';
        $isupload = 'false';
        if(strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
            $info = $upload->uploadOne($_FILES['teupload']);
            if($info){
                $isupload = 'true';
                $savepath = $upload->savePath.$info[0]['savename'];
                $savepath = substr($savepath, 1);
            }else{
                $error = $upload->getErrorMsg();
            }
        }
        import('@.TagLib.TagLibTp');
        //上面的上传只是写个例子,用户上传可以自定义的,但是下面的是传给编辑器的
        //参数必须为$isupload,是否成功,上传后的文件相对路径$savepath必须相对于项目根目录的,错误信息
TagLibTp::think_upload($isupload,$savepath,$error);
}

有能力的童鞋可以自己写上传方法,只要最后自己调用TagLibTp::think_upload($isupload,$savepath,$error);传入对应的参数即可,就可以使用本编辑器了。效果如图:
 
本编辑器内写了的自动刷新,保存文本时就不用调用方法保存了。还有标签调用时写了jquery的防冲突模式,因此其他类库可以与之同时使用。

至于插件的开发,看说明文档。我在plugins\system.js里写了个实现弹窗输入thinkphp的eq标签的
name 和value值后生成thinkphp eq 标签的插件,去掉注释,在thinkeditor.js里defaults配置里controls里加上eq,
 
这行去掉注释,应该就能出来了。不过我没加样式,用的html源码的图标。开发起来不难的,相信凭着大家的创造力,可以开发出很多编辑器的插件的.。
                   谢谢您的支持,thinkphp官方组
愿您过个好年!   2012年1月15日


3.0中不是extend里面有一个tool文件夹 里面自带了thinkeditor   还需要导入吗?

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

See all articles