<?php
// $Id: commentform.inc.php,v 1.1 2004/07/11 10:27:44 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
// ------------------------------------------------------------------------- //

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

if ( !isset($submit_page) ) {
	$submit_page = _PHP_SELF;
}

echo "<table><tr><td><form action='postcomment.php' method='post' id='commentform' onsubmit='return xoopsValidate(\"subject\", \"message\", \"comment_submit\");'><br /><br /><b>". _YOURNAME .":</b>&nbsp;";

if ( $xoopsUser ) {
	echo "<a href='".XOOPS_URL."/userinfo.php?uid=".$xoopsUser->getVar("uid")."'>".$xoopsUser->getVar("uname")."</a>&nbsp;[&nbsp;<a href='".XOOPS_URL."/user.php?op=logout'>"._LOGOUT."</a>&nbsp;]";
	} else {
		echo "<b>".$xoopsConfig['anonymous']."</b>";
		echo " [ <a href='".XOOPS_URL."/register.php'>"._REGISTER."</a> ] ";
	}

echo "<br /><br /><b>". _SUBJECT ."</b><br />";

if ( !preg_match("/^re:/i", $subject) ) {
	$subject = "Re: ".substr($subject, 0, 56);
}

echo "<input type='text' class='text' id='subject' name='subject' size='50' maxlength='60' value='$subject' /><br /><br /><b>". _MESSAGEICON ."</b><table><tr align='left'><td>";

$lists    = new XoopsLists;
$filelist = $lists->getSubjectsList();

$count = 1;
while ( list ($key, $file) = each ($filelist) ) {
	$checked = "";
	if ( isset($icon) && $file == $icon ) {
		$checked = " checked='checked'";
	}
	echo "<input type='radio' class='radio' value='$file' name='icon'$checked />&nbsp;";
	echo "<img src='".XOOPS_URL."/images/subject/".$file."' border='0' alt='' />&nbsp;";
	if ( $count == 8 ) {
		echo "<br />";
		$count = 0;
	}
	$count++;
}

echo "</td></tr></table><br /><b>". _COMMENT ."</b><br /><br />";

$desc = new XoopsFormDhtmlTextArea("", "message", $message, 10, 50);
echo $desc->render();

echo "<br /><br />";

if ( $xoopsUser && !empty($xoopsConfig['allow_html']) ) {
	echo _ALLOWEDHTML."<br />";
	echo get_allowed_html();
	if ($allow_html == '0' || $HTTP_POST_VARS['allow_html'] == '0') {
		$option0 = " selected";
		} elseif ($allow_html == '2' || $HTTP_POST_VARS['allow_html'] == '2') {
			$option2 = " selected";
			} else {
				$option1 = " selected";
			}
	echo "<br /><br />
	<select class='select' name='allow_html'>
	<option value='0'$option0>"._HTMLOFF."</option>
	<option value='1'$option1>"._HTMLAUTOWRAP."</option>
	<option value='2'$option2>"._HTMLNOAUTOWRAP."</option>
	</select><br />";
	} else {
		echo "<input type='hidden' name='allow_html' value='0'>";
	}

echo "<input type='checkbox' class='checkbox' name='allow_smileys' value='1'";
if ( (!isset($allow_smileys) && !isPost()) || $allow_smileys == '1' || $HTTP_POST_VARS['allow_smileys'] == '1' ) {
	echo " checked='checked'";
}
echo " /> "._ENABLESMILEY."<br />";

// Enable bbcode?
echo "<input type='checkbox' class='checkbox' name='allow_bbcode' value='1'";
if ( (!isset($allow_bbcode) && !isPost()) || $allow_bbcode == '1' || $HTTP_POST_VARS['allow_bbcode'] == '1' ) {
	echo " checked='checked'";
}
echo " />&nbsp;"._ENABLEBBCODE."<br />";

if ( $xoopsUser && $xoopsConfig['anonpost'] ) {
	echo "<input type='checkbox' class='checkbox' name='noname'";
	if ( !empty($noname) ) {
		echo " checked='checked'";
	}
	echo " />"._POSTANON."<br />";
}

?>
<input type="hidden" name="pid" value="<?php echo intval($pid);?>" />
<input type="hidden" name="comment_id" value="<?php echo intval($comment_id);?>" />
<input type="hidden" name="item_id" value="<?php echo intval($item_id);?>" />
<input type="hidden" name="order" value="<?php echo intval($order);?>" />
<select class="select" name="op">
<option value="preview" selected="selected"><?php echo _PREVIEW;?></option>
<option value="post"><?php echo _POSTCOMMENT;?></option>
</select>
<input type="submit" class="button" value="<?php echo _GO;?>" name="comment_submit" id="comment_submit" />
</form>
</td></tr></table>
<?php

unset($submit_page);
?>
