<?php $this->declareVars(array("messages"=>array(),
 "foundItems"=>array()))
?>

<h2>Comments</h2>

<?php foreach($this->messages as $message):?>
<div style="color:blue"><?php echo $message?></div>
<?php endforeach?>

<?php if ($this->foundItems):
    $this->comments = $this->foundItems;
?>
<p>found entries: <?php echo $this->paginator->getTotalItemCount()?></p>
<?php endif?>

<?php if ($this->paginator->getTotalItemCount()):?>
<table class="listtable">
 <tr>
  <th>From</th><th>Posted</th><th>Article</th><th colspan=2>Actions</th>
 </tr>
<?php foreach($this->comments as $comment):
 $relArticle = $comment->getArticle();
?>
 <tr>
  <td><?php echo MKLib_Utils::niceTruncate($this->escape($comment->getAuthorName()),10)?></td>
  <td><?php echo $this->commentDate($comment->getPosted())?></td>
  <td><?php echo $this->anchor($this->url(
        array("entry" => $relArticle->getTitleUrl()),
        "blogArticle"),MKLib_Utils::niceTruncate($relArticle->getTitle(),10))?></td>
  <td><?php echo $this->anchor($this->url(
        array("controller" => "comment",
            "action" => "edit",
            "itemId" => $comment->getId()),
        "blogAdminItemAction"),"Edit")?></td>
  <td><?php echo $this->anchor($this->url(
      array("controller" => "comment",
            "action" => "delete",
            "itemId" => $comment->getId()),
        "blogAdminItemAction"),"Delete")?></td>
 </tr>
<?php endforeach;?>
</table>

<!-- page navigator -->
<div style="text-align: center; margin:1em 0;">
<?php echo $this->paginationControl($this->paginator,null,null,array("mainUrl"=>$this->url()));?>
</div>
<!-- end of page navigator -->

<?php else:?>
No entries.
<?php endif;?>
