<?php
/**
 * @version $Id: modal.php 5112 2012-11-08 23:59:29Z btowles $
 * @author RocketTheme, LLC http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */

// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');

$function	= JFactory::getApplication()->input->getWord('function', 'selectMacro');
$listOrder	= $this->escape($this->state->get('list.ordering'));
$listDirn	= $this->escape($this->state->get('list.direction'));
?>
<form action="<?php echo JRoute::_('index.php?option=com_rokcandy&view=candymacros&layout=modal&tmpl=component&function='.$function);?>" method="post" name="adminForm" id="adminForm">
	<fieldset class="filter clearfix">
		<div class="left">
			<label for="filter_search">
				<?php echo JText::_('JSEARCH_FILTER_LABEL'); ?>
			</label>
			<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" size="100" title="<?php echo JText::_('COM_CONTENT_FILTER_SEARCH_DESC'); ?>" style="width: 75%;" />

			<button type="submit">
				<?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
			<button type="button" onclick="document.id('filter_search').value='';this.form.submit();">
				<?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?></button>
		</div>
	</fieldset>

	<table class="adminlist">
		<thead>
			<tr>
				<th width="40%">
					<?php echo JHtml::_('grid.sort', 'Shortcode', 'a.macro', $listDirn, $listOrder); ?>
				</th>
				<th>
					<?php echo JHtml::_('grid.sort',  'Html', 'a.html', $listDirn, $listOrder); ?>
				</th>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="15">
					<?php echo $this->pagination->getListFooter(); ?>
				</td>
			</tr>
		</tfoot>
		<tbody>
		<?php foreach ($this->items as $i => $item) : ?>
			<tr class="row<?php echo $i % 2; ?>">
				<td>
					<a class="pointer" onclick="if (window.parent) window.parent.<?php echo $this->escape($function);?>('<?php echo $this->escape(addslashes($item->macro)); ?>');">
					<?php echo $this->escape($item->macro); ?></a>
				</td>
				<td>
					<?php echo $this->escape($item->html); ?>
				</td>
			</tr>
			<?php endforeach; ?>

        <?php if ((count($this->overrides) > 0) && ($this->showOverrides)): ?>
        <?php $i=0; $i++; $n=0;?>
            <?php foreach ($this->overrides as $macro=>$html) : ?>
                <tr class="<?php echo $i % 2; ?>">
                    <td class="macro">
                        <a class="pointer" onclick="if (window.parent) window.parent.<?php echo $this->escape($function);?>('<?php echo $this->escape(addslashes($macro)); ?>');">
                        <?php echo $macro; ?>
                    </td></a>
                    <td><?php echo htmlentities($html); ?></td>
                    <td align="center" class="macro">Template Overrides</td>
                    <td align="center"><?php echo "t-".$n++; ?>
                </tr>
            <?php endforeach;?>
        <?php endif; ?>

		</tbody>
	</table>

	<div>
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
		<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
		<?php echo JHtml::_('form.token'); ?>
	</div>
</form>
