Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:joomla/joomla-cms into com_contact
Browse files Browse the repository at this point in the history
  • Loading branch information
zero-24 committed Aug 30, 2017
2 parents 2ca863a + b43687d commit db296f8
Show file tree
Hide file tree
Showing 13 changed files with 159 additions and 17 deletions.
16 changes: 15 additions & 1 deletion administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,7 @@ public function deleteUnexistingFiles()
'/components/com_wrapper/metadata.xml',
'/administrator/components/com_cache/layouts/joomla/searchtools/default/bar.php',
'/administrator/components/com_cache/layouts/joomla/searchtools/default.php',
'/administrator/components/com_content/models/fields/votelist.php',
'/administrator/components/com_languages/layouts/joomla/searchtools/default/bar.php',
'/administrator/components/com_languages/layouts/joomla/searchtools/default.php',
'/administrator/components/com_modules/layouts/joomla/searchtools/default/bar.php',
Expand Down Expand Up @@ -1827,6 +1828,15 @@ public function deleteUnexistingFiles()
'/libraries/joomla/form/rule/url.php',
'/libraries/joomla/form/rule/username.php',
'/libraries/joomla/form/wrapper/helper.php',
'/libraries/joomla/http/factory.php',
'/libraries/joomla/http/http.php',
'/libraries/joomla/http/response.php',
'/libraries/joomla/http/transport.php',
'/libraries/joomla/http/transport/cacert.pem',
'/libraries/joomla/http/transport/curl.php',
'/libraries/joomla/http/transport/socket.php',
'/libraries/joomla/http/transport/stream.php',
'/libraries/joomla/http/wrapper/factory.php',
'/libraries/joomla/image/filter/backgroundfill.php',
'/libraries/joomla/image/filter/brightness.php',
'/libraries/joomla/image/filter/contrast.php',
Expand Down Expand Up @@ -2123,6 +2133,9 @@ public function deleteUnexistingFiles()
'/libraries/joomla/filter',
'/libraries/joomla/form/rule',
'/libraries/joomla/form/wrapper',
'/libraries/joomla/http/transport',
'/libraries/joomla/http/wrapper',
'/libraries/joomla/http',
'/libraries/joomla/image/filter',
'/libraries/joomla/image',
'/libraries/joomla/input',
Expand All @@ -2147,10 +2160,11 @@ public function deleteUnexistingFiles()
'/libraries/legacy/categories',
'/libraries/legacy/controller',
'/libraries/legacy/model',
'/libraries/legacy/table/menu',
'/libraries/legacy/view',
'/libraries/legacy/web',
'/media/editors/tinymce/plugins/jdragdrop',
'/administrator/modules/mod_menu/preset',
'/administrator/components/com_content/models/fields/votelist.php',
);

jimport('joomla.filesystem.file');
Expand Down
7 changes: 7 additions & 0 deletions administrator/components/com_redirect/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="separator"
type="text"
label="COM_REDIRECT_BULK_SEPARATOR_LABEL"
description="COM_REDIRECT_BULK_SEPARATOR_DESC"
default="|"
/>
</fieldset>

<fieldset
Expand Down
3 changes: 2 additions & 1 deletion administrator/components/com_redirect/controllers/links.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public function batch()
{
if (!empty($batch_urls_line))
{
$batch_urls[] = array_map('trim', explode('|', $batch_urls_line));
$params = JComponentHelper::getParams('com_redirect');
$batch_urls[] = array_map('trim', explode($params->get('separator', '|'), $batch_urls_line));
}
}

Expand Down
10 changes: 1 addition & 9 deletions administrator/components/com_redirect/models/links.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,7 @@ public function batchProcess($batch_urls)

foreach ($batch_urls as $batch_url)
{
// Source URLs need to have the correct URL format to work properly
if (strpos($batch_url[0], JUri::root()) === false)
{
$old_url = JUri::root() . $batch_url[0];
}
else
{
$old_url = $batch_url[0];
}
$old_url = $batch_url[0];

// Destination URL can also be an external URL
if (!empty($batch_url[1]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
*/
defined('_JEXEC') or die;
$published = $this->state->get('filter.published');
$params = $this->params;
$separator = $params->get('separator', '|');
?>

<div class="container-fluid">
<div class="row-fluid">
<div class="control-group span12">
<p><?php echo JText::_('COM_REDIRECT_BATCH_TIP'); ?></p>
<p><?php echo JText::sprintf('COM_REDIRECT_BATCH_TIP', $separator); ?></p>
<div class="controls">
<textarea class="span12" rows="10" aria-required="true" value="" id="batch_urls" name="batch_urls"></textarea>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function display($tpl = null)
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->params = JComponentHelper::getParams('com_redirect');

// Check for errors.
if (count($errors = $this->get('Errors')))
Expand Down
4 changes: 3 additions & 1 deletion administrator/language/en-GB/en-GB.com_redirect.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
COM_REDIRECT="Redirects"
COM_REDIRECT_ADVANCED_OPTIONS="Advanced"
COM_REDIRECT_BATCH_OPTIONS="Bulk process to add new URLs"
COM_REDIRECT_BATCH_TIP="Enter expired URL (mandatory) with a new URL (optional) separated with | (eg old-url|new-url). Each line one entry!"
COM_REDIRECT_BATCH_TIP="Enter expired URL (mandatory) with a new URL (optional) separated with %1$s (eg old-url%1$snew-url). Each line one entry!"
COM_REDIRECT_BULK_SEPARATOR_DESC="The separator used for bulk import, by default it is '|' but it can be ',' for a copy / paste from a CSV file for instance."
COM_REDIRECT_BULK_SEPARATOR_LABEL="Bulk Import Separator"
COM_REDIRECT_BUTTON_UPDATE_LINKS="Update Links"
COM_REDIRECT_CLEAR_FAIL="Failed to delete disabled links."
COM_REDIRECT_CLEAR_SUCCESS="All disabled links have been deleted."
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/models/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function populateState($ordering = null, $direction = null)

$this->setState('category.id', $pk);

$value = $app->input->get('filter_tag', 0, 'uint');
$value = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', 0, 'int');
$this->setState('filter.tag', $value);

// Load the parameters. Merge Global and Menu Item params into new object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

namespace Joomla\CMS\Component\Exception;

use Joomla\CMS\Router\Exception\RouteNotFoundException;

defined('JPATH_PLATFORM') or die;

/**
* Exception class defining an error for a missing component
*
* @since 3.7.0
*/
class MissingComponentException extends \InvalidArgumentException
class MissingComponentException extends RouteNotFoundException
{
/**
* Constructor
Expand Down
38 changes: 38 additions & 0 deletions libraries/src/Router/Exception/RouteNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\Router\Exception;

defined('JPATH_PLATFORM') or die;

/**
* Exception class defining an error for a missing route
*
* @since __DEPLOY_VERSION__
*/
class RouteNotFoundException extends \InvalidArgumentException
{
/**
* Constructor
*
* @param string $message The Exception message to throw.
* @param integer $code The Exception code.
* @param \Exception $previous The previous exception used for the exception chaining.
*
* @since __DEPLOY_VERSION__
*/
public function __construct($message = '', $code = 404, \Exception $previous = null)
{
if (empty($message))
{
$message = 'URL was not found';
}

parent::__construct($message, $code, $previous);
}
}
3 changes: 2 additions & 1 deletion libraries/src/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Router\Exception\RouteNotFoundException;

/**
* Class to create and parse routes
Expand Down Expand Up @@ -234,7 +235,7 @@ public function parse(&$uri)
if (strlen($uri->getPath()) > 0 && array_key_exists('option', $vars)
&& ComponentHelper::getParams($vars['option'])->get('sef_advanced', 0))
{
throw new \Exception('URL invalid', 404);
throw new RouteNotFoundException('URL invalid');
}

return array_merge($this->getVars(), $vars);
Expand Down
53 changes: 53 additions & 0 deletions libraries/src/Table/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,57 @@ public function store($updateNulls = false)

return parent::store($updateNulls);
}

/**
* Method to compute the default name of the asset.
* The default name is in the form table_name.id
* where id is the value of the primary key of the table.
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
protected function _getAssetName()
{
return 'com_languages.language.' . $this->lang_id;
}

/**
* Method to return the title to use for the asset table.
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
protected function _getAssetTitle()
{
return $this->title;
}

/**
* Method to get the parent asset under which to register this one.
* By default, all assets are registered to the ROOT node with ID,
* which will default to 1 if none exists.
* The extended class can define a table and id to lookup. If the
* asset does not exist it will be created.
*
* @param Table $table A Table object for the asset parent.
* @param integer $id Id to look up
*
* @return integer
*
* @since __DEPLOY_VERSION__
*/
protected function _getAssetParentId(Table $table = null, $id = null)
{
$assetId = null;
$asset = Table::getInstance('asset');

if ($asset->loadByName('com_languages'))
{
$assetId = $asset->id;
}

return $assetId === null ? parent::_getAssetParentId($table, $id) : $assetId;
}
}
31 changes: 30 additions & 1 deletion plugins/system/redirect/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,24 @@ private static function doErrorHandling($error)
// These are the original URLs
$orgurl = rawurldecode($uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment')));
$orgurlRel = rawurldecode($uri->toString(array('path', 'query', 'fragment')));

// The above doesn't work for sub directories, so do this
$orgurlRootRel = str_replace(JUri::root(), '', $orgurl);

// For when users have added / to the url
$orgurlRootRelSlash = str_replace(JUri::root(), '/', $orgurl);
$orgurlWithoutQuery = rawurldecode($uri->toString(array('scheme', 'host', 'port', 'path', 'fragment')));
$orgurlRelWithoutQuery = rawurldecode($uri->toString(array('path', 'fragment')));

// These are the URLs we save and use
$url = StringHelper::strtolower(rawurldecode($uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment'))));
$urlRel = StringHelper::strtolower(rawurldecode($uri->toString(array('path', 'query', 'fragment'))));

// The above doesn't work for sub directories, so do this
$urlRootRel = str_replace(JUri::root(), '', $url);

// For when users have added / to the url
$urlRootRelSlash = str_replace(JUri::root(), '/', $url);
$urlWithoutQuery = StringHelper::strtolower(rawurldecode($uri->toString(array('scheme', 'host', 'port', 'path', 'fragment'))));
$urlRelWithoutQuery = StringHelper::strtolower(rawurldecode($uri->toString(array('path', 'fragment'))));

Expand Down Expand Up @@ -183,6 +195,10 @@ private static function doErrorHandling($error)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($urlRel)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($urlRootRel)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($urlRootRelSlash)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($urlWithoutQuery)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($urlRelWithoutQuery)
Expand All @@ -191,6 +207,10 @@ private static function doErrorHandling($error)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($orgurlRel)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($orgurlRootRel)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($orgurlRootRelSlash)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($orgurlWithoutQuery)
. ' OR '
. $db->quoteName('old_url') . ' = ' . $db->quote($orgurlRelWithoutQuery)
Expand All @@ -214,10 +234,14 @@ private static function doErrorHandling($error)
array(
$url,
$urlRel,
$urlRootRel,
$urlRootRelSlash,
$urlWithoutQuery,
$urlRelWithoutQuery,
$orgurl,
$orgurlRel,
$orgurlRootRel,
$orgurlRootRelSlash,
$orgurlWithoutQuery,
$orgurlRelWithoutQuery,
)
Expand Down Expand Up @@ -255,7 +279,12 @@ private static function doErrorHandling($error)
$redirect->new_url .= '?' . $urlQuery;
}

$destination = JUri::isInternal($redirect->new_url) ? JRoute::_($redirect->new_url) : $redirect->new_url;
$dest = JUri::isInternal($redirect->new_url) || strpos('http', $redirect->new_url) === false ?
JRoute::_(JUri::root() . $redirect->new_url) :
$redirect->new_url;

// In case the url contains double // lets remove it
$destination = str_replace(JUri::root() . '/', JUri::root(), $dest);

$app->redirect($destination, (int) $redirect->header);
}
Expand Down

0 comments on commit db296f8

Please sign in to comment.