commercesciences - Version 0.0.4

Version Notes

Stable release

Download this release

Release Info

Developer Magento Core Team
Extension commercesciences
Version 0.0.4
Comparing to
See all releases


Version 0.0.4

Files changed (22) hide show
  1. app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/About.php +90 -0
  2. app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Campaignid.php +110 -0
  3. app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Group/About.php +27 -0
  4. app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Isactive.php +79 -0
  5. app/code/local/Commercesciences/Base/Helper/Data.php +330 -0
  6. app/code/local/Commercesciences/Base/Model/Adminhtml/System/Config/Source/Fontstyle.php +32 -0
  7. app/code/local/Commercesciences/Base/Model/Config.php +10 -0
  8. app/code/local/Commercesciences/Base/Model/Mysql4/Config.php +11 -0
  9. app/code/local/Commercesciences/Base/Model/Observer.php +163 -0
  10. app/code/local/Commercesciences/Base/Model/Resource/Setup.php +6 -0
  11. app/code/local/Commercesciences/Base/controllers/ApiController.php +38 -0
  12. app/code/local/Commercesciences/Base/etc/config.xml +130 -0
  13. app/code/local/Commercesciences/Base/etc/system.xml +76 -0
  14. app/code/local/Commercesciences/Base/sql/commercesciences_base_setup/mysql4-install-0.0.1.php +28 -0
  15. app/design/adminhtml/default/default/layout/commercesciences.xml +8 -0
  16. app/etc/modules/Commercesciences_Base.xml +8 -0
  17. package.xml +18 -0
  18. skin/adminhtml/default/default/commercesciences/css/skin.css +312 -0
  19. skin/adminhtml/default/default/commercesciences/images/CS-Logo-innerpage.png +0 -0
  20. skin/adminhtml/default/default/commercesciences/images/icons-boxed.png +0 -0
  21. skin/adminhtml/default/default/commercesciences/images/intro-img.png +0 -0
  22. skin/adminhtml/default/default/commercesciences/images/setup-takes-2-minutes.png +0 -0
app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/About.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_About extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected $_csHelper = null;
6
+
7
+ /**
8
+ * retrieve the module helper
9
+ * @return Commercesciences_Base_Helper_Data
10
+ */
11
+ protected function getCsHelper(){
12
+ if(!$this->_csHelper){
13
+ $this->_csHelper = Mage::helper("commercesciences_base");
14
+ }
15
+ return $this->_csHelper;
16
+ }
17
+
18
+ /**
19
+ * renders and returns the full HTML of the lower part (about) on the configurations panel
20
+ * here we can decide just not to show anything
21
+ *
22
+ * @param Varien_Data_Form_Element_Abstract $element
23
+ * @return string
24
+ */
25
+ public function render(Varien_Data_Form_Element_Abstract $element){
26
+ $html = '<div class="cs_styles">
27
+ <div class="cs_wrap">
28
+ <div id="main" style="">
29
+
30
+ <div class="cs_key-text-block">
31
+ <div class="cs_container">
32
+ <div class="cs_row">
33
+ <div class="cs_span12">
34
+ <h3><strong>The Personal Bar<span class="cs_sans-serif cs_tm">™</span> Is a free E-Commerce add-on, floating at the bottom of your site\'s pages,</strong></h3>
35
+ <h3><strong>designed to ease navigation, increase engagement and revenue</strong></h3>
36
+ </div>
37
+ </div>
38
+ <div class="cs_setup-takes-2-min"></div>
39
+ </div>
40
+ </div>
41
+
42
+ <div class="cs_bar-guide-block">
43
+ <div class="cs_bar-guide-img"></div>
44
+ </div>
45
+
46
+ <div class="cs_details-block">
47
+ <div class="cs_container">
48
+ <div class="cs_row cs_highlight-details" id="getIntuitive">
49
+ <div class="cs_span2 cs_feature-icon"></div>
50
+ <div class="cs_span10 cs_highlight-details-desc">
51
+ <h3><strong>Get Intuitive.</strong> Enable quick access to key site\'s assets, anywhere.</h3>
52
+ <p>Avoid shoppers abandonment due to complex navigation. Improve site usability by gathering all key assets in one intuitive place which is always-on. Adding a <strong>Personal Bar</strong>™ will ease navigation with <i>Search &amp; Checkout</i>, emphasize customer care with <i>Chat &amp; Feedback</i>, boost social with <i>Facebook Like &amp; Google’s +1</i>. It\'s based on your existing site capabilities (e.g. search) as well as offers many new experiences.</p>
53
+ </div>
54
+ </div>
55
+
56
+ <div class="cs_row highlight-details" id="standOut">
57
+ <div class="cs_span10 cs_highlight-details-desc">
58
+ <h3><strong>Stand Out.</strong> Add a stunning edge to your online store in minutes.</h3>
59
+ <p>Improve your brand recognition through a compelling shopping experience. Creating your own <strong>Personal Bar</strong>™ is easy. You don\'t need to be a web designer or developer. Just choose or create a <strong>Personal Bar</strong>™ theme you love and customize it to your needs through our easy-to-use Config Panel. Upload your own logo and add a lovable Personal Shopper to enhance your store’s design.</p>
60
+ </div>
61
+ <div class="cs_span2 cs_feature-icon cs_stand-out"></div>
62
+ </div>
63
+
64
+ <div class="cs_row cs_highlight-details" id="growSales">
65
+ <div class="cs_span2 cs_feature-icon cs_grow-sales"></div>
66
+ <div class="cs_span10 cs_highlight-details-desc">
67
+ <h3><strong>Grow Sales.</strong> Increase your traffic and Facebook fanbase.</h3>
68
+ <p>In today\'s era of Social SEO, gaining social visibility is critical to your store\'s success. Recent studies show that up to 30% of traffic comes from social networks such as Facebook, Google +1 and Pinterest. The <strong>Personal Bar</strong>™ is designed to enable shoppers to easily share with their Facebook friends, join your fanbase, and click on +1 improving your Google ranking. And the best part - it encourages shoppers to further engage by rewarding them with a compelling coupon.</p>
69
+ </div>
70
+ </div>
71
+
72
+
73
+ </div>
74
+ </div>
75
+
76
+ <div class="cs_ending-block">
77
+ <div class="link-ph">
78
+ <p>Have Questions? <a class="start-now" href="http://commercesciences.com/contact">contact us</a></p>
79
+ </div>
80
+ </div>
81
+
82
+ </div>
83
+ </div>
84
+ </div>';
85
+
86
+
87
+ return $html;
88
+ }
89
+
90
+ }
app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Campaignid.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_Campaignid extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected $_csHelper = null;
6
+
7
+ /**
8
+ * retrieve the module helper
9
+ * @return Commercesciences_Base_Helper_Data
10
+ */
11
+ protected function getCsHelper(){
12
+ if(!$this->_csHelper){
13
+ $this->_csHelper = Mage::helper("commercesciences_base");
14
+ }
15
+ return $this->_csHelper;
16
+ }
17
+
18
+
19
+ /**
20
+ * renders and returns the full HTML of the upper part (email) on the configurations panel
21
+ * here we can decide just not to show anything
22
+ *
23
+ * @param Varien_Data_Form_Element_Abstract $element
24
+ * @return string
25
+ */
26
+ public function render(Varien_Data_Form_Element_Abstract $element){
27
+ $html = '<script type="text/javascript">
28
+ document.observe("dom:loaded", function() {
29
+
30
+ $$(".scalable.save").each(function(element){
31
+ element.writeAttribute("onclick",null);
32
+ element.observe("click", function(event){
33
+ $$(".scalable.save").each(function(element){
34
+ element.writeAttribute("disabled","disabled");
35
+ });
36
+ configForm.submit();
37
+ });
38
+
39
+ });
40
+
41
+ });
42
+ </script>
43
+ ';
44
+
45
+ try{
46
+
47
+ $step = $this->getCsHelper()->getStep();
48
+ $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
49
+
50
+ if(!$element->getValue()){
51
+ $currentUser = Mage::getSingleton('admin/session');
52
+ $currentUserEmail = $currentUser->getUser()->getEmail();
53
+
54
+ $element->setValue($currentUserEmail);
55
+ }
56
+ $inputBox = $element->getElementHtml();
57
+ $configEditBlock = Mage::getBlockSingleton("adminhtml/system_config_edit");
58
+ /* @var Mage_Adminhtml_Block_Widget_Button $saveButton */
59
+ $saveButton = $configEditBlock->getLayout()->createBlock('adminhtml/widget_button')
60
+ ->setData(array(
61
+ 'label' => Mage::helper('adminhtml')->__('Create My Account &#187;'),
62
+ 'onclick' => 'configForm.submit()',
63
+ 'class' => 'save',
64
+ ));
65
+ if($step == Commercesciences_Base_Helper_Data::STEP_ZERO){
66
+ $html .= '<div class="cswrapper form-list">';
67
+ $html .= '<div class="csexp1">'.$this->__("You're almost there! Please enter your email below to activate your account (Note: this email would be used to provide you updates and reports).").'</div>';
68
+ $html .= '<div class="csexp2"><div class="csexp2_left">Email Address</div><div class="csexp2_right">'.$inputBox.'</div></div>';
69
+ $html .= '<div class="csexp3"><div class="csexp3_left">Is Live on your store?</div><div class="csexp2_right"><select class="csexpt_right_select" disabled="disabled"><option>No</option></select><p class="note"><span>The personal bar will be hidden from your shoppers until you click "Go Live" from your Config Panel or your Magento dashboard.</span></p>'.$saveButton->toHtml().'</div></div>';
70
+ $html .= '</div>';
71
+
72
+ return $html;
73
+ }
74
+ if($step == Commercesciences_Base_Helper_Data::STEP_ONE){
75
+ $linkToConfBar = 'http://commercesciences.com/magento/configureInitial?userID='.$csConfig->getUserId().'&securityToken='.$csConfig->getSecurityToken();
76
+
77
+ $html .= '<div class="cswrapper form-list">';
78
+ $html .= '<div class="csexp11">';
79
+ $html .= '<div class="csexp11_1">'.$this->__("Congratulations! Your new Personal Bar account is now ready.").'</div>';
80
+ $html .= '<div class="csexp11_2">'.$this->__("To configure the Personal Bar Experiences, Style and more, please click on Go to my Config Panel below.").'</div>';
81
+ $html .= '<div class="csexp11_3">'.$this->__("Your personal Bar will remain hidden from your store visitors until you Publish it.").'</div>';
82
+ $html .= '<div class="csexp11_4">'.$this->__("You can either Publish the Personal Bar from your Config Panel or from the drop list below.").'</div>';
83
+ $html .= '</div>';
84
+ $html .= '<div class="csexp11_5">'.$this->__("Personal Bar Settings").'</div>';
85
+ $html .= '<div class="csexp11_6">'.$this->__("The Personal Bar is fully customizable to fit your store's look & feel and to help you increase engagement and revenue.").'</div>';
86
+ $html .= '<div class="csexp11_7"><a href="'.$linkToConfBar.'" target="_blank">'.$this->__("Go to my Config Panel&#187;").'</a></div>';
87
+
88
+ $html .= '</div>';
89
+
90
+ return $html;
91
+ }
92
+ if($step == Commercesciences_Base_Helper_Data::STEP_TWO){
93
+ $linkToConfBar = 'http://commercesciences.com/magento/configureInitial?userID='.$csConfig->getUserId().'&securityToken='.$csConfig->getSecurityToken();
94
+
95
+ $html .= '<div class="cswrapper form-list">';
96
+ $html .= '<div class="csexp21">'.$this->__("Personal Bar Settings").'</div>';
97
+ $html .= '<div class="csexp22">'.$this->__("The Personal Bar is fully customizable to fit your store’s look & feel and to help you increase engagement and revenue.").'</div>';
98
+ $html .= '<div class="csexp23"><a href="'.$linkToConfBar.'" target="_blank">'.$this->__("Go to my Config Panel&#187;").'</a></div>';
99
+ $html .= '</div>';
100
+
101
+ return $html;
102
+ }
103
+
104
+ return '';
105
+ }catch(Exception $e){
106
+ return '';
107
+ }
108
+ }
109
+
110
+ }
app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Group/About.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_Group_About extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
+ protected $_csHelper = null;
6
+
7
+ /**
8
+ * retrieve the module helper
9
+ * @return Commercesciences_Base_Helper_Data
10
+ */
11
+ protected function getCsHelper(){
12
+ if(!$this->_csHelper){
13
+ $this->_csHelper = Mage::helper("commercesciences_base");
14
+ }
15
+ return $this->_csHelper;
16
+ }
17
+
18
+ public function render(Varien_Data_Form_Element_Abstract $element)
19
+ {
20
+ $step = $this->getCsHelper()->getStep();
21
+ if($step != Commercesciences_Base_Helper_Data::STEP_ZERO){
22
+ return '';
23
+ }
24
+
25
+ return parent::render($element);
26
+ }
27
+ }
app/code/local/Commercesciences/Base/Block/Adminhtml/Config/Form/Renderer/Isactive.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Commercesciences_Base_Block_Adminhtml_Config_Form_Renderer_Isactive extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected $_csHelper = null;
6
+
7
+ /**
8
+ * retrieve the module helper
9
+ * @return Commercesciences_Base_Helper_Data
10
+ */
11
+ protected function getCsHelper(){
12
+ if(!$this->_csHelper){
13
+ $this->_csHelper = Mage::helper("commercesciences_base");
14
+ }
15
+ return $this->_csHelper;
16
+ }
17
+
18
+
19
+ /**
20
+ * renders and returns the full HTML of the lower part (is_active) on the configurations panel
21
+ * here we can decide just not to show anything
22
+ *
23
+ * @param Varien_Data_Form_Element_Abstract $element
24
+ * @return string
25
+ */
26
+ public function render(Varien_Data_Form_Element_Abstract $element){
27
+ try{
28
+
29
+ $step = $this->getCsHelper()->getStep();
30
+ if($step == Commercesciences_Base_Helper_Data::STEP_ZERO || $step == Commercesciences_Base_Helper_Data::STEP_ONE){
31
+ return '';
32
+ }
33
+
34
+ $activeState = $this->getCsHelper()->getActiveState();
35
+ if($activeState['error'] != false){
36
+ throw new Exception($activeState['error']);
37
+ }
38
+ $visible = -1;
39
+ if($activeState['data']=='Hidden'){
40
+ $visible = 0;
41
+ }elseif($activeState['data']=='Visible'){
42
+ $visible = 1;
43
+ }else{
44
+ throw new Exception($this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 005)"));
45
+ }
46
+
47
+ $element->setValue($visible);
48
+ $selectBox = $element->getElementHtml();
49
+
50
+ $configEditBlock = Mage::getBlockSingleton("adminhtml/system_config_edit");
51
+ /* @var Mage_Adminhtml_Block_Widget_Button $saveButton */
52
+ $saveButton = $configEditBlock->getLayout()->createBlock('adminhtml/widget_button')
53
+ ->setData(array(
54
+ 'label' => Mage::helper('adminhtml')->__('Save Config'),
55
+ 'onclick' => 'configForm.submit()',
56
+ 'class' => 'save',
57
+ ));
58
+
59
+ if($step == Commercesciences_Base_Helper_Data::STEP_ONE){
60
+ $html = '<div class="cswrapper form-list">';
61
+ $html .= '<div class="csexp12"><div class="csexp12_left">Enabled?</div><div class="csexp12_right">'.$selectBox.$saveButton->toHtml().'</div></div>';
62
+ $html .= '</div>';
63
+
64
+ return $html;
65
+ }
66
+ if($step == Commercesciences_Base_Helper_Data::STEP_TWO){
67
+ $html = '<div class="cswrapper form-list">';
68
+ $html .= '<div class="csexp24"><div class="csexp24_left">Is Live on my store?</div><div class="csexp24_right">'.$selectBox.$saveButton->toHtml().'</div></div>';
69
+ $html .= '<div class="csexp25"><div class="csexp25_left">'.$this->__("Have questions? contact our").'</div> <a class="csexp25_left2" href="mailto: support@commercesciences.com">'.$this->__("support team").'</a></div>';
70
+ $html .= '</div>';
71
+
72
+ return $html;
73
+ }
74
+ }catch(Exception $e){
75
+ return '';
76
+ }
77
+
78
+ }
79
+ }
app/code/local/Commercesciences/Base/Helper/Data.php ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Commercesciences_Base_Helper_Data extends Mage_Core_Helper_Abstract{
4
+
5
+ const STEP_ZERO = 0;
6
+ const STEP_ONE = 1;
7
+ const STEP_TWO = 2;
8
+
9
+ const CONFIG_EMAIL = 'commercesciences/required_param/email';
10
+ const DEFAULT_MYSQL_TIMEOUT = 10;
11
+
12
+ /**
13
+ * handles the errors
14
+ */
15
+ public function handleError($error){
16
+ //Mage::log("Error:".$error, null, 'cs-error.log', true);
17
+ throw new Exception($error);
18
+ }
19
+
20
+ /**
21
+ * return the current step of the system
22
+ *
23
+ * @return int
24
+ */
25
+ public function getStep(){
26
+ if(!$this->_step){
27
+ $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
28
+ if(!$csConfig || !$csConfig->getId()){
29
+ $csConfig = Mage::getModel("commercesciences_base/config");
30
+ $csConfig->save();
31
+ }
32
+ if(!$csConfig->getUserId()){
33
+ $this->_step = Commercesciences_Base_Helper_Data::STEP_ZERO;
34
+ return $this->_step;
35
+ }
36
+
37
+ //we have userId its step 1 or 2
38
+ $aStateArr = $this->getActiveState();
39
+ if($aStateArr['error'] != false){
40
+ $this->handleError($aStateArr['error']);
41
+ return;
42
+ }
43
+ if($aStateArr['data'] == 'NotConfigured'){
44
+ $this->_step = Commercesciences_Base_Helper_Data::STEP_ONE;
45
+ }elseif($aStateArr['data'] == 'Hidden' || $aStateArr['data'] == 'Visible'){
46
+ $this->_step = Commercesciences_Base_Helper_Data::STEP_TWO;
47
+ }else{
48
+ $error = $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 005)");
49
+ //Mage::log("Error:".$error, null, 'cs-error.log', true);
50
+ throw new Exception($error);
51
+ return;
52
+ }
53
+ }
54
+
55
+ return $this->_step;
56
+ }
57
+
58
+ /**
59
+ * converts the first layer of stdObject to array
60
+ * @param stdObject $stdObj
61
+ * @return array
62
+ */
63
+ public function stdObject2Array($stdObj)
64
+ {
65
+ if (is_object($stdObj)){
66
+ $stdObj = get_object_vars($stdObj);
67
+ }
68
+ return $stdObj;
69
+ }
70
+
71
+ /**
72
+ * register the email + domain on commercesciences
73
+ *
74
+ * @return array - format [error] => ''
75
+ */
76
+ public function register($email, $storeUrl){
77
+
78
+ $RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
79
+
80
+ $httpClient = $RESTClient->getHttpClient();
81
+ $httpClient->setConfig(array(
82
+ "timeout" => 30
83
+ ));
84
+
85
+ try {
86
+
87
+ //Mage::log("xxx", null, "debug6.log", true);
88
+
89
+ $timeBeforeApiCall = time();
90
+
91
+ $response = $RESTClient->restPost("/magento/registerPost", array('email' => $email, 'storeURL'=>$storeUrl));
92
+ $responseJson = $response->getBody();
93
+
94
+ $timeAfterApiCall = time();
95
+ //Mage::log("yyy-".$responseJson, null, "debug6.log", true);
96
+ //Mage::log("zzz-".($timeAfterApiCall-$timeBeforeApiCall), null, "debug6.log", true);
97
+
98
+ //fictive
99
+ //$responseJson = '{"good":true,"data":{"securityToken":"qfJpXFdiccH2LtAXy3U3mMZFRNiAbMsiGocKpk9RLarqda9001YYxXjYyQwy","userID":12296,"tag":"\u003c!-- CS Bar --\u003e\r\n\u003cscript type\u003d\u0027text/javascript\u0027\u003e\r\nvar script \u003d document.createElement(\u0027script\u0027);\r\nscript.type \u003d \u0027text/javascript\u0027;\r\nscript.src \u003d ((document.location.protocol \u003d\u003d \u0027https:\u0027) ? \u0027https://\u0027 : \u0027http://\u0027) +\r\n \u0027app.cdn-cs.com/b/4Udqvg/k9rip6/l/cs_all.js\u0027;\r\ndocument.getElementsByTagName(\u0027head\u0027)[0].appendChild(script);\r\n\u003c/script\u003e\r\n\u003c!-- end CS --\u003e\r\n"}}';
100
+
101
+ //Mage::log("response-".$responseJson, null, 'debug4.log', true);
102
+
103
+ //fictive response for testing
104
+
105
+ /*$parsedResponse = array(
106
+ 'security_token' => 'abcdefghijklmnop',
107
+ 'user_id' => '123456',
108
+ 'tag' => '<script type="text/javascript">alert(\'Hello!\');</script>'
109
+ );
110
+ */
111
+
112
+ $parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
113
+ if(!isset($parsedResponseArr['good'])){
114
+ //timeout occured
115
+ return array('error' => $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 003)"));
116
+ }
117
+ if($parsedResponseArr['good'] == false){
118
+ if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
119
+ $fieldErrorsArr = $parsedResponseArr['fieldErrors'];
120
+ $errorMsg = '';
121
+ foreach($fieldErrorsArr as $field => $fError){
122
+ $errorMsg .= $this->__($fError).",";
123
+ }
124
+ //remove the last comma
125
+ $errorMsg = substr($errorMsg, 0, strlen($errorMsg)-1);
126
+ return array('error' => $errorMsg);
127
+ }elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
128
+ return array('error' => $this->__($parsedResponseArr['globalError']));
129
+ }
130
+ }
131
+ $parsedResponse = $this->stdObject2Array($parsedResponseArr['data']);
132
+
133
+ if(!isset($parsedResponse['securityToken']) || !$parsedResponse['securityToken']
134
+ || !isset($parsedResponse['userID']) || !$parsedResponse['userID']
135
+ || !isset($parsedResponse['tag']) || !$parsedResponse['tag']){
136
+ return $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 001)");
137
+ }
138
+
139
+ if($timeAfterApiCall-$timeBeforeApiCall > self::DEFAULT_MYSQL_TIMEOUT){
140
+ //Mage::log("ffff", null, "debug6.log", true);
141
+
142
+ //pobably mysql serer has gone away, save data in the session
143
+
144
+ $adminSession = Mage::getModel('customer/session');
145
+ $adminSession->setCsUserId($parsedResponse['userID']);
146
+ $adminSession->setCsSecurityToken($parsedResponse['securityToken']);
147
+ $adminSession->setCsTag($parsedResponse['tag']);
148
+ }else{
149
+ $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
150
+ if(!$csConfig){
151
+ $csConfig = Mage::getModel("commercesciences_base/config");
152
+ }
153
+ $csConfig->setStep(Commercesciences_Base_Helper_Data::STEP_ONE)
154
+ ->setSecurityToken($parsedResponse['securityToken'])
155
+ ->setUserId($parsedResponse['userID'])
156
+ ->setTag($parsedResponse['tag'])
157
+ ->save();
158
+ }
159
+
160
+
161
+
162
+
163
+ return array('error' => false);
164
+ }catch(Exception $e){
165
+ //timeout or other unhandled exception was thrown
166
+ return array('error' => $this->__($e->getMessage()));
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Change the is_state of the bar
172
+ *
173
+ * @param int $changeTo
174
+ * @return array
175
+ */
176
+ protected function changeActiveState($changeTo=1){
177
+
178
+ $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
179
+ if(!$csConfig || !$csConfig->getUserId() || !$csConfig->getSecurityToken()){
180
+ //we must be already at least on step 1, so the DB record has to exist
181
+ return array('error' => $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 002)"));
182
+ }
183
+
184
+ $RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
185
+
186
+ $httpClient = $RESTClient->getHttpClient();
187
+ $httpClient->setConfig(array(
188
+ "timeout" => 30
189
+ ));
190
+
191
+ try{
192
+ if($changeTo){
193
+ $response = $RESTClient->restPost("/magento/showBarPost", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
194
+ }else{
195
+ $response = $RESTClient->restPost("/magento/hideBarPost", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
196
+ }
197
+
198
+ $responseJson = $response->getBody();
199
+ //Mage::log("activation-response-".$responseJson, null, 'debug4.log', true);
200
+
201
+ $parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
202
+ if(!isset($parsedResponseArr['good'])){
203
+ return $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 004)");
204
+ }
205
+ if($parsedResponseArr['good'] == false){
206
+ if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
207
+ $fieldErrorsArr = $parsedResponseArr['fieldErrors'];
208
+ $errorMsg = '';
209
+ foreach($fieldErrorsArr as $field => $fError){
210
+ $errorMsg .= $this->__($fError).",";
211
+ }
212
+ //remove the last comma
213
+ $errorMsg = substr($errorMsg, 0, strlen($errorMsg)-1);
214
+ return array('error' => $errorMsg);
215
+ }elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
216
+ return array('error' => $this->__($parsedResponseArr['globalError']));
217
+ }
218
+ }
219
+
220
+ return array('error'=> false, 'data' => ($parsedResponseArr['data']==true ? 1 : 0));
221
+
222
+
223
+ }catch(Exception $e){
224
+ //timeout or other unhandled exception was thrown
225
+ return array('error' => $this->__($e->getMessage()));
226
+ }
227
+ }
228
+
229
+ /**
230
+ * activate the CS bar
231
+ *
232
+ * @return array
233
+ */
234
+ public function activate(){
235
+ $this->changeActiveState(1);
236
+ }
237
+
238
+ /**
239
+ * deactivate the CS bar
240
+ *
241
+ * @return array
242
+ */
243
+ public function deactivate(){
244
+ $this->changeActiveState(0);
245
+ }
246
+
247
+ /**
248
+ * get commercesciences tag
249
+ *
250
+ * @return string
251
+ */
252
+ public function getTag(){
253
+ $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
254
+ if(!$csConfig){
255
+ return '';
256
+ }
257
+ return ($csConfig->getTag() ? $csConfig->getTag() : '');
258
+ }
259
+
260
+ /**
261
+ * check whether the bar is active
262
+ *
263
+ * @return array
264
+ */
265
+ public function getActiveState(){
266
+
267
+ $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
268
+ if(!$csConfig){
269
+ //we must be already at least on step 1, so the DB record has to exist
270
+ return array('error' => $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 005)"));
271
+ }
272
+
273
+
274
+ $RESTClient = new Zend_Rest_Client("http://api.commercesciences.com");
275
+
276
+ $httpClient = $RESTClient->getHttpClient();
277
+ $httpClient->setConfig(array(
278
+ "timeout" => 30
279
+ ));
280
+
281
+ try{
282
+ $response = $RESTClient->restGet("/magento/getBarStatus", array('userID' => $csConfig->getUserId(), 'securityToken'=>$csConfig->getSecurityToken()));
283
+
284
+ $responseJson = $response->getBody();
285
+ //dummy response
286
+ //$responseJson = '{"good":true,"data":"Hidden"}';
287
+
288
+ $parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
289
+
290
+
291
+ if(!isset($parsedResponseArr['good'])){
292
+ return array('error' => $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later. (error id: 006)"));
293
+ }
294
+ if($parsedResponseArr['good'] == false){
295
+ if(isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']){
296
+ $fieldErrorsArr = $parsedResponseArr['fieldErrors'];
297
+ $errorMsg = '';
298
+ foreach($fieldErrorsArr as $field => $fError){
299
+ $errorMsg .= $fError.",";
300
+ }
301
+ $errorMsg = substr($errorMsg, 0, strlen($errorMsg)-1);
302
+ return array('error' => $errorMsg);
303
+ }elseif(isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']){
304
+ return array('error' =>$parsedResponseArr['globalError']);
305
+ }
306
+ }
307
+ return array('error'=> false, 'data' => $parsedResponseArr['data']);
308
+ }catch(Exception $e){
309
+ return array('error' => $this->__($e->getMessage()));
310
+ }
311
+ }
312
+
313
+ /*
314
+ * get a code of the first store in the magento installation
315
+ */
316
+ public function getFirstStoreCode(){
317
+ if(!$this->_firstStore){
318
+ foreach (Mage::app()->getWebsites() as $website) {
319
+ foreach ($website->getGroups() as $group) {
320
+ $stores = $group->getStores();
321
+ foreach ($stores as $store) {
322
+ $this->_firstStore = $store->getCode();
323
+ break;
324
+ }
325
+ }
326
+ }
327
+ }
328
+ return $this->_firstStore;
329
+ }
330
+ }
app/code/local/Commercesciences/Base/Model/Adminhtml/System/Config/Source/Fontstyle.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Commercesciences_Base_Model_Adminhtml_System_Config_Source_Fontstyle{
5
+
6
+ /**
7
+ * Options getter
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ $helper = Mage::helper("commercesciences_base");
14
+ $options = array(
15
+ array('value' => 0, 'label'=>$helper->__('normal')),
16
+ array('value' => 1, 'label'=>$helper->__('italic')),
17
+ array('value' => 2, 'label'=>$helper->__('oblique')),
18
+ );
19
+
20
+ return $options;
21
+ }
22
+
23
+ public function toAssocArray(){
24
+ $helper = Mage::helper("commercesciences_base");
25
+ $assocArr = array(
26
+ '0' => $helper->__('normal'),
27
+ '1' => $helper->__('italic'),
28
+ '2' => $helper->__('oblique')
29
+ );
30
+ return $assocArr;
31
+ }
32
+ }
app/code/local/Commercesciences/Base/Model/Config.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Commercesciences_Base_Model_Config extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct ()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('commercesciences_base/config');
8
+ }
9
+
10
+ }
app/code/local/Commercesciences/Base/Model/Mysql4/Config.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Commercesciences_Base_Model_Mysql4_Config extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ /**
5
+ * parent construct
6
+ */
7
+ public function _construct ()
8
+ {
9
+ $this->_init('commercesciences_base/config', 'entity_id');
10
+ }
11
+ }
app/code/local/Commercesciences/Base/Model/Observer.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Commercesciences_Base_Model_Observer
3
+ {
4
+ private $_putcommercesciences = false;
5
+
6
+ /**
7
+ * retrieve the module helper
8
+ * @return Commercesciences_Base_Helper_Data
9
+ */
10
+ protected function getCsHelper(){
11
+ if(!$this->_csHelper){
12
+ $this->_csHelper = Mage::helper("commercesciences_base");
13
+ }
14
+ return $this->_csHelper;
15
+ }
16
+
17
+ /**
18
+ * observer for the event core_block_abstract_to_html_after
19
+ * adds the tag of commercescience to the block html
20
+ *
21
+ * @param $observer
22
+ * @return mixed
23
+ */
24
+ public function addCommercesciencesHtml($observer)
25
+ {
26
+ if($this->_putcommercesciences){
27
+ return;
28
+ }
29
+
30
+ $request = Mage::app()->getRequest();
31
+ if(($request->getRouteName() == "adminhtml")){
32
+ return;
33
+ }
34
+
35
+
36
+
37
+ $commercesciencesTag = Mage::helper("commercesciences_base")->getTag();
38
+ if(!$commercesciencesTag){
39
+ return;
40
+ }
41
+
42
+ $block = $observer->getBlock();
43
+ $transport = $observer->getTransport();
44
+
45
+ if($block->getNameInLayout() == "footer"){
46
+ $transportHTML = $transport->getHtml();
47
+ $transport->setHtml($transportHTML.$commercesciencesTag);
48
+ $this->_putcommercesciences = true;
49
+ return;
50
+ }
51
+
52
+ if($block->getNameInLayout() == "before_body_end"){
53
+ $transportHTML = $transport->getHtml();
54
+ $transport->setHtml($transportHTML.$commercesciencesTag);
55
+ $this->_putcommercesciences = true;
56
+ return;
57
+ }
58
+
59
+ }
60
+
61
+
62
+ /**
63
+ * observer for event model_config_data_save_before:
64
+ * before the configurations are saved on the admin panel,
65
+ * perform the logic of the flow
66
+ *
67
+ * @param $observer
68
+ * @return void
69
+ */
70
+ public function performStepLogic($observer){
71
+ $request = Mage::app()->getRequest();
72
+ $params = $request->getParams();
73
+ $savedConfigSection = $params['section'];
74
+ if($savedConfigSection != 'commercesciences'){
75
+ return;
76
+ }
77
+
78
+
79
+
80
+ $step = $this->getCsHelper()->getStep();
81
+ $csHelper = $this->getCsHelper();
82
+
83
+ $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
84
+ if(!$csConfig || !$csConfig->getId()){
85
+ $csConfig = Mage::getModel("commercesciences_base/config");
86
+ $csConfig->save();
87
+ }
88
+
89
+ $firstStoreCode = $csHelper->getFirstStoreCode();
90
+ $storeUrl = Mage::app()->getStore($firstStoreCode)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
91
+
92
+ if($step == Commercesciences_Base_Helper_Data::STEP_ZERO){
93
+ //check valid email
94
+ if(!isset($params['groups']['required_param']['fields']['email']['value'])
95
+ || !trim($params['groups']['required_param']['fields']['email']['value'])){
96
+ $csHelper->handleError($csHelper->__('The email should not be empty'));
97
+ return;
98
+ }
99
+ $email = trim($params['groups']['required_param']['fields']['email']['value']);
100
+ $email = filter_var($email, FILTER_VALIDATE_EMAIL);
101
+ if(!$email){
102
+ $csHelper->handleError($csHelper->__('The email %s is not valid', $email));
103
+ return;
104
+ }
105
+
106
+ //register
107
+ $result = $csHelper->register($email, $storeUrl);
108
+ if($result['error']){
109
+ $csHelper->handleError($result['error']);
110
+ return;
111
+ }
112
+
113
+ //customer registered - clear the cache
114
+ Mage::app()->cleanCache();
115
+ }
116
+
117
+ if($step == Commercesciences_Base_Helper_Data::STEP_ONE
118
+ || $step == Commercesciences_Base_Helper_Data::STEP_TWO){
119
+ if(!isset($params['groups']['required_param']['fields']['is_active']['value'])){
120
+ return;
121
+ }
122
+ $newIsActiveConfig = $params['groups']['required_param']['fields']['is_active']['value'];
123
+
124
+
125
+ if($newIsActiveConfig==0){
126
+ $csHelper->deactivate();
127
+ }else{
128
+ $csHelper->activate();
129
+ }
130
+ }
131
+ return;
132
+ }
133
+
134
+ public function beforeTabLoaded($observer){
135
+ $controller_action = $observer->getControllerAction();
136
+ $request = $controller_action->getRequest();
137
+ if($controller_action->getFullActionName() == "adminhtml_system_config_edit"){
138
+ if($request->getParam('section') == 'commercesciences'){
139
+ $adminSession = Mage::getModel('customer/session');
140
+ //Mage::log("vvvv", null, "debug6.log", true);
141
+ if($adminSession->getCsUserId()
142
+ && $adminSession->getCsSecurityToken()
143
+ && $adminSession->getCsTag()){
144
+ $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
145
+ if(!$csConfig || !$csConfig->getId()){
146
+ $csConfig = Mage::getModel("commercesciences_base/config");
147
+ }
148
+ $csConfig->setUserId($adminSession->getCsUserId());
149
+ $csConfig->setSecurityToken($adminSession->getCsSecurityToken());
150
+ $csConfig->setTag($adminSession->getCsTag());
151
+ $csConfig->save();
152
+
153
+ $adminSession->unsetData("cs_user_id");
154
+ $adminSession->unsetData("cs_security_token");
155
+ $adminSession->unsetData("cs_tag");
156
+
157
+ //Mage::log("ppp-".$csConfig->getUserId(), null, "debug6.log", true);
158
+ }
159
+ }
160
+ }
161
+ }
162
+
163
+ }
app/code/local/Commercesciences/Base/Model/Resource/Setup.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Commercesciences_Base_Model_Resource_Setup
3
+ extends Mage_Core_Model_Resource_Setup
4
+ {
5
+
6
+ }
app/code/local/Commercesciences/Base/controllers/ApiController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Commercesciences_Base_ApiController extends Mage_Core_Controller_Front_Action
5
+ {
6
+ public function setisconfiguredAction()
7
+ {
8
+ $request = $this->getRequest();
9
+ if ($request->isPost()) {
10
+ $userId = $request->getParam('userId');
11
+ $securityToken = $request->getParam('securityToken');
12
+
13
+ $csConfig = Mage::getModel("commercesciences_base/config")->load('1');
14
+ if($csConfig
15
+ && $csConfig->getUserId()==$userId
16
+ && $csConfig->getSecurityToken()==$securityToken){
17
+ $csConfig->setStep(Commercesciences_Base_Helper_Data::STEP_TWO);
18
+ $csConfig->save();
19
+ $responseArray = array(
20
+ 'good' => 'true'
21
+ );
22
+ }else{
23
+ $responseArray = array(
24
+ 'good' => 'false',
25
+ 'error' => 'The customer doesnt have such user_id/security_token in his database'
26
+ );
27
+ }
28
+ }else{
29
+ $responseArray = array(
30
+ 'good' => 'false',
31
+ 'error' => 'The request should be of type POST'
32
+ );
33
+ }
34
+
35
+ $this->getResponse()->setHeader('Content-Type', 'application/json', true)->setBody(json_encode($responseArray));
36
+ return;
37
+ }
38
+ }
app/code/local/Commercesciences/Base/etc/config.xml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Commercesciences_Base>
4
+ <version>0.0.1</version>
5
+ </Commercesciences_Base>
6
+ </modules>
7
+ <frontend>
8
+ <routers>
9
+ <commercesciences_base>
10
+ <use>standard</use>
11
+ <args>
12
+ <module>Commercesciences_Base</module>
13
+ <frontName>commercesciences</frontName>
14
+ </args>
15
+ </commercesciences_base>
16
+ </routers>
17
+ </frontend>
18
+ <global>
19
+ <events>
20
+ <core_block_abstract_to_html_after>
21
+ <observers>
22
+ <commercesciences_core_block_abstract_to_html_after>
23
+ <type>singleton</type>
24
+ <class>Commercesciences_Base_Model_Observer</class>
25
+ <method>addCommercesciencesHtml</method>
26
+ </commercesciences_core_block_abstract_to_html_after>
27
+ </observers>
28
+ </core_block_abstract_to_html_after>
29
+ <core_config_data_save_before>
30
+ <observers>
31
+ <commercesciences_admin_system_config_changed_section_commercesciences>
32
+ <type>singleton</type>
33
+ <class>Commercesciences_Base_Model_Observer</class>
34
+ <method>performStepLogic</method>
35
+ </commercesciences_admin_system_config_changed_section_commercesciences>
36
+ </observers>
37
+ </core_config_data_save_before>
38
+ <controller_action_predispatch_adminhtml_system_config_edit>
39
+ <observers>
40
+ <commercesciences_controller_action_predispatch_adminhtml_system_config_edit>
41
+ <type>singleton</type>
42
+ <class>Commercesciences_Base_Model_Observer</class>
43
+ <method>beforeTabLoaded</method>
44
+ </commercesciences_controller_action_predispatch_adminhtml_system_config_edit>
45
+ </observers>
46
+ </controller_action_predispatch_adminhtml_system_config_edit>
47
+ </events>
48
+ <helpers>
49
+ <commercesciences_base>
50
+ <class>Commercesciences_Base_Helper</class>
51
+ </commercesciences_base>
52
+ </helpers>
53
+ <blocks>
54
+ <commercesciences_base>
55
+ <class>Commercesciences_Base_Block</class>
56
+ </commercesciences_base>
57
+ </blocks>
58
+ <models>
59
+ <commercesciences_base>
60
+ <class>Commercesciences_Base_Model</class>
61
+ <resourceModel>commercesciences_base_mysql4</resourceModel>
62
+ </commercesciences_base>
63
+ <commercesciences_base_mysql4>
64
+ <class>Commercesciences_Base_Model_Mysql4</class>
65
+ <entities>
66
+ <config>
67
+ <table>commercesciences_base_config</table>
68
+ </config>
69
+ </entities>
70
+ </commercesciences_base_mysql4>
71
+ </models>
72
+ <resources>
73
+ <commercesciences_base_setup>
74
+ <setup>
75
+ <module>Commercesciences_Base</module>
76
+ <class>Commercesciences_Base_Model_Resource_Setup</class>
77
+ </setup>
78
+ </commercesciences_base_setup>
79
+ </resources>
80
+ </global>
81
+ <default>
82
+ <commercesciences>
83
+ <required_param>
84
+ <is_active>1</is_active>
85
+ </required_param>
86
+ </commercesciences>
87
+ </default>
88
+ <admin>
89
+ <routers>
90
+ <commercesciences>
91
+ <use>admin</use>
92
+ <args>
93
+ <module>Commercesciences_Base</module>
94
+ <frontName>commercesciences</frontName>
95
+ </args>
96
+ </commercesciences>
97
+ </routers>
98
+ </admin>
99
+ <adminhtml>
100
+ <layout>
101
+ <updates>
102
+ <commercesciences>
103
+ <file>commercesciences.xml</file>
104
+ </commercesciences>
105
+ </updates>
106
+ </layout>
107
+ <acl>
108
+ <resources>
109
+ <all>
110
+ <title>Allow Everything</title>
111
+ </all>
112
+ <admin>
113
+ <children>
114
+ <system>
115
+ <children>
116
+ <config>
117
+ <children>
118
+ <commercesciences>
119
+ <title>CommerceSciences</title>
120
+ </commercesciences>
121
+ </children>
122
+ </config>
123
+ </children>
124
+ </system>
125
+ </children>
126
+ </admin>
127
+ </resources>
128
+ </acl>
129
+ </adminhtml>
130
+ </config>
app/code/local/Commercesciences/Base/etc/system.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <tabs>
3
+ <commercesciences>
4
+ <label>CommerceSciences</label>
5
+ <sort_order>800</sort_order>
6
+ </commercesciences>
7
+ </tabs>
8
+ <sections>
9
+ <commercesciences>
10
+ <class>separator-top</class>
11
+ <label><![CDATA[<span class="stadmin-csconfig_menu">Personal Bar Configuration</span>]]></label>
12
+ <tab>commercesciences</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <required_param>
20
+ <label>Personal Bar account Details</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <expanded>1</expanded>
27
+ <fields>
28
+ <email>
29
+ <label></label>
30
+ <comment></comment>
31
+ <frontend_type>text</frontend_type>
32
+ <frontend_model>commercesciences_base/adminhtml_config_form_renderer_campaignid</frontend_model>
33
+ <sort_order>0</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </email>
38
+ <is_active>
39
+ <label>Is Active?</label>
40
+ <comment>[Activate/Deactivate CommerceSciences bar]</comment>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>adminhtml/system_config_source_yesno</source_model>
43
+ <frontend_model>commercesciences_base/adminhtml_config_form_renderer_isactive</frontend_model>
44
+ <sort_order>1</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </is_active>
49
+ </fields>
50
+ </required_param>
51
+ <about_the_bar>
52
+ <label>About the Personal Bar</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>20</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ <expanded>1</expanded>
59
+ <frontend_model>commercesciences_base/adminhtml_config_form_renderer_group_about</frontend_model>
60
+ <fields>
61
+ <email>
62
+ <label></label>
63
+ <comment></comment>
64
+ <frontend_type>text</frontend_type>
65
+ <frontend_model>commercesciences_base/adminhtml_config_form_renderer_about</frontend_model>
66
+ <sort_order>0</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </email>
71
+ </fields>
72
+ </about_the_bar>
73
+ </groups>
74
+ </commercesciences>
75
+ </sections>
76
+ </config>
app/code/local/Commercesciences/Base/sql/commercesciences_base_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+
7
+ /* clear cache & sessions */
8
+ Mage::app()->cleanCache();
9
+ Mage::app()->cleanAllSessions();
10
+
11
+
12
+ /* iterate on the stores and delete old cs configurations */
13
+ //@TODO
14
+
15
+
16
+ $installer->run("
17
+ DROP TABLE IF EXISTS `{$installer->getTable('commercesciences_base/config')}`;
18
+ CREATE TABLE `{$installer->getTable('commercesciences_base/config')}` (
19
+ `entity_id` int(1) unsigned NOT NULL default 1,
20
+ `step` int(1) unsigned default NULL,
21
+ `user_id` varchar(20) default NULL,
22
+ `security_token` varchar(1024) default NULL,
23
+ `tag` varchar(2048) default NULL,
24
+ PRIMARY KEY (`entity_id`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26
+ ");
27
+
28
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/commercesciences.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss"><name>commercesciences/css/skin.css</name></action>
6
+ </reference>
7
+ </default>
8
+ </layout>
app/etc/modules/Commercesciences_Base.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Commercesciences_Base>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ </Commercesciences_Base>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>commercesciences</name>
4
+ <version>0.0.4</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>An extension which enables easy installation for CommerceSciences bar</summary>
10
+ <description>With the installation of the extension, the user will be able to easily register to CommerceSciences and get the bar installed immediately in his website.</description>
11
+ <notes>Stable release</notes>
12
+ <authors><author><name>CommerceSciences</name><user>auto-converted</user><email>smartest_girl89@yahoo.com</email></author></authors>
13
+ <date>2012-10-23</date>
14
+ <time>20:47:26</time>
15
+ <contents><target name="magelocal"><dir name="Commercesciences"><dir name="Base"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Renderer"><dir name="Group"><file name="About.php" hash="a16457268fe17d002e171059bae3c34f"/></dir><file name="About.php" hash="0cb1eb47f815edbc7bd73f7b99f5e993"/><file name="Campaignid.php" hash="b5d09b5f78b50a434c190423844d8e6a"/><file name="Isactive.php" hash="2a25355d0f457f28a413d6a87ab45d2a"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="2a4b02da1d698ec720db77e7330abd03"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Fontstyle.php" hash="c651dc8613a3a501ae7c43dd56f7ca10"/></dir></dir></dir></dir><dir name="Mysql4"><file name="Config.php" hash="4d66326f7313bbdf67ca8c16ed34e87d"/></dir><dir name="Resource"><file name="Setup.php" hash="fb19aa68ae9c60f3869247ca109904a4"/></dir><file name="Config.php" hash="5db637f6c8a9ed31c113dde29d87e9de"/><file name="Observer.php" hash="c459e567ba7a9efaee8ce115e714371b"/></dir><dir name="controllers"><file name="ApiController.php" hash="254e5482daed31d581689f988593a99b"/></dir><dir name="etc"><file name="config.xml" hash="7404d3aae752c3a638c5fa3b55a4fbd6"/><file name="system.xml" hash="a287393592ccbf8c03e25311b8f0f9bc"/></dir><dir name="sql"><dir name="commercesciences_base_setup"><file name="mysql4-install-0.0.1.php" hash="69dffc16a50adfe11df29bae648676cc"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Commercesciences_Base.xml" hash="3223d3e6acdeac74abe8b6f10d899522"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="commercesciences.xml" hash="85100232edb979c031e05c3977664781"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="commercesciences"><dir name="css"><file name="skin.css" hash="f8aba0a288182ad85cf7029012dfe24e"/></dir><dir name="images"><file name="CS-Logo-innerpage.png" hash="450dc4a05822cba236a3400bfa1535f7"/><file name="icons-boxed.png" hash="703749e7a6dd991cffc3767244f14887"/><file name="intro-img.png" hash="20f4193fef90371b49379e6df1e8d523"/><file name="setup-takes-2-minutes.png" hash="9b69dde5ccc771e6910adb3a153cf591"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/adminhtml/default/default/commercesciences/css/skin.css ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .content-header h3 span.stadmin-csconfig_menu {
2
+ background-image:url("../images/CS-Logo-innerpage.png");
3
+ background-position: 0 0;
4
+ background-repeat:no-repeat;
5
+ color:#4799AE;
6
+ padding-left:51px;
7
+ padding-right:0;
8
+ }
9
+ .tabs.config-tabs span.stadmin-csconfig_menu,
10
+ .tabs a:hover.active span.stadmin-csconfig_menu,
11
+ .tabs.config-tabs span.stadmin-csconfig_menu a.stadmin-csconfig_menu:hover {
12
+ padding: 0;
13
+ background-image:url("../images/CS-Logo-innerpage.png");
14
+ background-position:0 2px;
15
+ background-repeat:no-repeat;
16
+ color:#4799AE;
17
+ padding-left:51px;
18
+ padding-right:0;
19
+ }
20
+ .cswrapper{
21
+ padding: 0 10px;
22
+ font-weight: bold;
23
+ }
24
+ .csexp2, .csexp3{
25
+ width: 500px;
26
+ margin: 20px 0 0;
27
+ }
28
+ .csexp2{
29
+ height: 20px;
30
+ }
31
+ .csexp3{
32
+ height: 75px;
33
+ }
34
+ .csexp2_left, .csexp3_left, .csexp12_left, .csexp24_left{
35
+ float: left;
36
+ width: 200px;
37
+ }
38
+ .csexp2_right, .csexp3_right, .csexp12_right, .csexp24_right{
39
+ float: right;
40
+ width: 300px;
41
+ }
42
+ .csexp2_right input{
43
+ width: 300px;
44
+ }
45
+ .csexpt_right_select{
46
+ width: 307px;
47
+ }
48
+ .csexp2_right button.save{
49
+ margin-top: 10px;
50
+ }
51
+ .csexp11{
52
+ border: 1px solid #BFBFBF;
53
+ background-color: #FFFFFF;
54
+ padding: 10px;
55
+ }
56
+ .csexp11_2,.csexp11_3,.csexp11_4,.csexp11_6{
57
+ font-weight: normal;
58
+ }
59
+ .csexp11_5{
60
+ margin: 10px 0px 0px 10px;
61
+ }
62
+ .csexp11_6,.csexp11_7{
63
+ margin: 2px 0px 0px 10px;
64
+ }
65
+ .csexp12{
66
+ width: 500px;
67
+ margin: 40px 0 0 10px;
68
+ }
69
+ .csexp24{
70
+ width: 500px;
71
+ height: 55px;
72
+ margin: 40px 0 0 0px;
73
+ }
74
+ .csexp12_right select, .csexp24_right select{
75
+ width: 250px;
76
+ }
77
+ .csexp12_right button, .csexp24_right button{
78
+ margin-top: 15px;
79
+ }
80
+ .csexp23{
81
+ margin-top: 10px;
82
+ }
83
+ .csexp25{
84
+ width: 500px;
85
+ margin-top: 50px;
86
+ }
87
+ .csexp25_left,.csexp25_left2{
88
+ float: left;
89
+ }
90
+ .csexp25_left2{
91
+ margin-left: 5px;
92
+ color: #000000;
93
+ font-weight: normal;
94
+ }
95
+
96
+
97
+ .cs_styles {
98
+ font-size: 100%;
99
+ -webkit-text-size-adjust: 100%;
100
+ -ms-text-size-adjust: 100%;
101
+ }
102
+ .cs_styles a:focus {
103
+ outline: thin dotted #333;
104
+ outline: 5px auto -webkit-focus-ring-color;
105
+ outline-offset: -2px;
106
+ outline: thin dotted #333;
107
+ outline: 5px auto -webkit-focus-ring-color;
108
+ outline-offset: -2px;
109
+ }
110
+ .cs_styles a:hover,
111
+ .cs_styles a:active {
112
+ outline: 0;
113
+ }
114
+
115
+ .cs_styles {
116
+ margin: 0;
117
+ height: 100%;
118
+ position: relative;
119
+ font-family: 'Pontano Sans', "Myriad Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
120
+ font-size: 14px;
121
+ line-height: 22px;
122
+ color: #000000;
123
+ background-color: #222222;
124
+ }
125
+ .cs_styles a {
126
+ color: #0088cc;
127
+ text-decoration: none;
128
+ }
129
+ .cs_styles a:hover {
130
+ color: #0064cd;
131
+ text-decoration: underline;
132
+ }
133
+ .cs_row {
134
+ margin-left: -20px;
135
+ *zoom: 1;
136
+ *zoom: 1;
137
+ }
138
+ .cs_row:before,
139
+ .cs_row:after {
140
+ display: table;
141
+ content: "";
142
+ }
143
+ .cs_row:after {
144
+ clear: both;
145
+ }
146
+ [class*="cs_span"] {
147
+ float: left;
148
+ margin-left: 20px;
149
+ }
150
+ .cs_container {
151
+ width: 940px;
152
+ }
153
+ .cs_span12 {
154
+ width: 940px;
155
+ }
156
+ .cs_span10 {
157
+ width: 780px;
158
+ }
159
+ .cs_span2 {
160
+ width: 140px;
161
+ }
162
+ .cs_row {
163
+ margin-left: -20px;
164
+ *zoom: 1;
165
+ *zoom: 1;
166
+ }
167
+ .cs_row:before,
168
+ .cs_row:after {
169
+ display: table;
170
+ content: "";
171
+ }
172
+ .cs_row:after {
173
+ clear: both;
174
+ }
175
+ .cs_container {
176
+ width: 940px;
177
+ }
178
+ .cs_span12 {
179
+ width: 940px;
180
+ }
181
+ .cs_span10 {
182
+ width: 780px;
183
+ }
184
+ .cs_span2 {
185
+ width: 140px;
186
+ }
187
+ .cs_container {
188
+ margin-right: auto;
189
+ margin-left: auto;
190
+ *zoom: 1;
191
+ *zoom: 1;
192
+ }
193
+
194
+ .cs_styles p {
195
+ margin: 0 0 11px;
196
+ font-family: 'Pontano Sans', "Myriad Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
197
+ font-size: 14px;
198
+ line-height: 22px;
199
+ }
200
+
201
+ .cs_styles h3 {
202
+ margin: 0;
203
+ font-family: inherit;
204
+ font-weight: normal;
205
+ color: inherit;
206
+ text-rendering: optimizelegibility;
207
+ }
208
+ .cs_styles h3 {
209
+ font-size: 18px;
210
+ line-height: 33px;
211
+ }
212
+ .cs_styles strong {
213
+ font-weight: 600;
214
+ }
215
+
216
+ .cs_styles {
217
+ padding-top: 60px;
218
+ background: #fdfcfb ;
219
+ }
220
+ .cs_sans-serif {
221
+ font-family: Arial, Helvetica, 'sans-serif';
222
+ }
223
+ .cs_sans-serif.cs_tm {
224
+ font-size: 75%;
225
+ }
226
+
227
+ .cs_key-text-block {
228
+ text-align: center;
229
+ }
230
+ .cs_ending-block {
231
+ text-align: center;
232
+ }
233
+ .cs_ending-block p {
234
+ font-weight: bold;
235
+ font-size: 17px;
236
+ }
237
+ .cs_key-text-block h3 {
238
+ font-size: 23px;
239
+ letter-spacing: -1px;
240
+ line-height: 24px;
241
+ position: relative;
242
+ display: inline-block;
243
+ text-align: center;
244
+ }
245
+ .cs_key-text-block .cs_container {
246
+ position: relative;
247
+ }
248
+
249
+ .cs_setup-takes-2-min {
250
+ background-image: url(../images/setup-takes-2-minutes.png);
251
+ width: 96px;
252
+ height:57px;
253
+ position: absolute;
254
+ top: 44px;
255
+ left: 0;
256
+ }
257
+
258
+ .cs_details-block {
259
+ padding: 20px 0 10px;
260
+ }
261
+ .cs_details-block .cs_feature-icon {
262
+ background-image: url(../images/icons-boxed.png);
263
+ background-repeat: no-repeat;
264
+ width: 140px;
265
+ height: 136px;
266
+ }
267
+ .cs_details-block .cs_feature-icon.cs_get-intuitive {
268
+ background-position: 0 0;
269
+ }
270
+ .cs_details-block .cs_feature-icon.cs_stand-out {
271
+ background-position: -145px 0;
272
+ }
273
+ .cs_details-block .cs_feature-icon.cs_grow-sales {
274
+ background-position: -290px 0;
275
+ }
276
+ .cs_details-block h3 {
277
+ font-size: 22px;
278
+ color: #0d2427;
279
+ text-shadow: 0 1px 0 white;
280
+ }
281
+ .cs_details-block .cs_highlight-details {
282
+ margin-top: 10px;
283
+ margin-bottom: 15px;
284
+ }
285
+ .cs_details-block .cs_highlight-details-desc p {
286
+ margin: 2px 0 0px;
287
+ display: block;
288
+ margin-bottom: 10px;
289
+ font-size: 15px;
290
+ line-height: 19px;
291
+ font-family: Helvetica, Arial, sans-serif;
292
+ color: #4D5657;
293
+ font-weight: normal;
294
+ }
295
+
296
+ .cs_bar-guide-block {
297
+ margin: 50px auto 30px;
298
+ }
299
+
300
+ .cs_bar-guide-img {
301
+ margin: 0 auto 0;
302
+ background: transparent url(../images/intro-img.png) no-repeat center center;
303
+ width: 696px;
304
+ height: 205px;
305
+ }
306
+
307
+ @font-face {
308
+ font-family: 'Pontano Sans';
309
+ font-style: normal;
310
+ font-weight: 400;
311
+ src: local('Pontano Sans'), local('PontanoSans-Regular'), url(http://themes.googleusercontent.com/static/fonts/pontanosans/v1/gTHiwyxi6S7iiHpqAoiE3HhCUOGz7vYGh680lGh-uXM.woff) format('woff');
312
+ }
skin/adminhtml/default/default/commercesciences/images/CS-Logo-innerpage.png ADDED
Binary file
skin/adminhtml/default/default/commercesciences/images/icons-boxed.png ADDED
Binary file
skin/adminhtml/default/default/commercesciences/images/intro-img.png ADDED
Binary file
skin/adminhtml/default/default/commercesciences/images/setup-takes-2-minutes.png ADDED
Binary file