Spade

Mini Shell

Directory:~$ /proc/self/root/home/lmsyaran/www/pusher/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/home/lmsyaran/www/pusher/com_redirect.tar

config.xml000064400000002257151170206740006544 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<config>
	<help key="Redirect:_Options"/>
	<inlinehelp button="show"/>
	<fieldset
		name="redirect"
		label="COM_REDIRECT_ADVANCED_OPTIONS"
		>
		<field
			name="mode"
			type="radio"
			label="COM_REDIRECT_MODE_LABEL"
			description="COM_REDIRECT_MODE_DESC"
			layout="joomla.form.field.radio.switcher"
			default="0"
			>
			<option value="0">JNO</option>
			<option value="1">JYES</option>
		</field>
		<field
			name="separator"
			type="text"
			label="COM_REDIRECT_BULK_SEPARATOR_LABEL"
			description="COM_REDIRECT_BULK_SEPARATOR_DESC"
			default="|"
		/>
		<field
			name="defaultImportState"
			type="radio"
			label="COM_REDIRECT_DEFAULT_IMPORT_STATE_LABEL"
			description="COM_REDIRECT_DEFAULT_IMPORT_STATE_DESC"
			layout="joomla.form.field.radio.switcher"
			default="0"
			>
			<option value="0">JDISABLED</option>
			<option value="1">JENABLED</option>
		</field>
	</fieldset>

	<fieldset
		name="permissions"
		label="JCONFIG_PERMISSIONS_LABEL"
		>
		<field
			name="rules"
			type="rules"
			label="JCONFIG_PERMISSIONS_LABEL"
			filter="rules"
			validate="rules"
			component="com_redirect"
			section="component"
		/>
	</fieldset>
</config>
forms/filter_links.xml000064400000004355151170206740011113 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<form
addfieldprefix="Joomla\Component\Redirect\Administrator\Field">
	<fields name="filter">
		<field
			name="search"
			type="text"
			inputmode="search"
			label="COM_REDIRECT_FILTER_SEARCH_LABEL"
			description="COM_REDIRECT_FILTER_SEARCH_DESC"
			hint="JSEARCH_FILTER"
		/>
		<field
			name="state"
			type="RedirectStatus"
			label="JSTATUS"
			class="js-select-submit-on-change"
			>
			<option value="">JOPTION_SELECT_PUBLISHED</option>
		</field>
		<field
			name="http_status"
			type="Redirect"
			label="COM_REDIRECT_HEADING_STATUS_CODE"
			class="js-select-submit-on-change"
			>
			<option
value="">COM_REDIRECT_FILTER_SELECT_OPTION_HTTP_HEADER</option>
		</field>
	</fields>
	<fields name="list">
		<field
			name="fullordering"
			type="list"
			label="JGLOBAL_SORT_BY"
			class="js-select-submit-on-change"
			default="a.old_url ASC"
			validate="options"
			>
			<option value="">JGLOBAL_SORT_BY</option>
			<option value="a.published
ASC">JSTATUS_ASC</option>
			<option value="a.published
DESC">JSTATUS_DESC</option>
			<option value="a.old_url
ASC">COM_REDIRECT_HEADING_OLD_URL_ASC</option>
			<option value="a.old_url
DESC">COM_REDIRECT_HEADING_OLD_URL_DESC</option>
			<option value="a.new_url
ASC">COM_REDIRECT_HEADING_NEW_URL_ASC</option>
			<option value="a.new_url
DESC">COM_REDIRECT_HEADING_NEW_URL_DESC</option>
			<option value="a.referer
ASC">COM_REDIRECT_HEADING_REFERRER_ASC</option>
			<option value="a.referer
DESC">COM_REDIRECT_HEADING_REFERRER_DESC</option>
			<option value="a.created_date
ASC">COM_REDIRECT_HEADING_CREATED_DATE_ASC</option>
			<option value="a.created_date
DESC">COM_REDIRECT_HEADING_CREATED_DATE_DESC</option>
			<option value="a.hits
ASC">COM_REDIRECT_HEADING_HITS_ASC</option>
			<option value="a.hits
DESC">COM_REDIRECT_HEADING_HITS_DESC</option>
			<option value="a.header
ASC">COM_REDIRECT_HEADING_STATUS_CODE_ASC</option>
			<option value="a.header
DESC">COM_REDIRECT_HEADING_STATUS_CODE_DESC</option>
			<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
			<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
		</field>
		<field
			name="limit"
			type="limitbox"
			label="JGLOBAL_LIST_LIMIT"
			default="5"
			class="js-select-submit-on-change"
		/>
	</fields>
</form>
forms/link.xml000064400000003345151170206740007361 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<form>
	<fieldset
addfieldprefix="Joomla\Component\Redirect\Administrator\Field">
		<field
			name="id"
			type="text"
			label="JGLOBAL_FIELD_ID_LABEL"
			default="0"
			readonly="true"
			class="readonly"
		/>

		<field
			name="old_url"
			type="text"
			label="COM_REDIRECT_FIELD_OLD_URL_LABEL"
			description="COM_REDIRECT_FIELD_OLD_URL_DESC"
			required="true"
		/>

		<field
			name="new_url"
			type="text"
			label="COM_REDIRECT_FIELD_NEW_URL_LABEL"
			description="COM_REDIRECT_FIELD_NEW_URL_DESC"
			required="true"
		/>

		<field
			name="comment"
			type="text"
			label="COM_REDIRECT_FIELD_COMMENT_LABEL"
		/>

		<field
			name="published"
			type="list"
			label="JSTATUS"
			class="form-select-color-state"
			default="1"
			validate="options"
			>
			<option value="1">JENABLED</option>
			<option value="0">JDISABLED</option>
			<option value="2">JARCHIVED</option>
			<option value="-2">JTRASHED</option>
		</field>

		<field
			name="referer"
			type="text"
			label="COM_REDIRECT_FIELD_REFERRER_LABEL"
			readonly="true"
		/>

		<field
			name="created_date"
			type="text"
			label="COM_REDIRECT_FIELD_CREATED_DATE_LABEL"
			class="readonly"
			readonly="true"
		/>

		<field
			name="modified_date"
			type="text"
			label="COM_REDIRECT_FIELD_UPDATED_DATE_LABEL"
			class="readonly"
			readonly="true"
		/>

		<field
			name="hits"
			type="text"
			label="JGLOBAL_HITS"
			class="readonly"
			readonly="true"
			filter="unset"
		/>
	</fieldset>
	<fieldset name="advanced">
		<field
			name="header"
			type="redirect"
			label="COM_REDIRECT_FIELD_REDIRECT_STATUS_CODE_LABEL"
			description="COM_REDIRECT_FIELD_REDIRECT_STATUS_CODE_DESC"
			default="301"
			validate="options"
		/>
	</fieldset>
</form>
access.xml000064400000000777151170206740006545 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<access component="com_redirect">
	<section name="component">
		<action name="core.admin" title="JACTION_ADMIN"
/>
		<action name="core.options"
title="JACTION_OPTIONS" />
		<action name="core.manage" title="JACTION_MANAGE"
/>
		<action name="core.create" title="JACTION_CREATE"
/>
		<action name="core.delete" title="JACTION_DELETE"
/>
		<action name="core.edit" title="JACTION_EDIT"
/>
		<action name="core.edit.state"
title="JACTION_EDITSTATE" />
	</section>
</access>
redirect.xml000064400000002213151170206740007070 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<extension type="component" method="upgrade">
	<name>com_redirect</name>
	<author>Joomla! Project</author>
	<creationDate>2006-04</creationDate>
	<copyright>(C) 2006 Open Source Matters, Inc.</copyright>
	<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
	<authorEmail>admin@joomla.org</authorEmail>
	<authorUrl>www.joomla.org</authorUrl>
	<version>4.0.0</version>
	<description>COM_REDIRECT_XML_DESCRIPTION</description>
	<namespace
path="src">Joomla\Component\Redirect</namespace>
	<administration>
		<menu link="option=com_redirect"
img="class:redirect">Redirect</menu>
		<files folder="admin">
			<filename>access.xml</filename>
			<filename>config.xml</filename>
			<filename>redirect.xml</filename>
			<folder>forms</folder>
			<folder>helpers</folder>
			<folder>layouts</folder>
			<folder>services</folder>
			<folder>src</folder>
			<folder>tmpl</folder>
		</files>
		<languages folder="admin">
			<language
tag="en-GB">language/en-GB/com_redirect.ini</language>
			<language
tag="en-GB">language/en-GB/com_redirect.sys.ini</language>
		</languages>
	</administration>
</extension>
layouts/toolbar/batch.php000064400000001273151170206740011506
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2016 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa =
\Joomla\CMS\Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->useScript('core');

$title = $displayData['title'];

?>
<button type="button" data-bs-toggle="modal"
onclick="{document.getElementById('collapseModal').open();
return true;}" class="btn btn-primary">
    <span class="icon-square"
aria-hidden="true"></span>
    <?php echo $title; ?>
</button>
services/provider.php000064400000003327151170206740010742 0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2018 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

\defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
use Joomla\CMS\HTML\Registry;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Redirect\Administrator\Extension\RedirectComponent;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;

/**
 * The redirect service provider.
 *
 * @since  4.0.0
 */
return new class () implements ServiceProviderInterface {
    /**
     * Registers the service provider with a DI container.
     *
     * @param   Container  $container  The DI container.
     *
     * @return  void
     *
     * @since   4.0.0
     */
    public function register(Container $container)
    {
        $container->registerServiceProvider(new
MVCFactory('\\Joomla\\Component\\Redirect'));
        $container->registerServiceProvider(new
ComponentDispatcherFactory('\\Joomla\\Component\\Redirect'));

        $container->set(
            ComponentInterface::class,
            function (Container $container) {
                $component = new
RedirectComponent($container->get(ComponentDispatcherFactoryInterface::class));
               
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
               
$component->setRegistry($container->get(Registry::class));

                return $component;
            }
        );
    }
};
tmpl/links/default_batch_body.php000064400000002265151170206740013163
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2015 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

/** @var \Joomla\Component\Redirect\Administrator\View\Links\HtmlView $this
*/

$published = $this->state->get('filter.published');
$params    = $this->params;
$separator = $params->get('separator', '|');
?>

<div class="container">
    <div class="row">
        <div class="control-group col-md-12 mt-3">
            <label for="batch_urls"
class="form-label"><?php echo
Text::sprintf('COM_REDIRECT_BATCH_TIP', $separator);
?></label>
            <div class="controls">
                <textarea class="form-control"
rows="10" id="batch_urls"
name="batch_urls"></textarea>
            </div>
        </div>
        <div class="btn-toolbar pb-3">
            <joomla-toolbar-button task="links.batch"
class="ms-auto">
                <button type="button" class="btn
btn-success"><?php echo
Text::_('JGLOBAL_BATCH_PROCESS'); ?></button>
            </joomla-toolbar-button>
        </div>
    </div>
</div>
tmpl/links/default_addform.php000064400000004316151170206740012500
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

?>

<div class="accordion d-none d-sm-block"
id="accordion1">
    <div class="accordion-heading pb-3">
        <button class="btn btn-primary"
type="button" data-bs-toggle="collapse"
data-bs-target="#batch" aria-expanded="false"
aria-controls="batch">
            <?php echo
Text::_('COM_REDIRECT_BATCH_UPDATE_WITH_NEW_URL'); ?>
        </button>
    </div>
    <div class="collapse card" id="batch">
        <div class="card-body">
            <fieldset>
                <div class="control-group">
                    <div class="control-label">
                        <label id="new_url-lbl"
for="new_url">
                            <?php echo
Text::_('COM_REDIRECT_FIELD_NEW_URL_LABEL'); ?>
                        </label>
                    </div>
                    <div class="controls">
                        <input class="form-control"
type="text" name="new_url" id="new_url"
value="" size="50">
                        <small id="new_url-desc"
class="form-text">
                            <?php echo
Text::_('COM_REDIRECT_FIELD_NEW_URL_DESC'); ?>
                        </small>
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                        <label id="comment-lbl"
for="comment">
                            <?php echo
Text::_('COM_REDIRECT_FIELD_COMMENT_LABEL'); ?>
                        </label>
                    </div>
                    <div class="controls">
                        <input class="form-control"
type="text" name="comment" id="comment"
value="" size="50">
                    </div>
                </div>
                <button class="btn btn-primary"
type="button"
onclick="this.form.task.value='links.duplicateUrls';this.form.submit();">
                    <?php echo
Text::_('COM_REDIRECT_BUTTON_UPDATE_LINKS'); ?>
                </button>
            </fieldset>
        </div>
    </div>
</div>

tmpl/links/default.xml000064400000000254151170206740011012 0ustar00<?xml
version="1.0" encoding="UTF-8"?>
<metadata>
	<layout title="COM_REDIRECT">
		<message>
			<![CDATA[COM_REDIRECT_XML_DESCRIPTION]]>
		</message>
	</layout>
</metadata>tmpl/links/emptystate.php000064400000006202151170206740011553
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2021 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Redirect\Administrator\Helper\RedirectHelper;

/** @var \Joomla\Component\Redirect\Administrator\View\Links\HtmlView $this
*/

$displayData = [
    'textPrefix' => 'COM_REDIRECT',
    'formURL'    =>
'index.php?option=com_redirect&view=links',
    'helpURL'    =>
'https://docs.joomla.org/Special:MyLanguage/Help5.x:Redirects:_Links',
    'icon'       => 'icon-map-signs redirect',
];

$app  = Factory::getApplication();
$user = $this->getCurrentUser();

if ($user->authorise('core.create', 'com_redirect'))
{
    $displayData['createURL'] =
'index.php?option=com_redirect&task=link.add';
}

if (
    $user->authorise('core.create', 'com_redirect')
    && $user->authorise('core.edit',
'com_redirect')
    && $user->authorise('core.edit.state',
'com_redirect')
) {
    $displayData['formAppend'] = '<template
id="joomla-dialog-batch">' .
$this->loadTemplate('batch_body') .
'</template>';
}

$collectUrlsEnabled = RedirectHelper::collectUrlsEnabled();
$pluginEnabled      = PluginHelper::isEnabled('system',
'redirect');
$redirectPluginId   = $this->redirectPluginId;

// Show messages about the enabled plugin and if the plugin should collect
URLs
if ($pluginEnabled && $collectUrlsEnabled) {
   
$app->enqueueMessage(Text::sprintf('COM_REDIRECT_COLLECT_URLS_ENABLED',
Text::_('COM_REDIRECT_PLUGIN_ENABLED')), 'notice');
} else {
    /** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
    $wa = $this->document->getWebAssetManager();
    $wa->useScript('joomla.dialog-autocreate');

    $popupOptions = [
        'popupType'  => 'iframe',
        'textHeader' =>
Text::_('COM_REDIRECT_EDIT_PLUGIN_SETTINGS'),
        'src'        =>
Route::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id='
. $redirectPluginId . '&tmpl=component&layout=modal',
false),
    ];
    $link = HTMLHelper::_(
        'link',
        '#',
        Text::_('COM_REDIRECT_SYSTEM_PLUGIN'),
        [
            'class'                 => 'alert-link',
            'data-joomla-dialog'    =>
$this->escape(json_encode($popupOptions, JSON_UNESCAPED_SLASHES)),
            'data-checkin-url'      =>
Route::_('index.php?option=com_plugins&task=plugins.checkin&format=json&cid[]='
. $redirectPluginId),
            'data-close-on-message' => '',
            'data-reload-on-close'  => '',
        ],
    );

    if ($pluginEnabled && !$collectUrlsEnabled) {
        $app->enqueueMessage(
           
Text::sprintf('COM_REDIRECT_COLLECT_MODAL_URLS_DISABLED',
Text::_('COM_REDIRECT_PLUGIN_ENABLED'), $link),
            'notice'
        );
    } else {
       
$app->enqueueMessage(Text::sprintf('COM_REDIRECT_PLUGIN_MODAL_DISABLED',
$link), 'error');
    }
}

echo LayoutHelper::render('joomla.content.emptystate',
$displayData);
tmpl/links/default.php000064400000022144151170206740011003 0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Redirect\Administrator\Helper\RedirectHelper;

/** @var \Joomla\Component\Redirect\Administrator\View\Link\HtmlView $this
*/

/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('table.columns')
    ->useScript('multiselect')
    ->useScript('joomla.dialog-autocreate');

$app       = Factory::getApplication();
$user      = $this->getCurrentUser();
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn  =
$this->escape($this->state->get('list.direction'));

$collectUrlsEnabled = RedirectHelper::collectUrlsEnabled();
$pluginEnabled      = PluginHelper::isEnabled('system',
'redirect');
$redirectPluginId   = $this->redirectPluginId;

// Show messages about the enabled plugin and if the plugin should collect
URLs
if ($pluginEnabled && $collectUrlsEnabled) {
   
$app->enqueueMessage(Text::sprintf('COM_REDIRECT_COLLECT_URLS_ENABLED',
Text::_('COM_REDIRECT_PLUGIN_ENABLED')), 'notice');
} else {
    $popupOptions = [
        'popupType'  => 'iframe',
        'textHeader' =>
Text::_('COM_REDIRECT_EDIT_PLUGIN_SETTINGS'),
        'src'        =>
Route::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id='
. $redirectPluginId . '&tmpl=component&layout=modal',
false),
    ];
    $link = HTMLHelper::_(
        'link',
        '#',
        Text::_('COM_REDIRECT_SYSTEM_PLUGIN'),
        [
            'class'                 => 'alert-link',
            'data-joomla-dialog'    =>
$this->escape(json_encode($popupOptions, JSON_UNESCAPED_SLASHES)),
            'data-checkin-url'      =>
Route::_('index.php?option=com_plugins&task=plugins.checkin&format=json&cid[]='
. $redirectPluginId),
            'data-close-on-message' => '',
            'data-reload-on-close'  => '',
        ],
    );

    if ($pluginEnabled && !$collectUrlsEnabled) {
        $app->enqueueMessage(
           
Text::sprintf('COM_REDIRECT_COLLECT_MODAL_URLS_DISABLED',
Text::_('COM_REDIRECT_PLUGIN_ENABLED'), $link),
            'notice'
        );
    } else {
       
$app->enqueueMessage(Text::sprintf('COM_REDIRECT_PLUGIN_MODAL_DISABLED',
$link), 'error');
    }
}

?>
<form action="<?php echo
Route::_('index.php?option=com_redirect&view=links');
?>" method="post" name="adminForm"
id="adminForm">
    <div id="j-main-container"
class="j-main-container">
        <?php echo
LayoutHelper::render('joomla.searchtools.default',
['view' => $this]); ?>
        <?php if (empty($this->items)) : ?>
            <div class="alert alert-info">
                <span class="icon-info-circle"
aria-hidden="true"></span><span
class="visually-hidden"><?php echo
Text::_('INFO'); ?></span>
                <?php echo
Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
            </div>
        <?php else : ?>
            <table class="table">
                <caption class="visually-hidden">
                    <?php echo
Text::_('COM_REDIRECTS_TABLE_CAPTION'); ?>,
                            <span id="orderedBy"><?php
echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
                            <span id="filteredBy"><?php
echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
                </caption>
                <thead>
                    <tr>
                        <td class="w-1 text-center">
                            <?php echo
HTMLHelper::_('grid.checkall'); ?>
                        </td>
                        <th scope="col" class="w-1
text-center">
                            <?php echo
HTMLHelper::_('searchtools.sort', 'JSTATUS',
'a.published', $listDirn, $listOrder); ?>
                        </th>
                        <th scope="col"
class="title">
                            <?php echo
HTMLHelper::_('searchtools.sort',
'COM_REDIRECT_HEADING_OLD_URL', 'a.old_url', $listDirn,
$listOrder); ?>
                        </th>
                        <th scope="col">
                            <?php echo
HTMLHelper::_('searchtools.sort',
'COM_REDIRECT_HEADING_NEW_URL', 'a.new_url', $listDirn,
$listOrder); ?>
                        </th>
                        <th scope="col" class="d-none
d-md-table-cell">
                            <?php echo
HTMLHelper::_('searchtools.sort',
'COM_REDIRECT_HEADING_REFERRER', 'a.referer',
$listDirn, $listOrder); ?>
                        </th>
                        <th scope="col" class="w-1 d-none
d-md-table-cell">
                            <?php echo
HTMLHelper::_('searchtools.sort',
'COM_REDIRECT_HEADING_CREATED_DATE', 'a.created_date',
$listDirn, $listOrder); ?>
                        </th>
                        <th scope="col" class="w-1 d-none
d-md-table-cell">
                            <?php echo
HTMLHelper::_('searchtools.sort',
'COM_REDIRECT_HEADING_HITS', 'a.hits', $listDirn,
$listOrder); ?>
                        </th>
                        <th scope="col" class="w-1 d-none
d-md-table-cell">
                            <?php echo
HTMLHelper::_('searchtools.sort',
'COM_REDIRECT_HEADING_STATUS_CODE', 'a.header',
$listDirn, $listOrder); ?>
                        </th>
                        <th scope="col" class="w-1 d-none
d-md-table-cell">
                            <?php echo
HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID',
'a.id', $listDirn, $listOrder); ?>
                        </th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($this->items as $i => $item) :
                    $canEdit   = $user->authorise('core.edit',
'com_redirect');
                    $canChange =
$user->authorise('core.edit.state', 'com_redirect');
                    ?>
                    <tr class="row<?php echo $i % 2;
?>">
                        <td class="text-center">
                            <?php echo
HTMLHelper::_('grid.id', $i, $item->id, false,
'cid', 'cb', $item->old_url); ?>
                        </td>
                        <td class="text-center">
                            <?php echo
HTMLHelper::_('redirect.published', $item->published, $i);
?>
                        </td>
                        <th scope="row"
class="break-word">
                            <?php if ($canEdit) : ?>
                                <a href="<?php echo
Route::_('index.php?option=com_redirect&task=link.edit&id='
. $item->id); ?>" title="<?php echo
Text::_('JACTION_EDIT'); ?> <?php echo
$this->escape($item->old_url); ?>">
                                    <?php echo
$this->escape(str_replace(Uri::root(), '',
rawurldecode($item->old_url))); ?>
                                </a>
                            <?php else : ?>
                                    <?php echo
$this->escape(str_replace(Uri::root(), '',
rawurldecode($item->old_url))); ?>
                            <?php endif; ?>
                        </th>
                        <td class="small break-word">
                            <?php echo
$this->escape(rawurldecode($item->new_url ?? '')); ?>
                        </td>
                        <td class="small break-word d-none
d-md-table-cell">
                            <?php echo
$this->escape($item->referer); ?>
                        </td>
                        <td class="small d-none
d-md-table-cell">
                            <?php echo HTMLHelper::_('date',
$item->created_date, Text::_('DATE_FORMAT_LC4')); ?>
                        </td>
                        <td class="d-none d-md-table-cell">
                            <?php echo (int) $item->hits; ?>
                        </td>
                        <td class="d-none d-md-table-cell">
                            <?php echo (int) $item->header; ?>
                        </td>
                        <td class="d-none d-md-table-cell">
                            <?php echo (int) $item->id; ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>

            <?php // load the pagination. ?>
            <?php echo $this->pagination->getListFooter(); ?>

        <?php endif; ?>

        <?php if (!empty($this->items)) : ?>
            <?php echo $this->loadTemplate('addform');
?>
        <?php endif; ?>
        <?php // Load the batch processing form if user is allowed ?>
            <?php
            if (
                $user->authorise('core.create',
'com_redirect')
                && $user->authorise('core.edit',
'com_redirect')
                && $user->authorise('core.edit.state',
'com_redirect')
            ) : ?>
                <template id="joomla-dialog-batch"><?php
echo $this->loadTemplate('batch_body'); ?></template>
            <?php endif; ?>

        <input type="hidden" name="task"
value="">
        <input type="hidden" name="boxchecked"
value="0">
        <?php echo HTMLHelper::_('form.token'); ?>
    </div>
</form>
tmpl/link/edit.php000064400000004160151170206740010117 0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

/** @var \Joomla\Component\Redirect\Administrator\View\Link\HtmlView $this
*/

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('keepalive')
    ->useScript('form.validate');

?>

<form action="<?php echo
Route::_('index.php?option=com_redirect&id=' . (int)
$this->item->id); ?>" method="post"
name="adminForm" id="link-form"
aria-label="<?php echo Text::_('COM_REDIRECT_FORM_' .
((int) $this->item->id === 0 ? 'NEW' : 'EDIT'),
true); ?>" class="form-validate">
    <fieldset class="main-card mt-3">
        <?php echo HTMLHelper::_('uitab.startTabSet',
'myTab', ['active' => 'basic',
'recall' => true, 'breakpoint' => 768]); ?>

            <?php echo HTMLHelper::_('uitab.addTab',
'myTab', 'basic', empty($this->item->id) ?
Text::_('COM_REDIRECT_NEW_LINK') :
Text::sprintf('COM_REDIRECT_EDIT_LINK', $this->item->id));
?>

            <?php echo
$this->form->renderField('old_url'); ?>
            <?php echo
$this->form->renderField('new_url'); ?>
            <?php echo
$this->form->renderField('published'); ?>
            <?php echo
$this->form->renderField('comment'); ?>
            <?php echo $this->form->renderField('id');
?>
            <?php echo
$this->form->renderField('created_date'); ?>
            <?php echo
$this->form->renderField('modified_date'); ?>
            <?php if
(ComponentHelper::getParams('com_redirect')->get('mode'))
: ?>
                <?php echo
$this->form->renderFieldset('advanced'); ?>
            <?php endif; ?>
            <?php echo HTMLHelper::_('uitab.endTab'); ?>
        <?php echo HTMLHelper::_('uitab.endTabSet'); ?>

        <input type="hidden" name="task"
value="">
        <?php echo HTMLHelper::_('form.token'); ?>
    </fieldset>
</form>
helpers/redirect.php000064400000001300151170206740010515 0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 *
 * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
 */

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Redirect component helper.
 *
 * @since       1.6
 * @deprecated  4.3 will be removed in 6.0
 *              Use
\Joomla\Component\Redirect\Administrator\Helper\RedirectHelp instead
 */
class RedirectHelper extends
\Joomla\Component\Redirect\Administrator\Helper\RedirectHelper
{
}
src/Table/LinkTable.php000064400000007773151170206740010761
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Table;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseDriver;
use Joomla\Event\DispatcherInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Link Table for Redirect.
 *
 * @since  1.6
 */
class LinkTable extends Table
{
    /**
     * Constructor
     *
     * @param   DatabaseDriver        $db          Database connector
object
     * @param   ?DispatcherInterface  $dispatcher  Event dispatcher for
this table
     *
     * @since   1.6
     */
    public function __construct(DatabaseDriver $db, DispatcherInterface
$dispatcher = null)
    {
        parent::__construct('#__redirect_links', 'id',
$db, $dispatcher);
    }

    /**
     * Overloaded check function
     *
     * @return  boolean
     *
     * @since   1.6
     */
    public function check()
    {
        try {
            parent::check();
        } catch (\Exception $e) {
            $this->setError($e->getMessage());

            return false;
        }

        $this->old_url = trim(rawurldecode($this->old_url));
        $this->new_url = trim(rawurldecode($this->new_url));

        // Check for valid name.
        if (empty($this->old_url)) {
           
$this->setError(Text::_('COM_REDIRECT_ERROR_SOURCE_URL_REQUIRED'));

            return false;
        }

        // Check for NOT NULL.
        if (empty($this->referer)) {
            $this->referer = '';
        }

        // Check for valid name if not in advanced mode.
        if (empty($this->new_url) &&
ComponentHelper::getParams('com_redirect')->get('mode',
0) == false) {
           
$this->setError(Text::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED'));

            return false;
        }

        if (empty($this->new_url) &&
ComponentHelper::getParams('com_redirect')->get('mode',
0) == true) {
            // Else if an empty URL and in redirect mode only throw the
same error if the code is a 3xx status code
            if ($this->header < 400 && $this->header >=
300) {
               
$this->setError(Text::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED'));

                return false;
            }
        }

        // Check for duplicates
        if ($this->old_url == $this->new_url) {
           
$this->setError(Text::_('COM_REDIRECT_ERROR_DUPLICATE_URLS'));

            return false;
        }

        $db = $this->getDbo();

        // Check for existing name
        $query = $db->getQuery(true)
            ->select($db->quoteName('id'))
            ->select($db->quoteName('old_url'))
            ->from($db->quoteName('#__redirect_links'))
            ->where($db->quoteName('old_url') . ' =
:url')
            ->bind(':url', $this->old_url);
        $db->setQuery($query);
        $urls = $db->loadAssocList();

        foreach ($urls as $url) {
            if ($url['old_url'] === $this->old_url &&
(int) $url['id'] != (int) $this->id) {
               
$this->setError(Text::_('COM_REDIRECT_ERROR_DUPLICATE_OLD_URL'));

                return false;
            }
        }

        return true;
    }

    /**
     * Overridden store method to set dates.
     *
     * @param   boolean  $updateNulls  True to update fields even if they
are null.
     *
     * @return  boolean  True on success.
     *
     * @since   1.6
     */
    public function store($updateNulls = false)
    {
        $date = Factory::getDate()->toSql();

        if (!$this->id) {
            // New record.
            $this->created_date  = $date;
            $this->modified_date = $date;
        }

        if (empty($this->modified_date)) {
            $this->modified_date = $this->created_date;
        }

        return parent::store($updateNulls);
    }
}
src/Service/HTML/Redirect.php000064400000004561151170206740011762
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Service\HTML;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\Utilities\ArrayHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Utility class for creating HTML Grids.
 *
 * @since  1.6
 */
class Redirect
{
    /**
     * Display the published or unpublished state of an item.
     *
     * @param   int      $value      The state value.
     * @param   int      $i          The ID of the item.
     * @param   boolean  $canChange  An optional prefix for the task.
     *
     * @return  string
     *
     * @since   1.6
     *
     * @throws  \InvalidArgumentException
     */
    public function published($value = 0, $i = null, $canChange = true)
    {
       
Factory::getDocument()->getWebAssetManager()->useScript('list-view');

        // Note: $i is required but has to be an optional argument in the
function call due to argument order
        if (null === $i) {
            throw new \InvalidArgumentException('$i is a required
argument in JHtmlRedirect::published');
        }

        // Array of image, task, title, action
        $states = [
            1  => ['publish', 'links.unpublish',
'JENABLED', 'COM_REDIRECT_DISABLE_LINK'],
            0  => ['unpublish', 'links.publish',
'JDISABLED', 'COM_REDIRECT_ENABLE_LINK'],
            2  => ['archive', 'links.unpublish',
'JARCHIVED', 'JUNARCHIVE'],
            -2 => ['trash', 'links.publish',
'JTRASHED', 'COM_REDIRECT_ENABLE_LINK'],
        ];

        $state = ArrayHelper::getValue($states, (int) $value, $states[0]);
        $icon  = $state[0];

        if ($canChange) {
            $html = '<a href="#"
class="js-grid-item-action tbody-icon' . ($value == 1 ? '
active' : '')
                . '" aria-labelledby="cb' . $state[0] .
$i . '-desc"'
                . ' data-item-id="cb' . $i . '"
data-item-task="' . $state[1] . '"'
                . '><span class="icon-' . $icon .
'" aria-hidden="true"></span></a>'
                . '<div role="tooltip" id="cb'
. $state[0] . $i . '-desc">' . Text::_($state[3]) .
'</div>';
        }

        return $html;
    }
}
src/Field/RedirectField.php000064400000011027151170206740011600
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2014 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Field;

use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\HTML\HTMLHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * A dropdown containing all valid HTTP 1.1 response codes.
 *
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 * @since       3.4
 */
class RedirectField extends ListField
{
    /**
     * The form field type.
     *
     * @var    string
     * @since  3.4
     */
    protected $type = 'Redirect';

    /**
     * A map of integer HTTP 1.1 response codes to the full HTTP Status for
the headers.
     *
     * @var    object
     * @since  3.4
     * @link  
https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
     */
    protected $responseMap = [
        100 => 'HTTP/1.1 100 Continue',
        101 => 'HTTP/1.1 101 Switching Protocols',
        102 => 'HTTP/1.1 102 Processing',
        103 => 'HTTP/1.1 103 Early Hints',
        200 => 'HTTP/1.1 200 OK',
        201 => 'HTTP/1.1 201 Created',
        202 => 'HTTP/1.1 202 Accepted',
        203 => 'HTTP/1.1 203 Non-Authoritative Information',
        204 => 'HTTP/1.1 204 No Content',
        205 => 'HTTP/1.1 205 Reset Content',
        206 => 'HTTP/1.1 206 Partial Content',
        207 => 'HTTP/1.1 207 Multi-Status',
        208 => 'HTTP/1.1 208 Already Reported',
        226 => 'HTTP/1.1 226 IM Used',
        300 => 'HTTP/1.1 300 Multiple Choices',
        301 => 'HTTP/1.1 301 Moved Permanently',
        302 => 'HTTP/1.1 302 Found',
        303 => 'HTTP/1.1 303 See other',
        304 => 'HTTP/1.1 304 Not Modified',
        305 => 'HTTP/1.1 305 Use Proxy',
        306 => 'HTTP/1.1 306 (Unused)',
        307 => 'HTTP/1.1 307 Temporary Redirect',
        308 => 'HTTP/1.1 308 Permanent Redirect',
        400 => 'HTTP/1.1 400 Bad Request',
        401 => 'HTTP/1.1 401 Unauthorized',
        402 => 'HTTP/1.1 402 Payment Required',
        403 => 'HTTP/1.1 403 Forbidden',
        404 => 'HTTP/1.1 404 Not Found',
        405 => 'HTTP/1.1 405 Method Not Allowed',
        406 => 'HTTP/1.1 406 Not Acceptable',
        407 => 'HTTP/1.1 407 Proxy Authentication Required',
        408 => 'HTTP/1.1 408 Request Timeout',
        409 => 'HTTP/1.1 409 Conflict',
        410 => 'HTTP/1.1 410 Gone',
        411 => 'HTTP/1.1 411 Length Required',
        412 => 'HTTP/1.1 412 Precondition Failed',
        413 => 'HTTP/1.1 413 Payload Too Large',
        414 => 'HTTP/1.1 414 URI Too Long',
        415 => 'HTTP/1.1 415 Unsupported Media Type',
        416 => 'HTTP/1.1 416 Requested Range Not Satisfiable',
        417 => 'HTTP/1.1 417 Expectation Failed',
        418 => 'HTTP/1.1 418 I\'m a teapot',
        421 => 'HTTP/1.1 421 Misdirected Request',
        422 => 'HTTP/1.1 422 Unprocessable Entity',
        423 => 'HTTP/1.1 423 Locked',
        424 => 'HTTP/1.1 424 Failed Dependency',
        425 => 'HTTP/1.1 425 Reserved for WebDAV advanced
collections expired proposal',
        426 => 'HTTP/1.1 426 Upgrade Required',
        428 => 'HTTP/1.1 428 Precondition Required',
        429 => 'HTTP/1.1 429 Too Many Requests',
        431 => 'HTTP/1.1 431 Request Header Fields Too Large',
        451 => 'HTTP/1.1 451 Unavailable For Legal Reasons',
        500 => 'HTTP/1.1 500 Internal Server Error',
        501 => 'HTTP/1.1 501 Not Implemented',
        502 => 'HTTP/1.1 502 Bad Gateway',
        503 => 'HTTP/1.1 503 Service Unavailable',
        504 => 'HTTP/1.1 504 Gateway Timeout',
        505 => 'HTTP/1.1 505 HTTP Version Not Supported',
        506 => 'HTTP/1.1 506 Variant Also Negotiates
(Experimental)',
        507 => 'HTTP/1.1 507 Insufficient Storage',
        508 => 'HTTP/1.1 508 Loop Detected',
        510 => 'HTTP/1.1 510 Not Extended',
        511 => 'HTTP/1.1 511 Network Authentication Required',
    ];

    /**
     * Method to get the field input markup.
     *
     * @return  array   The field input markup.
     *
     * @since   3.4
     */
    protected function getOptions()
    {
        $options = [];

        foreach ($this->responseMap as $key => $value) {
            $options[] = HTMLHelper::_('select.option', $key,
$value);
        }

        // Merge any additional options in the XML definition.
        $options = array_merge(parent::getOptions(), $options);

        return $options;
    }
}
src/Helper/RedirectHelper.php000064400000005261151170206740012173
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2017 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Helper;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Registry\Registry;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Redirect component helper.
 *
 * @since  1.6
 */
class RedirectHelper
{
    /**
     * Extension
     *
     * @var    string
     */
    public static $extension = 'com_redirect';

    /**
     * Returns an array of standard published state filter options.
     *
     * @return  array  An array containing the options
     *
     * @since   1.6
     */
    public static function publishedOptions()
    {
        // Build the active state filter options.
        $options   = [];
        $options[] = HTMLHelper::_('select.option',
'*', 'JALL');
        $options[] = HTMLHelper::_('select.option',
'1', 'JENABLED');
        $options[] = HTMLHelper::_('select.option',
'0', 'JDISABLED');
        $options[] = HTMLHelper::_('select.option',
'2', 'JARCHIVED');
        $options[] = HTMLHelper::_('select.option',
'-2', 'JTRASHED');

        return $options;
    }

    /**
     * Gets the redirect system plugin extension id.
     *
     * @return  integer  The redirect system plugin extension id.
     *
     * @since   3.6.0
     */
    public static function getRedirectPluginId()
    {
        $db    = Factory::getDbo();
        $query = $db->getQuery(true)
            ->select($db->quoteName('extension_id'))
            ->from($db->quoteName('#__extensions'))
            ->where($db->quoteName('folder') . ' =
' . $db->quote('system'))
            ->where($db->quoteName('element') . ' =
' . $db->quote('redirect'));
        $db->setQuery($query);

        try {
            $result = (int) $db->loadResult();
        } catch (\RuntimeException $e) {
           
Factory::getApplication()->enqueueMessage($e->getMessage(),
'error');
        }

        return $result;
    }

    /**
     * Checks whether the option "Collect URLs" is enabled for
the output message
     *
     * @return  boolean
     *
     * @since   3.4
     */
    public static function collectUrlsEnabled()
    {
        $collect_urls = false;

        if (PluginHelper::isEnabled('system',
'redirect')) {
            $params       = new
Registry(PluginHelper::getPlugin('system',
'redirect')->params);
            $collect_urls = (bool)
$params->get('collect_urls', 1);
        }

        return $collect_urls;
    }
}
src/Model/LinksModel.php000064400000017116151170206740011156
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Model;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Database\ParameterType;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Methods supporting a list of redirect links.
 *
 * @since  1.6
 */
class LinksModel extends ListModel
{
    /**
     * Constructor.
     *
     * @param   array                $config   An optional associative
array of configuration settings.
     * @param   MVCFactoryInterface  $factory  The factory.
     *
     * @since   1.6
     */
    public function __construct($config = [], MVCFactoryInterface $factory
= null)
    {
        if (empty($config['filter_fields'])) {
            $config['filter_fields'] = [
                'id', 'a.id',
                'state', 'a.state',
                'old_url', 'a.old_url',
                'new_url', 'a.new_url',
                'referer', 'a.referer',
                'hits', 'a.hits',
                'created_date', 'a.created_date',
                'published', 'a.published',
                'header', 'a.header',
'http_status',
            ];
        }

        parent::__construct($config, $factory);
    }
    /**
     * Removes all of the unpublished redirects from the table.
     *
     * @return  boolean result of operation
     *
     * @since   3.5
     */
    public function purge()
    {
        $db = $this->getDatabase();

        $query = $db->getQuery(true);

       
$query->delete('#__redirect_links')->where($db->quoteName('published')
. '= 0');

        $db->setQuery($query);

        try {
            $db->execute();
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }

    /**
     * Method to auto-populate the model state.
     *
     * Note. Calling getState in this method will result in recursion.
     *
     * @param   string  $ordering   An optional ordering field.
     * @param   string  $direction  An optional direction (asc|desc).
     *
     * @return  void
     *
     * @since   1.6
     */
    protected function populateState($ordering = 'a.old_url',
$direction = 'asc')
    {
        // Load the parameters.
        $params = ComponentHelper::getParams('com_redirect');
        $this->setState('params', $params);

        // List state information.
        parent::populateState($ordering, $direction);
    }

    /**
     * Method to get a store id based on model configuration state.
     *
     * This is necessary because the model is used by the component and
     * different modules that might need different sets of data or
different
     * ordering requirements.
     *
     * @param   string  $id  A prefix for the store id.
     *
     * @return  string  A store id.
     *
     * @since   1.6
     */
    protected function getStoreId($id = '')
    {
        // Compile the store id.
        $id .= ':' .
$this->getState('filter.search');
        $id .= ':' .
$this->getState('filter.state');
        $id .= ':' .
$this->getState('filter.http_status');

        return parent::getStoreId($id);
    }

    /**
     * Build an SQL query to load the list data.
     *
     * @return  \Joomla\Database\DatabaseQuery
     *
     * @since   1.6
     */
    protected function getListQuery()
    {
        // Create a new query object.
        $db    = $this->getDatabase();
        $query = $db->getQuery(true);

        // Select the required fields from the table.
        $query->select(
            $this->getState(
                'list.select',
                'a.*'
            )
        );
        $query->from($db->quoteName('#__redirect_links',
'a'));

        // Filter by published state
        $state = (string) $this->getState('filter.state');

        if (is_numeric($state)) {
            $state = (int) $state;
            $query->where($db->quoteName('a.published') .
' = :state')
                ->bind(':state', $state,
ParameterType::INTEGER);
        } elseif ($state === '') {
            $query->whereIn($db->quoteName('a.published'),
[0,1]);
        }

        // Filter the items over the HTTP status code header.
        if ($httpStatusCode =
$this->getState('filter.http_status')) {
            $httpStatusCode = (int) $httpStatusCode;
            $query->where($db->quoteName('a.header') .
' = :header')
                ->bind(':header', $httpStatusCode,
ParameterType::INTEGER);
        }

        // Filter the items over the search string if set.
        $search = $this->getState('filter.search');

        if (!empty($search)) {
            if (stripos($search, 'id:') === 0) {
                $ids = (int) substr($search, 3);
                $query->where($db->quoteName('a.id') .
' = :id');
                $query->bind(':id', $ids,
ParameterType::INTEGER);
            } else {
                $search = '%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%');
                $query->where(
                    '(' . $db->quoteName('old_url')
. ' LIKE :oldurl'
                    . ' OR ' .
$db->quoteName('new_url') . ' LIKE :newurl'
                    . ' OR ' .
$db->quoteName('comment') . ' LIKE :comment'
                    . ' OR ' .
$db->quoteName('referer') . ' LIKE :referer)'
                )
                    ->bind(':oldurl', $search)
                    ->bind(':newurl', $search)
                    ->bind(':comment', $search)
                    ->bind(':referer', $search);
            }
        }

        // Add the list ordering clause.
       
$query->order($db->escape($this->getState('list.ordering',
'a.old_url')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));

        return $query;
    }

    /**
     * Add the entered URLs into the database
     *
     * @param   array  $batchUrls  Array of URLs to enter into the database
     *
     * @return boolean
     */
    public function batchProcess($batchUrls)
    {
        $db    = $this->getDatabase();
        $query = $db->getQuery(true);

        $params  = ComponentHelper::getParams('com_redirect');
        $state   = (int) $params->get('defaultImportState',
0);
        $created = Factory::getDate()->toSql();

        $columns = [
            'old_url',
            'new_url',
            'referer',
            'comment',
            'hits',
            'published',
            'created_date',
            'modified_date',
        ];

        $values = [
            ':oldurl',
            ':newurl',
            $db->quote(''),
            $db->quote(''),
            0,
            ':state',
            ':created',
            ':modified',
        ];

        $query
            ->insert($db->quoteName('#__redirect_links'),
false)
            ->columns($db->quoteName($columns))
            ->values(implode(', ', $values))
            ->bind(':oldurl', $old_url)
            ->bind(':newurl', $new_url)
            ->bind(':state', $state, ParameterType::INTEGER)
            ->bind(':created', $created)
            ->bind(':modified', $created);

        $db->setQuery($query);

        foreach ($batchUrls as $batch_url) {
            $old_url = $batch_url[0];

            // Destination URL can also be an external URL
            if (!empty($batch_url[1])) {
                $new_url = $batch_url[1];
            } else {
                $new_url = '';
            }

            $db->execute();
        }

        return true;
    }
}
src/Model/LinkModel.php000064400000015420151170206740010767
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Model;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\Utilities\ArrayHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Redirect link model.
 *
 * @since  1.6
 */
class LinkModel extends AdminModel
{
    /**
     * @var        string    The prefix to use with controller messages.
     * @since   1.6
     */
    protected $text_prefix = 'COM_REDIRECT';

    /**
     * Method to test whether a record can be deleted.
     *
     * @param   object  $record  A record object.
     *
     * @return  boolean  True if allowed to delete the record. Defaults to
the permission set in the component.
     *
     * @since   1.6
     */
    protected function canDelete($record)
    {
        if ($record->published != -2) {
            return false;
        }

        return parent::canDelete($record);
    }

    /**
     * Method to get the record form.
     *
     * @param   array    $data      Data for the form.
     * @param   boolean  $loadData  True if the form is to load its own
data (default case), false if not.
     *
     * @return  \Joomla\CMS\Form\Form A Form object on success, false on
failure
     *
     * @since   1.6
     */
    public function getForm($data = [], $loadData = true)
    {
        // Get the form.
        $form = $this->loadForm('com_redirect.link',
'link', ['control' => 'jform',
'load_data' => $loadData]);

        if (empty($form)) {
            return false;
        }

        // Modify the form based on access controls.
        if ($this->canEditState((object) $data) != true) {
            // Disable fields for display.
            $form->setFieldAttribute('published',
'disabled', 'true');

            // Disable fields while saving.
            // The controller has already verified this is a record you can
edit.
            $form->setFieldAttribute('published',
'filter', 'unset');
        }

        // If in advanced mode then we make sure the new URL field is not
compulsory and the header
        // field compulsory in case people select non-3xx redirects
        if
(ComponentHelper::getParams('com_redirect')->get('mode',
0) == true) {
            $form->setFieldAttribute('new_url',
'required', 'false');
            $form->setFieldAttribute('header',
'required', 'true');
        }

        return $form;
    }

    /**
     * Method to get the data that should be injected in the form.
     *
     * @return  mixed  The data for the form.
     *
     * @since   1.6
     */
    protected function loadFormData()
    {
        // Check the session for previously entered form data.
        $data =
Factory::getApplication()->getUserState('com_redirect.edit.link.data',
[]);

        if (empty($data)) {
            $data = $this->getItem();
        }

        $this->preprocessData('com_redirect.link', $data);

        return $data;
    }

    /**
     * Method to activate links.
     *
     * @param   array   &$pks     An array of link ids.
     * @param   string  $url      The new URL to set for the redirect.
     * @param   string  $comment  A comment for the redirect links.
     *
     * @return  boolean  Returns true on success, false on failure.
     *
     * @since   1.6
     */
    public function activate(&$pks, $url, $comment = null)
    {
        $user = $this->getCurrentUser();
        $db   = $this->getDatabase();

        // Sanitize the ids.
        $pks = (array) $pks;
        $pks = ArrayHelper::toInteger($pks);

        // Populate default comment if necessary.
        $comment = (!empty($comment)) ? $comment :
Text::sprintf('COM_REDIRECT_REDIRECTED_ON',
HTMLHelper::_('date', time()));

        // Access checks.
        if (!$user->authorise('core.edit',
'com_redirect')) {
            $pks = [];
           
$this->setError(Text::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'));

            return false;
        }

        if (!empty($pks)) {
            // Update the link rows.
            $query = $db->getQuery(true)
               
->update($db->quoteName('#__redirect_links'))
                ->set($db->quoteName('new_url') . ' =
:url')
                ->set($db->quoteName('published') . '
= 1')
                ->set($db->quoteName('comment') . ' =
:comment')
                ->whereIn($db->quoteName('id'), $pks)
                ->bind(':url', $url)
                ->bind(':comment', $comment);
            $db->setQuery($query);

            try {
                $db->execute();
            } catch (\RuntimeException $e) {
                $this->setError($e->getMessage());

                return false;
            }
        }

        return true;
    }

    /**
     * Method to batch update URLs to have new redirect urls and comments.
Note will publish any unpublished URLs.
     *
     * @param   array   &$pks     An array of link ids.
     * @param   string  $url      The new URL to set for the redirect.
     * @param   string  $comment  A comment for the redirect links.
     *
     * @return  boolean  Returns true on success, false on failure.
     *
     * @since   3.6.0
     */
    public function duplicateUrls(&$pks, $url, $comment = null)
    {
        $user = $this->getCurrentUser();
        $db   = $this->getDatabase();

        // Sanitize the ids.
        $pks = (array) $pks;
        $pks = ArrayHelper::toInteger($pks);

        // Access checks.
        if (!$user->authorise('core.edit',
'com_redirect')) {
            $pks = [];
           
$this->setError(Text::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'));

            return false;
        }

        if (!empty($pks)) {
            $date = Factory::getDate()->toSql();

            // Update the link rows.
            $query = $db->getQuery(true)
               
->update($db->quoteName('#__redirect_links'))
                ->set($db->quoteName('new_url') . ' =
:url')
                ->set($db->quoteName('modified_date') .
' = :date')
                ->set($db->quoteName('published') . '
= 1')
                ->whereIn($db->quoteName('id'), $pks)
                ->bind(':url', $url)
                ->bind(':date', $date);

            if (!empty($comment)) {
                $query->set($db->quoteName('comment') .
' = ' . $db->quote($comment));
            }

            $db->setQuery($query);

            try {
                $db->execute();
            } catch (\RuntimeException $e) {
                $this->setError($e->getMessage());

                return false;
            }
        }

        return true;
    }
}
src/Extension/RedirectComponent.php000064400000002550151170206740013451
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2018 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Extension;

use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use Joomla\Component\Redirect\Administrator\Service\HTML\Redirect;
use Psr\Container\ContainerInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Component class for com_redirect
 *
 * @since  4.0.0
 */
class RedirectComponent extends MVCComponent implements
BootableExtensionInterface
{
    use HTMLRegistryAwareTrait;

    /**
     * Booting the extension. This is the function to set up the
environment of the extension like
     * registering new class loaders, etc.
     *
     * If required, some initial set up can be done from services of the
container, eg.
     * registering HTML services.
     *
     * @param   ContainerInterface  $container  The container
     *
     * @return  void
     *
     * @since   4.0.0
     */
    public function boot(ContainerInterface $container)
    {
        $this->getRegistry()->register('redirect', new
Redirect());
    }
}
src/Controller/DisplayController.php000064400000003674151170206740013655
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2017 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Controller;

use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Router\Route;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Redirect display controller.
 *
 * @since  1.6
 */
class DisplayController extends BaseController
{
    /**
     * @var     string  The default view.
     * @since   1.6
     */
    protected $default_view = 'links';

    /**
     * Method to display a view.
     *
     * @param   boolean  $cachable   If true, the view output will be
cached.
     * @param   mixed    $urlparams  An array of safe URL parameters and
their variable types.
     *                   @see       
\Joomla\CMS\Filter\InputFilter::clean() for valid values.
     *
     * @return  static|boolean   This object to support chaining or false
on failure.
     *
     * @since   1.5
     */
    public function display($cachable = false, $urlparams = false)
    {
        $view   = $this->input->get('view',
'links');
        $layout = $this->input->get('layout',
'default');
        $id     = $this->input->getInt('id');

        // Check for edit form.
        if ($view == 'link' && $layout ==
'edit' &&
!$this->checkEditId('com_redirect.edit.link', $id)) {
            // Somehow the person just went to the form - we don't
allow that.
            if (!\count($this->app->getMessageQueue())) {
               
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID',
$id), 'error');
            }

           
$this->setRedirect(Route::_('index.php?option=com_redirect&view=links',
false));

            return false;
        }

        return parent::display();
    }
}
src/Controller/LinkController.php000064400000001174151170206740013136
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Controller;

use Joomla\CMS\MVC\Controller\FormController;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Redirect link controller class.
 *
 * @since  1.6
 */
class LinkController extends FormController
{
    // Parent class access checks are sufficient for this controller.
}
src/Controller/LinksController.php000064400000012677151170206750013334
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\Controller;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\AdminController;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Redirect link list controller class.
 *
 * @since  1.6
 */
class LinksController extends AdminController
{
    /**
     * Method to update a record.
     *
     * @return  void
     *
     * @since   1.6
     */
    public function activate()
    {
        // Check for request forgeries.
        $this->checkToken();

        $ids = (array) $this->input->get('cid', [],
'int');

        // Remove zero values resulting from input filter
        $ids = array_filter($ids);

        if (empty($ids)) {
           
$this->app->enqueueMessage(Text::_('COM_REDIRECT_NO_ITEM_SELECTED'),
'warning');
        } else {
            $newUrl  = $this->input->getString('new_url');
            $comment = $this->input->getString('comment');

            // Get the model.
            $model = $this->getModel();

            // Remove the items.
            if (!$model->activate($ids, $newUrl, $comment)) {
                $this->app->enqueueMessage($model->getError(),
'warning');
            } else {
               
$this->setMessage(Text::plural('COM_REDIRECT_N_LINKS_UPDATED',
\count($ids)));
            }
        }

       
$this->setRedirect('index.php?option=com_redirect&view=links');
    }

    /**
     * Method to duplicate URLs in records.
     *
     * @return  void
     *
     * @since   3.6.0
     */
    public function duplicateUrls()
    {
        // Check for request forgeries.
        $this->checkToken();

        $ids = (array) $this->input->get('cid', [],
'int');

        // Remove zero values resulting from input filter
        $ids = array_filter($ids);

        if (empty($ids)) {
           
$this->app->enqueueMessage(Text::_('COM_REDIRECT_NO_ITEM_SELECTED'),
'warning');
        } else {
            $newUrl  = $this->input->getString('new_url');
            $comment = $this->input->getString('comment');

            // Get the model.
            $model = $this->getModel();

            // Remove the items.
            if (!$model->duplicateUrls($ids, $newUrl, $comment)) {
                $this->app->enqueueMessage($model->getError(),
'warning');
            } else {
               
$this->setMessage(Text::plural('COM_REDIRECT_N_LINKS_UPDATED',
\count($ids)));
            }
        }

       
$this->setRedirect('index.php?option=com_redirect&view=links');
    }

    /**
     * Proxy for getModel.
     *
     * @param   string  $name    The name of the model.
     * @param   string  $prefix  The prefix of the model.
     * @param   array   $config  An array of settings.
     *
     * @return  \Joomla\CMS\MVC\Model\BaseDatabaseModel The model instance
     *
     * @since   1.6
     */
    public function getModel($name = 'Link', $prefix =
'Administrator', $config = ['ignore_request' =>
true])
    {
        return parent::getModel($name, $prefix, $config);
    }

    /**
     * Executes the batch process to add URLs to the database
     *
     * @return  void
     */
    public function batch()
    {
        // Check for request forgeries.
        $this->checkToken();

        $batch_urls_request =
$this->input->post->get('batch_urls', [],
'array');
        $batch_urls_lines   = array_map('trim',
explode("\n", $batch_urls_request[0]));

        $batch_urls = [];

        foreach ($batch_urls_lines as $batch_urls_line) {
            if (!empty($batch_urls_line)) {
                $params    =
ComponentHelper::getParams('com_redirect');
                $separator = $params->get('separator',
'|');

                // Basic check to make sure the correct separator is being
used
                if (!\Joomla\String\StringHelper::strpos($batch_urls_line,
$separator)) {
                   
$this->setMessage(Text::sprintf('COM_REDIRECT_NO_SEPARATOR_FOUND',
$separator), 'error');
                   
$this->setRedirect('index.php?option=com_redirect&view=links');

                    return;
                }

                $batch_urls[] = array_map('trim',
explode($separator, $batch_urls_line));
            }
        }

        // Set default message on error - overwrite if successful
       
$this->setMessage(Text::_('COM_REDIRECT_NO_ITEM_ADDED'),
'error');

        if (!empty($batch_urls)) {
            $model = $this->getModel('Links');

            // Execute the batch process
            if ($model->batchProcess($batch_urls)) {
               
$this->setMessage(Text::plural('COM_REDIRECT_N_LINKS_ADDED',
\count($batch_urls)));
            }
        }

       
$this->setRedirect('index.php?option=com_redirect&view=links');
    }

    /**
     * Clean out the unpublished links.
     *
     * @return  void
     *
     * @since   3.5
     */
    public function purge()
    {
        // Check for request forgeries.
        $this->checkToken();

        $model = $this->getModel('Links');

        if ($model->purge()) {
            $message = Text::_('COM_REDIRECT_CLEAR_SUCCESS');
        } else {
            $message = Text::_('COM_REDIRECT_CLEAR_FAIL');
        }

       
$this->setRedirect('index.php?option=com_redirect&view=links',
$message);
    }
}
src/View/Links/HtmlView.php000064400000014200151170206750011576
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\View\Links;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Toolbar\Button\DropdownButton;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Component\Redirect\Administrator\Helper\RedirectHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * View class for a list of redirection links.
 *
 * @since  1.6
 */
class HtmlView extends BaseHtmlView
{
    /**
     * True if "System - Redirect Plugin" is enabled
     *
     * @var  boolean
     */
    protected $enabled;

    /**
     * True if "Collect URLs" is enabled
     *
     * @var  boolean
     */
    protected $collect_urls_enabled;

    /**
     * The id of the redirect plugin in mysql
     *
     * @var    integer
     * @since  3.8.0
     */
    protected $redirectPluginId = 0;

    /**
     * An array of items
     *
     * @var  array
     */
    protected $items;

    /**
     * The pagination object
     *
     * @var    \Joomla\CMS\Pagination\Pagination
     */
    protected $pagination;

    /**
     * The model state
     *
     * @var  \Joomla\Registry\Registry
     */
    protected $state;

    /**
     * The model state
     *
     * @var  \Joomla\Registry\Registry
     */
    protected $params;

    /**
     * Form object for search filters
     *
     * @var    \Joomla\CMS\Form\Form
     *
     * @since  4.0.0
     */
    public $filterForm;

    /**
     * The active search filters
     *
     * @var    array
     * @since  4.0.0
     */
    public $activeFilters;

    /**
     * Is this view an Empty State
     *
     * @var  boolean
     * @since 4.0.0
     */
    private $isEmptyState = false;

    /**
     * Display the view.
     *
     * @param   string  $tpl  The name of the template file to parse;
automatically searches through the template paths.
     *
     * @return  void
     *
     * @throws  GenericDataException
     * @since   1.6
     */
    public function display($tpl = null)
    {
        // Set variables
        $this->items                = $this->get('Items');
        $this->pagination           =
$this->get('Pagination');
        $this->state                = $this->get('State');
        $this->filterForm           =
$this->get('FilterForm');
        $this->activeFilters        =
$this->get('ActiveFilters');
        $this->params               =
ComponentHelper::getParams('com_redirect');

        if (!\count($this->items) && $this->isEmptyState =
$this->get('IsEmptyState')) {
            $this->setLayout('emptystate');
        }

        // Check for errors.
        if (\count($errors = $this->get('Errors'))) {
            throw new GenericDataException(implode("\n",
$errors), 500);
        }

        if (!PluginHelper::isEnabled('system',
'redirect') || !RedirectHelper::collectUrlsEnabled()) {
            $this->redirectPluginId =
RedirectHelper::getRedirectPluginId();
        }

        $this->addToolbar();

        parent::display($tpl);
    }

    /**
     * Add the page title and toolbar.
     *
     * @return  void
     *
     * @since   1.6
     */
    protected function addToolbar()
    {
        $state   = $this->get('State');
        $canDo   = ContentHelper::getActions('com_redirect');
        $toolbar = Toolbar::getInstance();

       
ToolbarHelper::title(Text::_('COM_REDIRECT_MANAGER_LINKS'),
'map-signs redirect');

        if ($canDo->get('core.create')) {
            $toolbar->addNew('link.add');
        }

        if (!$this->isEmptyState &&
($canDo->get('core.edit.state') ||
$canDo->get('core.admin'))) {
            /** @var DropdownButton $dropdown */
            $dropdown =
$toolbar->dropdownButton('status-group',
'JTOOLBAR_CHANGE_STATUS')
                ->toggleSplit(false)
                ->icon('icon-ellipsis-h')
                ->buttonClass('btn btn-action')
                ->listCheck(true);

            $childBar = $dropdown->getChildToolbar();

            if ($state->get('filter.state') != 2) {
                $childBar->publish('links.publish',
'JTOOLBAR_ENABLE')->listCheck(true);
                $childBar->unpublish('links.unpublish',
'JTOOLBAR_DISABLE')->listCheck(true);
            }

            if ($state->get('filter.state') != -1) {
                if ($state->get('filter.state') != 2) {
                   
$childBar->archive('links.archive')->listCheck(true);
                } elseif ($state->get('filter.state') == 2) {
                   
$childBar->unarchive('links.unpublish')->listCheck(true);
                }
            }

            if (!$state->get('filter.state') == -2) {
               
$childBar->trash('links.trash')->listCheck(true);
            }
        }

        if ($state->get('filter.state') == -2 &&
$canDo->get('core.delete')) {
            $toolbar->delete('links.delete',
'JTOOLBAR_EMPTY_TRASH')
                ->message('JGLOBAL_CONFIRM_DELETE')
                ->listCheck(true);
        }

        if (!$this->isEmptyState &&
(!$state->get('filter.state') == -2 &&
$canDo->get('core.delete'))) {
            $toolbar->confirmButton('delete',
'COM_REDIRECT_TOOLBAR_PURGE', 'links.purge')
                ->message('COM_REDIRECT_CONFIRM_PURGE');
        }

        if ($canDo->get('core.create')) {
            $toolbar->popupButton('batch',
'JTOOLBAR_BULK_IMPORT')
                ->popupType('inline')
               
->textHeader(Text::_('COM_REDIRECT_BATCH_OPTIONS'))
                ->url('#joomla-dialog-batch')
                ->modalWidth('800px')
                ->modalHeight('fit-content')
                ->listCheck(false);
        }

        if ($canDo->get('core.admin') ||
$canDo->get('core.options')) {
            $toolbar->preferences('com_redirect');
        }

        $toolbar->help('Redirects:_Links');
    }
}
src/View/Link/HtmlView.php000064400000006363151170206750011426
0ustar00<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_redirect
 *
 * @copyright   (C) 2009 Open Source Matters, Inc.
<https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

namespace Joomla\Component\Redirect\Administrator\View\Link;

use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * View to edit a redirect link.
 *
 * @since  1.6
 */
class HtmlView extends BaseHtmlView
{
    /**
     * The active item
     *
     * @var  object
     */
    protected $item;

    /**
     * The Form object
     *
     * @var  \Joomla\CMS\Form\Form
     */
    protected $form;

    /**
     * The model state
     *
     * @var   \Joomla\Registry\Registry
     */
    protected $state;

    /**
     * Display the view.
     *
     * @param   string  $tpl  The name of the template file to parse;
automatically searches through the template paths.
     *
     * @return  void
     *
     * @since   1.6
     */
    public function display($tpl = null)
    {
        $this->form  = $this->get('Form');
        $this->item  = $this->get('Item');
        $this->state = $this->get('State');

        // Check for errors.
        if (\count($errors = $this->get('Errors'))) {
            throw new GenericDataException(implode("\n",
$errors), 500);
        }

        $this->addToolbar();
        parent::display($tpl);
    }

    /**
     * Add the page title and toolbar.
     *
     * @return  void
     *
     * @since   1.6
     */
    protected function addToolbar()
    {
       
Factory::getApplication()->getInput()->set('hidemainmenu',
true);

        $isNew   = ($this->item->id == 0);
        $canDo   = ContentHelper::getActions('com_redirect');
        $toolbar = Toolbar::getInstance();

        ToolbarHelper::title($isNew ?
Text::_('COM_REDIRECT_MANAGER_LINK_NEW') :
Text::_('COM_REDIRECT_MANAGER_LINK_EDIT'), 'map-signs
redirect');

        if ($canDo->get('core.edit')) {
            $toolbar->apply('link.apply');
        }

        $saveGroup = $toolbar->dropdownButton('save-group');

        $saveGroup->configure(
            function (Toolbar $childBar) use ($canDo) {
                // If not checked out, can save the item.
                if ($canDo->get('core.edit')) {
                    $childBar->save('link.save');
                }

                /**
                 * This component does not support Save as Copy due to
uniqueness checks.
                 * While it can be done, it causes too much confusion if
the user does
                 * not change the Old URL.
                 */
                if ($canDo->get('core.edit') &&
$canDo->get('core.create')) {
                    $childBar->save2new('link.save2new');
                }
            }
        );

        if (empty($this->item->id)) {
            $toolbar->cancel('link.cancel',
'JTOOLBAR_CANCEL');
        } else {
            $toolbar->cancel('link.cancel');
        }

        $toolbar->help('Redirects:_New_or_Edit');
    }
}