<?php

/**

 * SEF component for Joomla!

 * 

 * @package   JoomSEF

 * @version   3.11.0

 * @author    ARTIO s.r.o., http://www.artio.net

 * @copyright Copyright (C) 2013 ARTIO s.r.o. 

 * @license   GNU/GPLv3 http://www.artio.net/license/gnu-general-public-license

 */

 

// Check to ensure this file is included in Joomla!

defined('_JEXEC') or die('Restricted access');



$sefConfig =& SEFConfig::getConfig();

if ($sefConfig->useCache) {

    require(JPATH_ROOT.DS.'components'.DS.'com_sef'.DS.'sef.cache.php');

    $cache =& sefCache::getInstance();

}

?>

<form action="index.php" method="post" name="adminForm" id="adminForm">



<script type="text/javascript">

<!--

function useRE(el1, el2)

{

    if( !el1 || !el2 ) {

        return;

    }

    

    if( el1.checked && el2.value.substr(0, 4) != 'reg:' ) {

        el2.value = 'reg:' + el2.value;

    }

    else if( !el1.checked && el2.value.substr(0,4) == 'reg:' ) {

        el2.value = el2.value.substr(4);

    }

}



function handleKeyDown(e)

{

    var code;

    code = e.keyCode;

    

    if (code == 13) {

        // Enter pressed

        document.adminForm.submit();

        return false;

    }

    

    return true;

}



function resetFilters()

{

    document.adminForm.filterHitsCmp.value = '0';

    document.adminForm.filterHitsVal.value = '';

    document.adminForm.filterItemid.value = '';

    document.adminForm.filterSEF.value = '';

    document.adminForm.filterReal.value = '';

    document.adminForm.comFilter.value = '';

    <?php if( SEFTools::JoomFishInstalled() ) { ?>

    document.adminForm.filterLang.value = '';

    <?php } ?>

    

    document.adminForm.submit();

}



function doAction()

{

    var sel = document.getElementById('sef_selection').value;

    var action = document.getElementById('sef_actions').value;

    

    if (action == 'sep') {

        return;

    }

    

    if (sel == 'selected') {

        // Check that there is at least one URL selected

        if (document.adminForm.boxchecked.value == 0) {

            alert('<?php echo JText::_('Please make a selection from the list'); ?>');

            return;

        }

    }

    

    // If trash or delete, show warning

    if (action == 'trash') {

        if (!confirm('<?php echo JText::_('Are you sure you want to trash selected URLs? The associated aliases, meta tags and internal links will be preserved.'); ?>')) {

            return;

        }

    }

    else if (action == 'delete') {

        if (!confirm('<?php echo JText::_('Are you sure you want to completely delete selected URLs? The associated aliases, meta tags and internal links will also be deleted.'); ?>')) {

            return;

        }

    }

    

    // Call the action

    document.adminForm.selection.value = sel;

    submitbutton(action);

}

-->

</script>



<?php require('navigation.php'); ?>



<div class="current">

<fieldset>

    <legend><?php echo JText::_('Filters'); ?></legend>

<table>

    <tr>

        <td width="100%" valign="bottom">

        </td>

        <td nowrap="nowrap" align="right">

            <?php

            echo JText::_('Hits') . ':';

            ?>

        </td>

        <?php if( $this->viewmode != _COM_SEF_VIEWMODE_404 ) { ?>

        <td nowrap="nowrap" align="right">

            <?php

            echo JText::_('ItemID') . ':';

            ?>

        </td>

        <?php } ?>

        <td nowrap="nowrap">

            <?php echo $this->lists['filterSEFRE']; ?>

        </td>

        <td nowrap="nowrap" align="right">

            <?php

            echo (($this->viewmode == _COM_SEF_VIEWMODE_404) ? JText::_('Filter Urls') : JText::_('Filter SEF Urls')) . ':';

            ?>

        </td>

        <?php if( $this->viewmode != _COM_SEF_VIEWMODE_404 ) { ?>

        <td nowrap="nowrap">

            <?php echo $this->lists['filterRealRE']; ?>

        </td>

        <td nowrap="nowrap" align="right">

            <?php

            echo JText::_('Filter Real Urls') . ':';

            ?>

        </td>

        <?php } ?>

        <td nowrap="nowrap" align="right">

            <?php

            echo JText::_('Component') . ':';

            ?>

        </td>

        <?php if (SEFTools::JoomFishInstalled() && ($this->viewmode != _COM_SEF_VIEWMODE_404)) { ?>

        <td nowrap="nowrap" align="right">

            <?php

            echo JText::_('Language') . ':';

            ?>

        </td>

        <?php } ?>

        <td></td>

    </tr>

    <tr>

        <td></td>

        <td nowrap="nowrap">

            <?php echo $this->lists['hitsCmp'] . $this->lists['hitsVal']; ?>

        </td>

        <?php if ($this->viewmode != _COM_SEF_VIEWMODE_404) { ?>

        <td>

            <?php echo $this->lists['itemid']; ?>

        </td>

        <?php } ?>

        <td colspan="2">

            <?php echo $this->lists['filterSEF']; ?>

        </td>

        <?php if ($this->viewmode != _COM_SEF_VIEWMODE_404) { ?>

        <td colspan="2">

            <?php echo $this->lists['filterReal']; ?>

        </td>

        <?php } ?>

        <td>

            <?php echo $this->lists['comList']; ?>

        </td>

        <?php if (SEFTools::JoomFishInstalled() && ($this->viewmode != _COM_SEF_VIEWMODE_404)) { ?>

        <td>

            <?php echo $this->lists['filterLang']; ?>

        </td>

        <?php } ?>

        <td>

            <?php echo $this->lists['filterReset']; ?>

        </td>

    </tr>

</table>

<?php

// Links to homepage

if ($this->viewmode == _COM_SEF_VIEWMODE_HOMEPAGE) { ?>

<table width="100%">

    <tr>

        <td nowrap="nowrap" align="right">

        <input type="button" value="<?php echo JText::_('Create links to homepage'); ?>" onclick="submitbutton('createlinks');" />

        </td>

    </tr>

</table>

<?php } ?>

</fieldset>



<table class="adminlist">

<thead>

    <tr>

        <th width="5">

            <?php echo JText::_('Num'); ?>

        </th>

        <th width="20">

            <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />

        </th>

        <th class="title" width="40px">

            <?php echo JHTML::_('grid.sort', JText::_('Hits'), 'cpt', $this->lists['filter_order'] == 'cpt' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']); ?>

        </th>

        <th class="title">

            <?php

            if ($this->viewmode == _COM_SEF_VIEWMODE_404) {

                echo JHTML::_('grid.sort', JText::_('Date Added'), 'dateadd', $this->lists['filter_order'] == 'dateadd' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']);

            } else {

                echo JHTML::_('grid.sort', JText::_('SEF Url'), 'sefurl', $this->lists['filter_order'] == 'sefurl' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']);

            }

            ?>

        </th>

        <th class="title">

            <?php

            if ($this->viewmode == _COM_SEF_VIEWMODE_404) {

                echo JHTML::_('grid.sort', JText::_('Url'), 'sefurl', $this->lists['filter_order'] == 'sefurl' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']);

            } else {

                echo JHTML::_('grid.sort', JText::_('Real Url'), 'origurl', $this->lists['filter_order'] == 'origurl' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']);

            }

            ?>

        </th>

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

        <th class="title" width="40px">

	        <?php echo JText::_('Trace'); ?>

        </th>

		<?php endif; ?>        

		<?php if ($this->viewmode != _COM_SEF_VIEWMODE_404) : ?>

		<th class="title" width="55px">

		    <?php echo JHTML::_('grid.sort', JText::_('Enabled'), 'enabled', $this->lists['filter_order'] == 'enabled' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']); ?>

        </th>

		<th class="title" width="50px">

		    <?php echo JHTML::_('grid.sort', JText::_('SEF'), 'sef', $this->lists['filter_order'] == 'sef' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']); ?>

        </th>

		<th class="title" width="50px">

        	<?php echo JHTML::_('grid.sort', JText::_('Locked'), 'locked', $this->lists['filter_order'] == 'locked' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']); ?>

        </th>

		<th class="title" width="50px">

        	<?php echo JHTML::_('grid.sort', JText::_('Active'), 'priority', $this->lists['filter_order'] == 'priority' ? $this->lists['filter_order_Dir'] : 'desc', $this->lists['filter_order']); ?>

        </th>

        <?php if ($sefConfig->useCache) : ?>

		<th class="title" width="50px">

        	<?php echo JText::_('Cached'); ?>

        </th>

		<?php endif; ?>

        <th class="title">

            <?php echo JText::_('COM_SEF_HOST'); ?>

        </th>

		<?php endif; ?>

    </tr>

</thead>

<?php

	$colspan = 5;

	if ($this->viewmode != _COM_SEF_VIEWMODE_404) {

	    $colspan += 5;

	    if ($sefConfig->useCache) $colspan++;

	}

	if ($this->trace )$colspan++;

?>

<tfoot>

    <tr>

        <td colspan="<?php echo $colspan; ?>">

            <?php echo $this->pagination->getListFooter(); ?>

        </td>

    </tr>

</tfoot>

<tbody>

    <?php

    $k = 0;

    //for ($i=0, $n=count( $rows ); $i < $n; $i++) {

    foreach (array_keys($this->items) as $i) {

        $row = &$this->items[$i];

        ?>

        <tr class="<?php echo 'row'. $k; ?>">

            <td align="center">

                <?php echo $this->pagination->getRowOffset($i); ?>

            </td>

            <td>

                <?php echo JHTML::_('grid.id', $i, $row->id ); ?>

            </td>

            <td>

                <?php echo $row->cpt; ?>

            </td>

            <td style="text-align:left;">

                <?php if ($this->viewmode == _COM_SEF_VIEWMODE_404) {

                    echo $row->dateadd;

                } else if ($this->viewmode == _COM_SEF_VIEWMODE_TRASH) {

                    echo htmlspecialchars(strlen($row->sefurl) ? $row->sefurl : '('.JText::_('COM_SEF_HOMEPAGE').')');

                } else { ?>

                    <div id="sef_sefurl_<?php echo $row->id; ?>">

                        <div id="sef_sefurl_<?php echo $row->id; ?>_txt">

                            <span class="editlinktip hasTip" title="<?php echo JText::_('COM_SEF_AJAX_EDIT_SEFURL'); ?>">

                                <a href="javascript:void(0)" onclick="JoomSEF.ajaxEditSefurl('<?php echo $row->id; ?>');">

                                    <img src="<?php echo JUri::base(true); ?>/components/com_sef/assets/images/icon-16-edit2.png" border="0" alt="<?php echo JText::_('COM_SEF_AJAX_EDIT_SEFURL'); ?>" />

                                </a>

                            </span>

    	                    <a href="javascript:void(0);" id="sef_sefurl_<?php echo $row->id; ?>_spn" onclick="return listItemTask('cb<?php echo $i;?>', 'edit')">

    	                       <?php echo strlen($row->sefurl) ? htmlspecialchars($row->sefurl) : '('.JText::_('COM_SEF_HOMEPAGE').')';?>

    	                    </a>

                        </div>

                        <div id="sef_sefurl_<?php echo $row->id; ?>_edit" style="display: none;">

                            <span class="editlinktip hasTip" title="<?php echo JText::_('COM_SEF_AJAX_EDIT_CANCEL'); ?>">

                                <a href="javascript:void(0)" onclick="JoomSEF.ajaxShowElement('sef_sefurl_<?php echo $row->id; ?>', 'txt');">

                                    <img src="<?php echo JUri::base(true); ?>/components/com_sef/assets/images/icon-16-cancel.png" border="0" alt="<?php echo JText::_('COM_SEF_AJAX_EDIT_CANCEL'); ?>" />

                                </a>

                            </span>

                            <span class="editlinktip hasTip" title="<?php echo JText::_('COM_SEF_AJAX_EDIT_SAVE'); ?>">

                                <a href="javascript:void(0)" onclick="JoomSEF.ajaxSaveSefurl('<?php echo $row->id; ?>');">

                                    <img src="<?php echo JUri::base(true); ?>/components/com_sef/assets/images/icon-16-apply.png" border="0" alt="<?php echo JText::_('COM_SEF_AJAX_EDIT_SAVE'); ?>" />

                                </a>

                            </span>

                            <input type="text" size="70" id="sef_sefurl_<?php echo $row->id; ?>_url" value="" />

                        </div>

                        <?php

                        echo $this->getAjaxWorking('sefurl_'.$row->id);

                        ?>

                    </div>

                <?php } ?>

            </td>

            <td style="text-align:left;">

                <?php if ($this->viewmode == _COM_SEF_VIEWMODE_404 ) { ?>

                    <a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i;?>', 'edit')">

                    <?php echo $row->sefurl; ?>

                    </a>

                <?php

                    } else if ($this->viewmode == _COM_SEF_VIEWMODE_TRASH) {

                        echo htmlspecialchars($row->origurl . ($row->Itemid == '' ? '' : (strpos($row->origurl, '?') ? '&' : '?') . 'Itemid='.$row->Itemid));

                    } else {

                    ?>

                    <div id="sef_origurl_<?php echo $row->id; ?>">

                        <div id="sef_origurl_<?php echo $row->id; ?>_txt">

                            <span class="editlinktip hasTip" title="<?php echo JText::_('COM_SEF_AJAX_EDIT_ORIGURL'); ?>">

                                <a href="javascript:void(0)" onclick="JoomSEF.ajaxEditOrigurl('<?php echo $row->id; ?>');">

                                    <img src="<?php echo JUri::base(true); ?>/components/com_sef/assets/images/icon-16-edit2.png" border="0" alt="<?php echo JText::_('COM_SEF_AJAX_EDIT_ORIGURL'); ?>" />

                                </a>

                            </span>

                            <span id="sef_origurl_<?php echo $row->id; ?>_spn"><?php echo htmlspecialchars($row->origurl . ($row->Itemid == '' ? '' : (strpos($row->origurl, '?') ? '&' : '?') . 'Itemid='.$row->Itemid)); ?></span>

                        </div>

                        <div id="sef_origurl_<?php echo $row->id; ?>_edit" style="display: none;">

                            <span class="editlinktip hasTip" title="<?php echo JText::_('COM_SEF_AJAX_EDIT_CANCEL'); ?>">

                                <a href="javascript:void(0)" onclick="JoomSEF.ajaxShowElement('sef_origurl_<?php echo $row->id; ?>', 'txt');">

                                    <img src="<?php echo JUri::base(true); ?>/components/com_sef/assets/images/icon-16-cancel.png" border="0" alt="<?php echo JText::_('COM_SEF_AJAX_EDIT_CANCEL'); ?>" />

                                </a>

                            </span>

                            <span class="editlinktip hasTip" title="<?php echo JText::_('COM_SEF_AJAX_EDIT_SAVE'); ?>">

                                <a href="javascript:void(0)" onclick="JoomSEF.ajaxSaveOrigurl('<?php echo $row->id; ?>');">

                                    <img src="<?php echo JUri::base(true); ?>/components/com_sef/assets/images/icon-16-apply.png" border="0" alt="<?php echo JText::_('COM_SEF_AJAX_EDIT_SAVE'); ?>" />

                                </a>

                            </span>

                            <input type="text" size="70" id="sef_origurl_<?php echo $row->id; ?>_url" value="" />

                            &amp;Itemid=<input type="text" size="5" id="sef_origurl_<?php echo $row->id; ?>_itemid" value="" />

                        </div>

                        <?php

                        echo $this->getAjaxWorking('origurl_'.$row->id);

                        ?>

                    </div>

                    <?php

                } ?>

            </td>

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

            <td style="text-align: center;">

            	<?php echo JHTML::_('tooltip', nl2br($row->trace), JText::_('Trace Information'));?>

            </td>

            <?php endif; ?>

            <?php

            if( $this->viewmode != _COM_SEF_VIEWMODE_404 ) {

                ?>

                <td style="text-align: center;">

                    <?php

                    if ($this->viewmode == _COM_SEF_VIEWMODE_TRASH) {

                        if ($row->enabled) {

                            echo '<img src="images/tick.png" border="0" alt="'.JText::_('COM_SEF_ENABLED').'" />';

                        }

                        else {

                            echo '<img src="images/publish_x.png" border="0" alt="'.JText::_('COM_SEF_DISABLED').'" />';

                        }

                    }

                    else {

                        ?>

                        <div id="sef_enabled_<?php echo $row->id; ?>">

                            <?php

                            echo $this->getAjaxField('enabled', $row->id, '1', 'disable', JText::_('COM_SEF_DISABLE').'::'.JText::_('COM_SEF_TT_DISABLED_URL'), 'administrator/images/tick.png', JText::_('COM_SEF_ENABLED'), $row->enabled);

                            echo $this->getAjaxField('enabled', $row->id, '0', 'enable', JText::_('COM_SEF_ENABLE').'::'.JText::_('COM_SEF_TT_ENABLED_URL'), 'administrator/images/publish_x.png', JText::_('COM_SEF_DISABLED'), !$row->enabled);

                            echo $this->getAjaxWorking('enabled_'.$row->id);

                            ?>

                        </div>

                        <?php

                    }

                    ?>

                </td>

                <td style="text-align: center;">

                    <?php

                    if ($this->viewmode == _COM_SEF_VIEWMODE_TRASH) {

                        if ($row->sef) {

                            echo '<img src="images/tick.png" border="0" alt="'.JText::_('COM_SEF_SEF').'" />';

                        }

                        else {

                            echo '<img src="images/publish_x.png" border="0" alt="'.JText::_('COM_SEF_DONT_SEF').'" />';

                        }

                    }

                    else {

                        ?>

                        <div id="sef_sef_<?php echo $row->id; ?>">

                            <?php

                            echo $this->getAjaxField('sef', $row->id, '1', 'sefdisable', JText::_('COM_SEF_DONT_SEF').'::'.JText::_('COM_SEF_TT_SEF_REAL_URL'), 'administrator/images/tick.png', JText::_('COM_SEF_SEF'), $row->sef);

                            echo $this->getAjaxField('sef', $row->id, '0', 'sefenable', JText::_('COM_SEF_SEF').'::'.JText::_('COM_SEF_TT_SEF_SEF_URL'), 'administrator/images/publish_x.png', JText::_('COM_SEF_DONT_SEF'), !$row->sef);

                            echo $this->getAjaxWorking('sef_'.$row->id);

                            ?>

                        </div>

                        <?php

                    }

                    ?>

                </td>

                <td style="text-align: center;">

                    <?php

                    if ($this->viewmode == _COM_SEF_VIEWMODE_TRASH) {

                        if ($row->locked) {

                            echo '<img src="images/checked_out.png" border="0" alt="'.JText::_('COM_SEF_LOCKED').'" />';

                        }

                        else {

                            echo '<img src="images/publish_x.png" border="0" alt="'.JText::_('COM_SEF_UNLOCKED').'" />';

                        }

                    }

                    else {

                        ?>

                        <div id="sef_locked_<?php echo $row->id; ?>">

                            <?php

                            echo $this->getAjaxField('locked', $row->id, '1', 'unlock', JText::_('COM_SEF_UNLOCK').'::'.JText::_('COM_SEF_TT_UNLOCKED_URLS'), 'administrator/images/checked_out.png', JText::_('COM_SEF_LOCKED'), $row->locked);

                            echo $this->getAjaxField('locked', $row->id, '0', 'lock', JText::_('COM_SEF_LOCK').'::'.JText::_('COM_SEF_TT_LOCKED_URLS'), 'administrator/images/publish_x.png', JText::_('COM_SEF_UNLOCKED'), !$row->locked);

                            echo $this->getAjaxWorking('locked_'.$row->id);

                            ?>

                        </div>

                        <?php

                    }

                    ?>

                </td>

                <td style="text-align: center;">

                    <?php

                    if ($this->viewmode == _COM_SEF_VIEWMODE_TRASH) {

                        if ($row->priority == 0) {

                            echo '<img src="images/tick.png" border="0" alt="'.JText::_('COM_SEF_ACTIVE').'" />';

                        }

                        else {

                            $img = ($row->priority == 100 ? 'publish_r.png' : 'publish_g.png');

                            echo '<img src="images/'.$img.'" border="0" alt="'.JText::_('COM_SEF_TT_NOT_ACTIVE').'" />';

                        }

                    }

                    else {

                        ?>

                        <div id="sef_active_<?php echo $row->id; ?>">

                            <?php

                            echo $this->getAjaxField('active', $row->id, '0', '', JText::_('COM_SEF_TT_ACTIVE_LINK'), 'administrator/images/tick.png', JText::_('COM_SEF_ACTIVE'), $row->priority == 0, false);

                            echo $this->getAjaxField('active', $row->id, '50', 'setActive', JText::_('COM_SEF_TT_MAKE_ACTIVE'), 'administrator/images/publish_g.png', JText::_('COM_SEF_TT_NOT_ACTIVE'), ($row->priority > 0) && ($row->priority < 100));

                            echo $this->getAjaxField('active', $row->id, '100', 'setActive', JText::_('COM_SEF_TT_MAKE_ACTIVE'), 'administrator/images/publish_r.png', JText::_('COM_SEF_TT_NOT_ACTIVE'), $row->priority == 100);

                            echo $this->getAjaxWorking('active_'.$row->id);

                            ?>

                        </div>

                        <?php

                    }

                    ?>

                </td>

                <?php

                if ($sefConfig->useCache) {

                    ?>

                    <td style="text-align: center;">

                    <?php

                    if( $cache->getNonSefUrl($row->sefurl) !== false ) {

                        ?>

                        <span class="hasTip" title="<?php echo JText::_('Cached').'::'.JText::_('This URL is stored in cache.'); ?>">

                        <img src="images/tick.png" border="0" alt="Active" />

                        </span>

                        <?php

                    }

                    else {

                        ?>

                        <span class="hasTip" title="<?php echo JText::_('Not cached').'::'.JText::_('This URL is not stored in cache.'); ?>">

                        <img src="images/publish_x.png" border="0" alt="Active" />

                        </span>

                        <?php

                    }

                    ?>

                    </td>

                    <?php

                }

                ?>

                <td>

                <?php echo $row->host; ?>

                </td>

                <?php

            }

            ?>

        </tr>

        <?php

        $k = 1 - $k;

    }

    ?>

</tbody>

</table>

</div>



<input type="hidden" name="option" value="com_sef" />

<input type="hidden" name="task" value="" />

<input type="hidden" name="boxchecked" value="0" />

<input type="hidden" name="controller" value="sefurls" />

<input type="hidden" name="filter_order" value="<?php echo $this->lists['filter_order']; ?>" />

<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['filter_order_Dir']; ?>" />

<input type="hidden" name="selection" value="selected" />

<input type="hidden" name="viewmode" value="<?php echo $this->viewmode; ?>" />

</form>