<?php 
/**
 * @category    Mana
 * @package     ManaPro_FilterRadios
 * @copyright   Copyright (c) http://www.manadev.com
 * @license     http://www.manadev.com/license  Proprietary License
 */
/** 
 * Template for showing options for filter as a list of radio buttons as a popup
 * @author Mana Team
 */
/* @var $this Mana_Filters_Block_Filter_Attribute */
/* @var $filters Mana_Filters_Helper_Data */ $filters = Mage::helper(strtolower('Mana_Filters'));
/* @var $showmore ManaPro_FilterShowMore_Helper_Data */ $showmore = Mage::helper(strtolower('ManaPro_FilterShowMore'));
/* @var $jsonHelper Mana_Core_Helper_Json */
$jsonHelper = Mage::helper('mana_core/json');
$MAX_ROW_COUNT = $showmore->getMaxRowCount(); // 20
$MAX_COLUMN_COUNT = $showmore->getMaxColumnCount(); // 4
$items = $this->getItems();
list($rowCount, $columnCount) = $showmore->getPopupDimensions($items, $MAX_ROW_COUNT, $MAX_COLUMN_COUNT);
?>
<div class="m-filter-popup">
<ol class="m-rows" data-max-rows="<?php echo $MAX_ROW_COUNT ?>">
    <?php for($rowIndex = 0; $rowIndex < $rowCount; $rowIndex++) : ?>
    <li>
        <ol class="m-columns">
            <?php for ($columnIndex = 0; $columnIndex < $columnCount; $columnIndex++) : if ($columnIndex * $rowCount + $rowIndex < count($items)) : ?>
            <?php $_item = $items[$columnIndex * $rowCount + $rowIndex]; ?>
            <li  <?php echo $this->getListItemClass($_item) ?> >
                <?php if (!$this->getFilterOptions()->getDisableNoResultOptions() || $_item->getCount() || $_item->getMSelected()): ?>
                    <input type="radio" id="popup_<?php echo $_item->getUniqueId($this) ?>"
                           name="popup_<?php echo $filters->getFilterName($this, $this->getFilter()) ?>"
                           value="<?php echo $_item->getSeoValue() ?>" <?php if ($_item->getMSelected()): ?>checked="checked"<?php endif; ?>
                           data-item="<?php echo $jsonHelper->encodeAttribute($_item->getSeoData()) ?>"
                           data-is-reverse="<?php echo $this->getFilterOptions()->getIsReverse() ?>"
                           data-index="<?php echo $columnIndex * $rowCount + $rowIndex ?>" />
                <label for="popup_<?php echo $_item->getUniqueId($this) ?>"><span <?php if ($_item->getMSelected()): ?>class="m-selected-radio-button"<?php endif; ?>
                            title="<?php echo $this->escapeHtml($_item->getLabel()) ?>"><?php echo $this->escapeHtml($_item->getLabel()) ?></span></label>
                <?php else: ?>
                    <input type="radio" id="<?php echo $_item->getUniqueId($this) ?>" name="<?php echo $filters->getFilterName($this, $this->getFilter()) ?>" value="<?php echo $_item->getValue() ?>" <?php if ($_item->getMShowSelected()): ?>checked="checked"<?php endif; ?>
                           disabled="disabled"/>
                    <label for="<?php echo $_item->getUniqueId($this) ?>"><span class="<?php if ($_item->getMShowSelected()): ?>m-selected-checkbox-item<?php endif; ?>"
                                                                                title="<?php echo $this->escapeHtml($_item->getLabel()) ?>"><?php echo $this->escapeHtml($_item->getLabel()) ?></span></label>
                <?php endif; ?>
                <?php if (Mage::getStoreConfigFlag('mana_filters/display/count')) : ?>
                    (<?php echo $_item->getCount() ?>)
                <?php endif; ?>
            </li>
            <?php endif; endfor; ?>
        </ol>
    </li>
    <?php endfor; ?>
</ol>
</div>
