<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Flagbit
 * @copyright  Copyright (c) 2009 Flagbit GmbH & Co. KG (http://www.flagbit.de)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
/* @var $this Flagbit_Faq_Block_Frontend_List */
?>
<div class="page-title">
	<h1><?php echo $this->__('FAQ overview'); ?></h1>
</div>

<?php if ($this->hasFaq()): ?>

<h2><?php echo $this->__('Questions'); ?></h2>
<?php if ($this->getCategoryCollection()) : ?>
<dl class="faq-list">
    <?php foreach ($this->getCategoryCollection() as $category) : ?>
        <dt><?php echo $this->htmlEscape($category->getName()); ?></dt><dd><ul class="faq-list">
        <?php foreach ($this->getItemCollectionByCategory($category) as $item) : ?>
            <li>
                <a href="#faq-item-<?php echo $item->getId() ?>">
                    <?php echo $this->htmlEscape($item->getQuestion()); ?>
                </a>
            </li>
        <?php endforeach; ?>
        </ul></dd>
    <?php endforeach; ?>
</dl>
<?php else : ?>
<ul class="faq-list">
    <?php foreach ($this->getFaqCollection() as $faqItem): ?>
    <li>
        <a href="#faq-item-<?php echo $faqItem->getId() ?>">
            <?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
        </a>
    </li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

<h2><?php echo $this->__('Answers'); ?></h2>
<dl class="faq-items">
	<?php foreach ($this->getFaqCollection() as $faqItem): ?>
	<dt id="faq-item-<?php echo $faqItem->getId() ?>">
		<?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
	</dt>
	<dd>
		<?php echo ($faqItem->getAnswerHtml() ? $faqItem->getAnswer() : '<p>' . implode('</p><p>', explode("\n", $this->htmlEscape($faqItem->getAnswer()))) . '</p>') ?>
	</dd>
	<?php endforeach; ?>
</dl>
<?php else: ?>
<p class="faq-items"><?php echo $this->__('There are no FAQ items at the moment.') ?></p>
<?php endif; ?>
