Home Backend Development PHP Tutorial fckeditor download FCKeditor adds custom button

fckeditor download FCKeditor adds custom button

Jul 29, 2016 am 08:37 AM

在FCKeditor目录里的fckconfig.js打开,找到FCKConfig.ToolbarSets["Default"] 这里的设置是配置功能按钮的,你需要的留下,不需要的可以删掉,也可以注释掉。

如需要多种配置,可以设置多个FCKConfig.ToolbarSets["你自己命个名name"] 后面跟配置详情。在引用编辑器的时候,以PHP为例:把fckeditor.php复制一个命名fckeditor1.php,在这里可以改配置。($this->ToolbarSet= '你自己命的名name' ;)

复制代码 代码如下:


include("editor/fckeditor1.php") ;//这里调用
$oFCKeditor = new FCKeditor('FormContent') ;//实例化
$oFCKeditor->BasePath = 'editor/';//这个路径一定要和上面那个引入路径一致,否则会报错:找不到fckeditor.html页面
//$oFCKeditor->Value = '' ; 
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '300' ;
$oFCKeditor->Create() ;
?>


下面是其他网友的补充,很详细,也可以参考下:
FCKeditor是一款非常流行的WEB可视化编辑器,其程序的的成熟度也非常高、功能丰富,但是再丰富也无法完全满足我们的实际要求,有时我们还是需要增加一些自己的功能。但FCKeditor的程序结构还是比较复杂的,对JS不是很了解的人很难对其灵活定制,本文就如何为FCKeditor的工具条增加一个打开我的像册的自定义按钮做一介绍。
先看看效果:
增加按钮有以下几步:
1、为按钮增加图片:
  FCK的所有按钮图片是存放在一个图片文件里的,这一点比较独特,文件存放在相应皮肤目录下,如:/FCK/skins/silever/fck_strip.gif。通过Fireworks或Phtoshop打开该文件可以发现一个很长的图片,里面包含所有按钮的图片,现在您可以在该图片的最下面增加您自定义的按钮,注意,每个按钮的尺寸是16*16px。
2、为按钮增加功能代码:
  增加按钮需要对FCK/editor/js目录中的两个核心文件进行修改:fckeditorcode_gecko.js和fckeditorcode_ie.js,前者是使用于gecko核心的浏览器如Firefox等,而后者应用于以IE为核心的浏览器如MyIE(傲游)等,这两个文件大体是相似的,仅有微小差别,在此我们基本无须担心。
  修改的方法非常简单,基本是一个照葫芦画瓢的过程,首先我们找一个与我们将要添加的按钮功能相似的一个按钮,这里我们选择了Newpage,这是一个清空编辑器以备新建一个文件的按钮。首先我们修改fckeditorcode_ie.js,fckeditorcode_gecko.js直接复制更改的代码就可以了。
  打开fckeditorcode_ie.js,这里需要说明的是,fckeditorcode_ie.js是多个文件合并经过代码优化的(即去掉了大部分换行、空格、注释等)不是很容易阅读,而且这样一百多K的JS文件用Dreamweaver、ZDE等工具打开后CPU立刻升至100%,相信计算机就变成痴呆一样了,经过一翻比较,发现曾被我认为一文不值的Golive竟然可以轻松打开该文件并快速编辑!不管你用什么软件反正能打开并编辑就行了。以关键词Newpage进行查找,你会发现一个按钮的功能定义分三大部分:
A、功能原型
  // 按钮功能原型
  var FCKNewPageCommand=function(){this.Name='NewPage';};
  FCKNewPageCommand.prototype.Execute=function(){FCKUndo.SaveUndoStep();FCK.SetHTML('');FCKUndo.Typing=true;};
  FCKNewPageCommand.prototype.GetState=function(){return FCK_TRISTATE_OFF;};
  var FCKMyAlbumCommand=function(){this.Name='DISPLAY: none';};
  FCKMyAlbumCommand.prototype.Execute=function(){if(typeof(parent.showMyAlbum)=="function"){parent.showMyAlbum(FCK);}else{alert(FCKLang.NoAlbum);}};
  FCKMyAlbumCommand.prototype.GetState=function(){return FCK_TRISTATE_OFF;};
B、功能的实例化
  case 'NewPage':B=new FCKNewPageCommand();break;
  case 'MyAlbum':B=new FCKMyAlbumCommand();break;
C、按钮的显示
  case 'NewPage':B=new FCKToolbarButton('NewPage',FCKLang.NewPage,null,null,true,null,4);break;
  case 'MyAlbum':B=new FCKToolbarButton('MyAlbum',FCKLang.MyAlbum,null,null,true,null,67);break;
  上面代码中第一部分是Newpage的原代码,后一部分是我们自定义的代码,您一看应该明白怎么回事了吧?仅红色部分和名称不同而已!而红色部分就是我们的自定义功能。
  FCKLang是语言包对象,您只要打开FCK/editor/lang/下面的相应语言包添加相应的名称属性就可以了,比如:MyAlbum打开我的像册。注意大小写!至此我们的添加工作已完成。

The above introduces how to download fckeditor and add custom buttons to FCKeditor, including the content of fckeditor download. I hope it will be helpful to friends who are interested in PHP tutorials.

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)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months 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)

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,

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

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.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

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�...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

See all articles