<?php

/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Kbase
 * @copyright  Copyright (c) 2008-2010 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */

$item = Mage::app()->getLayout()->createBlock('kbase/list_item')
            ->setCategory($this->getCategory());
$blockId = 'kbase_'.$this->getBlockType();

?>
<div class="kbase kbase-<?php echo $this->getBlockType() ?>" >

    <?php echo $this->getChildHtml('kbase_header'); ?>
    <?php echo $this->getChildHtml('kbase_main_search'); ?>
    <?php echo $this->getChildHtml('kbase_breadcrumbs'); ?>

    <h2><?php echo htmlspecialchars($this->getTitle()) ?></h2>

    <?php if($this->_collection->getSize()): ?>
        <?php echo $this->getChildHtml('kbase_sorter'); ?>

        <table cellpadding="0" cellspacing="0" width="100%" class="kbase-listing" id="<?php echo $blockId ?>" >
                <col />
                <?php if($this->getRatingEnabled()): ?>
                    <col width="100px" align="center" />
                <?php endif; ?>
                <col width="100px" />
            <thead>
                <tr>
                    <th><?php echo $this->__('Article') ?></th>
                    <?php if($this->getRatingEnabled()): ?>
                        <th class="a-center"><?php echo $this->__('Rating') ?></th>
                    <?php endif; ?>
                    <th class="a-center"><?php echo $this->__('Date') ?></th>
                </tr>
            </thead>
            <tbody>
                <?php $even = true;
                    foreach($this->_collection->getItems() as $article): ?>
                    <?php echo $item->setArticle($article)->setEven($even = !$even)->toHtml(); ?>
                <?php endforeach; ?>
            </tbody>
        </table>

        <script type="text/javascript">
        //<![CDATA[
            initGrid('<?php echo $blockId ?>');
        //]]>
        </script>

        <?php echo $this->getChildHtml('kbase_pager'); ?>
    <?php else: ?>
        <p><?php echo $this->__('No articles found'); ?></p>
    <?php endif; ?>

</div>
