<?php

/**
 *
 * @copyright  2010-2016 izend.org
 * @version    13
 * @link       http://www.izend.org
 */
?>
<?php require_once 'dateen.php'; ?>
<?php require_once 'bbcode.php'; ?>
<?php if ($comments or $newcomment or $user_page): ?>
<?php extract($errors); ?>
<div id="comments">
<h4<?php if (!$comments): ?> class="noprint"<?php endif; ?>>Comments</h4>
<?php if ($moderated or $newcomment): ?>
<form action="#pagemark" method="post">
<input type="hidden" name="comment_token" value="<?php echo $token; ?>" />
<?php endif; ?>
<?php if ($comments): ?>
<?php if ($id): ?>
<input name="comment_id" type="hidden" value="<?php echo $id; ?>" />
<?php endif; ?>
<?php
$i=1;
foreach ($comments as $c) {
	extract($c);	/* comment_id, comment_text, comment_user_name, comment_mail, comment_created */
?>
<?php if ($id and $comment_id == $id): ?>
<div id="pagemark"></div>
<div id="oldcomment" class="noprint">
<?php endif; ?>
<p class="headline"><span class="longdate"><?php echo longdate_en($comment_created); ?> at <?php echo date('H:i', $comment_created); ?></span>
<?php if ($moderated === true or (is_array($moderated) and in_array($comment_id, $moderated))): ?><input class="moderate noprint" name="comment_moderate" type="submit" value="<?php echo $comment_id; ?>" title="Edit" /><?php endif; ?>
<?php if (true): ?>
<?php if ($comment_user_name): ?><span class="signature"><span class="author"> by <?php if ($comment_user_website): ?><a href="http://<?php echo $comment_user_website; ?>" title="<?php echo $comment_user_website; ?>"><?php endif; ?><?php echo $comment_user_name; ?><?php if ($comment_user_website): ?></a><?php endif; ?></span>&nbsp;<?php if ($comment_user_website): ?><a href="http://<?php echo $comment_user_website; ?>"><?php endif; ?><img class="avatar noprint" src="/avatars/<?php echo $comment_user_name; ?>.png" alt="" title="<?php echo $comment_user_name; ?><?php if ($comment_user_website): ?> - <?php echo $comment_user_website; ?><?php endif; ?>" /><?php if ($comment_user_website): ?></a><?php endif; ?></span><?php endif; ?>
<?php else: ?>
<?php if ($comment_user_lastname): ?><span class="signature"><span class="author"> by <?php if ($comment_user_website): ?><a href="http://<?php echo $comment_user_website; ?>"><?php endif; ?><?php if ($comment_user_firstname): ?><?php echo $comment_user_firstname; ?> <?php endif; ?><?php echo $comment_user_lastname; ?><?php if ($comment_user_website): ?></a><?php endif; ?></span></span><?php endif; ?>
<?php endif; ?>
</p>
<?php if ($id and $comment_id == $id): ?>
<?php if (!($missing_message or $message_too_long)): ?>
<?php
if (!$message) {
	$message=$comment_text;
}
?>
<div class="comment_text">
<?php echo bbcode($message), PHP_EOL; ?>
</div>
<?php endif; ?>
<?php echo view('editcomment', 'en', compact('message', 'message_maxlen')); ?>
<p>
<input class="submit submit_modify" name="comment_modify" type="submit" value="Modify" />
the comment or
<input class="submit submit_delete" name="comment_delete" type="submit" value="Delete" />
it
</p>
</div>
<?php else: ?>
<div class="comment_text">
<?php echo bbcode($comment_text), PHP_EOL; ?>
</div>
<?php endif; ?>
<?php
	$i++;
}
?>
<?php endif; ?>
<?php if ($newcomment): ?>
<div id="pagemark"></div>
<div id="newcomment" class="noprint">
<h6>Your comment:</h6>
<?php if ($message and !$message_too_long): ?>
<div class="comment_text">
<?php echo bbcode($message), PHP_EOL; ?>
</div>
<?php endif; ?>
<?php echo view('editcomment', 'en', compact('message', 'message_maxlen')); ?>
<?php if ($message): ?>
<?php if ($with_mail): ?>
<p><input type="text" name="comment_mail" id="comment_mail" size="30" maxlength="100" title="Email" onkeypress="return submitonenter(event, 'comment_validate')" value="<?php echo htmlspecialchars($mail, ENT_COMPAT, 'UTF-8'); ?>" />
<p class="info<?php if ($missing_mail or $bad_mail): ?> inerror<?php endif; ?>">Enter your email address to validate your message.</p>
<?php endif; ?>
<?php if ($with_captcha): ?>
<p>
<img src="<?php echo $base_path; ?>/captcha/comment" alt="" height="40" title="Verification code" />
:
<input type="text" name="comment_code" id="comment_code" size="4" maxlength="4" title="4 letters" autocomplete="off" onkeypress="return submitonenter(event, 'comment_validate')" value="" />
</p>
<?php endif; ?>
<p>
<input class="submit submit_edit" name="comment_edit" type="submit" value="Edit" />
the text or
<input class="submit submit_validate" name="comment_validate" id="comment_validate" type="submit" value="Validate" />
it
</p>
<?php else: ?>
<p>
<input class="submit submit_comment" name="comment_comment" type="submit" value="Comment" />
</p>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($moderated or $newcomment): ?>
</form>
<?php if ($with_mail or $with_captcha): ?>
<div class="errors">
<?php if ($missing_code): ?>
<p>Enter the verification code displayed in the image.</p>
<?php elseif ($bad_code): ?>
<p>The verification code is incorrect.</p>
<?php endif; ?>
</div>
<?php
$focus=false;
if ($missing_code or $bad_code) {
	$focus='#comment_code';
}
else if ($missing_mail or $bad_mail) {
	$focus='#comment_mail';
}
?>
<?php if ($focus): ?>
<script type="text/javascript">
$(function() {$('<?php echo $focus; ?>').focus();});
</script>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($user_page): ?>
<p class="info noprint">To add a comment, <a href="<?php echo $user_page; ?>?r=<?php echo urlencode($node_url . '#pagemark'); ?>" rel="nofollow">click here</a>.</p>
<?php endif; ?>
</div>
<?php endif; ?>
