Optimiseweb_Redirects - Version 0.1.3

Version Notes

First stable release

Download this release

Release Info

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


Version 0.1.3

app/code/community/Optimiseweb/Redirects/Block/System/Config/Backend/Download.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Optimiseweb Redirects Block System Config Backend Download
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
+ }
app/code/community/Optimiseweb/Redirects/Helper/Data.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Optimiseweb Redirects Data Helper
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
+ }
app/code/community/Optimiseweb/Redirects/Model/Redirector.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Optimiseweb Redirects Model Redirector
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
+ }
app/code/community/Optimiseweb/Redirects/etc/adminhtml.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
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>
31
+ </config>
32
+ </children>
33
+ </system>
34
+ </children>
35
+ </admin>
36
+ </resources>
37
+ </acl>
38
+ </config>
app/code/community/Optimiseweb/Redirects/etc/config.xml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
app/code/community/Optimiseweb/Redirects/etc/system.xml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
16
+ <sort_order>99999</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <groups>
21
+
22
+ <general translate="label comment">
23
+ <label>Upload / Download CSV File</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>1</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <fields>
30
+ <upload translate="label comment">
31
+ <label>Upload Redirects File</label>
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>
40
+ <show_in_store>1</show_in_store>
41
+ </upload>
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>
49
+ <show_in_store>1</show_in_store>
50
+ </download>
51
+ </fields>
52
+ </general>
53
+
54
+ </groups>
55
+ </optimisewebredirects>
56
+ </sections>
57
+
58
+ </config>
app/etc/modules/Optimiseweb_Redirects.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
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>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
8
+ <extends/>
9
+ <summary>Broken links can affect traffic and conversions. The Optimise Web Redirects extension helps setup bulk 301 redirects.</summary>
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>