<?php
/** View Template: view one blog entry template
 *
 * @package koubel homepage
 * @author Miroslav Kubelik (koubel@volny.cz)
 * @copyright Copyright (c) 2007-2009 Miroslav Kubelik
 * @license http://opensource.org/licenses/gpl-license.php GNU GPL
 */
?>
<?php if(isset($this->messages)):foreach($this->messages as $message):?>
<div style="color:blue"><?php echo $message?></div>
<?php endforeach;endif?>

<div class="post">
<h2 style="margin-bottom:0"><?php echo $this->escape($this->article->getTitle())?></h2>

<p class="info"><span class="date"><?php echo $this->commentDate($this->article->getPosted(),"true")?></span> |
 <span class="author"><?php echo $this->escape($this->author->getUsername())?></span> |
 <?php echo $this->articleCategories($this->article->getCategories())?>
</p>

<?php echo $this->textRenderer($this->article)?>

<?php echo $this->articleRating($this->article,$this->voted)?>

<div style="text-align: right">
 <img style="border:none;position:relative;top:+3px" src="<?php echo MKLib_AppBaseUrl::getBaseUrl()?>/images/eyesmall.png" alt="viewpic" />
 <?php echo $this->article->getViewCount()?>x
</div>

<!-- navigation -->
<div class="navigation">
 <?php if ($this->previousArticle):?>
 <div class="previous">&laquo; <?php echo $this->anchor(
  $this->url(array("entry" => $this->previousArticle->getTitleUrl()),"blogArticle"),
  MKLib_Utils::niceTruncate($this->previousArticle->getTitle(),20),array("title"=>$this->previousArticle->getTitle()))?>
 </div>
 <?php endif;
  if ($this->nextArticle):
 ?>
 <div class="next"><?php echo $this->anchor(
  $this->url(array("entry" => $this->nextArticle->getTitleUrl()),"blogArticle"),
  MKLib_Utils::niceTruncate($this->nextArticle->getTitle(),20),array("title"=>$this->nextArticle->getTitle()))?>
  &raquo;
 </div>
 <?php endif?>
 <hr style="clear: both; height: 0; visibility: hidden;" />
</div>

<!-- trackbacks info block -->
<div style="margin-top:1em" class="info">
 <?php echo count($this->trackbacks)
 ." ".$this->trans("trackbacks",count($this->trackbacks))?>
  - <a href="<?php echo $this->trackBackUrl?>"><?php echo $this->trans("trackback url")?></a>
</div>

<!-- trackback list view -->
<a name="trackbacks"></a>
<div class="allComments">
<?php
 $commentCnt=0;
 foreach($this->trackbacks as $trackBack):
 $commentCnt++;
?>
 <a name="trackback<?php echo $commentCnt?>"></a>
 <div class="commentHeader">
  <?php echo "$commentCnt."?>&nbsp;&nbsp;
  <?php echo $this->trackBackHeadUrl($trackBack)." - ".$this->commentDate($trackBack->getPosted())?>
 </div>
 <div class="commentBody">[&#8230;] <?php echo $this->commentBody($trackBack->getExcerpt())?> [&#8230;]</div>
<?php endforeach;?>
</div>

<!-- comments info block -->
<div style="margin-top:1em" class="info">
 <?php echo count($this->comments)
 ." ".$this->trans("comments",count($this->comments))." - ".$this->anchor("#AddComment",$this->trans("Add comment"))?>
</div>

<!-- comments list view -->
<a name="comments"></a>
<div class="allComments">
<?php 
 $commentCnt=0; 
 foreach($this->comments as $comment):
 $commentCnt++;
?>
 <a name="comment<?php echo $commentCnt?>"></a>
 <div class="commentHeader">
  <?php echo "$commentCnt."?>&nbsp;&nbsp;
  <?php
$authorWWW = $comment->getAuthorWWW();$authorName = $comment->getAuthorName();
echo (empty($authorWWW) ? $this->escape($authorName) : $this->anchor($authorWWW,$authorName))
   . " - " . $this->commentDate($comment->getPosted())
  ?>
 </div>
 <div class="commentBody"><?php echo $this->commentBody($comment->getMessage())?></div>
<?php endforeach;?>
</div>

<a name="AddComment"></a>
<?php echo $this->commentForm?>

<div class="commentBody" id="commentPreview" style="margin-top:0.5em"></div>
</div>

<?php echo $this->trackbackRDF?>

<script type="text/javascript">

/**
 * make ajax preview for a comment
 */
function commentPreview()
{
  var ajax = new sack();
	ajax.setVar("message",document.getElementById("message").value); // recomended method of setting data to be parsed.
	ajax.requestFile = baseurl+"/blog/action/comment-preview";
	ajax.method = "POST";
	ajax.element = 'commentPreview';
	ajax.onLoading = function(){ ajaxWhenLoading('commentPreview') };
	ajax.onLoaded = ajax.onLoading;
	ajax.onInteractive = ajax.onLoading;
	ajax.runAJAX();
}
</script>
