Optimiseweb_Redirects - Version 0.1.5

Version Notes

Renamed the blocks, helpers and models to ow_redirects. The previously used name was causing problems with compilation. If you encounter any issues with this version please write to us and we will sort it out quickly.

Download this release

Release Info

Developer Kathir Vel
Extension Optimiseweb_Redirects
Version 0.1.5
Comparing to
See all releases


Code changes from version 0.1.3 to 0.1.5

app/code/community/Optimiseweb/Redirects/Block/System/Config/Backend/Download.php CHANGED
@@ -5,31 +5,26 @@
5
  *
6
  * @package Optimiseweb_Redirects
7
  * @author Kathir Vel (sid@optimiseweb.co.uk)
8
- * @copyright Copyright (c) 2012 Optimiseweb Ltd
9
- * @license Optimiseweblicense
10
  */
11
- class Optimiseweb_Redirects_Block_System_Config_Backend_Download extends Mage_Adminhtml_Block_System_Config_Form_Field
12
- {
13
 
14
- /**
15
- * Get the system config field and insert a HTML link
16
- *
17
- * @param Varien_Data_Form_Element_Abstract $element
18
- * @return string
19
- */
20
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
21
- {
22
- $this->setElement($element);
23
- if (Mage::getStoreConfig('optimisewebredirects/general/upload'))
24
- {
25
- $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'optimiseweb/redirects/' . Mage::getStoreConfig('optimisewebredirects/general/upload');
26
- $html = "<a href='" . $url . "'>Download</a>";
 
 
27
  }
28
- else
29
- {
30
- $html = "No CSV file provided.";
31
- }
32
- return $html;
33
- }
34
 
35
  }
5
  *
6
  * @package Optimiseweb_Redirects
7
  * @author Kathir Vel (sid@optimiseweb.co.uk)
8
+ * @copyright Copyright (c) 2013 Optimise Web Limited
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  */
11
+ class Optimiseweb_Redirects_Block_System_Config_Backend_Download extends Mage_Adminhtml_Block_System_Config_Form_Field {
 
12
 
13
+ /**
14
+ * Get the system config field and insert a HTML link
15
+ *
16
+ * @param Varien_Data_Form_Element_Abstract $element
17
+ * @return string
18
+ */
19
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
20
+ $this->setElement($element);
21
+ if (Mage::getStoreConfig('optimisewebredirects/general/upload')) {
22
+ $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'optimiseweb/redirects/' . Mage::getStoreConfig('optimisewebredirects/general/upload');
23
+ $html = "<a href='" . $url . "'>Download</a>";
24
+ } else {
25
+ $html = "No CSV file provided.";
26
+ }
27
+ return $html;
28
  }
 
 
 
 
 
 
29
 
30
  }
app/code/community/Optimiseweb/Redirects/Helper/Data.php CHANGED
@@ -5,10 +5,9 @@
5
  *
6
  * @package Optimiseweb_Redirects
7
  * @author Kathir Vel (sid@optimiseweb.co.uk)
8
- * @copyright Copyright (c) 2012 Optimiseweb Ltd
9
- * @license Optimiseweblicense
10
  */
11
- class Optimiseweb_Redirects_Helper_Data extends Mage_Core_Helper_Abstract
12
- {
13
-
14
  }
5
  *
6
  * @package Optimiseweb_Redirects
7
  * @author Kathir Vel (sid@optimiseweb.co.uk)
8
+ * @copyright Copyright (c) 2013 Optimise Web Limited
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  */
11
+ class Optimiseweb_Redirects_Helper_Data extends Mage_Core_Helper_Abstract {
12
+
 
13
  }
app/code/community/Optimiseweb/Redirects/Model/Redirector.php CHANGED
@@ -5,54 +5,47 @@
5
  *
6
  * @package Optimiseweb_Redirects
7
  * @author Kathir Vel (sid@optimiseweb.co.uk)
8
- * @copyright Copyright (c) 2012 Optimiseweb Ltd
9
- * @license Optimiseweblicense
10
  */
11
- class Optimiseweb_Redirects_Model_Redirector
12
- {
13
-
14
- /**
15
- * Redirect Function
16
- *
17
- * Looks at 404 pages and then loads up the csv file to see if a match exists
18
- *
19
- * @param Varien_Event_Observer $observer
20
- */
21
- public function doRedirects(Varien_Event_Observer $observer)
22
- {
23
- $request = $observer->getEvent()->getControllerAction()->getRequest();
24
-
25
- $actionName = $request->getActionName();
26
- $requestUrl = rtrim($request->getScheme() . '://' . $request->getHttpHost() . $request->getRequestUri(), '/');
27
-
28
- if ($actionName == 'noRoute')
29
- {
30
- if (Mage::getStoreConfig('optimisewebredirects/general/upload') AND file_exists(Mage::getBaseDir('media') . '/optimiseweb/redirects/' . Mage::getStoreConfig('optimisewebredirects/general/upload')))
31
- {
32
- $redirectLines = file(Mage::getBaseDir('media') . '/optimiseweb/redirects/' . Mage::getStoreConfig('optimisewebredirects/general/upload'));
33
-
34
- foreach ($redirectLines AS $redirectLine)
35
- {
36
- $sourceDestination = explode(';', $redirectLine);
37
-
38
- $sourceUrl = rtrim(trim($sourceDestination[0]), '/');
39
-
40
- if (count($sourceDestination) == 2)
41
- {
42
- $destinationUrl = trim($sourceDestination[1]);
43
-
44
- if ($sourceUrl == $requestUrl)
45
- {
46
- $response = Mage::app()->getResponse();
47
- $response->setRedirect($destinationUrl, 301);
48
- $response->sendResponse();
49
- exit;
50
  }
51
- continue;
52
- }
53
  }
54
- }
55
  }
56
- }
57
 
58
  }
5
  *
6
  * @package Optimiseweb_Redirects
7
  * @author Kathir Vel (sid@optimiseweb.co.uk)
8
+ * @copyright Copyright (c) 2013 Optimise Web Limited
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  */
11
+ class Optimiseweb_Redirects_Model_Redirector {
12
+
13
+ /**
14
+ * Redirect Function
15
+ *
16
+ * Looks at 404 pages and then loads up the csv file to see if a match exists
17
+ *
18
+ * @param Varien_Event_Observer $observer
19
+ */
20
+ public function doRedirects(Varien_Event_Observer $observer) {
21
+ $request = $observer->getEvent()->getControllerAction()->getRequest();
22
+
23
+ $actionName = $request->getActionName();
24
+ $requestUrl = rtrim($request->getScheme() . '://' . $request->getHttpHost() . $request->getRequestUri(), '/');
25
+
26
+ if ($actionName == 'noRoute') {
27
+ if (Mage::getStoreConfig('optimisewebredirects/general/upload') AND file_exists(Mage::getBaseDir('media') . '/optimiseweb/redirects/' . Mage::getStoreConfig('optimisewebredirects/general/upload'))) {
28
+ $redirectLines = file(Mage::getBaseDir('media') . '/optimiseweb/redirects/' . Mage::getStoreConfig('optimisewebredirects/general/upload'));
29
+
30
+ foreach ($redirectLines AS $redirectLine) {
31
+ $sourceDestination = explode(';', $redirectLine);
32
+
33
+ $sourceUrl = rtrim(trim($sourceDestination[0]), '/');
34
+
35
+ if (count($sourceDestination) == 2) {
36
+ $destinationUrl = trim($sourceDestination[1]);
37
+
38
+ if ($sourceUrl == $requestUrl) {
39
+ $response = Mage::app()->getResponse();
40
+ $response->setRedirect($destinationUrl, 301);
41
+ $response->sendResponse();
42
+ exit;
43
+ }
44
+ continue;
45
+ }
46
+ }
 
 
 
47
  }
 
 
48
  }
 
49
  }
 
50
 
51
  }
app/code/community/Optimiseweb/Redirects/etc/adminhtml.xml CHANGED
@@ -1,4 +1,12 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
 
 
 
 
 
 
 
 
2
  <config>
3
  <acl>
4
  <resources>
@@ -7,24 +15,24 @@
7
  </all>
8
  <admin>
9
  <children>
10
- <optimiseweball translate="title" module="redirects">
11
  <title>Optimise Web - Menu Group</title>
12
  <sort_order>10</sort_order>
13
  <children>
14
- <redirects translate="title" module="redirects">
15
  <title>Optimise Web - Mass 301 Redirects</title>
16
  <sort_order>10</sort_order>
17
- </redirects>
18
  </children>
19
  </optimiseweball>
20
  <system>
21
  <children>
22
  <config>
23
  <children>
24
- <optimisewebconfig translate="title" module="redirects">
25
  <title>Optimise Web - System Configuration Group</title>
26
  </optimisewebconfig>
27
- <optimisewebredirects translate="title" module="redirects">
28
  <title>Optimise Web - Mass 301 Redirects</title>
29
  </optimisewebredirects>
30
  </children>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @package Optimiseweb_Redirects
5
+ * @author Kathir Vel (sid@optimiseweb.co.uk)
6
+ * @copyright Copyright (c) 2013 Optimise Web Limited
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
  <config>
11
  <acl>
12
  <resources>
15
  </all>
16
  <admin>
17
  <children>
18
+ <optimiseweball translate="title" module="ow_redirects">
19
  <title>Optimise Web - Menu Group</title>
20
  <sort_order>10</sort_order>
21
  <children>
22
+ <ow_redirects translate="title" module="ow_redirects">
23
  <title>Optimise Web - Mass 301 Redirects</title>
24
  <sort_order>10</sort_order>
25
+ </ow_redirects>
26
  </children>
27
  </optimiseweball>
28
  <system>
29
  <children>
30
  <config>
31
  <children>
32
+ <optimisewebconfig translate="title" module="ow_redirects">
33
  <title>Optimise Web - System Configuration Group</title>
34
  </optimisewebconfig>
35
+ <optimisewebredirects translate="title" module="ow_redirects">
36
  <title>Optimise Web - Mass 301 Redirects</title>
37
  </optimisewebredirects>
38
  </children>
app/code/community/Optimiseweb/Redirects/etc/config.xml CHANGED
@@ -1,62 +1,70 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
 
 
 
 
 
 
 
 
2
  <config>
3
 
4
- <modules>
5
- <Optimiseweb_Redirects>
6
- <version>0.1.3</version>
7
- </Optimiseweb_Redirects>
8
- </modules>
9
-
10
- <frontend>
11
- <events>
12
- <controller_action_predispatch>
13
- <observers>
14
- <optimiseweb_redirects_model_redirector>
15
- <type>singleton</type>
16
- <class>optimiseweb_redirects_model_redirector</class>
17
- <method>doRedirects</method>
18
- </optimiseweb_redirects_model_redirector>
19
- </observers>
20
- </controller_action_predispatch>
21
- </events>
22
- </frontend>
23
-
24
- <adminhtml>
25
- <menu>
26
- <optimiseweball translate="title" module="redirects">
27
- <title>Optimise Web</title>
28
- <sort_order>71</sort_order>
29
- <children>
30
- <redirects translate="title" module="redirects">
31
- <title>Mass 301 Redirects</title>
32
- <sort_order>5</sort_order>
33
- <action>adminhtml/system_config/edit/section/optimisewebredirects</action>
34
- </redirects>
35
- </children>
36
- </optimiseweball>
37
- </menu>
38
- </adminhtml>
39
-
40
- <global>
41
-
42
- <blocks>
43
- <redirects>
44
- <class>Optimiseweb_Redirects_Block</class>
45
- </redirects>
46
- </blocks>
47
-
48
- <helpers>
49
- <redirects>
50
- <class>Optimiseweb_Redirects_Helper</class>
51
- </redirects>
52
- </helpers>
53
-
54
- <models>
55
- <redirects>
56
- <class>Optimiseweb_Redirects_Model</class>
57
- </redirects>
58
- </models>
59
-
60
- </global>
61
 
62
  </config>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @package Optimiseweb_Redirects
5
+ * @author Kathir Vel (sid@optimiseweb.co.uk)
6
+ * @copyright Copyright (c) 2013 Optimise Web Limited
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
  <config>
11
 
12
+ <modules>
13
+ <Optimiseweb_Redirects>
14
+ <version>0.1.5</version>
15
+ </Optimiseweb_Redirects>
16
+ </modules>
17
+
18
+ <frontend>
19
+ <events>
20
+ <controller_action_predispatch>
21
+ <observers>
22
+ <optimiseweb_redirects_model_redirector>
23
+ <type>singleton</type>
24
+ <class>ow_redirects/redirector</class>
25
+ <method>doRedirects</method>
26
+ </optimiseweb_redirects_model_redirector>
27
+ </observers>
28
+ </controller_action_predispatch>
29
+ </events>
30
+ </frontend>
31
+
32
+ <adminhtml>
33
+ <menu>
34
+ <optimiseweball translate="title" module="ow_redirects">
35
+ <title>Optimise Web</title>
36
+ <sort_order>71</sort_order>
37
+ <children>
38
+ <ow_redirects translate="title" module="ow_redirects">
39
+ <title>Mass 301 Redirects</title>
40
+ <sort_order>5</sort_order>
41
+ <action>adminhtml/system_config/edit/section/optimisewebredirects</action>
42
+ </ow_redirects>
43
+ </children>
44
+ </optimiseweball>
45
+ </menu>
46
+ </adminhtml>
47
+
48
+ <global>
49
+
50
+ <blocks>
51
+ <ow_redirects>
52
+ <class>Optimiseweb_Redirects_Block</class>
53
+ </ow_redirects>
54
+ </blocks>
55
+
56
+ <helpers>
57
+ <ow_redirects>
58
+ <class>Optimiseweb_Redirects_Helper</class>
59
+ </ow_redirects>
60
+ </helpers>
61
+
62
+ <models>
63
+ <ow_redirects>
64
+ <class>Optimiseweb_Redirects_Model</class>
65
+ </ow_redirects>
66
+ </models>
67
+
68
+ </global>
69
 
70
  </config>
app/code/community/Optimiseweb/Redirects/etc/system.xml CHANGED
@@ -1,15 +1,23 @@
1
- <?xml version="1.0"?>
 
 
 
 
 
 
 
 
2
  <config>
3
 
4
  <tabs>
5
- <optimisewebconfig translate="label comment" module="redirects">
6
  <label>Optimise Web</label>
7
  <sort_order>0</sort_order>
8
  </optimisewebconfig>
9
  </tabs>
10
 
11
  <sections>
12
- <optimisewebredirects translate="label comment" module="redirects">
13
  <label>Mass 301 Redirects</label>
14
  <tab>optimisewebconfig</tab>
15
  <frontend_type>text</frontend_type>
@@ -32,8 +40,8 @@
32
  <comment>If you have already uploaded a CSV file and wish to add or edit the URLs, please download the current CSV file and reupload that file after making the changes.</comment>
33
  <frontend_type>file</frontend_type>
34
  <backend_model>adminhtml/system_config_backend_file</backend_model>
35
- <upload_dir config="system/filesystem/media">optimiseweb/redirects</upload_dir>
36
- <base_url type="media">optimiseweb/redirects</base_url>
37
  <sort_order>1</sort_order>
38
  <show_in_default>1</show_in_default>
39
  <show_in_website>1</show_in_website>
@@ -42,7 +50,7 @@
42
  <download translate="label comment">
43
  <label>Download Redirects File</label>
44
  <comment>Right click on this link and click on 'Save Link As...'</comment>
45
- <frontend_model>redirects/system_config_backend_download</frontend_model>
46
  <sort_order>2</sort_order>
47
  <show_in_default>1</show_in_default>
48
  <show_in_website>1</show_in_website>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @package Optimiseweb_Redirects
5
+ * @author Kathir Vel (sid@optimiseweb.co.uk)
6
+ * @copyright Copyright (c) 2013 Optimise Web Limited
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
  <config>
11
 
12
  <tabs>
13
+ <optimisewebconfig translate="label comment" module="ow_redirects">
14
  <label>Optimise Web</label>
15
  <sort_order>0</sort_order>
16
  </optimisewebconfig>
17
  </tabs>
18
 
19
  <sections>
20
+ <optimisewebredirects translate="label comment" module="ow_redirects">
21
  <label>Mass 301 Redirects</label>
22
  <tab>optimisewebconfig</tab>
23
  <frontend_type>text</frontend_type>
40
  <comment>If you have already uploaded a CSV file and wish to add or edit the URLs, please download the current CSV file and reupload that file after making the changes.</comment>
41
  <frontend_type>file</frontend_type>
42
  <backend_model>adminhtml/system_config_backend_file</backend_model>
43
+ <upload_dir config="system/filesystem/media" scope_info="1">optimiseweb/redirects</upload_dir>
44
+ <base_url type="media" scope_info="1">optimiseweb/redirects</base_url>
45
  <sort_order>1</sort_order>
46
  <show_in_default>1</show_in_default>
47
  <show_in_website>1</show_in_website>
50
  <download translate="label comment">
51
  <label>Download Redirects File</label>
52
  <comment>Right click on this link and click on 'Save Link As...'</comment>
53
+ <frontend_model>ow_redirects/system_config_backend_download</frontend_model>
54
  <sort_order>2</sort_order>
55
  <show_in_default>1</show_in_default>
56
  <show_in_website>1</show_in_website>
app/etc/modules/Optimiseweb_Redirects.xml CHANGED
@@ -1,9 +1,17 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <modules>
4
- <Optimiseweb_Redirects>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </Optimiseweb_Redirects>
8
- </modules>
 
 
 
 
 
 
 
 
9
  </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @package Optimiseweb_Redirects
5
+ * @author Kathir Vel (sid@optimiseweb.co.uk)
6
+ * @copyright Copyright (c) 2013 Optimise Web Limited
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Optimiseweb_Redirects>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Optimiseweb_Redirects>
16
+ </modules>
17
  </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Optimiseweb_Redirects</name>
4
- <version>0.1.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -10,11 +10,11 @@
10
  <description>Magento has an internal URL Rewrite Management system. It can be a laborious task to add all your redirects, one by one.&#xD;
11
  &#xD;
12
  The Optimise Web Redirects extension allows you to upload all your redirect data as a CSV file.</description>
13
- <notes>First stable release</notes>
14
  <authors><author><name>Kathir Vel</name><user>OptimiseWeb</user><email>info@optimiseweb.co.uk</email></author></authors>
15
- <date>2012-10-14</date>
16
- <time>11:12:34</time>
17
- <contents><target name="magecommunity"><dir name="Optimiseweb"><dir name="Redirects"><dir name="Block"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Download.php" hash="9624d76346a97d69875be5288ca8e568"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="949cce02b498d4ce711591e000c38602"/></dir><dir name="Model"><file name="Redirector.php" hash="d17fb991942792e0de44868d37c5b6a2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="26aa20843f2fef2c879d9b325d7bf6e6"/><file name="config.xml" hash="995b8ee12ecc5edfc857c51c3c5de50b"/><file name="system.xml" hash="50814613f6fbcfef4b5b58b37ead9450"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Optimiseweb_Redirects.xml" hash="681b9c478a3c64ad940fc22eea4a789b"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Optimiseweb_Redirects</name>
4
+ <version>0.1.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
10
  <description>Magento has an internal URL Rewrite Management system. It can be a laborious task to add all your redirects, one by one.&#xD;
11
  &#xD;
12
  The Optimise Web Redirects extension allows you to upload all your redirect data as a CSV file.</description>
13
+ <notes>Renamed the blocks, helpers and models to ow_redirects. The previously used name was causing problems with compilation. If you encounter any issues with this version please write to us and we will sort it out quickly.</notes>
14
  <authors><author><name>Kathir Vel</name><user>OptimiseWeb</user><email>info@optimiseweb.co.uk</email></author></authors>
15
+ <date>2013-07-17</date>
16
+ <time>09:45:09</time>
17
+ <contents><target name="magecommunity"><dir name="Optimiseweb"><dir name="Redirects"><dir name="Block"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Download.php" hash="4d7976863e76ff6aba22f37b46a04cc7"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ef4e86f64b9f046a5ccb79b1111e1927"/></dir><dir name="Model"><file name="Redirector.php" hash="acc75ccfbd13c699cf6015d9e69baad4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3e583ea2eaeaa0aa352c0a3a985d0ad0"/><file name="config.xml" hash="0f9342ed0c0b443f9384c3ff4475f69e"/><file name="system.xml" hash="760fc753f20b60b8143cc78d7f3b52e5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Optimiseweb_Redirects.xml" hash="455126831539cd3afc0aab1125bf41e5"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>