ArchApps_EmailSpellCheck - Version 0.1.1

Version Notes

Release of v0.1.1

Download this release

Release Info

Developer ArchApps
Extension ArchApps_EmailSpellCheck
Version 0.1.1
Comparing to
See all releases


Version 0.1.1

app/code/community/ArchApps/EmailSpellCheck/Helper/Data.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ArchApps
4
+ * @package ArchApps_EmailSpellCheck
5
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
6
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
7
+ */
8
+
9
+ class ArchApps_EmailSpellCheck_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+ const XML_PATH_ENABLED_IN_FRONT = 'archapps_emailspellcheck/general/enabled_in_front';
12
+ const XML_PATH_ENABLED_IN_ADMIN = 'archapps_emailspellcheck/general/enabled_in_admin';
13
+ const XML_PATH_SUGGESTION_TEXT = 'archapps_emailspellcheck/general/suggestion_text';
14
+
15
+ const XML_PATH_FRONT_FIELD_SELECTOR = 'archapps_emailspellcheck/general/front_field_selector';
16
+ const XML_PATH_ADMIN_FIELD_SELECTOR = 'archapps_emailspellcheck/general/admin_field_selector';
17
+
18
+ const XML_PATH_DOMAINS = 'archapps_emailspellcheck/advanced/domains';
19
+ const XML_PATH_TOP_LEVEL_DOMAINS = 'archapps_emailspellcheck/advanced/top_level_domains';
20
+ const XML_PATH_SECOND_LEVEL_DOMAINS = 'archapps_emailspellcheck/advanced/second_level_domains';
21
+
22
+ /**
23
+ * @var array Array of default second level domains that are used for email suggestions
24
+ */
25
+ protected $_defaultSLDomains = array('yahoo', 'hotmail', 'mail', 'live', 'outlook', 'gmx');
26
+
27
+ /**
28
+ * @var array Array of default domains that are used for email suggestions
29
+ */
30
+ protected $_defaultDomains = array(
31
+ 'msn.com', 'bellsouth.net', 'telus.net', 'comcast.net', 'optusnet.com.au', 'web.de',
32
+ 'earthlink.net', 'qq.com', 'sky.com', 'icloud.com', 'mac.com', 'sympatico.ca', 'googlemail.com', 'att.net',
33
+ 'xtra.co.nz', 'cox.net', 'gmail.com', 'ymail.com', 'aim.com', 'rogers.com', 'verizon.net', 'rocketmail.com',
34
+ 'google.com', 'optonline.net', 'sbcglobal.net', 'aol.com', 'me.com', 'btinternet.com', 'charter.net', 'shaw.ca'
35
+ );
36
+
37
+ /**
38
+ * @var array Array of default top level domains that are used for email suggestions
39
+ */
40
+ protected $_defaultTLDomains = array(
41
+ 'com', 'com.au', 'com.tw', 'ca', 'co.nz', 'co.uk', 'de', 'fr', 'it', 'ru', 'net', 'org', 'edu', 'gov', 'jp',
42
+ 'nl', 'kr', 'se', 'eu', 'ie', 'co.il', 'us', 'at', 'be', 'dk', 'hk', 'es', 'gr', 'ch', 'no', 'cz', 'in', 'net',
43
+ 'net.au', 'info', 'biz', 'mil', 'co.jp', 'sg', 'hu'
44
+ );
45
+
46
+ /**
47
+ * Whether email spell check is enabled on frontend
48
+ *
49
+ * @return bool
50
+ */
51
+ public function isEnabledInFront()
52
+ {
53
+ return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED_IN_FRONT);
54
+ }
55
+
56
+ /**
57
+ * Whether email spell check is enabled on admin side
58
+ *
59
+ * @return bool
60
+ */
61
+ public function isEnabledInAdmin()
62
+ {
63
+ return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED_IN_ADMIN);
64
+ }
65
+
66
+ /**
67
+ * Returns front-end field selector specified in config
68
+ *
69
+ * @return mixed
70
+ */
71
+ public function getFrontFieldSelector()
72
+ {
73
+ return Mage::getStoreConfig(self::XML_PATH_FRONT_FIELD_SELECTOR);
74
+ }
75
+
76
+ /**
77
+ * Returns admin field selector specified in config
78
+ *
79
+ * @return mixed
80
+ */
81
+ public function getAdminFieldSelector()
82
+ {
83
+ return Mage::getStoreConfig(self::XML_PATH_ADMIN_FIELD_SELECTOR);
84
+ }
85
+
86
+ /**
87
+ * Returns suggestion text specified in config
88
+ *
89
+ * @return mixed
90
+ */
91
+ public function getSuggestionText()
92
+ {
93
+ return Mage::getStoreConfig(self::XML_PATH_SUGGESTION_TEXT);
94
+ }
95
+
96
+ /**
97
+ * Returns array of domains specified in config
98
+ *
99
+ * @return array
100
+ */
101
+ public function getDomains()
102
+ {
103
+ $config = (string) Mage::getStoreConfig(self::XML_PATH_DOMAINS);
104
+ $domains = explode(',', str_replace(' ', '', $config));
105
+
106
+ return array_merge($this->_defaultDomains, $domains);
107
+ }
108
+
109
+ /**
110
+ * Returns array of top level domains specified in config
111
+ *
112
+ * @return array
113
+ */
114
+ public function getTopLevelDomains()
115
+ {
116
+ $config = (string) Mage::getStoreConfig(self::XML_PATH_TOP_LEVEL_DOMAINS);
117
+ $domains = explode(',', str_replace(' ', '', $config));
118
+
119
+ return array_merge($this->_defaultTLDomains, $domains);
120
+ }
121
+
122
+ /**
123
+ * Returns array of second level domains specified in config
124
+ *
125
+ * @return array
126
+ */
127
+ public function getSecondLevelDomains()
128
+ {
129
+ $config = (string) Mage::getStoreConfig(self::XML_PATH_SECOND_LEVEL_DOMAINS);
130
+ $domains = explode(',', str_replace(' ', '', $config));
131
+
132
+ return array_merge($this->_defaultSLDomains, $domains);
133
+ }
134
+
135
+ /**
136
+ * Returns JSON config for initialization of spell check object in front
137
+ *
138
+ * @return string
139
+ */
140
+ public function getJsonConfig()
141
+ {
142
+ $config = $this->_getJsonConfig();
143
+ $config['selector'] = $this->getFrontFieldSelector();
144
+
145
+ return Mage::helper('core')->jsonEncode($config);
146
+ }
147
+
148
+ /**
149
+ * Returns JSON config for initialization of spell check object in admin
150
+ *
151
+ * @return string
152
+ */
153
+ public function getAdminJsonConfig()
154
+ {
155
+ $config = $this->_getJsonConfig();
156
+ $config['selector'] = $this->getAdminFieldSelector();
157
+
158
+ return Mage::helper('core')->jsonEncode($config);
159
+ }
160
+
161
+ /**
162
+ * Returns common JSON config for initialization of spell check object
163
+ *
164
+ * @return string
165
+ */
166
+ protected function _getJsonConfig()
167
+ {
168
+ return array(
169
+ 'domains' => $this->getDomains(),
170
+ 'suggestionText' => $this->getSuggestionText(),
171
+ 'topLevelDomains' => $this->getTopLevelDomains(),
172
+ 'secondLevelDomains' => $this->getSecondLevelDomains(),
173
+ );
174
+ }
175
+ }
app/code/community/ArchApps/EmailSpellCheck/etc/adminhtml.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category ArchApps
5
+ * @package ArchApps_EmailSpellCheck
6
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
7
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
8
+ */
9
+ -->
10
+ <config>
11
+ <acl>
12
+ <resources>
13
+ <admin>
14
+ <children>
15
+ <system>
16
+ <children>
17
+ <config>
18
+ <children>
19
+ <archapps_emailspellcheck translate="title" module="archapps_emailspellcheck">
20
+ <title>Email Spell Check Section</title>
21
+ <sort_order>130</sort_order>
22
+ </archapps_emailspellcheck>
23
+ </children>
24
+ </config>
25
+ </children>
26
+ </system>
27
+ </children>
28
+ </admin>
29
+ </resources>
30
+ </acl>
31
+ </config>
app/code/community/ArchApps/EmailSpellCheck/etc/config.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category ArchApps
5
+ * @package ArchApps_EmailSpellCheck
6
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
7
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <ArchApps_EmailSpellCheck>
13
+ <version>0.1.1</version>
14
+ </ArchApps_EmailSpellCheck>
15
+ </modules>
16
+
17
+ <global>
18
+ <helpers>
19
+ <archapps_emailspellcheck>
20
+ <class>ArchApps_EmailSpellCheck_Helper</class>
21
+ </archapps_emailspellcheck>
22
+ </helpers>
23
+ </global>
24
+
25
+ <frontend>
26
+ <layout>
27
+ <updates>
28
+ <archapps_emailspellcheck>
29
+ <file>archapps/emailspellcheck.xml</file>
30
+ </archapps_emailspellcheck>
31
+ </updates>
32
+ </layout>
33
+
34
+ <translate>
35
+ <modules>
36
+ <archapps_emailspellcheck>
37
+ <files>
38
+ <default>ArchApps_EmailSpellCheck.csv</default>
39
+ </files>
40
+ </archapps_emailspellcheck>
41
+ </modules>
42
+ </translate>
43
+ </frontend>
44
+
45
+ <adminhtml>
46
+ <layout>
47
+ <updates>
48
+ <archapps_emailspellcheck>
49
+ <file>archapps/emailspellcheck.xml</file>
50
+ </archapps_emailspellcheck>
51
+ </updates>
52
+ </layout>
53
+
54
+ <translate>
55
+ <modules>
56
+ <archapps_emailspellcheck>
57
+ <files>
58
+ <default>ArchApps_EmailSpellCheck.csv</default>
59
+ </files>
60
+ </archapps_emailspellcheck>
61
+ </modules>
62
+ </translate>
63
+ </adminhtml>
64
+
65
+ <default>
66
+ <archapps_emailspellcheck>
67
+ <general>
68
+ <enabled_in_front>1</enabled_in_front>
69
+ <enabled_in_admin>1</enabled_in_admin>
70
+ <front_field_selector>input[type=email],input[name=email],input.validate-email</front_field_selector>
71
+ <admin_field_selector>input[type=email],input[name=email],input.validate-email</admin_field_selector>
72
+ <suggestion_text>Did you mean %suggestion%?</suggestion_text>
73
+ </general>
74
+ </archapps_emailspellcheck>
75
+ </default>
76
+ </config>
app/code/community/ArchApps/EmailSpellCheck/etc/system.xml ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category ArchApps
5
+ * @package ArchApps_EmailSpellCheck
6
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
7
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
8
+ */
9
+ -->
10
+ <config>
11
+ <sections>
12
+ <archapps_emailspellcheck translate="label" module="archapps_emailspellcheck">
13
+ <frontend_type>text</frontend_type>
14
+ <label>Email SpellCheck</label>
15
+ <sort_order>1030</sort_order>
16
+ <tab>general</tab>
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
+ <general translate="label">
22
+ <label>General</label>
23
+ <sort_order>10</sort_order>
24
+ <frontend_type>text</frontend_type>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <fields>
29
+ <enabled_in_front translate="label comment">
30
+ <label>Enabled In Front</label>
31
+ <frontend_type>select</frontend_type>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <sort_order>10</sort_order>
36
+ <source_model>adminhtml/system_config_source_yesno</source_model>
37
+ <comment>Whether to Enable Email SpellCheck In Front-End.</comment>
38
+ </enabled_in_front>
39
+
40
+ <front_field_selector translate="label comment">
41
+ <label>Front-End Email Field Selector</label>
42
+ <frontend_type>textarea</frontend_type>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <sort_order>20</sort_order>
47
+ <depends>
48
+ <enabled_in_front>1</enabled_in_front>
49
+ </depends>
50
+ <comment>Comma Separated CSS Selectors for Email Fields To Be Checked on Front-End, f.e. input[type=email]</comment>
51
+ </front_field_selector>
52
+
53
+ <enabled_in_admin translate="label comment">
54
+ <label>Enabled In Admin</label>
55
+ <frontend_type>select</frontend_type>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>0</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ <sort_order>30</sort_order>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <comment>Whether to Enable Email SpellCheck in Admin Side.</comment>
62
+ </enabled_in_admin>
63
+
64
+ <admin_field_selector translate="label comment">
65
+ <label>Admin Email Field Selector</label>
66
+ <frontend_type>textarea</frontend_type>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>0</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ <sort_order>40</sort_order>
71
+ <depends>
72
+ <enabled_in_admin>1</enabled_in_admin>
73
+ </depends>
74
+ <comment>Comma Separated CSS Selectors for Email Fields To Be Checked in Admin, f.e. input[type=email]</comment>
75
+ </admin_field_selector>
76
+
77
+ <suggestion_text translate="label comment">
78
+ <label>Suggestion Text</label>
79
+ <frontend_type>text</frontend_type>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ <sort_order>50</sort_order>
84
+ <comment>Email Suggestion Text. The %suggestion% Placeholder Will Be Replaced With an Email.</comment>
85
+ </suggestion_text>
86
+ </fields>
87
+ </general>
88
+
89
+ <advanced translate="label">
90
+ <label>Advanced</label>
91
+ <sort_order>20</sort_order>
92
+ <frontend_type>text</frontend_type>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ <fields>
97
+ <domains translate="label comment">
98
+ <label>Domains</label>
99
+ <frontend_type>textarea</frontend_type>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ <sort_order>10</sort_order>
104
+ <comment>Comma Separated List of Additional Domains to Suggest, f.e. gmail.com, aol.com, yahoo.com</comment>
105
+ </domains>
106
+
107
+ <second_level_domains translate="label comment">
108
+ <label>Second Level Domains</label>
109
+ <frontend_type>textarea</frontend_type>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ <sort_order>20</sort_order>
114
+ <comment>Comma Separated List of Additional Second Level Domains to Suggest, f.e. gmail, aol, yahoo</comment>
115
+ </second_level_domains>
116
+
117
+ <top_level_domains translate="label comment">
118
+ <label>Top Level Domains</label>
119
+ <frontend_type>textarea</frontend_type>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>1</show_in_store>
123
+ <sort_order>30</sort_order>
124
+ <comment>Comma Separated List of Additional Top Level Domains to Suggest, f.e. com, co.uk, de, it</comment>
125
+ </top_level_domains>
126
+ </fields>
127
+ </advanced>
128
+ </groups>
129
+ </archapps_emailspellcheck>
130
+ </sections>
131
+ </config>
app/design/adminhtml/default/default/layout/archapps/emailspellcheck.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category ArchApps
5
+ * @package ArchApps_EmailSpellCheck
6
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
7
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
8
+ */
9
+ -->
10
+ <layout>
11
+ <!-- Common JavaScript Used for EmailSpellCheck -->
12
+ <default>
13
+ <reference name="head">
14
+ <!-- Main JavaScript Files -->
15
+ <action method="addJs" ifconfig="archapps_emailspellcheck/general/enabled_in_admin">
16
+ <name>archapps/emailspellcheck/emailspellcheck.js</name>
17
+ </action>
18
+
19
+ <action method="addJs" ifconfig="archapps_emailspellcheck/general/enabled_in_admin">
20
+ <name>archapps/emailspellcheck/mailcheck-plugin.js</name>
21
+ </action>
22
+
23
+ <!-- Main CSS File -->
24
+ <action method="addItem" ifconfig="archapps_emailspellcheck/general/enabled_in_admin">
25
+ <type>js_css</type><name>archapps/emailspellcheck/css/emailspellcheck.css</name>
26
+ </action>
27
+ </reference>
28
+
29
+ <!-- Add Block With JS Initialization -->
30
+ <reference name="js">
31
+ <block type="core/template" name="archapps.emailspellcheck.js"
32
+ template="archapps/emailspellcheck/email-spell-check.phtml"/>
33
+ </reference>
34
+ </default>
35
+ </layout>
app/design/adminhtml/default/default/template/archapps/emailspellcheck/email-spell-check.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ArchApps
4
+ * @package ArchApps_EmailSpellCheck
5
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
6
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
7
+ */
8
+ ?>
9
+ <?php
10
+ /** @var ArchApps_EmailSpellCheck_Helper_Data $helper */
11
+ $helper = Mage::helper('archapps_emailspellcheck');
12
+ ?>
13
+ <?php if ($helper->isEnabledInAdmin()): ?>
14
+ <script type="text/javascript">
15
+ document.observe('dom:loaded', function() {
16
+ new ArchApps.EmailSpellCheck(<?php echo $helper->getAdminJsonConfig() ?>);
17
+ });
18
+ </script>
19
+ <?php endif; ?>
app/design/frontend/base/default/layout/archapps/emailspellcheck.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category ArchApps
5
+ * @package ArchApps_EmailSpellCheck
6
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
7
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
8
+ */
9
+ -->
10
+ <layout>
11
+ <!-- Common JavaScript Used for EmailSpellCheck -->
12
+ <default>
13
+ <reference name="head">
14
+ <!-- Main JavaScript Files -->
15
+ <action method="addJs" ifconfig="archapps_emailspellcheck/general/enabled_in_front">
16
+ <name>archapps/emailspellcheck/emailspellcheck.js</name>
17
+ </action>
18
+
19
+ <action method="addJs" ifconfig="archapps_emailspellcheck/general/enabled_in_front">
20
+ <name>archapps/emailspellcheck/mailcheck-plugin.js</name>
21
+ </action>
22
+
23
+ <!-- Main CSS File -->
24
+ <action method="addItem" ifconfig="archapps_emailspellcheck/general/enabled_in_front">
25
+ <type>js_css</type><name>archapps/emailspellcheck/css/emailspellcheck.css</name>
26
+ </action>
27
+ </reference>
28
+
29
+ <!-- Add Block With JS Initialization -->
30
+ <reference name="before_body_end">
31
+ <block type="core/template" name="archapps.emailspellcheck.js"
32
+ template="archapps/emailspellcheck/email-spell-check.phtml"/>
33
+ </reference>
34
+ </default>
35
+ </layout>
app/design/frontend/base/default/template/archapps/emailspellcheck/email-spell-check.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ArchApps
4
+ * @package ArchApps_EmailSpellCheck
5
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
6
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
7
+ */
8
+ ?>
9
+ <?php
10
+ /** @var ArchApps_EmailSpellCheck_Helper_Data $helper */
11
+ $helper = Mage::helper('archapps_emailspellcheck');
12
+ ?>
13
+ <?php if ($helper->isEnabledInFront()): ?>
14
+ <script type="text/javascript">
15
+ document.observe('dom:loaded', function() {
16
+ new ArchApps.EmailSpellCheck(<?php echo $helper->getJsonConfig() ?>);
17
+ });
18
+ </script>
19
+ <?php endif; ?>
app/etc/modules/ArchApps_EmailSpellCheck.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category ArchApps
5
+ * @package ArchApps_EmailSpellCheck
6
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
7
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <ArchApps_EmailSpellCheck>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ <depends>
16
+ <Mage_Customer />
17
+ <Mage_Checkout />
18
+ </depends>
19
+ </ArchApps_EmailSpellCheck>
20
+ </modules>
21
+ </config>
app/locale/en_US/ArchApps_EmailSpellCheck.csv ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Email SpellCheck", "Email SpellCheck"
2
+ "General", "General"
3
+ "Enabled In Front", "Enabled In Front"
4
+ "Whether to Enable Email SpellCheck In Front-End", "Whether to Enable Email SpellCheck In Front-End"
5
+ "Enabled In Admin", "Enabled In Admin"
6
+ "Whether to Enable Email SpellCheck in Admin Side.", "Whether to Enable Email SpellCheck in Admin Side."
7
+ "Suggestion Text", "Suggestion Text"
8
+ "Email Suggestion Text. The %suggestion% Placeholder Will Be Replaced With an Email.", "Email Suggestion Text. The %suggestion% Placeholder Will Be Replaced With an Email."
9
+ "Front-End Email Field Selector", "Front-End Email Field Selector"
10
+ "Admin Email Field Selector", "Admin Email Field Selector"
11
+ "Comma Separated CSS Selectors for Email Fields To Be Checked on Front-End, f.e. input[type=email]", "Comma Separated CSS Selectors for Email Fields To Be Checked on Front-End, f.e. input[type=email]"
12
+ "Comma Separated CSS Selectors for Email Fields To Be Checked in Admin, f.e. input[type=email]", "Comma Separated CSS Selectors for Email Fields To Be Checked in Admin, f.e. input[type=email]"
13
+ "Advanced" ,"Advanced"
14
+ "Domains" ,"Domains"
15
+ "Comma Separated List of Additional Domains to Suggest, f.e. gmail.com, aol.com, yahoo.com", "Comma Separated List of Additional Domains to Suggest, f.e. gmail.com, aol.com, yahoo.com"
16
+ "Second Level Domains" ,"Second Level Domains"
17
+ "Comma Separated List of Additional Second Level Domains to Suggest, f.e. gmail, aol, yahoo", "Comma Separated List of Additional Second Level Domains to Suggest, f.e. gmail, aol, yahoo"
18
+ "Top Level Domains", "Top Level Domains"
19
+ "Comma Separated List of Additional Top Level Domains to Suggest, f.e. com, co.uk, de, it", "Comma Separated List of Additional Top Level Domains to Suggest, f.e. com, co.uk, de, it"
js/archapps/emailspellcheck/css/emailspellcheck.css ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @category ArchApps
3
+ * @package ArchApps_EmailSpellCheck
4
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
5
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
6
+ */
7
+ .esp-wrap {
8
+ padding: 5px 10px;
9
+ text-transform: none;
10
+ display: inline-block;
11
+ text-decoration: none;
12
+ }
13
+
14
+ .esp-email:hover {
15
+ text-decoration: none;
16
+ }
17
+
18
+ .esp-email {
19
+ font-weight: bold;
20
+ text-decoration: underline;
21
+ }
js/archapps/emailspellcheck/emailspellcheck.js ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @category ArchApps
3
+ * @package ArchApps_EmailSpellCheck
4
+ * @copyright Copyright 2016 ArchApps (https://archapps.io)
5
+ * @license https://opensource.org/licenses/osl-3.0.php OSL 3.0
6
+ */
7
+
8
+ /*global Class, Mailcheck, $$, Template*/
9
+
10
+ /**
11
+ * ArchApps object in the global scope
12
+ *
13
+ * @type {ArchApps|*|{}}
14
+ */
15
+ var ArchApps = window.ArchApps || {};
16
+
17
+ /**
18
+ * Class to handle email spell check feature
19
+ *
20
+ * @type {*}
21
+ */
22
+ ArchApps.EmailSpellCheck = Class.create();
23
+ ArchApps.EmailSpellCheck.prototype = {
24
+ /**
25
+ * Initialization function. Apply configs, events, observers
26
+ *
27
+ * @param {Object} config Object of options for the email spell check
28
+ */
29
+ initialize: function (config) {
30
+ if (typeof Mailcheck !== 'object') {
31
+ console.log('EmailSpellCheck :: No Mailcheck Plugin, Add Plugin');
32
+ return;
33
+ }
34
+
35
+ this.elements = $$(config.selector);
36
+
37
+ if (!this.elements.length) {
38
+ console.log('EmailSpellCheck :: No Elements To Run Mailcheck On');
39
+ return;
40
+ }
41
+
42
+ this.suggestionText = config.suggestionText;
43
+ this.htmlWrapClass = config.htmlWrapClass || 'esp-wrap';
44
+ this.htmlEmailClass = config.htmlEmailClass || 'esp-email';
45
+ this.htmlTextClass = config.htmlTextClass || 'esp-text';
46
+
47
+ this.suggestionEmailMarkup = new Template(
48
+ '<a href="#" class="#{emailClass}">#{email}</a>'
49
+ );
50
+
51
+ this.suggestionMarkup = new Template(
52
+ '<div class="#{wrapClass}">' +
53
+ '<span class="#{textClass}">#{text}</span>' +
54
+ '</div>'
55
+ );
56
+
57
+ /**
58
+ * Extend Mailcheck plugin all default domains as specified in config
59
+ */
60
+ Mailcheck.defaultTopLevelDomains = config.topLevelDomains
61
+ || Mailcheck.defaultTopLevelDomains;
62
+
63
+ Mailcheck.defaultSecondLevelDomains = config.secondLevelDomains
64
+ || Mailcheck.defaultSecondLevelDomains;
65
+
66
+ Mailcheck.defaultDomains = config.domains || Mailcheck.defaultDomains;
67
+
68
+ /**
69
+ * Run email spell check for each selected field on element blur event
70
+ */
71
+ this.elements.each(function (element) {
72
+ if (element.nodeName.toLocaleLowerCase() === 'input') {
73
+ element.observe('blur', function () {
74
+ this.check(element);
75
+ }.bind(this));
76
+ }
77
+ }.bind(this));
78
+ },
79
+
80
+ /**
81
+ * Run mail-check for given element, show or remove the suggestion
82
+ * @param {Object} element DOM element of which email to be checked
83
+ */
84
+ check: function (element) {
85
+ Mailcheck.run({
86
+ email: element.value,
87
+
88
+ empty: function () {
89
+ this.removeSuggestion(element);
90
+ }.bind(this),
91
+
92
+ suggested: function (suggestion) {
93
+ this.removeSuggestion(element);
94
+ this.showSuggestion(element, suggestion);
95
+ }.bind(this)
96
+ });
97
+ },
98
+
99
+ /**
100
+ * Display the suggestion after the specified DOM input element
101
+ * @param {Object} after DOM input element after which to add suggestion
102
+ * @param {Object} suggestion Suggestion object containing correct email
103
+ */
104
+ showSuggestion: function (after, suggestion) {
105
+ var emailMarkup = this.suggestionEmailMarkup.evaluate({
106
+ emailClass: this.htmlEmailClass,
107
+ email: suggestion.full
108
+ }),
109
+
110
+ suggestionMarkup = this.suggestionMarkup.evaluate({
111
+ wrapClass: this.htmlWrapClass,
112
+ textClass: this.htmlTextClass,
113
+ text: this.suggestionText.replace(
114
+ '%suggestion%', emailMarkup
115
+ )
116
+ });
117
+
118
+ after.insert({after: suggestionMarkup});
119
+
120
+ var suggestionElement = after.next(),
121
+ emailElement = suggestionElement
122
+ .select('.' + this.htmlEmailClass)[0];
123
+
124
+ emailElement.observe('click', function (event) {
125
+ after.value = event.currentTarget.innerHTML;
126
+ this.removeSuggestion(after);
127
+ event.preventDefault();
128
+ }.bind(this));
129
+ },
130
+
131
+ /**
132
+ * Remove the suggestion after the specified DOM input element
133
+ * @param {Object} after DOM element of which to remove suggestion
134
+ */
135
+ removeSuggestion: function (after) {
136
+ var suggestionElement = after.next('.' + this.htmlWrapClass);
137
+
138
+ if (suggestionElement) {
139
+ suggestionElement.remove();
140
+ }
141
+ }
142
+ };
js/archapps/emailspellcheck/mailcheck-plugin.js ADDED
@@ -0,0 +1 @@
 
1
+ /*! mailcheck v1.1.1 @licence MIT */var Mailcheck={domainThreshold:2,secondLevelThreshold:2,topLevelThreshold:2,defaultDomains:["msn.com","bellsouth.net","telus.net","comcast.net","optusnet.com.au","earthlink.net","qq.com","sky.com","icloud.com","mac.com","sympatico.ca","googlemail.com","att.net","xtra.co.nz","web.de","cox.net","gmail.com","ymail.com","aim.com","rogers.com","verizon.net","rocketmail.com","google.com","optonline.net","sbcglobal.net","aol.com","me.com","btinternet.com","charter.net","shaw.ca"],defaultSecondLevelDomains:["yahoo","hotmail","mail","live","outlook","gmx"],defaultTopLevelDomains:["com","com.au","com.tw","ca","co.nz","co.uk","de","fr","it","ru","net","org","edu","gov","jp","nl","kr","se","eu","ie","co.il","us","at","be","dk","hk","es","gr","ch","no","cz","in","net","net.au","info","biz","mil","co.jp","sg","hu"],run:function(a){a.domains=a.domains||Mailcheck.defaultDomains,a.secondLevelDomains=a.secondLevelDomains||Mailcheck.defaultSecondLevelDomains,a.topLevelDomains=a.topLevelDomains||Mailcheck.defaultTopLevelDomains,a.distanceFunction=a.distanceFunction||Mailcheck.sift3Distance;var b=function(a){return a},c=a.suggested||b,d=a.empty||b,e=Mailcheck.suggest(Mailcheck.encodeEmail(a.email),a.domains,a.secondLevelDomains,a.topLevelDomains,a.distanceFunction);return e?c(e):d()},suggest:function(a,b,c,d,e){a=a.toLowerCase();var f=this.splitEmail(a);if(c&&d&&-1!==c.indexOf(f.secondLevelDomain)&&-1!==d.indexOf(f.topLevelDomain))return!1;var g=this.findClosestDomain(f.domain,b,e,this.domainThreshold);if(g)return g==f.domain?!1:{address:f.address,domain:g,full:f.address+"@"+g};var h=this.findClosestDomain(f.secondLevelDomain,c,e,this.secondLevelThreshold),i=this.findClosestDomain(f.topLevelDomain,d,e,this.topLevelThreshold);if(f.domain){var g=f.domain,j=!1;if(h&&h!=f.secondLevelDomain&&(g=g.replace(f.secondLevelDomain,h),j=!0),i&&i!=f.topLevelDomain&&(g=g.replace(f.topLevelDomain,i),j=!0),1==j)return{address:f.address,domain:g,full:f.address+"@"+g}}return!1},findClosestDomain:function(a,b,c,d){d=d||this.topLevelThreshold;var e,f=99,g=null;if(!a||!b)return!1;c||(c=this.sift3Distance);for(var h=0;h<b.length;h++){if(a===b[h])return a;e=c(a,b[h]),f>e&&(f=e,g=b[h])}return d>=f&&null!==g?g:!1},sift3Distance:function(a,b){if(null==a||0===a.length)return null==b||0===b.length?0:b.length;if(null==b||0===b.length)return a.length;for(var c=0,d=0,e=0,f=0,g=5;c+d<a.length&&c+e<b.length;){if(a.charAt(c+d)==b.charAt(c+e))f++;else{d=0,e=0;for(var h=0;g>h;h++){if(c+h<a.length&&a.charAt(c+h)==b.charAt(c)){d=h;break}if(c+h<b.length&&a.charAt(c)==b.charAt(c+h)){e=h;break}}}c++}return(a.length+b.length)/2-f},splitEmail:function(a){var b=a.trim().split("@");if(b.length<2)return!1;for(var c=0;c<b.length;c++)if(""===b[c])return!1;var d=b.pop(),e=d.split("."),f="",g="";if(0==e.length)return!1;if(1==e.length)g=e[0];else{f=e[0];for(var c=1;c<e.length;c++)g+=e[c]+".";g=g.substring(0,g.length-1)}return{topLevelDomain:g,secondLevelDomain:f,domain:d,address:b.join("@")}},encodeEmail:function(a){var b=encodeURI(a);return b=b.replace("%20"," ").replace("%25","%").replace("%5E","^").replace("%60","`").replace("%7B","{").replace("%7C","|").replace("%7D","}")}};"undefined"!=typeof module&&module.exports&&(module.exports=Mailcheck),"function"==typeof define&&define.amd&&define("mailcheck",[],function(){return Mailcheck}),"undefined"!=typeof window&&window.jQuery&&!function(a){a.fn.mailcheck=function(a){var b=this;if(a.suggested){var c=a.suggested;a.suggested=function(a){c(b,a)}}if(a.empty){var d=a.empty;a.empty=function(){d.call(null,b)}}a.email=this.val(),Mailcheck.run(a)}}(jQuery);
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ArchApps_EmailSpellCheck</name>
4
+ <version>0.1.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Check &amp; suggest correct email address when user misspells it in your web forms.</summary>
10
+ <description>Email SpellCheck extension for Magento helps your customers to spot and correct any misspelled email addresses in your web forms - be it checkout, registration, newsletter or any other form. Right after user finishes typing an email, extension checks it for typos and suggests to correct it if finds any.</description>
11
+ <notes>Release of v0.1.1</notes>
12
+ <authors><author><name>ArchApps</name><user>ArchApps</user><email>raivis@archapps.io</email></author></authors>
13
+ <date>2016-04-06</date>
14
+ <time>09:32:33</time>
15
+ <contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="ArchApps"><dir name="EmailSpellCheck"><dir><dir name="Helper"><file name="Data.php" hash="c64d4c406fc7812461924ff7501725b8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f120395450864cffd7648fd0ca963825"/><file name="config.xml" hash="fb970f4d846f3272ff47f172836c33fd"/><file name="system.xml" hash="5c60ee63ae868cbb954d73cb97bc0ab3"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="ArchApps_EmailSpellCheck.xml" hash="888f626fa3835c6579be2d5a50e3cff3"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="archapps"><file name="emailspellcheck.xml" hash="45c5177d314662825a5075c3008d3431"/></dir></dir><dir name="template"><dir name="archapps"><dir name="emailspellcheck"><file name="email-spell-check.phtml" hash="5a42eb858bf1487d6ac8c088fbcbf94c"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="archapps"><dir name="emailspellcheck"><file name="email-spell-check.phtml" hash="5c4a081829e816c4517eb0f885255ae7"/></dir></dir></dir><dir name="layout"><dir name="archapps"><file name="emailspellcheck.xml" hash="022f71e7728286b51ef8f15b24e5a1ad"/></dir></dir></dir></dir></dir></dir><dir name="locale"><dir name="en_US"><file name="ArchApps_EmailSpellCheck.csv" hash="097b1aa15b832ce7114d74cb397ce612"/></dir></dir></dir><dir name="js"><dir name="archapps"><dir name="emailspellcheck"><dir><dir name="css"><file name="emailspellcheck.css" hash="963a3a50b816b61bfefe9505e74bfbe1"/></dir></dir><file name="emailspellcheck.js" hash="d466b31a8b068ede1f4eba0975394450"/><file name="mailcheck-plugin.js" hash="97717ff8f16b797c38ab28ebef2dee8a"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>