<?php
/*
* Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* \brief CKEditor class that can be used to create editor
* instances in PHP pages on server side.
* @see http://ckeditor.com
*
* Sample usage:
* @code
* $CKEditor = new CKEditor();
* $CKEditor->editor("editor1", "<p>Initial value.</p>");
* @endcode
*/
class CKEditor
{
/**
* The version of %CKEditor.
* \private
*/
var $version = '3.6.2';
/**
* A constant string unique for each release of %CKEditor.
* \private
*/
var $_timestamp = 'B8DJ5M3';
/**
* URL to the %CKEditor installation directory (absolute or relative to document root).
* If not set, CKEditor will try to guess it's path.
*
* Example usage:
* @code
* $CKEditor->basePath = '/ckeditor/';
* @endcode
*/
var $basePath;
/**
* An array that holds the global %CKEditor configuration.
* For the list of available options, see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
*
* Example usage:
* @code
* $CKEditor->config['height'] = 400;
* // Use @@ at the beggining of a string to ouput it without surrounding quotes.
* $CKEditor->config['width'] = '@@screen.width * 0.8';
* @endcode
*/
var $config = array();
/**
* A boolean variable indicating whether CKEditor has been initialized.
* Set it to true only if you have already included
* <script> tag loading ckeditor.js in your website.
*/
var $initialized = false;
/**
* Boolean variable indicating whether created code should be printed out or returned by a function.
*
* Example 1: get the code creating %CKEditor instance and print it on a page with the "echo" function.
* @code
* $CKEditor = new CKEditor();
* $CKEditor->returnOutput = true;
* $code = $CKEditor->editor("editor1", "<p>Initial value.</p>");
* echo "<p>Editor 1:</p>";
* echo $code;
* @endcode
*/
var $returnOutput = false;
/**
* An array with textarea attributes.
*
* When %CKEditor is created with the editor() method, a HTML <textarea> element is created,
* it will be displayed to anyone with JavaScript disabled or with incompatible browser.
*/
var $textareaAttributes = array( "rows" => 8, "cols" => 60 );
/**
* A string indicating the creation date of %CKEditor.
* Do not change it unless you want to force browsers to not use previously cached version of %CKEditor.
*/
var $timestamp = "B8DJ5M3";
/**
* An array that holds event listeners.
* \private
*/
var $_events = array();
/**
* An array that holds global event listeners.
* \private
*/
var $_globalEvents = array();
/**
* Main Constructor.
*
* @param $basePath (string) URL to the %CKEditor installation directory (optional).
*/
function CKEditor($basePath = null) {
if (!empty($basePath)) {
$this->basePath = $basePath;
}
}
/**
* Creates a %CKEditor instance.
* In incompatible browsers %CKEditor will downgrade to plain HTML <textarea> element.
*
* @param $name (string) Name of the %CKEditor instance (this will be also the "name" attribute of textarea element).
* @param $value (string) Initial value (optional).
* @param $config (array) The specific configurations to apply to this editor instance (optional).
* @param $events (array) Event listeners for this editor instance (optional).
*
* Example usage:
* @code
* $CKEditor = new CKEditor();
* $CKEditor->editor("field1", "<p>Initial value.</p>");
* @endcode
*
* Advanced example:
* @code
* $CKEditor = new CKEditor();
* $config = array();
* $config['toolbar'] = array(
* array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
* array( 'Image', 'Link', 'Unlink', 'Anchor' )
* );
* $events['instanceReady'] = 'function (ev) {
* alert("Loaded: " + ev.editor.name);
* }';
* $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events);
* @endcode
*/
function editor($name, $value = "", $config = array(), $events = array())
{
$attr = "";
foreach ($this->textareaAttributes as $key => $val) {
$attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"';
}
$out = "<textarea name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value) . "</textarea>\n";
if (!$this->initialized) {
$out .= $this->init();
}
$_config = $this->configSettings($config, $events);
$js = $this->returnGlobalEvents();
if (!empty($_config))
$js .= "CKEDITOR.replace('".$name."', ".$this->jsEncode($_config).");";
else
$js .= "CKEDITOR.replace('".$name."');";
$out .= $this->script($js);
if (!$this->returnOutput) {
print $out;
$out = "";
}
return $out;
}
/**
* Replaces a <textarea> with a %CKEditor instance.
*
* @param $id (string) The id or name of textarea element.
* @param $config (array) The specific configurations to apply to this editor instance (optional).
* @param $events (array) Event listeners for this editor instance (optional).
*
* Example 1: adding %CKEditor to <textarea name="article"></textarea> element:
* @code
* $CKEditor = new CKEditor();
* $CKEditor->replace("article");
* @endcode
*/
function replace($id, $config = array(), $events = array())
{
$out = "";
if (!$this->initialized) {
$out .= $this->init();
}
$_config = $this->configSettings($config, $events);
$js = $this->returnGlobalEvents();
if (!empty($_config)) {
$js .= "CKEDITOR.replace('".$id."', ".$this->jsEncode($_config).");";
}
else {
$js .= "CKEDITOR.replace('".$id."');";
}
$out .= $this->script($js);
if (!$this->returnOutput) {
print $out;
$out = "";
}
return $out;
}
/**
* Replace all <textarea> elements available in the document with editor instances.
*
* @param $className (string) If set, replace all textareas with class className in the page.
*
* Example 1: replace all <textarea> elements in the page.
* @code
* $CKEditor = new CKEditor();
* $CKEditor->replaceAll();
* @endcode
*
* Example 2: replace all <textarea class="myClassName"> elements in the page.
* @code
* $CKEditor = new CKEditor();
* $CKEditor->replaceAll( 'myClassName' );
* @endcode
*/
function replaceAll($className = null)
{
$out = "";
if (!$this->initialized) {
$out .= $this->init();
}
$_config = $this->configSettings();
$js = $this->returnGlobalEvents();
if (empty($_config)) {
if (empty($className)) {
$js .= "CKEDITOR.replaceAll();";
}
else {
$js .= "CKEDITOR.replaceAll('".$className."');";
}
}
else {
$classDetection = "";
$js .= "CKEDITOR.replaceAll( function(textarea, config) {\n";
if (!empty($className)) {
$js .= " var classRegex = new RegExp('(?:^| )' + '". $className ."' + '(?:$| )');\n";
$js .= " if (!classRegex.test(textarea.className))\n";
$js .= " return false;\n";
}
$js .= " CKEDITOR.tools.extend(config, ". $this->jsEncode($_config) .", true);";
$js .= "} );";
}
$out .= $this->script($js);
if (!$this->returnOutput) {
print $out;
$out = "";
}
return $out;
}
/**
* Adds event listener.
* Events are fired by %CKEditor in various situations.
*
* @param $event (string) Event name.
* @param $javascriptCode (string) Javascript anonymous function or function name.
*
* Example usage:
* @code
* $CKEditor->addEventHandler('instanceReady', 'function (ev) {
* alert("Loaded: " + ev.editor.name);
* }');
* @endcode
*/
function addEventHandler($event, $javascriptCode)
{
if (!isset($this->_events[$event])) {
$this->_events[$event] = array();
}
// Avoid duplicates.
i
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于PHP、MySQL等技术构建的web系统,框架,PHP学习,课程设计作业,可用于毕业设计,源码项目,可直接运行,实测! 基于PHP、MySQL等技术构建的web系统,框架,PHP学习,课程设计作业,可用于毕业设计,源码项目,可直接运行,实测! 基于PHP、MySQL等技术构建的web系统,框架,PHP学习,课程设计作业,可用于毕业设计,源码项目,可直接运行,实测!
资源推荐
资源详情
资源评论
收起资源包目录
毕设项目:基于bootstrap+PHP+MySQL的个人博客系统(源码+数据库).zip (972个子文件)
ckeditor.asp 30KB
events.asp 4KB
advanced.asp 3KB
replaceall.asp 3KB
replace.asp 2KB
standalone.asp 2KB
sample_posteddata.asp 1KB
run.bat 270B
bootstrap.css 134KB
bootstrap.min.css 111KB
editor.css 35KB
editor.css 31KB
editor.css 30KB
dialog.css 22KB
style.css 21KB
bootstrap-theme.css 21KB
dialog.css 20KB
dialog.css 19KB
bootstrap-theme.min.css 19KB
dialog.css 18KB
dialog.css 16KB
dialog.css 15KB
toolbar.css 13KB
toolbar.css 10KB
toolbar.css 10KB
richcombo.css 8KB
richcombo.css 7KB
default.css 7KB
icons.css 7KB
richcombo.css 7KB
icons.css 7KB
icons.css 6KB
menu.css 6KB
menu.css 5KB
menu.css 5KB
datepicker.css 4KB
mainui.css 4KB
panel.css 4KB
panel.css 4KB
datepicker.css 4KB
panel.css 4KB
css.css 3KB
mainui.css 3KB
yui.css 3KB
mainui.css 3KB
yui.css 3KB
sample.css 2KB
output_xhtml.css 2KB
templates.css 2KB
style.css 2KB
templates.css 2KB
invalid.css 2KB
templates.css 2KB
reset.css 2KB
style.css 2KB
reset.css 2KB
reset.css 2KB
templates.css 2KB
templates.css 1KB
templates.css 1KB
elementspath.css 1KB
gdt-style.css 1KB
toolbar.css 1KB
elementspath.css 1KB
elementspath.css 1KB
wsc.css 1KB
toolbar.css 1KB
reset.css 1KB
wsc.css 1004B
presets.css 908B
presets.css 888B
parsesample.css 876B
presets.css 866B
style.css 691B
style.css 601B
editor.css 574B
editor.css 562B
contents.css 559B
editor.css 558B
WdatePicker.css 158B
Thumbs.db 77KB
Thumbs.db 77KB
Thumbs.db 76KB
Thumbs.db 6KB
glyphicons-halflings-regular.eot 20KB
output_for_flash.fla 84KB
login_04.gif 72KB
bg-sidebar.gif 32KB
bg-body.gif 21KB
bg-radial-gradient.gif 17KB
login1.gif 13KB
login2.gif 13KB
bg-login.gif 13KB
main_01.gif 11KB
login_11.gif 9KB
login4.gif 7KB
login3.gif 7KB
login_06.gif 5KB
jquery.wysiwyg.gif 4KB
login_10.gif 4KB
共 972 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
- m0_684320712023-12-25资源内容总结的很到位,内容详实,很受用,学到了~
白话机器学习
- 粉丝: 1w+
- 资源: 7650
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 造价咨询薪酬管理办法.doc
- 中铁三局集团第二工程有限公司项目薪酬实施办法.doc
- 2025健康管理师三级专业能力考试题及答案.docx
- 2025健康素养知识竞赛题库(含答案).docx
- 2025交管12123驾驶证学法减分(学法免分)测试题及答案.docx
- 造价咨询公司绩效提成方案 (1).docx
- 造价咨询公司绩效提成方案.docx
- 工程造价咨询从业人员绩效考核制度.docx
- 造价咨询公司(咨询工作室)绩效提成方案-2018修订版 (1).docx
- 2025交管12123学法减分考试试题库及答案(通用版).docx
- 2025交管12123学法减分题库大全(附答案).docx
- 2025教师资格证结构化面试题库及答案.docx
- 2025教师招聘义务教育道德与法治课程方案(2022版)必考题库及答案.docx
- 2025教师资格证考试《教育知识与能力》知识点大全.docx
- 2025教育学公共基础知识考试题库及答案(通用版).docx
- 2025京东pop售前客服认证考试题及答案.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功