| Current Path : /home/digilove/www/41423/ |
| Current File : /home/digilove/www/41423/com_redirect.tar |
controllers/index.html 0000644 00000000037 15234543703 0011115 0 ustar 00 <!DOCTYPE html><title></title>
controllers/link.php 0000644 00000000703 15234543703 0010566 0 ustar 00 <?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;
/**
* Redirect link controller class.
*
* @since 1.6
*/
class RedirectControllerLink extends JControllerForm
{
// Parent class access checks are sufficient for this controller.
}
controllers/links.php 0000644 00000010637 15234543703 0010760 0 ustar 00 <?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;
/**
* Redirect link list controller class.
*
* @since 1.6
*/
class RedirectControllerLinks extends JControllerAdmin
{
/**
* 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', array(), 'int');
// Remove zero values resulting from input filter
$ids = array_filter($ids);
if (empty($ids))
{
JError::raiseWarning(500, JText::_('COM_REDIRECT_NO_ITEM_SELECTED'));
}
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))
{
JError::raiseWarning(500, $model->getError());
}
else
{
$this->setMessage(JText::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', array(), 'int');
// Remove zero values resulting from input filter
$ids = array_filter($ids);
if (empty($ids))
{
JError::raiseWarning(500, JText::_('COM_REDIRECT_NO_ITEM_SELECTED'));
}
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))
{
JError::raiseWarning(500, $model->getError());
}
else
{
$this->setMessage(JText::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 JModel instance
*
* @since 1.6
*/
public function getModel($name = 'Link', $prefix = 'RedirectModel', $config = array('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(), 'array');
$batch_urls_lines = array_map('trim', explode("\n", $batch_urls_request[0]));
$batch_urls = array();
foreach ($batch_urls_lines as $batch_urls_line)
{
if (!empty($batch_urls_line))
{
$params = JComponentHelper::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(JText::sprintf('COM_REDIRECT_NO_SEPARATOR_FOUND', $separator), 'error');
$this->setRedirect('index.php?option=com_redirect&view=links');
return false;
}
$batch_urls[] = array_map('trim', explode($separator, $batch_urls_line));
}
}
// Set default message on error - overwrite if successful
$this->setMessage(JText::_('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(JText::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 = JText::_('COM_REDIRECT_CLEAR_SUCCESS');
}
else
{
$message = JText::_('COM_REDIRECT_CLEAR_FAIL');
}
$this->setRedirect('index.php?option=com_redirect&view=links', $message);
}
}
helpers/html/index.html 0000644 00000000037 15234543703 0011155 0 ustar 00 <!DOCTYPE html><title></title>
helpers/html/redirect.php 0000644 00000003477 15234543703 0011505 0 ustar 00 <?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\Utilities\ArrayHelper;
/**
* Utility class for creating HTML Grids.
*
* @since 1.6
*/
class JHtmlRedirect
{
/**
* 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 static function published($value = 0, $i = null, $canChange = true)
{
// 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 = array(
1 => array('publish', 'links.unpublish', 'JENABLED', 'COM_REDIRECT_DISABLE_LINK'),
0 => array('unpublish', 'links.publish', 'JDISABLED', 'COM_REDIRECT_ENABLE_LINK'),
2 => array('archive', 'links.unpublish', 'JARCHIVED', 'JUNARCHIVE'),
-2 => array('trash', 'links.publish', 'JTRASHED', 'COM_REDIRECT_ENABLE_LINK'),
);
$state = ArrayHelper::getValue($states, (int) $value, $states[0]);
$icon = $state[0];
if ($canChange)
{
$html = '<a href="#" onclick="return listItemTask(\'cb' . $i . '\',\'' . $state[1] . '\')" class="btn btn-micro hasTooltip'
. ($value == 1 ? ' active' : '') . '" title="' . JHtml::_('tooltipText', $state[3])
. '"><span class="icon-' . $icon . '" aria-hidden="true"></span></a>';
}
return $html;
}
}
helpers/index.html 0000644 00000000037 15234543703 0010211 0 ustar 00 <!DOCTYPE html><title></title>
helpers/redirect.php 0000644 00000005566 15234543703 0010542 0 ustar 00 <?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\Registry\Registry;
/**
* Redirect component helper.
*
* @since 1.6
*/
class RedirectHelper
{
public static $extension = 'com_redirect';
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
// No submenu for this component.
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions()
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
return JHelperContent::getActions('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 = array();
$options[] = JHtml::_('select.option', '*', 'JALL');
$options[] = JHtml::_('select.option', '1', 'JENABLED');
$options[] = JHtml::_('select.option', '0', 'JDISABLED');
$options[] = JHtml::_('select.option', '2', 'JARCHIVED');
$options[] = JHtml::_('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 = JFactory::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)
{
JError::raiseWarning(500, $e->getMessage());
}
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 (JPluginHelper::isEnabled('system', 'redirect'))
{
$params = new Registry(JPluginHelper::getPlugin('system', 'redirect')->params);
$collect_urls = (bool) $params->get('collect_urls', 1);
}
return $collect_urls;
}
}
layouts/toolbar/batch.php 0000644 00000001051 15234543703 0011503 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage Layout
*
* @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;
JHtml::_('behavior.core');
$title = $displayData['title'];
?>
<button type="button" data-toggle="modal" onclick="{jQuery( '#collapseModal' ).modal('show'); return true;}" class="btn btn-small">
<span class="icon-checkbox-partial" aria-hidden="true"></span>
<?php echo $title; ?>
</button>
models/fields/redirect.php 0000644 00000007435 15234543703 0011626 0 ustar 00 <?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
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* A dropdown containing all valid HTTP 1.1 response codes.
*
* @package Joomla.Administrator
* @subpackage com_redirect
* @since 3.4
*/
class JFormFieldRedirect extends JFormFieldList
{
/**
* 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 http://www.iana.org/assignments/http-status-codes/
*/
protected $responseMap = array(
100 => 'HTTP/1.1 100 Continue',
101 => 'HTTP/1.1 101 Switching Protocols',
102 => 'HTTP/1.1 102 Processing',
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',
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 string The field input markup.
*
* @since 3.4
*/
protected function getOptions()
{
$options = array();
foreach ($this->responseMap as $key => $value)
{
$options[] = JHtml::_('select.option', $key, $value);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
models/forms/filter_links.xml 0000644 00000004565 15234543703 0012404 0 ustar 00 <?xml version="1.0" encoding="utf-8"?>
<form>
<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="redirect_status"
label="COM_REDIRECT_FILTER_PUBLISHED"
description="COM_REDIRECT_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="http_status"
type="Redirect"
label="COM_REDIRECT_FILTER_HTTP_HEADER_LABEL"
description="COM_REDIRECT_FILTER_HTTP_HEADER_DESC"
onchange="this.form.submit();"
>
<option value="">COM_REDIRECT_FILTER_SELECT_OPTION_HTTP_HEADER</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
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_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="5"
onchange="this.form.submit();"
/>
</fields>
</form>
models/forms/index.html 0000644 00000000037 15234543703 0011160 0 ustar 00 <!DOCTYPE html><title></title>
models/forms/link.xml 0000644 00000004021 15234543703 0010637 0 ustar 00 <?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
id="id"
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"
class="input-xxlarge"
size="50"
required="true"
/>
<field
name="new_url"
type="text"
label="COM_REDIRECT_FIELD_NEW_URL_LABEL"
description="COM_REDIRECT_FIELD_NEW_URL_DESC"
class="input-xxlarge"
size="50"
required="true"
/>
<field
name="comment"
type="text"
label="COM_REDIRECT_FIELD_COMMENT_LABEL"
description="COM_REDIRECT_FIELD_COMMENT_DESC"
size="40"
/>
<field
name="published"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="chzn-color-state"
size="1"
default="1"
>
<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"
id="referer"
size="50"
readonly="true"
/>
<field
name="created_date"
type="text"
label="COM_REDIRECT_FIELD_CREATED_DATE_LABEL"
id="created_date"
class="readonly"
size="20"
readonly="true"
/>
<field
name="modified_date"
type="text"
label="COM_REDIRECT_FIELD_UPDATED_DATE_LABEL"
id="modified_date"
class="readonly"
size="20"
readonly="true"
/>
<field
name="hits"
type="number"
label="JGLOBAL_HITS"
id="hits"
class="readonly"
size="20"
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"
class="input-xlarge"
/>
</fieldset>
</form>
models/index.html 0000644 00000000037 15234543703 0010032 0 ustar 00 <!DOCTYPE html><title></title>
models/link.php 0000644 00000014042 15234543703 0007504 0 ustar 00 <?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\Utilities\ArrayHelper;
/**
* Redirect link model.
*
* @since 1.6
*/
class RedirectModelLink extends JModelAdmin
{
/**
* @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);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Link', $prefix = 'RedirectTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* 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 JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_redirect.link', 'link', array('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 (JComponentHelper::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 = JFactory::getApplication()->getUserState('com_redirect.edit.link.data', array());
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 = JFactory::getUser();
$db = $this->getDbo();
// Sanitize the ids.
$pks = (array) $pks;
$pks = ArrayHelper::toInteger($pks);
// Populate default comment if necessary.
$comment = (!empty($comment)) ? $comment : JText::sprintf('COM_REDIRECT_REDIRECTED_ON', JHtml::_('date', time()));
// Access checks.
if (!$user->authorise('core.edit', 'com_redirect'))
{
$pks = array();
$this->setError(JText::_('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') . ' = ' . $db->quote($url))
->set($db->quoteName('published') . ' = ' . (int) 1)
->set($db->quoteName('comment') . ' = ' . $db->quote($comment))
->where($db->quoteName('id') . ' IN (' . implode(',', $pks) . ')');
$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 = JFactory::getUser();
$db = $this->getDbo();
// Sanitize the ids.
$pks = (array) $pks;
$pks = ArrayHelper::toInteger($pks);
// Access checks.
if (!$user->authorise('core.edit', 'com_redirect'))
{
$pks = array();
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'));
return false;
}
if (!empty($pks))
{
$date = JFactory::getDate()->toSql();
// Update the link rows.
$query = $db->getQuery(true)
->update($db->quoteName('#__redirect_links'))
->set($db->quoteName('new_url') . ' = ' . $db->quote($url))
->set($db->quoteName('modified_date') . ' = ' . $db->quote($date))
->set($db->quoteName('published') . ' = ' . 1)
->where($db->quoteName('id') . ' IN (' . implode(',', $pks) . ')');
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;
}
}
models/links.php 0000644 00000013556 15234543703 0007700 0 ustar 00 <?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;
/**
* Methods supporting a list of redirect links.
*
* @since 1.6
*/
class RedirectModelLinks extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'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);
}
/**
* Removes all of the unpublished redirects from the table.
*
* @return boolean result of operation
*
* @since 3.5
*/
public function purge()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->delete('#__redirect_links')->where($db->qn('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 filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string'));
$this->setState('filter.http_status', $this->getUserStateFromRequest($this->context . '.filter.http_status', 'filter_http_status', '', 'cmd'));
// Load the parameters.
$params = JComponentHelper::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 JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$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 = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where($db->quoteName('a.published') . ' = ' . (int) $state);
}
elseif ($state === '')
{
$query->where($db->quoteName('a.published') . ' IN (0,1)');
}
// Filter the items over the HTTP status code header.
if ($httpStatusCode = $this->getState('filter.http_status'))
{
$query->where($db->quoteName('a.header') . ' = ' . (int) $httpStatusCode);
}
// Filter the items over the search string if set.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where($db->quoteName('a.id') . ' = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
$query->where(
'(' . $db->quoteName('old_url') . ' LIKE ' . $search .
' OR ' . $db->quoteName('new_url') . ' LIKE ' . $search .
' OR ' . $db->quoteName('comment') . ' LIKE ' . $search .
' OR ' . $db->quoteName('referer') . ' LIKE ' . $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 = JFactory::getDbo();
$query = $db->getQuery(true);
$params = JComponentHelper::getParams('com_redirect');
$state = (int) $params->get('defaultImportState', 0);
$columns = array(
$db->quoteName('old_url'),
$db->quoteName('new_url'),
$db->quoteName('referer'),
$db->quoteName('comment'),
$db->quoteName('hits'),
$db->quoteName('published'),
$db->quoteName('created_date')
);
$query->columns($columns);
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 = '';
}
$query->insert($db->quoteName('#__redirect_links'), false)
->values(
$db->quote($old_url) . ', ' . $db->quote($new_url) . ' ,' . $db->quote('') . ', ' . $db->quote('') . ', 0, ' . $state . ', ' .
$db->quote(JFactory::getDate()->toSql())
);
}
$db->setQuery($query);
$db->execute();
return true;
}
}
tables/index.html 0000644 00000000037 15234543703 0010021 0 ustar 00 <!DOCTYPE html><title></title>
tables/link.php 0000644 00000005407 15234543703 0007500 0 ustar 00 <?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;
/**
* Link Table for Redirect.
*
* @since 1.6
*/
class RedirectTableLink extends JTable
{
/**
* Constructor
*
* @param JDatabaseDriver $db Database object.
*
* @since 1.6
*/
public function __construct($db)
{
parent::__construct('#__redirect_links', 'id', $db);
}
/**
* Overloaded check function
*
* @return boolean
*
* @since 1.6
*/
public function check()
{
$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(JText::_('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) && JComponentHelper::getParams('com_redirect')->get('mode', 0) == false)
{
$this->setError(JText::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED'));
return false;
}
elseif (empty($this->new_url) && JComponentHelper::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(JText::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED'));
return false;
}
}
// Check for duplicates
if ($this->old_url == $this->new_url)
{
$this->setError(JText::_('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('#__redirect_links')
->where($db->quoteName('old_url') . ' = ' . $db->quote($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(JText::_('COM_REDIRECT_ERROR_DUPLICATE_OLD_URL'));
return false;
}
}
return true;
}
/**
* Overriden 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 = JFactory::getDate()->toSql();
$this->modified_date = $date;
if (!$this->id)
{
// New record.
$this->created_date = $date;
}
return parent::store($updateNulls);
}
}
views/link/tmpl/edit.php 0000644 00000003661 15234543703 0011264 0 ustar 00 <?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;
// Include the HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
{
if (task == 'link.cancel' || document.formvalidator.isValid(document.getElementById('link-form')))
{
Joomla.submitform(task, document.getElementById('link-form'));
}
};
");
?>
<form action="<?php echo JRoute::_('index.php?option=com_redirect&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="link-form" class="form-validate form-horizontal">
<fieldset>
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'basic')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'basic', empty($this->item->id) ? JText::_('COM_REDIRECT_NEW_LINK') : JText::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 (JComponentHelper::getParams('com_redirect')->get('mode')) : ?>
<?php echo $this->form->renderFieldset('advanced'); ?>
<?php endif; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</fieldset>
</form>
views/link/tmpl/index.html 0000644 00000000037 15234543703 0011615 0 ustar 00 <!DOCTYPE html><title></title>
views/link/index.html 0000644 00000000037 15234543703 0010641 0 ustar 00 <!DOCTYPE html><title></title>
views/link/view.html.php 0000644 00000004113 15234543703 0011271 0 ustar 00 <?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;
/**
* View to edit a redirect link.
*
* @since 1.6
*/
class RedirectViewLink extends JViewLegacy
{
protected $item;
protected $form;
protected $state;
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed False if unsuccessful, otherwise 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 Exception(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$isNew = ($this->item->id == 0);
$canDo = JHelperContent::getActions('com_redirect');
JToolbarHelper::title($isNew ? JText::_('COM_REDIRECT_MANAGER_LINK_NEW') : JText::_('COM_REDIRECT_MANAGER_LINK_EDIT'), 'refresh redirect');
// If not checked out, can save the item.
if ($canDo->get('core.edit'))
{
JToolbarHelper::apply('link.apply');
JToolbarHelper::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'))
{
JToolbarHelper::save2new('link.save2new');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('link.cancel');
}
else
{
JToolbarHelper::cancel('link.cancel', 'JTOOLBAR_CLOSE');
}
JToolbarHelper::help('JHELP_COMPONENTS_REDIRECT_MANAGER_EDIT');
}
}
views/links/tmpl/default.php 0000644 00000015707 15234543703 0012152 0 ustar 00 <?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;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<form action="<?php echo JRoute::_('index.php?option=com_redirect&view=links'); ?>" method="post" name="adminForm" id="adminForm">
<div id="j-main-container">
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php if ($this->redirectPluginId) : ?>
<?php $link = JRoute::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->redirectPluginId . '&tmpl=component&layout=modal'); ?>
<?php echo JHtml::_(
'bootstrap.renderModal',
'plugin' . $this->redirectPluginId . 'Modal',
array(
'url' => $link,
'title' => JText::_('COM_REDIRECT_EDIT_PLUGIN_SETTINGS'),
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'closeButton' => false,
'backdrop' => 'static',
'keyboard' => false,
'footer' => '<button type="button" class="btn" data-dismiss="modal"'
. ' onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#closeBtn\').click();">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
. '<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#saveBtn\').click();">'
. JText::_("JSAVE") . '</button>'
. '<button type="button" class="btn btn-success" onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#applyBtn\').click(); return false;">'
. JText::_("JAPPLY") . '</button>'
)
); ?>
<?php endif; ?>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped">
<thead>
<tr>
<th width="1%" class="center nowrap">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th width="1%" class="center nowrap">
<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
</th>
<th class="nowrap title">
<?php echo JHtml::_('searchtools.sort', 'COM_REDIRECT_HEADING_OLD_URL', 'a.old_url', $listDirn, $listOrder); ?>
</th>
<th width="30%" class="nowrap">
<?php echo JHtml::_('searchtools.sort', 'COM_REDIRECT_HEADING_NEW_URL', 'a.new_url', $listDirn, $listOrder); ?>
</th>
<th width="30%" class="nowrap hidden-phone hidden-tablet">
<?php echo JHtml::_('searchtools.sort', 'COM_REDIRECT_HEADING_REFERRER', 'a.referer', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone hidden-tablet">
<?php echo JHtml::_('searchtools.sort', 'COM_REDIRECT_HEADING_CREATED_DATE', 'a.created_date', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'COM_REDIRECT_HEADING_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'COM_REDIRECT_HEADING_STATUS_CODE', 'a.header', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="9">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<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="center">
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<td class="center">
<div class="btn-group">
<?php echo JHtml::_('redirect.published', $item->published, $i); ?>
<?php // Create dropdown items and render the dropdown list.
if ($canChange)
{
JHtml::_('actionsdropdown.' . ((int) $item->published === 2 ? 'un' : '') . 'archive', 'cb' . $i, 'links');
JHtml::_('actionsdropdown.' . ((int) $item->published === -2 ? 'un' : '') . 'trash', 'cb' . $i, 'links');
echo JHtml::_('actionsdropdown.render', $this->escape($item->old_url));
}
?>
</div>
</td>
<td class="break-word">
<?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_redirect&task=link.edit&id=' . $item->id); ?>" title="<?php echo $this->escape($item->old_url); ?>">
<?php echo $this->escape(str_replace(JUri::root(), '', rawurldecode($item->old_url))); ?></a>
<?php else : ?>
<?php echo $this->escape(str_replace(JUri::root(), '', rawurldecode($item->old_url))); ?>
<?php endif; ?>
</td>
<td class="small break-word">
<?php echo $this->escape(rawurldecode($item->new_url)); ?>
</td>
<td class="small break-word hidden-phone hidden-tablet">
<?php echo $this->escape($item->referer); ?>
</td>
<td class="small hidden-phone hidden-tablet">
<?php echo JHtml::_('date', $item->created_date, JText::_('DATE_FORMAT_LC4')); ?>
</td>
<td class="hidden-phone">
<?php echo (int) $item->hits; ?>
</td>
<td class="hidden-phone">
<?php echo (int) $item->header; ?>
</td>
<td class="hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?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')) : ?>
<?php echo JHtml::_(
'bootstrap.renderModal',
'collapseModal',
array(
'title' => JText::_('COM_REDIRECT_BATCH_OPTIONS'),
'footer' => $this->loadTemplate('batch_footer'),
),
$this->loadTemplate('batch_body')
); ?>
<?php endif; ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
views/links/tmpl/default.xml 0000644 00000000254 15234543703 0012152 0 ustar 00 <?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_REDIRECT">
<message>
<![CDATA[COM_REDIRECT_XML_DESCRIPTION]]>
</message>
</layout>
</metadata>