// // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // /** * Adapted FCKeditor * * @author phppp, http://xoops.org.cn * @copyright copyright (c) 2004 XOOPS.org * * @package XOOPS 2.2 * @subpackage form */ class XoopsFormFckeditor extends XoopsFormTextArea { var $rootpath = ""; var $language = _LANGCODE; var $filepath; var $upload; 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; } function setConfig($configs) { foreach($configs as $key=>$val){ $this->$key = $val; } } /** * get textarea width * * @return string */ function getWidth() { return $this->width; } /** * get textarea height * * @return string */ function getHeight() { return $this->height; } /** * get language * * @return string */ function getLanguage() { return str_replace('_','-',strtolower($this->language)); } /** * get allowed extensions for uploading * * @return string */ function getAllowedExtensions() { return $this->extensions; } /** * enable upload * * @return null */ function getUploadStatus() { return $this->upload; } /** * get file path * * @return null */ function getFilepath() { $check_func = ($this->getUploadStatus())? "is_writable":"is_readable"; return $check_func($this->filepath)? $this->filepath: false; } /** * prepare HTML for output * * @return sting HTML */ function render() { global $myts; $ret = ''; if ( is_readable(XOOPS_ROOT_PATH . $this->rootpath. "/fckeditor.php")) { include_once(XOOPS_ROOT_PATH . $this->rootpath. "/fckeditor.php"); $oFCKeditor=new FCKeditor($this->getName()); $oFCKeditor->BasePath = XOOPS_URL.$this->rootpath. "/"; $oFCKeditor->Width = $this->getWidth(); $oFCKeditor->Height = $this->getHeight(); $oFCKeditor->Value = $this->getValue(); if(is_readable(XOOPS_ROOT_PATH . $this->rootpath. '/editor/lang/'.$this->getLanguage().'.js')) { $oFCKeditor->Config['DefaultLanguage'] = $this->getLanguage(); $oFCKeditor->Config['AutoDetectLanguage'] = false; } if(defined("_XOOPS_EDITOR_FCKEDITOR_FONTLIST")){ $oFCKeditor->Config['FontNames'] = _XOOPS_EDITOR_FCKEDITOR_FONTLIST; } $oFCKeditor->Config['BaseHref'] = XOOPS_URL.$this->rootpath. "/"; $oFCKeditor->Config['CustomConfigurationsPath'] = $oFCKeditor->BasePath.'fckconfig-xoops.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(); } } ?>