From b604311c54eded74cb336098d56145947fe583aa Mon Sep 17 00:00:00 2001 From: tonypartridge <6GW7iqJ78B> Date: Sun, 25 Mar 2018 00:15:27 +0000 Subject: [PATCH 01/10] Basic check to make sure the bulk import seperator is being used. Added Import State function as to how the urls should be imported, enabled or disabled. --- administrator/components/com_redirect/config.xml | 11 +++++++++++ .../components/com_redirect/controllers/links.php | 10 +++++++++- .../components/com_redirect/models/links.php | 5 ++++- administrator/language/en-GB/en-GB.com_redirect.ini | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_redirect/config.xml b/administrator/components/com_redirect/config.xml index a91b70005ab43..558fca44249c2 100644 --- a/administrator/components/com_redirect/config.xml +++ b/administrator/components/com_redirect/config.xml @@ -22,6 +22,17 @@ description="COM_REDIRECT_BULK_SEPARATOR_DESC" default="|" /> + + + +
get('separator', '|'), $batch_urls_line)); + $seperator = $params->get('separator', '|'); + + // Basic check to make sure the correct separator is being used + if (!\Joomla\String\StringHelper::strpos($batch_urls_line, $seperator)) { + $this->setMessage(JText::sprintf('COM_REDIRECT_NO_SEPERATOR_FOUND', $seperator), 'error'); + $this->setRedirect('index.php?option=com_redirect&view=links'); + return false; + } + $batch_urls[] = array_map('trim', explode($seperator, $batch_urls_line)); } } diff --git a/administrator/components/com_redirect/models/links.php b/administrator/components/com_redirect/models/links.php index e85e0502de2fc..a1fd48dfe8380 100644 --- a/administrator/components/com_redirect/models/links.php +++ b/administrator/components/com_redirect/models/links.php @@ -200,6 +200,9 @@ public function batchProcess($batch_urls) $db = JFactory::getDbo(); $query = $db->getQuery(true); + $params = JComponentHelper::getParams('com_redirect'); + $state = $params->get('defaultImportState', 0); + $columns = array( $db->quoteName('old_url'), $db->quoteName('new_url'), @@ -228,7 +231,7 @@ public function batchProcess($batch_urls) $query->insert($db->quoteName('#__redirect_links'), false) ->values( - $db->quote($old_url) . ', ' . $db->quote($new_url) . ' ,' . $db->quote('') . ', ' . $db->quote('') . ', 0, 0, ' . + $db->quote($old_url) . ', ' . $db->quote($new_url) . ' ,' . $db->quote('') . ', ' . $db->quote('') . ', 0, ' . $state . ', ' . $db->quote(JFactory::getDate()->toSql()) ); } diff --git a/administrator/language/en-GB/en-GB.com_redirect.ini b/administrator/language/en-GB/en-GB.com_redirect.ini index 57e55225b2b3e..aeaf856e44b67 100644 --- a/administrator/language/en-GB/en-GB.com_redirect.ini +++ b/administrator/language/en-GB/en-GB.com_redirect.ini @@ -17,6 +17,8 @@ COM_REDIRECT_COLLECT_URLS_ENABLED="%1$s The option 'Collect URLs' is enabled." ; The following string is deprecated and will be removed with 4.0. COM_REDIRECT_COLLECT_URLS_DISABLED="The 'Collect URLs' option in the Redirect System Plugin is disabled. Error page URLs will not be collected by this component." COM_REDIRECT_CONFIGURATION="Redirect: Options" +COM_REDIRECT_DEFAULT_IMPORT_STATE_DESC="When batch importing redirects, enable or disable by default." +COM_REDIRECT_DEFAULT_IMPORT_STATE_LABEL="Import State" COM_REDIRECT_DISABLE_LINK="Disable Link" COM_REDIRECT_EDIT_LINK="Edit Link #%d" COM_REDIRECT_EDIT_PLUGIN_SETTINGS="Edit Plugin Settings" @@ -84,6 +86,7 @@ COM_REDIRECT_N_LINKS_UPDATED_1="1 link has been updated." COM_REDIRECT_NEW_LINK="New Link" COM_REDIRECT_NO_ITEM_ADDED="No links added." COM_REDIRECT_NO_ITEM_SELECTED="No links selected." +COM_REDIRECT_NO_SEPERATOR_FOUND="The seperator %s was not found in your import." ; The following string is deprecated and will be removed with 4.0. COM_REDIRECT_PLUGIN_DISABLED="The Redirect System Plugin is disabled. It needs to be enabled for this component to work." COM_REDIRECT_PLUGIN_ENABLED="The Redirect Plugin is enabled." From 7f0542075bf3d4a59f6ccfe74bec63734c0dbfd7 Mon Sep 17 00:00:00 2001 From: tonypartridge <6GW7iqJ78B> Date: Sun, 25 Mar 2018 00:20:07 +0000 Subject: [PATCH 02/10] force int. --- administrator/components/com_redirect/models/links.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_redirect/models/links.php b/administrator/components/com_redirect/models/links.php index a1fd48dfe8380..088bb625c33be 100644 --- a/administrator/components/com_redirect/models/links.php +++ b/administrator/components/com_redirect/models/links.php @@ -201,7 +201,7 @@ public function batchProcess($batch_urls) $query = $db->getQuery(true); $params = JComponentHelper::getParams('com_redirect'); - $state = $params->get('defaultImportState', 0); + $state = (int) $params->get('defaultImportState', 0); $columns = array( $db->quoteName('old_url'), From c2de0b0188379b83e32593c5062dd07b7dbf3a28 Mon Sep 17 00:00:00 2001 From: Tony Partridge Date: Sun, 25 Mar 2018 11:38:20 +0100 Subject: [PATCH 03/10] Update config.xml --- administrator/components/com_redirect/config.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/administrator/components/com_redirect/config.xml b/administrator/components/com_redirect/config.xml index 558fca44249c2..222ca4c1e59a2 100644 --- a/administrator/components/com_redirect/config.xml +++ b/administrator/components/com_redirect/config.xml @@ -23,12 +23,12 @@ default="|" /> From c2f9e7e3d3b0d82c77090592c6a46678723c54cc Mon Sep 17 00:00:00 2001 From: Tony Partridge Date: Sun, 25 Mar 2018 11:39:19 +0100 Subject: [PATCH 04/10] Update links.php --- .../components/com_redirect/controllers/links.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_redirect/controllers/links.php b/administrator/components/com_redirect/controllers/links.php index 8483055805207..7b4f58784dd6c 100644 --- a/administrator/components/com_redirect/controllers/links.php +++ b/administrator/components/com_redirect/controllers/links.php @@ -133,15 +133,16 @@ public function batch() if (!empty($batch_urls_line)) { $params = JComponentHelper::getParams('com_redirect'); - $seperator = $params->get('separator', '|'); + $separator = $params->get('separator', '|'); // Basic check to make sure the correct separator is being used - if (!\Joomla\String\StringHelper::strpos($batch_urls_line, $seperator)) { - $this->setMessage(JText::sprintf('COM_REDIRECT_NO_SEPERATOR_FOUND', $seperator), 'error'); + 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($seperator, $batch_urls_line)); + $batch_urls[] = array_map('trim', explode($separator, $batch_urls_line)); } } From ca4630acc89ea82fab3c63efb2c616d11790a963 Mon Sep 17 00:00:00 2001 From: Tony Partridge Date: Sun, 25 Mar 2018 11:39:49 +0100 Subject: [PATCH 05/10] Update en-GB.com_redirect.ini --- administrator/language/en-GB/en-GB.com_redirect.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/en-GB.com_redirect.ini b/administrator/language/en-GB/en-GB.com_redirect.ini index aeaf856e44b67..ad00153688b24 100644 --- a/administrator/language/en-GB/en-GB.com_redirect.ini +++ b/administrator/language/en-GB/en-GB.com_redirect.ini @@ -86,7 +86,7 @@ COM_REDIRECT_N_LINKS_UPDATED_1="1 link has been updated." COM_REDIRECT_NEW_LINK="New Link" COM_REDIRECT_NO_ITEM_ADDED="No links added." COM_REDIRECT_NO_ITEM_SELECTED="No links selected." -COM_REDIRECT_NO_SEPERATOR_FOUND="The seperator %s was not found in your import." +COM_REDIRECT_NO_SEPARATOR_FOUND="The seperator %s was not found in your import." ; The following string is deprecated and will be removed with 4.0. COM_REDIRECT_PLUGIN_DISABLED="The Redirect System Plugin is disabled. It needs to be enabled for this component to work." COM_REDIRECT_PLUGIN_ENABLED="The Redirect Plugin is enabled." From 3521bbf200041c5d697cb64ac710bfdc9b2017bf Mon Sep 17 00:00:00 2001 From: Tony Partridge Date: Sun, 25 Mar 2018 21:32:50 +0100 Subject: [PATCH 06/10] Update config.xml --- administrator/components/com_redirect/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_redirect/config.xml b/administrator/components/com_redirect/config.xml index 222ca4c1e59a2..d7c415ccd61d6 100644 --- a/administrator/components/com_redirect/config.xml +++ b/administrator/components/com_redirect/config.xml @@ -11,7 +11,7 @@ description="COM_REDIRECT_MODE_DESC" class="btn-group btn-group-yesno" default="0" - > + > From fb3514f29d14721f6ab6e3fb2d52611dc7eb7f0c Mon Sep 17 00:00:00 2001 From: Tony Partridge Date: Sun, 25 Mar 2018 21:34:29 +0100 Subject: [PATCH 07/10] Update links.php --- administrator/components/com_redirect/controllers/links.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/administrator/components/com_redirect/controllers/links.php b/administrator/components/com_redirect/controllers/links.php index 7b4f58784dd6c..5383e2943036f 100644 --- a/administrator/components/com_redirect/controllers/links.php +++ b/administrator/components/com_redirect/controllers/links.php @@ -140,8 +140,10 @@ public function batch() { $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)); } } From ae5b479130bc0ab9bde55b936fbf6362c01ba07f Mon Sep 17 00:00:00 2001 From: Tony Partridge Date: Sun, 25 Mar 2018 21:34:51 +0100 Subject: [PATCH 08/10] Update en-GB.com_redirect.ini --- administrator/language/en-GB/en-GB.com_redirect.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/en-GB.com_redirect.ini b/administrator/language/en-GB/en-GB.com_redirect.ini index ad00153688b24..f0ba0c7542e17 100644 --- a/administrator/language/en-GB/en-GB.com_redirect.ini +++ b/administrator/language/en-GB/en-GB.com_redirect.ini @@ -86,7 +86,7 @@ COM_REDIRECT_N_LINKS_UPDATED_1="1 link has been updated." COM_REDIRECT_NEW_LINK="New Link" COM_REDIRECT_NO_ITEM_ADDED="No links added." COM_REDIRECT_NO_ITEM_SELECTED="No links selected." -COM_REDIRECT_NO_SEPARATOR_FOUND="The seperator %s was not found in your import." +COM_REDIRECT_NO_SEPARATOR_FOUND="The separator %s was not found in your import." ; The following string is deprecated and will be removed with 4.0. COM_REDIRECT_PLUGIN_DISABLED="The Redirect System Plugin is disabled. It needs to be enabled for this component to work." COM_REDIRECT_PLUGIN_ENABLED="The Redirect Plugin is enabled." From 3398605e0c93548ab031ebf90068f54ceee0bfee Mon Sep 17 00:00:00 2001 From: Tony Partridge Date: Tue, 27 Mar 2018 21:19:39 +0100 Subject: [PATCH 09/10] Update config.xml As per standards i.e: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_config/model/form/application.xml i.e. endtag inline with options and closing tag inline with opening tag. --- administrator/components/com_redirect/config.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_redirect/config.xml b/administrator/components/com_redirect/config.xml index d7c415ccd61d6..9c87ece04da68 100644 --- a/administrator/components/com_redirect/config.xml +++ b/administrator/components/com_redirect/config.xml @@ -3,7 +3,7 @@
+ > + > @@ -29,7 +29,7 @@ description="COM_REDIRECT_DEFAULT_IMPORT_STATE_DESC" class="btn-group btn-group-yesno" default="0" - > + > @@ -39,7 +39,7 @@ name="permissions" label="JCONFIG_PERMISSIONS_LABEL" description="JCONFIG_PERMISSIONS_DESC" - > + > Date: Wed, 28 Mar 2018 15:47:29 +0100 Subject: [PATCH 10/10] Update links.php --- administrator/components/com_redirect/controllers/links.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_redirect/controllers/links.php b/administrator/components/com_redirect/controllers/links.php index 5383e2943036f..925c5bc411288 100644 --- a/administrator/components/com_redirect/controllers/links.php +++ b/administrator/components/com_redirect/controllers/links.php @@ -133,17 +133,17 @@ public function batch() if (!empty($batch_urls_line)) { $params = JComponentHelper::getParams('com_redirect'); - $separator = $params->get('separator', '|'); + $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)); } }