<?php
// $Id: formdhtmltextarea.php,v 1.1 2004/07/11 10:27:19 Farsus Exp $
// -------------------------------------------------------------------------//
//			                 RUNCMS                                         //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //

if (!defined("EXOOPS_XOOPSFORMDHTMLTEXTAREA_INCLUDED")) {
	define("EXOOPS_XOOPSFORMDHTMLTEXTAREA_INCLUDED", 1);

include_once(XOOPS_ROOT_PATH."/class/xoopsform/formtextarea.php");

class XoopsFormDhtmlTextArea extends XoopsFormTextArea {

	function XoopsFormDhtmlTextArea($caption, $name, $value="", $rows=10, $cols=50) {
		$this->XoopsFormTextArea($caption, $name, $value, $rows, $cols);
	}

//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function render() {
global $myts, $xoopsUser;

include_once(XOOPS_ROOT_PATH."/class/xoopsform/formdhtmltextarea.js.php");

$admin = 0;
if ($xoopsUser && $xoopsUser->isAdmin()) {
	$admin = 1;
}

$ret  = "<a href='javascript:justReturn();'><img src='".XOOPS_URL."/images/editor/link.gif' alt='"._URL."' onclick='xoopsCodeUrl(\"".$this->getName()."\");' /></a>";
$ret .= " <a href='javascript:justReturn();'><img src='".XOOPS_URL."/images/editor/image.gif' alt='"._IMG."' onclick='xoopsCodeImg(\"".$this->getName()."\");' /></a>";

if ($admin || $myts->allowLibrary == 1) {
	$ret .= " <a href='javascript:justReturn();'><img src='".XOOPS_URL."/images/editor/image-m.gif' alt='"._LIB."' onclick='openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&type=images&target=".$this->getName()."\", \"images\", 350, 450);' /></a>";
}

$ret .= "
	<a href='javascript:justReturn();'><img src='".XOOPS_URL."/images/editor/email.gif' alt='"._EMAIL."' onclick='xoopsCodeEmail(\"".$this->getName()."\");' /></a>
	<a href='javascript:justReturn();'><img src='".XOOPS_URL."/images/editor/quote.gif' alt='"._QUOTE."' onclick='xoopsCodeQuote(\"".$this->getName()."\");' /></a>
	<a href='javascript:justReturn();'><img src='".XOOPS_URL."/images/editor/code.gif' alt='"._CODE."' onclick='xoopsCodeCode(\"".$this->getName()."\");' /></a>
	<br /><br />";

$ret .= "<select class='select' id='".$this->getName()."Size' onchange='setVisible(\"".$this->getName()."hiddenText\");setElementSize(\"".$this->getName()."hiddenText\",this.options[this.selectedIndex].value);'></a>";
$ret .= "<option value='SIZE'>"._SIZE."</option>";

$sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large");
foreach ($sizearray as $size) {
	$ret .=  "<option value='$size'>$size</option>";
}
$ret .= "</select> ";

$fontarray = array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana");
$ret      .= "<select class='select' id='".$this->getName()."Font' onchange='setVisible(\"".$this->getName()."hiddenText\");setElementFont(\"".$this->getName()."hiddenText\",this.options[this.selectedIndex].value);'>";
$ret      .= "<option value='FONT'>"._FONT."</option>";

foreach ($fontarray as $font) {
	$ret .= "<option value='$font'>$font</option>";
}
$ret .= "</select> ";

$ret .= "<select class='select' id='".$this->getName()."Color' onchange='setVisible(\"".$this->getName()."hiddenText\"); setElementColor(\"".$this->getName()."hiddenText\", this.options[this.selectedIndex].value);'>";
$ret .= "<option value='COLOR'>"._COLOR."</option>";

$colorarray = array("00", "33", "66", "99", "CC", "FF");
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>";
		}
	}
}

$ret .= "
	</select>
	<span id='".$this->getName()."hiddenText' style='visibility: hidden;'>"._EXAMPLE."</span>
	<br />
	<input type='checkbox' class='checkbox' id='".$this->getName()."Bold' onclick='setVisible(\"".$this->getName()."hiddenText\");makeBold(\"".$this->getName()."hiddenText\");' /><b>B</b>
	<input type='checkbox' class='checkbox' id='".$this->getName()."Italic' onclick='setVisible(\"".$this->getName()."hiddenText\");makeItalic(\"".$this->getName()."hiddenText\");' /><i>I</i>
	<input type='checkbox' class='checkbox' id='".$this->getName()."Underline' onclick='setVisible(\"".$this->getName()."hiddenText\");makeUnderline(\"".$this->getName()."hiddenText\");' /><u>U</u>
	<input type='text' class='text' id='".$this->getName()."Addtext' size='20' />
	<input type='button' class='button' onclick='xoopsCodeText(\"".$this->getName()."\")' value='"._ADD."'>
	<br /><br />
	<textarea class='textarea' id='".$this->getName()."' name='".$this->getName()."' cols='".$this->getCols()."' rows='".$this->getRows()."'".$this->getExtra().">".$this->getValue()."</textarea>
	<br />";

$ret .= $this->renderSmileys();

return $ret;
}

//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function renderSmileys() {

$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 .= " [<a href='javascript:openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&amp;type=smilies&amp;target=".$this->getName()."\",\"smilies\", 300, 475);'>"._MORE."</a>]";

return $ret;
}

//---------------------------------------------------------------------------------------//
} // END CLASS
} // END DEFINED
?>
