📄 formdhtmltextarea.php
字号:
<?php
// $Id: formdhtmltextarea.php 1276 2008-01-26 06:31:31Z phppp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// 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 //
// ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu) //
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
if (!defined('XOOPS_ROOT_PATH')) {
die("XOOPS root path not defined");
}
/**
*
*
* @package kernel
* @subpackage form
*
* @author Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
*/
/**
* base class
*/
include_once XOOPS_ROOT_PATH."/class/xoopsform/formtextarea.php";
// Make sure you have included /include/xoopscodes.php, otherwise DHTML will not work properly!
/**
* A textarea with xoopsish formatting and smilie buttons
*
* @author Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
*
* @package kernel
* @subpackage form
*/
class XoopsFormDhtmlTextArea extends XoopsFormTextArea {
/**
* Extended HTML editor definition
*
* Set this property value if you want the editor to delegate rendering to an external class.
*
* Note: this functionality is experimental, but feedback is welcome.
* Note: the PM window doesn't use XoopsFormDhtmlTextArea, so no need to report it doesn't work here
*
* array( 'bundleId' ): For XOS components (2.3+)
* array( 'className', 'classPath' ): To create an instance of "className", declared in the file XOOPS_ROOT_PATH . $classPath
*
* Example:
* $htmlEditor = array( 'XoopsFormTinyeditorTextArea', '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php' );
*/
var $htmlEditor = array();
/**
* Hidden text
* @var string
* @access private
*/
var $_hiddenText;
/**
* Constructor
*
* @param string $caption Caption
* @param string $name "name" attribute
* @param string $value Initial text
* @param int $rows Number of rows
* @param int $cols Number of columns
* @param string $hiddentext Hidden Text
*/
function XoopsFormDhtmlTextArea($caption, $name, $value, $rows=5, $cols=50, $hiddentext="xoopsHiddenText", $options = array() )
{
$this->XoopsFormTextArea($caption, $name, $value, $rows, $cols);
$this->_hiddenText = $hiddentext;
if ( !empty( $this->htmlEditor ) ) {
$options['name'] = $this->_name;
$options['value'] = $this->_value;
if ( count( $this->htmlEditor ) == 1 ) {
$this->htmlEditor = XOS::create( $this->htmlEditor[0] );
} else {
list( $class, $path ) = $this->htmlEditor;
include_once XOOPS_ROOT_PATH . $path;
if ( class_exists( $class ) ) {
$this->htmlEditor = new $class( $options );
} else {
$this->htmlEditor = false;
}
}
}
}
/**
* Prepare HTML for output
*
* @return string HTML
*/
function render()
{
$editor = false;
if ( $this->htmlEditor && is_object( $this->htmlEditor ) ) {
if ( !isset( $this->htmlEditor->isEnabled ) || $this->htmlEditor->isEnabled ) {
$editor = true;
}
}
if ( $editor ) {
return $this->htmlEditor->render();
}
$ele_name = $this->getName();
$ret = "<a name='moresmiley'></a>".
"<img onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/url.gif' alt='url' onclick='xoopsCodeUrl(\"".$ele_name."\", \"".htmlspecialchars(_ENTERURL, ENT_QUOTES)."\", \"".htmlspecialchars(_ENTERWEBTITLE, ENT_QUOTES)."\");' /> ".
"<img onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/email.gif' alt='email' onclick='javascript:xoopsCodeEmail(\"".$ele_name."\", \"".htmlspecialchars(_ENTEREMAIL, ENT_QUOTES)."\");' /> ".
"<img onclick='javascript:xoopsCodeImg(\"".$ele_name."\", \"".htmlspecialchars(_ENTERIMGURL, ENT_QUOTES)."\", \"".htmlspecialchars(_ENTERIMGPOS, ENT_QUOTES)."\", \"".htmlspecialchars(_IMGPOSRORL, ENT_QUOTES)."\", \"".htmlspecialchars(_ERRORIMGPOS, ENT_QUOTES)."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/imgsrc.gif' alt='imgsrc' /> ".
"<img onmouseover='style.cursor=\"hand\"' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/imagemanager.php?target=".$ele_name."\",\"imgmanager\",400,430);' src='".XOOPS_URL."/images/image.gif' alt='image' /> ".
"<img src='".XOOPS_URL."/images/code.gif' onmouseover='style.cursor=\"hand\"' alt='code' onclick='javascript:xoopsCodeCode(\"".$ele_name."\", \"".htmlspecialchars(_ENTERCODE, ENT_QUOTES)."\");' /> ".
"<img onclick='javascript:xoopsCodeQuote(\"".$ele_name."\", \"".htmlspecialchars(_ENTERQUOTE, ENT_QUOTES)."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/quote.gif' alt='quote' /><br />\n";
$sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large");
$ret .= "<select id='".$ele_name."Size' onchange='setVisible(\"".$this->_hiddenText."\");setElementSize(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
$ret .= "<option value='SIZE'>"._SIZE."</option>\n";
foreach ( $sizearray as $size ) {
$ret .= "<option value='$size'>$size</option>\n";
}
$ret .= "</select>\n";
$fontarray = array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana");
$ret .= "<select id='".$ele_name."Font' onchange='setVisible(\"".$this->_hiddenText."\");setElementFont(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
$ret .= "<option value='FONT'>"._FONT."</option>\n";
foreach ( $fontarray as $font ) {
$ret .= "<option value='$font'>$font</option>\n";
}
$ret .= "</select>\n";
$colorarray = array("00", "33", "66", "99", "CC", "FF");
$ret .= "<select id='".$ele_name."Color' onchange='setVisible(\"".$this->_hiddenText."\");setElementColor(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
$ret .= "<option value='COLOR'>"._COLOR."</option>\n";
foreach ( $colorarray as $color1 ) {
foreach ( $colorarray as $color2 ) {
foreach ( $colorarray as $color3 ) {
$ret .= "<option value='".$color1.$color2.$color3."' style='background-color:#".$color1.$color2.$color3.";color:#".$color1.$color2.$color3.";'>#".$color1.$color2.$color3."</option>\n";
}
}
}
$ret .= "</select><span id='".$this->_hiddenText."'>"._EXAMPLE."</span>\n";
$ret .= "<br />\n";
$ret .= "<img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeBold(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/bold.gif' alt='bold' /> <img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeItalic(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/italic.gif' alt='italic' /> <img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeUnderline(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/underline.gif' alt='underline' /> <img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeLineThrough(\"".$this->_hiddenText."\");' src='".XOOPS_URL."/images/linethrough.gif' alt='linethrough' onmouseover='style.cursor=\"hand\"' /> <input type='text' id='".$ele_name."Addtext' size='20' /> <input type='button' onclick='xoopsCodeText(\"".$ele_name."\", \"".$this->_hiddenText."\", \"".htmlspecialchars(_ENTERTEXTBOX, ENT_QUOTES)."\")' class='formButton' value='"._ADD."' /><br /><br /><textarea id='".$ele_name."' name='".$ele_name."' onselect=\"xoopsSavePosition('".$ele_name."');\" onclick=\"xoopsSavePosition('".$ele_name."');\" onkeyup=\"xoopsSavePosition('".$ele_name."');\" cols='".$this->getCols()."' rows='".$this->getRows()."'".$this->getExtra().">".$this->getValue()."</textarea><br />\n";
$ret .= $this->_renderSmileys();
return $ret;
}
function renderValidationJS() {
if ( $this->htmlEditor && is_object( $this->htmlEditor ) && method_exists( $this->htmlEditor, "renderValidationJS" ) ) {
if ( !isset( $this->htmlEditor->isEnabled ) || $this->htmlEditor->isEnabled ) {
return $this->htmlEditor->renderValidationJS();
}
}
return '';
}
/**
* prepare HTML for output of the smiley list.
*
* @return string HTML
*/
function _renderSmileys()
{
$myts =& MyTextSanitizer::getInstance();
$smiles = $myts->getSmileys( false );
$ret = '';
$count = count($smiles);
$ele_name = $this->getName();
for ($i = 0; $i < $count; $i++) {
$ret .= "<img onclick='xoopsCodeSmilie(\"".$ele_name."\", \" ".$smiles[$i]['code']." \");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_UPLOAD_URL."/".htmlspecialchars($smiles[$i]['smile_url'], ENT_QUOTES)."' border='0' alt='' />";
}
$ret .= " [<a href='#moresmiley' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&type=smilies&target=".$ele_name."\",\"smilies\",300,475);'>"._MORE."</a>]";
return $ret;
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -