Version Notes
- Improvements to the extension’s admin page UI
- Improved validation of your Yieldify ID
- You can now clear your Yieldify ID (removes the integration)
Download this release
Release Info
Developer | Yieldify |
Extension | Yieldify_Integration |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.1.0
- app/code/community/Yieldify/Integration/Helper/Data.php +46 -8
- app/code/community/Yieldify/Integration/controllers/Adminhtml/YieldifyuuidController.php +27 -1
- app/code/community/Yieldify/Integration/etc/config.xml +1 -1
- app/design/adminhtml/default/default/template/yieldify_integration/backend.phtml +73 -19
- app/design/frontend/base/default/template/yieldify_integration/frontend.phtml +1 -1
- package.xml +8 -6
app/code/community/Yieldify/Integration/Helper/Data.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
class Yieldify_Integration_Helper_Data extends Mage_Core_Helper_Abstract {
|
3 |
const VARIABLE_NAME = 'yieldify_uuid';
|
4 |
const ENVIRONMENT = 'YIELDIFY_ENV';
|
|
|
5 |
protected static $DOMAIN_LIST = array( // due to PHP5.5 not allowing arrays to be constant variables
|
6 |
'production' => 'app.yieldify.com',
|
7 |
);
|
@@ -18,6 +19,32 @@ class Yieldify_Integration_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
18 |
$this->valueName = ($this->majorVersion==1 && $this->minorVersion>=6)? 'plain' : 'text';
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
public function getVariable() {
|
22 |
$this->_tryCreateVariable();
|
23 |
$tmp = $this->_getVariable();
|
@@ -29,6 +56,8 @@ class Yieldify_Integration_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
29 |
|
30 |
public function setVariable($uuid) {
|
31 |
$this->_tryCreateVariable();
|
|
|
|
|
32 |
return $this->_setVariable($uuid);
|
33 |
}
|
34 |
|
@@ -49,19 +78,30 @@ class Yieldify_Integration_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
49 |
return self::$DOMAIN_LIST[$keys[0]];
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
52 |
private function _tryCreateVariable() {
|
53 |
-
$tmp = $this->_getVariable();
|
54 |
-
if(!is_null($tmp) && $tmp!=='')
|
55 |
-
return false;
|
56 |
try {
|
57 |
$this->_createVariable();
|
58 |
return true;
|
59 |
}
|
60 |
catch (Exception $e) {
|
|
|
|
|
|
|
|
|
61 |
return false;
|
62 |
}
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
private function _getVariable() {
|
66 |
return Mage::getModel('core/variable')
|
67 |
->loadByCode(self::VARIABLE_NAME)
|
@@ -78,10 +118,8 @@ class Yieldify_Integration_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
78 |
|
79 |
private function _createVariable() {
|
80 |
return Mage::getModel('core/variable')
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
->setPlainValue('')
|
85 |
-
->save();
|
86 |
}
|
87 |
}
|
2 |
class Yieldify_Integration_Helper_Data extends Mage_Core_Helper_Abstract {
|
3 |
const VARIABLE_NAME = 'yieldify_uuid';
|
4 |
const ENVIRONMENT = 'YIELDIFY_ENV';
|
5 |
+
const ID_REGEX = '/^[\d,\w]{8}-[\d,\w]{4}-[\d,\w]{4}-[\d,\w]{4}-[\d,\w]{12}$/';
|
6 |
protected static $DOMAIN_LIST = array( // due to PHP5.5 not allowing arrays to be constant variables
|
7 |
'production' => 'app.yieldify.com',
|
8 |
);
|
19 |
$this->valueName = ($this->majorVersion==1 && $this->minorVersion>=6)? 'plain' : 'text';
|
20 |
}
|
21 |
|
22 |
+
public function validateID($new_uuid) {
|
23 |
+
// check if invalid format on id
|
24 |
+
if(!$this->_preg_match($new_uuid))
|
25 |
+
return 'format';
|
26 |
+
|
27 |
+
// check if uuid is invalid by checking the tag
|
28 |
+
$error_type = 'none';
|
29 |
+
try {
|
30 |
+
$contents = file_get_contents('http://'.$this->getDomain().'/yieldify/'.
|
31 |
+
'code.js?w_uuid='.$new_uuid.
|
32 |
+
'&i_s=m&loca=http://'.$_SERVER['HTTP_HOST'].'/'
|
33 |
+
);
|
34 |
+
if( is_null($http_response_header) ||
|
35 |
+
!is_array($http_response_header) ||
|
36 |
+
count($http_response_header)<5 ||
|
37 |
+
$http_response_header[4]!=='Status: 200 OK')
|
38 |
+
$error_type = 'server';
|
39 |
+
else if(strlen($contents)===0)
|
40 |
+
$error_type = 'invalid';
|
41 |
+
}
|
42 |
+
catch(Exception $e) {
|
43 |
+
$error_type = 'server';//'unknown';
|
44 |
+
}
|
45 |
+
return $error_type;
|
46 |
+
}
|
47 |
+
|
48 |
public function getVariable() {
|
49 |
$this->_tryCreateVariable();
|
50 |
$tmp = $this->_getVariable();
|
56 |
|
57 |
public function setVariable($uuid) {
|
58 |
$this->_tryCreateVariable();
|
59 |
+
if(!$this->_preg_match($uuid) && $uuid!=='')
|
60 |
+
return false;
|
61 |
return $this->_setVariable($uuid);
|
62 |
}
|
63 |
|
78 |
return self::$DOMAIN_LIST[$keys[0]];
|
79 |
}
|
80 |
|
81 |
+
public function getIDRegex() {
|
82 |
+
return self::ID_REGEX;
|
83 |
+
}
|
84 |
+
|
85 |
private function _tryCreateVariable() {
|
|
|
|
|
|
|
86 |
try {
|
87 |
$this->_createVariable();
|
88 |
return true;
|
89 |
}
|
90 |
catch (Exception $e) {
|
91 |
+
$tmp = $this->_getVariable();
|
92 |
+
//check if valid(1) or invalid(0)
|
93 |
+
if(!$this->_preg_match($tmp))
|
94 |
+
$this->_setVariable('');
|
95 |
return false;
|
96 |
}
|
97 |
}
|
98 |
|
99 |
+
private function _preg_match($uuid) {
|
100 |
+
if(preg_match(self::ID_REGEX, $uuid)!==1)
|
101 |
+
return false;
|
102 |
+
return true;
|
103 |
+
}
|
104 |
+
|
105 |
private function _getVariable() {
|
106 |
return Mage::getModel('core/variable')
|
107 |
->loadByCode(self::VARIABLE_NAME)
|
118 |
|
119 |
private function _createVariable() {
|
120 |
return Mage::getModel('core/variable')
|
121 |
+
->setCode(self::VARIABLE_NAME)
|
122 |
+
->setName(self::VARIABLE_NAME)
|
123 |
+
->save();
|
|
|
|
|
124 |
}
|
125 |
}
|
app/code/community/Yieldify/Integration/controllers/Adminhtml/YieldifyuuidController.php
CHANGED
@@ -18,12 +18,38 @@ class Yieldify_Integration_Adminhtml_YieldifyuuidController extends Mage_Adminht
|
|
18 |
->_setActiveMenu('yieldifytab')
|
19 |
->_title($this->__('Yieldify - Set Yieldify ID'));
|
20 |
|
|
|
|
|
|
|
21 |
$new_uuid = $this->getRequest()->getParam('new_uuid');
|
22 |
if(!is_null($new_uuid)) {
|
23 |
-
$this->variablesHelper->
|
|
|
|
|
|
|
|
|
24 |
$this->_redirect('*/*/index');
|
|
|
25 |
}
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
$this->renderLayout();
|
28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
18 |
->_setActiveMenu('yieldifytab')
|
19 |
->_title($this->__('Yieldify - Set Yieldify ID'));
|
20 |
|
21 |
+
// make sure the variable is valid by forcing it to check while getting it
|
22 |
+
$variable = $this->variablesHelper->getVariable();
|
23 |
+
|
24 |
$new_uuid = $this->getRequest()->getParam('new_uuid');
|
25 |
if(!is_null($new_uuid)) {
|
26 |
+
$error_type = $this->variablesHelper->validateID($new_uuid);
|
27 |
+
if($error_type==='none') {
|
28 |
+
$this->variablesHelper->setVariable($new_uuid);
|
29 |
+
}
|
30 |
+
Mage::getSingleton('adminhtml/session')->setYieldifyError($error_type);
|
31 |
$this->_redirect('*/*/index');
|
32 |
+
return;
|
33 |
}
|
34 |
|
35 |
+
$error = Mage::getSingleton('adminhtml/session')->getYieldifyError(true);
|
36 |
+
$last_valid_id = Mage::getSingleton('adminhtml/session')->getYieldifyLastValidId(true);
|
37 |
+
if(!is_null($error))
|
38 |
+
Mage::register('yieldify_error', $error, true);
|
39 |
+
if(!is_null($last_valid_id))
|
40 |
+
Mage::register('yieldify_last_valid_id', $last_valid_id, true);
|
41 |
+
|
42 |
$this->renderLayout();
|
43 |
}
|
44 |
+
|
45 |
+
public function clearAction() {
|
46 |
+
$variable = $this->variablesHelper->getVariable();
|
47 |
+
|
48 |
+
$this->variablesHelper->setVariable('');
|
49 |
+
Mage::getSingleton('adminhtml/session')->setYieldifyError('clear');
|
50 |
+
Mage::getSingleton('adminhtml/session')->setYieldifyLastValidId($variable);
|
51 |
+
|
52 |
+
$this->_redirect('*/*/index');
|
53 |
+
return;
|
54 |
+
}
|
55 |
}
|
app/code/community/Yieldify/Integration/etc/config.xml
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
<!-- Basic module configuration -->
|
4 |
<modules>
|
5 |
<Yieldify_Integration>
|
6 |
-
<version>1.
|
7 |
</Yieldify_Integration>
|
8 |
</modules>
|
9 |
<!-- Add layout file to the frontend -->
|
3 |
<!-- Basic module configuration -->
|
4 |
<modules>
|
5 |
<Yieldify_Integration>
|
6 |
+
<version>1.1.0</version>
|
7 |
</Yieldify_Integration>
|
8 |
</modules>
|
9 |
<!-- Add layout file to the frontend -->
|
app/design/adminhtml/default/default/template/yieldify_integration/backend.phtml
CHANGED
@@ -2,34 +2,88 @@
|
|
2 |
|
3 |
$helper = Mage::helper('yieldify_helper');
|
4 |
$yieldify_uuid = $helper->getVariable();
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
|
|
|
|
|
|
10 |
<script>
|
11 |
-
function _yieldify_redirect_set_uuid() {
|
12 |
document.getElementById('_yieldify_uuid_submit').disabled = true;
|
13 |
-
document.getElementById('
|
14 |
var element_value = document.getElementById('_yieldify_uuid_input').value;
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
-
|
20 |
-
|
21 |
-
for(i=0; i<url_arr.length; i++) {
|
22 |
-
if(url_arr[i]==='yieldifyuuid')
|
23 |
-
break;
|
24 |
}
|
25 |
-
|
26 |
-
|
27 |
}
|
28 |
-
window.location = url_arr.join('/') + 'new_uuid/' + element_value;
|
29 |
}
|
30 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
<div class="content-body">
|
32 |
<label>Please insert the unique Yieldify ID you were provided during account set-up:</label>
|
33 |
-
<input id="_yieldify_uuid_input" type="text" value="<?php echo $yieldify_uuid; ?>" style="width: 250px;"/>
|
34 |
-
<input id="_yieldify_uuid_submit" type="submit" value="Save" onclick="javascript:_yieldify_redirect_set_uuid();" style="width: 60px;"></input>
|
35 |
</div>
|
2 |
|
3 |
$helper = Mage::helper('yieldify_helper');
|
4 |
$yieldify_uuid = $helper->getVariable();
|
5 |
+
$yieldify_regex = $helper->getIDRegex();
|
6 |
+
|
7 |
+
$yieldify_error = Mage::registry('yieldify_error');
|
8 |
+
$yieldify_error_status = null;
|
9 |
+
switch ($yieldify_error) {
|
10 |
+
case 'none':
|
11 |
+
$yieldify_error = 'The Yieldify ID is valid and was successfully updated.';
|
12 |
+
$yieldify_error_status = 'success';
|
13 |
+
break;
|
14 |
+
case 'clear':
|
15 |
+
$yieldify_last_valid_id = Mage::registry('yieldify_last_valid_id');
|
16 |
+
$id_string = (is_null($yieldify_last_valid_id)||$yieldify_last_valid_id==='') ? '' : " ($yieldify_last_valid_id)";
|
17 |
+
$yieldify_error = 'Your Yieldify ID'.$id_string.' was successfully cleared';
|
18 |
+
$yieldify_error_status = 'success';
|
19 |
+
break;
|
20 |
+
case 'format':
|
21 |
+
$yieldify_error = 'The ID you provided is not a valid Yieldify ID. A valid ID is made up of letters and numbers and looks like this: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
|
22 |
+
$yieldify_error_status = 'error';
|
23 |
+
break;
|
24 |
+
case 'server':
|
25 |
+
$yieldify_error = 'There was a problem connecting to Yieldify, please try again or contact Yieldify if the issue persists.';
|
26 |
+
$yieldify_error_status = 'error';
|
27 |
+
break;
|
28 |
+
case 'invalid':
|
29 |
+
$yieldify_error = 'The Yieldify ID you entered does not exist, please double check the value you entered or contact Yieldify to make sure you have the correct ID.';
|
30 |
+
$yieldify_error_status = 'error';
|
31 |
+
break;
|
32 |
+
case 'unknown':
|
33 |
+
$yieldify_error = 'An unknown error has occured, please contact Yieldify to make sure you have the correct ID.';
|
34 |
+
$yieldify_error_status = 'error';
|
35 |
+
break;
|
36 |
+
default:
|
37 |
+
$yieldify_error = null;
|
38 |
+
$yieldify_error_status = null;
|
39 |
+
break;
|
40 |
+
}
|
41 |
|
42 |
+
$yieldify_index_url = Mage::helper('adminhtml')->getUrl('adminhtml/yieldifyuuid/index');
|
43 |
+
$yieldify_clear_url = Mage::helper('adminhtml')->getUrl('adminhtml/yieldifyuuid/clear');
|
44 |
+
?>
|
45 |
<script>
|
46 |
+
function _yieldify_redirect_set_uuid(action) {
|
47 |
document.getElementById('_yieldify_uuid_submit').disabled = true;
|
48 |
+
document.getElementById('_yieldify_uuid_clear').disabled = true;
|
49 |
var element_value = document.getElementById('_yieldify_uuid_input').value;
|
50 |
+
if(action==='clear') {
|
51 |
+
var confirmation = confirm('Are you sure you want to clear your Yieldify ID?');
|
52 |
+
if(confirmation) {
|
53 |
+
window.location = '<?php echo $yieldify_clear_url; ?>';
|
54 |
+
}
|
55 |
+
else {
|
56 |
+
document.getElementById('_yieldify_uuid_submit').disabled = false;
|
57 |
+
document.getElementById('_yieldify_uuid_clear').disabled = false;
|
58 |
+
}
|
59 |
}
|
60 |
+
else if(action==='index') {
|
61 |
+
window.location = '<?php echo $yieldify_index_url; ?>' + 'new_uuid/' + element_value;
|
|
|
|
|
|
|
62 |
}
|
63 |
+
else {
|
64 |
+
window.location = '<?php echo $yieldify_index_url; ?>';
|
65 |
}
|
|
|
66 |
}
|
67 |
</script>
|
68 |
+
|
69 |
+
<?php if(!is_null($yieldify_error_status)) { ?>
|
70 |
+
<div id="messages"><ul class="messages"><li class="<?php echo $yieldify_error_status; ?>-msg"><ul><li><span>
|
71 |
+
<?php echo $yieldify_error; ?>
|
72 |
+
</span></li></ul></li></ul></div>
|
73 |
+
<?php } ?>
|
74 |
+
|
75 |
+
<div class="content-header"><table cellspacing="0"><tbody><tr><td>
|
76 |
+
<h3>Yieldify</h3>
|
77 |
+
<p class="form-buttons">
|
78 |
+
<button id="_yieldify_uuid_clear" title="Clear" type="button" class="scalable" onclick="javascript:_yieldify_redirect_set_uuid('clear');" style="">
|
79 |
+
<span><span><span>Clear Yieldify ID</span></span></span>
|
80 |
+
</button>
|
81 |
+
<button id="_yieldify_uuid_submit" title="Save" type="button" class="scalable save" onclick="javascript:_yieldify_redirect_set_uuid('index');" style="">
|
82 |
+
<span><span><span>Validate & Save</span></span></span>
|
83 |
+
</button>
|
84 |
+
</p>
|
85 |
+
</td></tr></tbody></table></div>
|
86 |
<div class="content-body">
|
87 |
<label>Please insert the unique Yieldify ID you were provided during account set-up:</label>
|
88 |
+
<input id="_yieldify_uuid_input" type="text" value="<?php echo $yieldify_uuid; ?>" style="width: 250px;" />
|
|
|
89 |
</div>
|
app/design/frontend/base/default/template/yieldify_integration/frontend.phtml
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
<script>
|
13 |
(function(d) {
|
14 |
var e = d.createElement('script');
|
15 |
-
e.src = d.location.protocol + '//<?php echo $environment; ?>/yieldify/code.js?w_uuid=<?php echo $yieldify_uuid; ?>&loca=' + window.location.href;
|
16 |
e.async = true;
|
17 |
d.getElementsByTagName('head')[0].appendChild(e);
|
18 |
}(document));
|
12 |
<script>
|
13 |
(function(d) {
|
14 |
var e = d.createElement('script');
|
15 |
+
e.src = d.location.protocol + '//<?php echo $environment; ?>/yieldify/code.js?w_uuid=<?php echo $yieldify_uuid; ?>&i_s=m&loca=' + window.location.href;
|
16 |
e.async = true;
|
17 |
d.getElementsByTagName('head')[0].appendChild(e);
|
18 |
}(document));
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Yieldify_Integration</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
@@ -41,11 +41,13 @@ If you’re new to Yieldify, you’ll need to get in touch with us usi
|
|
41 |
Existing customers
|
42 |
If you already have an account with us and need help with getting started via Magento, please contact your Account Manager
|
43 |
Learn more at yieldify.com</description>
|
44 |
-
<notes>-
|
45 |
-
|
46 |
-
|
47 |
-
<
|
48 |
-
<
|
|
|
|
|
49 |
<compatible/>
|
50 |
<dependencies><required><php><min>5.3.0</min><max>5.6.99</max></php></required></dependencies>
|
51 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Yieldify_Integration</name>
|
4 |
+
<version>1.1.0</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>
|
41 |
Existing customers
|
42 |
If you already have an account with us and need help with getting started via Magento, please contact your Account Manager
|
43 |
Learn more at yieldify.com</description>
|
44 |
+
<notes>- Improvements to the extension’s admin page UI
|
45 |
+
- Improved validation of your Yieldify ID
|
46 |
+
- You can now clear your Yieldify ID (removes the integration)</notes>
|
47 |
+
<authors><author><name>Yieldify</name><user>Yieldify</user><email>integrations@yieldify.com</email></author></authors>
|
48 |
+
<date>2016-04-04</date>
|
49 |
+
<time>16:27:16</time>
|
50 |
+
<contents><target name="magecommunity"><dir name="Yieldify"><dir name="Integration"><dir name="Helper"><file name="Data.php" hash="5752b9a90e2b9ae95e4cf7ae23745cfd"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="YieldifyuuidController.php" hash="bf5d3d5e87c9cc6df4153351a3007494"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7626b6772262e64b9839f2c83f47af85"/><file name="config.xml" hash="66e4b44b1158b8b3ea2c6bb36949b0a4"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="yieldifyuuid.xml" hash="d9692c9afaea94f7669606b87778a9c8"/></dir><dir name="template"><dir name="yieldify_integration"><file name="backend.phtml" hash="46c8a19512260e1c092099762c38ad9f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="yieldify_integration.xml" hash="cae7e1f3cb4ddeb928ee1c91dd6de877"/></dir><dir name="template"><dir name="yieldify_integration"><file name="frontend.phtml" hash="cebcafe256cdd5914fd39202a34f6e4f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Yieldify_Integration.xml" hash="6fa40cdb40349504d56529a5d4595b28"/></dir></target></contents>
|
51 |
<compatible/>
|
52 |
<dependencies><required><php><min>5.3.0</min><max>5.6.99</max></php></required></dependencies>
|
53 |
</package>
|