📄 formfckeditor.php
字号:
<?php
/**
* FCKeditor adapter for XOOPS
*
* @copyright The XOOPS project http://www.xoops.org/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Taiwen Jiang (phppp or D.J.) <php_pp@hotmail.com>
* @since 4.00
* @version $Id$
* @package xoopseditor
*/
if (!defined("XOOPS_ROOT_PATH")) {
die("XOOPS root path not defined");
}
class XoopsFormFckeditor extends XoopsFormTextArea
{
var $rootpath = "";
var $language = _LANGCODE;
var $filepath;
var $upload = true;
var $extensions;
var $width = "100%";
var $height = "400px";
/**
* Constructor
*
* @param array $configs Editor Options
* @param binary $checkCompatible true - return false on failure
*/
function XoopsFormFckeditor($configs, $checkCompatible = false)
{
$current_path = __FILE__;
if ( DIRECTORY_SEPARATOR != "/" ) $current_path = str_replace( strpos( $current_path, "\\\\", 2 ) ? "\\\\" : DIRECTORY_SEPARATOR, "/", $current_path);
$this->rootpath = substr(dirname($current_path), strlen(XOOPS_ROOT_PATH));
if(is_array($configs)) foreach($configs as $key => $val){
${$key} = $val;
$this->$key = $val;
}
if($checkCompatible && !$this->isCompatible()) {
return false;
}
//$this->XoopsFormTextArea("", $name, $value);
$this->width= empty($width) ? $this->width : $width;
$this->height= empty($height) ? $this->height : $height;
$this->XoopsFormTextArea("", $name, $value, $rows, $cols);
}
/**
* get language
*
* @return string
*/
function getLanguage()
{
return str_replace('_','-',strtolower($this->language));
}
/**
* prepare HTML for output
*
* @return sting HTML
*/
function render()
{
global $myts;
$ret = '';
if ( @include_once(XOOPS_ROOT_PATH . $this->rootpath. "/fckeditor.php") ) {
$oFCKeditor = new FCKeditor($this->getName());
$oFCKeditor->BasePath = XOOPS_URL.$this->rootpath. "/";
$oFCKeditor->Width = $this->width;
$oFCKeditor->Height = $this->height;
//$conv_pattern = array("/>/i", "/</i", "/"/i", "/'/i"/* , "/(\015\012)|(\015)|(\012)|(\r\n)/" */);
//$conv_replace = array(">", "<", "\"", "'"/* , "<br />" */);
//$this->Value = preg_replace($conv_pattern, $conv_replace, $this->value);
$oFCKeditor->Value = $myts->undoHtmlSpecialChars($this->value);
//$oFCKeditor->Config['BaseHref'] = XOOPS_URL.$this->rootpath. "/";
if(is_readable(XOOPS_ROOT_PATH . $this->rootpath. '/editor/lang/'.$this->getLanguage().'.js')) {
$oFCKeditor->Config['DefaultLanguage'] = $this->getLanguage();
}
if(defined("_XOOPS_EDITOR_FCKEDITOR_FONTLIST")){
$oFCKeditor->Config['FontNames'] = _XOOPS_EDITOR_FCKEDITOR_FONTLIST;
}
if(!file_exists($config_file = XOOPS_ROOT_PATH."/cache/fckconfig.".$GLOBALS["xoopsModule"]->getVar("dirname").".js")) {
if ( $fp = fopen( $config_file , "wt" ) ) {
$fp_content = "/* FCKconfig module configuration */\n";
if(is_readable($config_mod = XOOPS_ROOT_PATH."/modules/".$GLOBALS["xoopsModule"]->getVar("dirname")."/fckeditor.config.js")) {
$fp_content .= "/* Loaded from module local config file */\n".implode("", file($config_mod))."\n\n";
}
if(is_readable(XOOPS_ROOT_PATH."/modules/".$GLOBALS["xoopsModule"]->getVar("dirname")."/fckeditor.connector.php")) {
$fp_content .= "var browser_path = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector=".XOOPS_URL."/modules/".$GLOBALS["xoopsModule"]->getVar("dirname")."/fckeditor.connector.php';\n";
$fp_content .= "FCKConfig.LinkBrowserURL = browser_path ;\n";
$fp_content .= "FCKConfig.ImageBrowserURL = browser_path + '&Type=Image';\n";
$fp_content .= "FCKConfig.FlashBrowserURL = browser_path + '&Type=Flash';\n\n";
}
if(is_readable(XOOPS_ROOT_PATH."/modules/".$GLOBALS["xoopsModule"]->getVar("dirname")."/fckeditor.upload.php")) {
$fp_content .= "var uploader_path = '".XOOPS_URL."/modules/".$GLOBALS["xoopsModule"]->getVar("dirname")."/fckeditor.upload.php';\n";
$fp_content .= "FCKConfig.LinkUploadURL = uploader_path;\n";
$fp_content .= "FCKConfig.ImageUploadURL = uploader_path + '?Type=Image';\n";
$fp_content .= "FCKConfig.FlashUploadURL = uploader_path + '?Type=Flash';\n\n";
}
if(empty($this->upload)) {
$fp_content .= "FCKConfig.LinkUpload = false;\n";
$fp_content .= "FCKConfig.ImageUpload = false;\n";
$fp_content .= "FCKConfig.FlashUpload = false;\n\n";
}
fwrite( $fp, $fp_content );
fclose( $fp );
} else {
xoops_error( "Cannot create fckeditor config file" );
}
}
if(is_readable($config_file = XOOPS_ROOT_PATH."/cache/fckconfig.".$GLOBALS["xoopsModule"]->getVar("dirname").".js")) {
$oFCKeditor->Config['CustomConfigurationsPath'] = XOOPS_URL . "/cache/fckconfig.".$GLOBALS["xoopsModule"]->getVar("dirname").".js";
}
//$oFCKeditor->SetVar('ToolbarSet', "Basic");
$ret = $oFCKeditor->CreateHtml();
}
return $ret;
}
/**
* Check if compatible
*
* @return
*/
function isCompatible()
{
if ( !is_readable(XOOPS_ROOT_PATH . $this->rootpath. "/fckeditor.php")) return false;
include_once(XOOPS_ROOT_PATH . $this->rootpath. "/fckeditor.php");
return FCKeditor::IsCompatible();
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -