<?php
// ------------------------------------------------------------------------- //
//                XOOPS - PHP Content Management System                      //
//                       <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.                                      //
//                                                                           //
//  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 of File: 							     //
// Kazumi Ono (http://www.mywebaddons.com/ , http://www.myweb.ne.jp/)        //
// ------------------------------------------------------------------------- //
include_once(XOOPS_ROOT_PATH."/class/xoopsform/formtextarea.php");


// Make sure you have included /include/xoopscodes.php, otherwise DHTML will not work properly!

class XoopsFormDhtmlTextArea extends XoopsFormTextArea {

	function XoopsFormDhtmlTextArea($caption, $name, $values, $rows=5, $cols=50){
		$this->XoopsFormTextArea($caption, $name, $values, $rows, $cols);
	}

	function render(){
		$ret = "<input type='button' value='URL' onclick='xoopsCodeUrl(\"".$this->getName()."\");' /><input type='button' value='IMG' onclick='xoopsCodeImg(\"".$this->getName()."\");' /><input type='button' value='EMAIL' onclick='xoopsCodeEmail(\"".$this->getName()."\");' /><input type='button' value='QUOTE' onclick='xoopsCodeQuote(\"".$this->getName()."\");' /><br />\n";

		$sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large");
		$ret .= "<select id='".$this->getName()."Size' onchange='setVisible(\"hiddenText\");setElementSize(\"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='".$this->getName()."Font' onchange='setVisible(\"hiddenText\");setElementFont(\"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='".$this->getName()."Color' onchange='setVisible(\"hiddenText\");setElementColor(\"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='hiddenText'>"._EXAMPLE."</span>\n";
		$ret .= "<br />\n";
		$ret .= "<input type='checkbox' id='".$this->getName()."Bold' onclick='setVisible(\"hiddenText\");makeBold(\"hiddenText\");' /><b>B</b>&nbsp;<input type='checkbox' id='".$this->getName()."Italic' onclick='setVisible(\"hiddenText\");makeItalic(\"hiddenText\");' /><i>I</i>&nbsp;<input type='checkbox' id='".$this->getName()."Underline' onclick='setVisible(\"hiddenText\");makeUnderline(\"hiddenText\");' /><u>U</u>&nbsp;&nbsp;<input type='textbox' id='".$this->getName()."Addtext' size='20' />&nbsp;<input type='button' onclick='xoopsCodeText(\"".$this->getName()."\")' value='"._ADD."'><br /><br /><textarea id='".$this->getName()."' name='".$this->getName()."' wrap='virtual' cols='".$this->getCols()."' rows='".$this->getRows()."'".$this->getExtra().">".$this->getValue()."</textarea><br />\n";
		$ret .= $this->renderSmileys();
		return $ret;
	}

	function renderSmileys(){
		global $xoopsConfig;
		$ret = "";
		$smileyPath = "images/smilies";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" :-) \");'><img width='15' height='15' src='".XOOPS_URL."/".$smileyPath."/icon_smile.gif' border='0' alt=':-)' /></a>";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" :-( \");'><img width='15' height='15' src='".XOOPS_URL."/".$smileyPath."/icon_frown.gif' border='0' alt=':-(' /></a>";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" :-D \");'><img width='15' height='15' src='".XOOPS_URL."/".$smileyPath."/icon_biggrin.gif' border='0' alt=':-D' /></a>";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" ;-) \");'><img width='15' height='15' src='".XOOPS_URL."/".$smileyPath."/icon_wink.gif' border='0' alt=';-)' /></a>";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" :-o \");'><img width='15' height='15' src='".XOOPS_URL."/".$smileyPath."/icon_eek.gif' border='0' alt=':-o' /></a>";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" 8-) \");'><img width='15' height='15' src='".XOOPS_URL."/".$smileyPath."/icon_cool.gif' border='0' alt='8-)' /></a>";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" :-? \");'><img width='15' height='22' src='".XOOPS_URL."/".$smileyPath."/icon_confused.gif' border='0' alt=':-?' /></a>";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" :-P \");'><img width='15' height='15' src='".XOOPS_URL."/".$smileyPath."/icon_razz.gif' border='0' alt=':-P' /></a>";
		$ret .= "<a href='javascript: justReturn()' onclick='xoopsCodeSmilie(\"".$this->getName()."\", \" :-x \");'><img width='15' height='15' src='".XOOPS_URL."/".$smileyPath."/icon_mad.gif' border='0' alt=':-x' /></a>";
		$ret .= "&nbsp;[<a href='javascript:openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&amp;type=smilies&amp;target=".$this->getName()."\",\"smilies\",300,430);'>"._MORE."</a>]";
		return $ret;
	}
}
?>
