[ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // $Id: formdhtmltextarea.php 758 2006-09-24 21:41:09Z phppp $ 3 // ------------------------------------------------------------------------ // 4 // XOOPS - PHP Content Management System // 5 // Copyright (c) 2000 XOOPS.org // 6 // <http://www.xoops.org/> // 7 // ------------------------------------------------------------------------ // 8 // This program is free software; you can redistribute it and/or modify // 9 // it under the terms of the GNU General Public License as published by // 10 // the Free Software Foundation; either version 2 of the License, or // 11 // (at your option) any later version. // 12 // // 13 // You may not change or alter any portion of this comment or credits // 14 // of supporting developers from this source code or any supporting // 15 // source code which is considered copyrighted (c) material of the // 16 // original comment or credit authors. // 17 // // 18 // This program is distributed in the hope that it will be useful, // 19 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 21 // GNU General Public License for more details. // 22 // // 23 // You should have received a copy of the GNU General Public License // 24 // along with this program; if not, write to the Free Software // 25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 26 // ------------------------------------------------------------------------ // 27 // Author: Kazumi Ono (AKA onokazu) // 28 // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // 29 // Project: The XOOPS Project // 30 // ------------------------------------------------------------------------- // 31 if (!defined('XOOPS_ROOT_PATH')) { 32 die("XOOPS root path not defined"); 33 } 34 /** 35 * 36 * 37 * @package kernel 38 * @subpackage form 39 * 40 * @author Kazumi Ono <onokazu@xoops.org> 41 * @copyright copyright (c) 2000-2003 XOOPS.org 42 */ 43 /** 44 * base class 45 */ 46 include_once XOOPS_ROOT_PATH."/class/xoopsform/formtextarea.php"; 47 48 // Make sure you have included /include/xoopscodes.php, otherwise DHTML will not work properly! 49 50 /** 51 * A textarea with xoopsish formatting and smilie buttons 52 * 53 * @author Kazumi Ono <onokazu@xoops.org> 54 * @copyright copyright (c) 2000-2003 XOOPS.org 55 * 56 * @package kernel 57 * @subpackage form 58 */ 59 class XoopsFormDhtmlTextArea extends XoopsFormTextArea { 60 /** 61 * Extended HTML editor definition 62 * 63 * Set this property value if you want the editor to delegate rendering to an external class. 64 * 65 * Note: this functionality is experimental, but feedback is welcome. 66 * Note: the PM window doesn't use XoopsFormDhtmlTextArea, so no need to report it doesn't work here 67 * 68 * array( 'bundleId' ): For XOS components (2.3+) 69 * array( 'className', 'classPath' ): To create an instance of "className", declared in the file XOOPS_ROOT_PATH . $classPath 70 * 71 * Example: 72 * $htmlEditor = array( 'XoopsFormTinyeditorTextArea', '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php' ); 73 */ 74 var $htmlEditor = array(); 75 76 /** 77 * Hidden text 78 * @var string 79 * @access private 80 */ 81 var $_hiddenText; 82 83 /** 84 * Constructor 85 * 86 * @param string $caption Caption 87 * @param string $name "name" attribute 88 * @param string $value Initial text 89 * @param int $rows Number of rows 90 * @param int $cols Number of columns 91 * @param string $hiddentext Hidden Text 92 */ 93 function XoopsFormDhtmlTextArea($caption, $name, $value, $rows=5, $cols=50, $hiddentext="xoopsHiddenText", $options = array() ) 94 { 95 $this->XoopsFormTextArea($caption, $name, $value, $rows, $cols); 96 $this->_hiddenText = $hiddentext; 97 98 if ( !empty( $this->htmlEditor ) ) { 99 $options['name'] = $this->_name; 100 $options['value'] = $this->_value; 101 102 if ( count( $this->htmlEditor ) == 1 ) { 103 $this->htmlEditor = XOS::create( $this->htmlEditor[0] ); 104 } else { 105 list( $class, $path ) = $this->htmlEditor; 106 include_once XOOPS_ROOT_PATH . $path; 107 if ( class_exists( $class ) ) { 108 $this->htmlEditor = new $class( $options ); 109 } else { 110 $this->htmlEditor = false; 111 } 112 } 113 } 114 } 115 116 /** 117 * Prepare HTML for output 118 * 119 * @return string HTML 120 */ 121 function render() 122 { 123 $editor = false; 124 if ( $this->htmlEditor && is_object( $this->htmlEditor ) ) { 125 if ( !isset( $this->htmlEditor->isEnabled ) || $this->htmlEditor->isEnabled ) { 126 $editor = true; 127 } 128 } 129 if ( $editor ) { 130 return $this->htmlEditor->render(); 131 } 132 133 $ret = "<a name='moresmiley'></a><img onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/url.gif' alt='url' onclick='xoopsCodeUrl(\"".$this->getName()."\", \"".htmlspecialchars(_ENTERURL, ENT_QUOTES)."\", \"".htmlspecialchars(_ENTERWEBTITLE, ENT_QUOTES)."\");' /> <img onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/email.gif' alt='email' onclick='javascript:xoopsCodeEmail(\"".$this->getName()."\", \"".htmlspecialchars(_ENTEREMAIL, ENT_QUOTES)."\");' /> <img onclick='javascript:xoopsCodeImg(\"".$this->getName()."\", \"".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=".$this->getName()."\",\"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(\"".$this->getName()."\", \"".htmlspecialchars(_ENTERCODE, ENT_QUOTES)."\");' /> <img onclick='javascript:xoopsCodeQuote(\"".$this->getName()."\", \"".htmlspecialchars(_ENTERQUOTE, ENT_QUOTES)."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/quote.gif' alt='quote' /><br />\n"; 134 135 $sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"); 136 $ret .= "<select id='".$this->getName()."Size' onchange='setVisible(\"".$this->_hiddenText."\");setElementSize(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n"; 137 $ret .= "<option value='SIZE'>"._SIZE."</option>\n"; 138 foreach ( $sizearray as $size ) { 139 $ret .= "<option value='$size'>$size</option>\n"; 140 } 141 $ret .= "</select>\n"; 142 $fontarray = array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana"); 143 $ret .= "<select id='".$this->getName()."Font' onchange='setVisible(\"".$this->_hiddenText."\");setElementFont(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n"; 144 $ret .= "<option value='FONT'>"._FONT."</option>\n"; 145 foreach ( $fontarray as $font ) { 146 $ret .= "<option value='$font'>$font</option>\n"; 147 } 148 $ret .= "</select>\n"; 149 $colorarray = array("00", "33", "66", "99", "CC", "FF"); 150 $ret .= "<select id='".$this->getName()."Color' onchange='setVisible(\"".$this->_hiddenText."\");setElementColor(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n"; 151 $ret .= "<option value='COLOR'>"._COLOR."</option>\n"; 152 foreach ( $colorarray as $color1 ) { 153 foreach ( $colorarray as $color2 ) { 154 foreach ( $colorarray as $color3 ) { 155 $ret .= "<option value='".$color1.$color2.$color3."' style='background-color:#".$color1.$color2.$color3.";color:#".$color1.$color2.$color3.";'>#".$color1.$color2.$color3."</option>\n"; 156 } 157 } 158 } 159 $ret .= "</select><span id='".$this->_hiddenText."'>"._EXAMPLE."</span>\n"; 160 $ret .= "<br />\n"; 161 $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='".$this->getName()."Addtext' size='20' /> <input type='button' onclick='xoopsCodeText(\"".$this->getName()."\", \"".$this->_hiddenText."\", \"".htmlspecialchars(_ENTERTEXTBOX, ENT_QUOTES)."\")' class='formButton' value='"._ADD."' /><br /><br /><textarea id='".$this->getName()."' name='".$this->getName()."' onselect=\"xoopsSavePosition('".$this->getName()."');\" onclick=\"xoopsSavePosition('".$this->getName()."');\" onkeyup=\"xoopsSavePosition('".$this->getName()."');\" cols='".$this->getCols()."' rows='".$this->getRows()."'".$this->getExtra().">".$this->getValue()."</textarea><br />\n"; 162 $ret .= $this->_renderSmileys(); 163 return $ret; 164 } 165 166 function renderValidationJS() { 167 if ( $this->htmlEditor && is_object( $this->htmlEditor ) && method_exists( $this->htmlEditor, "renderValidationJS" ) ) { 168 if ( !isset( $this->htmlEditor->isEnabled ) || $this->htmlEditor->isEnabled ) { 169 return $this->htmlEditor->renderValidationJS(); 170 } 171 } 172 return ''; 173 } 174 175 /** 176 * prepare HTML for output of the smiley list. 177 * 178 * @return string HTML 179 */ 180 function _renderSmileys() 181 { 182 $myts =& MyTextSanitizer::getInstance(); 183 $smiles =& $myts->getSmileys(); 184 $ret = ''; 185 if (empty($smiles)) { 186 $db =& Database::getInstance(); 187 if ($result = $db->query('SELECT * FROM '.$db->prefix('smiles').' WHERE display=1')) { 188 while ($smiles = $db->fetchArray($result)) { 189 $ret .= "<img onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" ".$smiles['code']." \");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_UPLOAD_URL."/".htmlspecialchars($smiles['smile_url'], ENT_QUOTES)."' alt='' />"; 190 } 191 } 192 } else { 193 $count = count($smiles); 194 for ($i = 0; $i < $count; $i++) { 195 if ($smiles[$i]['display'] == 1) { 196 $ret .= "<img onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" ".$smiles[$i]['code']." \");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_UPLOAD_URL."/".$myts->oopsHtmlSpecialChars($smiles[$i]['smile_url'])."' border='0' alt='' />"; 197 } 198 } 199 } 200 $ret .= " [<a href='#moresmiley' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&type=smilies&target=".$this->getName()."\",\"smilies\",300,475);'>"._MORE."</a>]"; 201 return $ret; 202 } 203 } 204 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |