source: temp/test-xoops.ec-cube.net/html/class/xoopsform/formdhtmltextarea.php @ 405

Revision 405, 9.8 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: formdhtmltextarea.php,v 1.5 2006/05/01 02:37:26 onokazu Exp $
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/**
32 *
33 *
34 * @package     kernel
35 * @subpackage  form
36 *
37 * @author      Kazumi Ono  <[email protected]>
38 * @copyright   copyright (c) 2000-2003 XOOPS.org
39 */
40/**
41 * base class
42 */
43include_once XOOPS_ROOT_PATH."/class/xoopsform/formtextarea.php";
44
45// Make sure you have included /include/xoopscodes.php, otherwise DHTML will not work properly!
46
47/**
48 * A textarea with xoopsish formatting and smilie buttons
49 *
50 * @author  Kazumi Ono  <[email protected]>
51 * @copyright   copyright (c) 2000-2003 XOOPS.org
52 *
53 * @package     kernel
54 * @subpackage  form
55 */
56class XoopsFormDhtmlTextArea extends XoopsFormTextArea
57{
58    /**
59     * Hidden text
60     * @var string
61     * @access  private
62     */
63    var $_hiddenText;
64
65    /**
66     * Constructor
67     *
68     * @param   string  $caption    Caption
69     * @param   string  $name       "name" attribute
70     * @param   string  $value      Initial text
71     * @param   int     $rows       Number of rows
72     * @param   int     $cols       Number of columns
73     * @param   string  $hiddentext Hidden Text
74     */
75    function XoopsFormDhtmlTextArea($caption, $name, $value, $rows=5, $cols=50, $hiddentext="xoopsHiddenText")
76    {
77        $this->XoopsFormTextArea($caption, $name, $value, $rows, $cols);
78        $this->_hiddenText = $hiddentext;
79    }
80
81    /**
82     * Prepare HTML for output
83     *
84     * @return  string  HTML
85     */
86    function render()
87    {
88        $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)."\");' />&nbsp;<img onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/email.gif' alt='email' onclick='javascript:xoopsCodeEmail(\"".$this->getName()."\", \"".htmlspecialchars(_ENTEREMAIL, ENT_QUOTES)."\");' />&nbsp;<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' />&nbsp;<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' />&nbsp;<img src='".XOOPS_URL."/images/code.gif' onmouseover='style.cursor=\"hand\"' alt='code' onclick='javascript:xoopsCodeCode(\"".$this->getName()."\", \"".htmlspecialchars(_ENTERCODE, ENT_QUOTES)."\");' />&nbsp;<img onclick='javascript:xoopsCodeQuote(\"".$this->getName()."\", \"".htmlspecialchars(_ENTERQUOTE, ENT_QUOTES)."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/quote.gif' alt='quote' /><br />\n";
89
90        $sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large");
91        $ret .= "<select id='".$this->getName()."Size' onchange='setVisible(\"".$this->_hiddenText."\");setElementSize(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
92        $ret .= "<option value='SIZE'>"._SIZE."</option>\n";
93        foreach ( $sizearray as $size ) {
94            $ret .=  "<option value='$size'>$size</option>\n";
95        }
96        $ret .= "</select>\n";
97        $fontarray = array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana");
98        $ret .= "<select id='".$this->getName()."Font' onchange='setVisible(\"".$this->_hiddenText."\");setElementFont(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
99        $ret .= "<option value='FONT'>"._FONT."</option>\n";
100        foreach ( $fontarray as $font ) {
101            $ret .= "<option value='$font'>$font</option>\n";
102        }
103        $ret .= "</select>\n";
104        $colorarray = array("00", "33", "66", "99", "CC", "FF");
105        $ret .= "<select id='".$this->getName()."Color' onchange='setVisible(\"".$this->_hiddenText."\");setElementColor(\"".$this->_hiddenText."\",this.options[this.selectedIndex].value);'>\n";
106        $ret .= "<option value='COLOR'>"._COLOR."</option>\n";
107        foreach ( $colorarray as $color1 ) {
108            foreach ( $colorarray as $color2 ) {
109                foreach ( $colorarray as $color3 ) {
110                    $ret .= "<option value='".$color1.$color2.$color3."' style='background-color:#".$color1.$color2.$color3.";color:#".$color1.$color2.$color3.";'>#".$color1.$color2.$color3."</option>\n";
111                }
112            }
113        }
114        $ret .= "</select><span id='".$this->_hiddenText."'>"._EXAMPLE."</span>\n";
115        $ret .= "<br />\n";
116        $ret .= "<img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeBold(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/bold.gif' alt='bold' />&nbsp;<img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeItalic(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/italic.gif' alt='italic' />&nbsp;<img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeUnderline(\"".$this->_hiddenText."\");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_URL."/images/underline.gif' alt='underline' />&nbsp;<img onclick='javascript:setVisible(\"".$this->_hiddenText."\");makeLineThrough(\"".$this->_hiddenText."\");' src='".XOOPS_URL."/images/linethrough.gif' alt='linethrough' onmouseover='style.cursor=\"hand\"' />&nbsp;&nbsp;<input type='text' id='".$this->getName()."Addtext' size='20' />&nbsp;<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";
117        $ret .= $this->_renderSmileys();
118        return $ret;
119    }
120
121    /**
122     * prepare HTML for output of the smiley list.
123     *
124     * @return  string HTML
125     */
126    function _renderSmileys()
127    {
128        $myts =& MyTextSanitizer::getInstance();
129        $smiles = $myts->getSmileys();
130        $ret = '';
131        if (empty($smiles)) {
132            $db =& Database::getInstance();
133            if ($result = $db->query('SELECT * FROM '.$db->prefix('smiles').' WHERE display=1')) {
134                while ($smiles = $db->fetchArray($result)) {
135                    $ret .= "<img onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" ".$smiles['code']." \");' onmouseover='style.cursor=\"hand\"' src='".XOOPS_UPLOAD_URL."/".htmlspecialchars($smiles['smile_url'], ENT_QUOTES)."' alt='' />";
136                }
137            }
138        } else {
139            $count = count($smiles);
140            for ($i = 0; $i < $count; $i++) {
141                if ($smiles[$i]['display'] == 1) {
142                    $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='' />";
143                }
144            }
145        }
146        $ret .= "&nbsp;[<a href='#moresmiley' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&amp;type=smilies&amp;target=".$this->getName()."\",\"smilies\",300,475);'>"._MORE."</a>]";
147        return $ret;
148    }
149}
150?>
Note: See TracBrowser for help on using the repository browser.