<?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
 * @package     default_default
 * @copyright   Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * @methods
 *  getTitle() - string
 *  getSaveUrl() - string
 *  getSections() - array
 *  getForm() - html
 */
?>
<div class="content-header">
    <table cellspacing="0">
        <tr>
            <td><h3><?php echo Mage::helper('adminhtml')->__($this->getTitle()) ?></h3></td><td class="form-buttons"><?php echo $this->getSaveButtonHtml() ?></td>
         </tr>
    </table>
</div>
<form action="<?php echo $this->getSaveUrl() ?>" method="post" id="config_edit_form" enctype="multipart/form-data">
    <?php echo $this->getBlockHtml('formkey')?>

    <script type="text/javascript">
    function setCacheAction(id, button)
    {
        $(id).value = button.id;
        configForm.submit();
    }
    </script>

    <input type="hidden" id="catalog_action" name="catalog_action" value="" />
    <input type="hidden" id="jscss_action" name="jscss_action" value="" />

    <?php echo $this->getChildHtml('form') ?>
    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Catalog') ?></h4>
        </div>
        <fieldset id="catalog">
            <table cellspacing="0" class="form-list">
                <tbody>
                    <?php foreach ($this->getCatalogData() as $_item): ?>
                    <?php /* disable reindex buttons. functionality moved to index management*/?>
                    <?php if ($_item['buttons'][0]['name']!='clear_images_cache') continue;?>
                    <tr>
                        <td class="label"><label><?php echo $_item['label'] ?></label></td>
                        <td class="value">
                            <?php foreach ($_item['buttons'] as $_button): ?>
                                <?php $clickAction = "setCacheAction('catalog_action',this)"; ?>
                                <?php if (isset($_button['warning']) && $_button['warning']): ?>
                                    <?php $clickAction = "if (confirm('".addslashes($_button['warning'])."')) {{$clickAction}}"; ?>
                                <?php endif; ?>
                                <button <?php if (!isset($_button['disabled']) || !$_button['disabled']):?>onclick="<?php echo $clickAction; ?>"<?php endif; ?> id="<?php echo $_button['name'] ?>" type="button" class="scalable <?php if (isset($_button['disabled']) && $_button['disabled']):?>disabled<?php endif; ?>" style=""><span><span><span><?php echo $_button['action'] ?></span></span></span></button>
                                <?php if (isset($_button['comment'])): ?> <br /> <small><?php echo $_button['comment']; ?></small> <?php endif; ?>
                            <?php endforeach; ?>
                        </td>
                        <td><small>&nbsp;</small></td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </fieldset>
    </div>

    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('JavaScript/CSS') ?></h4>
        </div>

        <fieldset id="jscss">
            <table cellspacing="0" class="form-list">
                <tbody>
                    <tr>
                        <td class="label"><label><?php echo $this->__('JavaScript/CSS Cache') ?></label></td>
                        <td class="value">
                            <button onclick="setCacheAction('jscss_action', this)" id='jscss_action' type="button" class="scalable"><span><span><span><?php echo $this->__('Clear') ?></span></span></span></button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
    </div>
</form>
<script type="text/javascript">
    var configForm = new varienForm('config_edit_form');
</script>
