Magespeedtest_Speedtest - Version 0.0.2

Version Notes

0.0.1 - initial release. Helps users create sitemap.xml and redirect to MageSpeedTest.com, pre-populating the required fields for easy testing.

0.0.2 - Released to Magento Connect

Download this release

Release Info

Developer Magento Core Team
Extension Magespeedtest_Speedtest
Version 0.0.2
Comparing to
See all releases


Version 0.0.2

app/code/community/Magespeedtest/Speedtest/Block/Adminhtml/Test.php ADDED
@@ -0,0 +1,84 @@
1
+ <?php
2
+
3
+ /**
4
+ * MageSpeedTest.com Magento Test Button
5
+ *
6
+ * @package Magespeedtest_Speedtest
7
+ * @author Ashley Schroder (magespeedtest.com)
8
+ * @copyright Copyright 2012 Ashley Schroder
9
+ */
10
+
11
+
12
+ class Magespeedtest_Speedtest_Block_Adminhtml_Test
13
+ extends Mage_Adminhtml_Block_System_Config_Form_Field {
14
+
15
+ const BASE_URL = 'magespeedtest/settings/baseurl';
16
+ const DEFAULT_LOCATION = 'USAWEST'; // USA, West
17
+ const EXT = 'ext'; // for analytics
18
+ const DEFAULT_CONCURRENCY = '10'; // 10 users
19
+ const DEFAULT_DURATION = '30'; // 30 seconds
20
+ const HIDE_SITEMAP_WARNING = "<style type='text/css'>.sitemapWarning{display:none;}</style>";
21
+
22
+
23
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
24
+
25
+ $this->setElement($element);
26
+
27
+ $sitemap = Mage::helper('magespeedtest')->sitemapExists();
28
+ if ($sitemap) {
29
+ return $this->_getAddRowButtonHtml($this->__('Run A Magento Speed Test'));
30
+ } else {
31
+ return $this->_getAddRowButtonHtml($this->__('Create a sitemap.xml first'));
32
+ }
33
+
34
+ }
35
+
36
+
37
+ protected function _getAddRowButtonHtml($title) {
38
+
39
+ $buttonBlock =
40
+ $this->getElement()->getForm()->getParent()->getLayout()->createBlock('adminhtml/widget_button');
41
+
42
+ $_websiteCode = $buttonBlock->getRequest()->getParam('website');
43
+
44
+ $sitemap = Mage::helper('magespeedtest')->sitemapExists();
45
+ $url = Mage::getStoreConfig(self::BASE_URL);
46
+ $extraHTML = ""; // used to hide sitemap warning.
47
+
48
+ if ($sitemap) {
49
+
50
+ $sitemapURL = Mage::helper('magespeedtest')->getSitemapURL();
51
+ $currentUserEmail = Mage::helper('magespeedtest')->getCurrentUserEmail();
52
+
53
+ $params = http_build_query(array(
54
+ 'domain' => $sitemapURL,
55
+ 'concurrency' => self::DEFAULT_CONCURRENCY,
56
+ 'duration' => self::DEFAULT_DURATION,
57
+ 'location' => self::DEFAULT_LOCATION,
58
+ 'ref' => self::EXT,
59
+ 'email' => $currentUserEmail
60
+ ));
61
+
62
+ $url .= "?$params";
63
+
64
+ // we have a sitemap, no need for the sitemap warning.
65
+ $extraHTML = self::HIDE_SITEMAP_WARNING;
66
+
67
+ } else {
68
+
69
+ $params = array(
70
+ 'website' => $_websiteCode,
71
+ '_store' => $_websiteCode ? $_websiteCode : Mage::app()->getDefaultStoreView()->getId()
72
+ );
73
+
74
+ $url = Mage::helper('adminhtml')->getUrl("*/sitemap/new", $params);
75
+ }
76
+
77
+
78
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
79
+ ->setType('button')
80
+ ->setLabel($this->__($title))
81
+ ->setOnClick("window.location.href='".$url."'")
82
+ ->toHtml() . $extraHTML;
83
+ }
84
+ }
app/code/community/Magespeedtest/Speedtest/Helper/Data.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ /**
3
+ * MageSpeedTest.com Magento integration
4
+ *
5
+ * @package Magespeedtest_Speedtest
6
+ * @author Ashley Schroder (magespeedtest.com)
7
+ * @copyright Copyright 2012 Ashley Schroder
8
+ */
9
+ class Magespeedtest_Speedtest_Helper_Data extends Mage_Core_Helper_Abstract {
10
+
11
+ /**
12
+ * Check if there is a sitemap.xml file.
13
+ * return the path to it, or false if no sitemap exists
14
+ */
15
+ public function sitemapExists() {
16
+
17
+ //TODO: check if we have a sitemap.xml
18
+ $collection = Mage::getModel('sitemap/sitemap')->getCollection();
19
+ $collection->load();
20
+
21
+ foreach($collection as $sitemap) {
22
+
23
+ Mage::log("Found sitemap: " . $sitemap->getPreparedFilename());
24
+ return $sitemap->getPreparedFilename();
25
+
26
+ }
27
+
28
+ Mage::log("Found no sitemap.");
29
+ return false;
30
+ }
31
+
32
+ /**
33
+ * Get the URL for the sitemap, or simply the
34
+ * base URL if it is the default name and root path.
35
+ *
36
+ * return false if no sitemap exists.
37
+ */
38
+ public function getSitemapURL() {
39
+
40
+ if ($sitemap = $this->sitemapExists()) {
41
+
42
+ $baseURL = Mage::getUrl('');
43
+
44
+ if ($sitemap == "/sitemap.xml") {
45
+ return $baseURL;
46
+ } else {
47
+ // non-standard location or name
48
+ return $baseURL.$sitemap;
49
+ }
50
+
51
+ } else {
52
+ return false;
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Get the current admin user email, or false if no admin user
58
+ */
59
+ public function getCurrentUserEmail() {
60
+
61
+ $user = Mage::getSingleton('admin/session');
62
+ if ($user && $user->getUser()) {
63
+ return $user->getUser()->getEmail();
64
+ } else {
65
+ return false;
66
+ }
67
+ }
68
+ }
69
+
app/code/community/Magespeedtest/Speedtest/etc/config.xml ADDED
@@ -0,0 +1,35 @@
1
+ <config>
2
+ <!--
3
+ /**
4
+ * MageSpeedTest.com Magento integration
5
+ *
6
+ * @package Magespeedtest_Speedtest
7
+ * @author Ashley Schroder (magespeedtest.com)
8
+ * @copyright Copyright 2012 Ashley Schroder
9
+ */
10
+ -->
11
+ <modules>
12
+ <Magespeedtest_Speedtest>
13
+ <version>0.0.2</version>
14
+ </Magespeedtest_Speedtest>
15
+ </modules>
16
+ <global>
17
+ <models>
18
+ <magespeedtest>
19
+ <class>Magespeedtest_Speedtest_Model</class>
20
+ </magespeedtest>
21
+ </models>
22
+ <helpers>
23
+ <magespeedtest>
24
+ <class>Magespeedtest_Speedtest_Helper</class>
25
+ </magespeedtest>
26
+ </helpers>
27
+ </global>
28
+ <default>
29
+ <magespeedtest>
30
+ <settings>
31
+ <baseurl>http://www.magespeedtest.com</baseurl>
32
+ </settings>
33
+ </magespeedtest>
34
+ </default>
35
+ </config>
app/code/community/Magespeedtest/Speedtest/etc/system.xml ADDED
@@ -0,0 +1,44 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * MageSpeedTest.com Magento integration
5
+ *
6
+ * @package Magespeedtest_Speedtest
7
+ * @author Ashley Schroder (magespeedtest.com)
8
+ * @copyright Copyright 2012 Ashley Schroder
9
+ */
10
+ -->
11
+ <config>
12
+ <sections>
13
+ <admin>
14
+ <groups>
15
+ <magespeedtest translate="label" module="magespeedtest">
16
+ <label>MageSpeedTest.com Speed Testing</label>
17
+ <comment>
18
+ &lt;div style='background-repeat: repeat-x; background-image: linear-gradient(top, #333333, #222222); background-image: -o-linear-gradient(top, #333333, #222222); background-image: -webkit-linear-gradient(top, #333333, #222222); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222)); background-image: -ms-linear-gradient(top, #333333, #222222); background-image: -moz-linear-gradient(center top , #333333, #222222); background-color: #222222;'&gt; &lt;a href='http://www.magespeedtest.com'&gt;&lt;img src='http://www.magespeedtest.com/images/extension-banner.png' /&gt;&lt;/a&gt; &lt;/div&gt;
19
+ &lt;div&gt; &lt;br/&gt; &lt;p&gt; &lt;a href='http://www.magespeedtest.com&amp;ref=ext'&gt;Magento Speed Test&lt;/a&gt; is a free Magento speed testing service that runs a simulated multi-customer tests on your store and reports on performance. Detect and address performance issues before they affect your customers. For more advanced testing and monitoring &lt;a href='http://www.magespeedtest.com/subscribe&amp;ref=ext'&gt;read more&lt;/a&gt; about our premium service for $9/month.&lt;/p&gt;
20
+ &lt;/div&gt;
21
+ &lt;div&gt;
22
+ &lt;p class="sitemapWarning"&gt; &lt;strong&gt; Note:&lt;/strong&gt; To get started with testing you first need to &lt;a href='http://www.aschroder.com/2010/12/making-a-site-map-for-magento/'&gt;create a sitemap.xml&lt;/a&gt; for your store. You should have one &lt;a href='http://en.wikipedia.org/wiki/Google_Sitemaps'&gt;for the benefit of search engines&lt;/a&gt;, if not now's a great time to make one - it'll only take a second. &lt;/p&gt;
23
+ &lt;/div&gt;
24
+ </comment>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>999</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>0</show_in_store>
30
+ <fields>
31
+ <test translate="label comment">
32
+ <frontend_type>select</frontend_type>
33
+ <frontend_model>Magespeedtest_Speedtest_Block_Adminhtml_Test</frontend_model>
34
+ <sort_order>20</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>0</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </test>
39
+ </fields>
40
+ </magespeedtest>
41
+ </groups>
42
+ </admin>
43
+ </sections>
44
+ </config>
app/code/community/Magespeedtest/Speedtest/modman ADDED
@@ -0,0 +1,7 @@
1
+ # modman module description
2
+ # see https://github.com/colinmollenhour/modman/ for more info
3
+ # author: ashley@magespeedtest.com
4
+
5
+ # MageSpeedTest.com Magento extension
6
+ * app/code/community/Magespeedtest/Speedtest
7
+ modules/Magespeedtest_Speedtest.xml app/etc/modules/Magespeedtest_Speedtest.xml
app/code/community/Magespeedtest/Speedtest/modules/Magespeedtest_Speedtest.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magespeedtest_Speedtest>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Magespeedtest_Speedtest>
8
+ </modules>
9
+ </config>
app/etc/modules/Magespeedtest_Speedtest.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magespeedtest_Speedtest>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Magespeedtest_Speedtest>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magespeedtest_Speedtest</name>
4
+ <version>0.0.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>MageSpeedTest.com is a free service to simulate multiple customers on your webstore and test the speed.</summary>
10
+ <description>MageSpeedTest.com is a free service to simulate multiple customers on your webstore and test the speed. This extension will help you create your sitemap.xml file and run your first test.</description>
11
+ <notes>0.0.1 - initial release. Helps users create sitemap.xml and redirect to MageSpeedTest.com, pre-populating the required fields for easy testing.&#xD;
12
+ &#xD;
13
+ 0.0.2 - Released to Magento Connect</notes>
14
+ <authors><author><name>Ashley Schroder</name><user>auto-converted</user><email>ashley.schroder@gmail.com</email></author></authors>
15
+ <date>2012-07-22</date>
16
+ <time>05:43:10</time>
17
+ <contents><target name="magecommunity"><dir name="Magespeedtest"><dir name="Speedtest"><dir name="Block"><dir name="Adminhtml"><file name="Test.php" hash="dd7669eac084481d58d2573751663dc3"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4ddfb52f3b7ca6684169bbfdf86bb4c2"/></dir><dir name="etc"><file name="config.xml" hash="43bad2fb4cecbce257d92487b82c9052"/><file name="system.xml" hash="11fd7a35e80fcc4815fe458e736b91ce"/></dir><dir name="modules"><file name="Magespeedtest_Speedtest.xml" hash="ee97f56a9f80c45d8df8697290a6038c"/></dir><file name="modman" hash="01bf71ab8639ce99e35d4867b95dc579"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magespeedtest_Speedtest.xml" hash="ee97f56a9f80c45d8df8697290a6038c"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies/>
20
+ </package>