


How to use the Thinkphp editor extension class kindeditor
1. Preparation before use.
Please make sure you have created a Thinkphp website project before using it.
1. Keditor.class.php and JSON.class.php are editor extension class files. Copy them to the ThinkPHPLibORGNet folder of your website project.
2. The editor folder is the core package of kindeditor. Copy it to the Public folder of your project (the Public at the same level as the entry file), and create an Upload folder under Public to store images uploaded using the editor.
3. KeditorAction.class.php is the editor’s image upload function and remote image browsing function. Copy it to the libAction folder of your project.
2. Object call
Call object in controller method:
import("ORG.Net.Keditor"); $ke=new Keditor(); $ke->id="content";//指定textarea的id $keshow=$ke->show();//生成js代码 $this->assign("keshow",$keshow); $this->display();
Display the editor in the template file corresponding to the method:
<html> <head>{$keshow}</head><!--输出js,建议放在head--> <body> </body> </html>
The above is the simplest calling method, and the extended class also has many properties and methods. To achieve more perfect functions, read on.
3. Object properties
I divide the attributes into two types, one is the kindeditor's own attributes, and the other is the extended new attributes. If you have used kindeditor before, you should know that kindeditor itself has 30 attributes such as id, items, width, height, afterCreate, etc. These attributes can now be defined directly using PHP, such as defining id: $ke->id="content" and defining width: $ke->width="700px"; Let me first talk about the new attributes of the object.
New properties of objects:
1. jspath: Define the core js file of kindeditor. The default value is /Public/editor/kindeditor.js. If your editor folder is not placed under Publib, you need to specify this attribute, such as $ke->jspath="/kind/ kindeditor.js”;
2. Form: Specify the id of the submitted form (from), the default is form1. This attribute is used in combination with the ctrl+enter submission function. For example, if your editor is placed in the form id "formid", you need to implement ctrl +enter submits the formid form, you need to define $ke->form="formid". The ctrl+enter submission function also needs to set other attributes, which will be explained later.
3. imgid: Specifies the hidden domain id where the image address is stored. The default is img. Every time the editor uploads an image, the image address will be stored in this hidden field. When adding data to the database, you can also save the data in this hidden field to the database field. When deleting data, first read the image address stored in the database and delete it. The deletion process only requires calling the delimg method of the object. This method will be explained in detail later. In this way, the purpose of deleting content and pictures is achieved.
Comes with attributes:
1. items: Configure the toolbar of the editor, defined as
$ke->items=”['source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste']";
I added the little keyword to quickly define a streamlined model editor, using the method $ke->items="little";
2. afterCreate: Set the callback function to be executed after the editor is created. The definition method is such as
$ke->afterCreate=”function(id){
alert(‘successfully created’+id)
}";
I added the ctrlenter keyword to quickly define ctrl+enter to submit the form. How to use:
$ke->afterCreate=”ctrlenter”;
At the same time, you need to define $ke->form="formname", and replace formname with the form id where your editor is located.
3. resizeMode: 2 or 1 or 0. When 2, you can drag to change the width and height. When 1, you can only change the height. When 0, you cannot drag. The definition method is as follows: $ke->resizeMode=1; Note that numeric attribute values should not be placed in quotation marks, such as $ke->resizeMode="1"; such a definition is wrong.
4. allowFileManager: true or false. When true, the function of browsing server images is displayed (click the upload image button to see this function). The definition method is as follows:
$ke-> allowFileManager=ture;
Note that when the attribute value is a Boolean value, do not put it in quotes.
5. imageUploadJson specifies the server-side program for uploading images. The default value is /index.php/Keditor/upload
6. fileManagerJson: specifies the server-side program for browsing remote images,
The default value is /index.php/Keditor/filemanager
Note: The KeditorAction.class.php you copied before is used for uploading images and browsing remote images. The upload method in the file defines the process of uploading images, and the filemanager method in the file defines the process of browsing images. You can add code to determine permissions to these two methods so that only administrators can upload pictures or browse pictures. You can also define your own upload processing process and image browsing process instead of using the default KeditorAction.class.php. In this case, you need to redefine the imageUploadJson attribute value and fileManagerJson attribute value. The custom processing process will be explained in detail later.
There are other built-in attributes, so I won’t list them all. You can view the official documentation of kindeditor
http://www.kindsoft.net/doc.php?cmd=config
Note that attribute values of numeric type or Boolean type should not be placed in quotation marks. Other attribute values are placed in quotation marks, and the format of the attribute value is the same as the format of kindeditor itself.
四 对象的方法。
1,upload,上传图片。此方法在编辑器上传图片处理过程中使用,使用方法:
import("ORG.Net.Keditor"); Keditor::upload('./Public/Upload/','/Public/Upload/',array('gif','jpg','jpeg','png','bmp'),1000000);
upload方法有三个参数,依次是,“上传图片目录”,“图片显示地址”,“允许上传图片格式”,“允许的图片大小(单位kb)”
上传图片目录:默认值“./Public/Upload/”(注意Public前面有个“点”符号,是使用的相对地址,不可使用绝对地址),上传图片目录地址是相当于处理文件的。Thinkphp所有的代码都是通过入口文件运行的,所以这个地址其实是相对于入口文件的。
显示图片地址:默认值“/Public/Upload”(一般是绝对地址),假设我们上传了一张图片,服务器端生成的图片名为 12345.gif。上传会显示的图片地址则为/Public/Upload/12345.gif ,因为我们使用的是绝对地址,所以编辑器发布的内容不管在网站的哪儿,图片都能正常显示。
允许上传的图片格式:定义一个数组,默认值为array('gif','jpg','jpeg','png','bmp')
允许的图片大小:默认值为,1000000 ,单位是bk。
2,filemanager,浏览服务器的图片。此方法在浏览图片处理过程中使用。使用方法:
import("ORG.Net.Keditor"); Keditor::filemanager("./Public/Upload/","/Public/Upload/",array('gif','jpg','jpeg', 'png', 'bmp'));
参数依次是:“浏览图片目录”,“图片显示地址”,“允许浏览的图片格式”,和upload方法一样,浏览图片目录是相对地址,图片显示地址是觉得地址。
3,delimg:删除通过编辑器上传的图片。此方法一般在你删除数据库数据时使用。
import("ORG.Net.Keditor"); Keditor::delimg($imgfield); //$imgfield 一般是你数据库存放图片地址的字段。
4,show:返回生成的js代码。此方法一般在显示编辑器的控制器中使用。
show方法可以使用一个参数定义kindeditor自带属性。如:
import("ORG.Net.Keditor"); $ke=new Keditor(); $ke->show(“{ id : ”content”, width: ‘700px’; height : ”300px”; imgid : ”img” }”);
不建议用show传参方式定义kindeditor属性。show传参方式不能定义jspath和form两个新站属性,也不能使用little和ctrlenter关键词。

您在传输文件时是否遇到过任何问题,并且禁止您这样做?好吧,许多Windows用户最近报告说,他们在将文件复制并粘贴到文件夹中时遇到了问题,其中抛出了一个错误,提示“目标文件夹的文件名太长”。此外,其他一些Windows用户在打开任何文件时表示失望,并说“文件名或扩展名太长”,他们无法打开文件。这不允许他们将文件传输到任何其他文件夹,这让用户感到失望。在分析问题时,我们提出了一系列解决方案,可能有助于缓解问题,用户可以轻松传输文件。如果您也遇到类似情况,请参阅此帖子以了解更多信息。来源:https

许多Windows用户最近报告说,当WindowsDefenderSmartScreen警告用户不要启动MicrosoftWindows无法识别的应用程序时,他们感到恼火,他们每次都必须单击“仍然运行”选项。Windows用户不确定他们目前可以做些什么来避免或禁用它。在研究了这个问题后,我们发现系统上的WindowsDefender功能可以通过设置应用程序或本地组策略编辑器或通过调整注册表文件来禁用。通过这样做,用户将不再需要面对防守者SmartScreen。如果您的系统也遇到

写 Python 代码最好的方式莫过于使用集成开发环境(IDE)了。它们不仅能使你的工作更加简单、更具逻辑性,还能够提升编程体验和效率。每个人都知道这一点。而问题在于,如何从众多选项中选择最好的 Python 开发环境。

许多Windows用户都遇到过由于登录尝试失败或多次关闭系统而无法登录Windows11/10系统的问题。用户很沮丧,因为他们对此无能为力。用户可能忘记了登录系统的PIN码,或者在使用或安装软件时出现卡顿,系统可能被多次强制关闭。因此,我们制定了一份最好的可用解决方案列表,这些解决方案无疑将帮助消费者解决这个问题。要了解更多信息,请继续阅读本文。注意:在此之前,请确保您拥有系统的管理员凭据和Microsoft帐户密码以重置PIN。如果没有,请等待一个小时左右,然后尝试使用正确的PIN

随着Golang的流行和普及,越来越多的开发者开始使用这门编程语言。然而,和其他流行的编程语言一样,Golang的开发需要选择一款适合的编辑器来提高开发效率。在本文中,我们将介绍五个适合Golang开发的编辑器。VisualStudioCodeVisualStudioCode(简称VSCode)是微软开发的一款免费的跨平台编辑器。它是基于Elect

Python非常易学,强大的编程语言。Python包括高效高级的数据结构,提供简单且高效的面向对象编程。Python的学习过程少不了IDE或者代码编辑器,或者集成的开发编辑器(IDE)。这些Python开发工具帮助开发者加快使用Python开发的速度,提高效率。高效的代码编辑器或者IDE应该会提供插件,工具等能帮助开发者高效开发的特性。1.VimVim可以说是Python最好的IDE。Vim是高级文本编辑器,旨在提供实际的Unix编辑器‘Vi’功能,支持更多更完善的特

还记得Windows7上的WindowsMovieMaker吗?自从停止WindowsMovieMaker以来,微软还没有推出任何真正的电影制作者。另一方面,他们尝试用一个小巧轻便的内置视频编辑器来改造照片应用程序。很长一段时间后,微软推出了Clipchamp,这是一款适用于所有Windows11设备的更好的视频处理器。在本文中,我们将深入探讨如何从Windows11设备上的Clipchamp应用程序中获取所有内容。如何使用Clipchamp–详细教程我们提供

USB端口是计算机中非常有用的连接选项之一,可帮助您将笔式驱动器或USB驱动器连接到PC并在几分钟内完成工作。这是来回传输数据的最佳方式之一,无需有效的互联网连接。但是,有时您可能会意识到系统上的USB端口被滥用。例如,任何人都可以未经授权访问您的PC、连接笔式驱动器并窃取数据。这就是为什么,您可能已经注意到在某些组织和教育机构中,禁止使用USB端口的全部原因。在这种情况下,管理员会阻止对USB端口的访问,因此任何尝试使用USB驱动器的人都无法这样做。因此,如果您想禁用Win


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
