facebookfreebelvg - Version 1.0.0

Version Notes

Please, feel free to contact us at store@belvg.com

Download this release

Release Info

Developer Magento Core Team
Extension facebookfreebelvg
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (92) hide show
  1. app/code/community/Belvg/All/Helper/Data.php +34 -0
  2. app/code/community/Belvg/All/etc/config.xml +51 -0
  3. app/code/community/Belvg/All/etc/system.xml +40 -0
  4. app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard.php +98 -0
  5. app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Diagrams.php +59 -0
  6. app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Graph.php +611 -0
  7. app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Orders/Grid.php +115 -0
  8. app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Sales.php +45 -0
  9. app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Tab/Amounts.php +36 -0
  10. app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Tab/Orders.php +35 -0
  11. app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Totals.php +45 -0
  12. app/code/community/Belvg/Dashboard/Helper/Dashboard/Order.php +63 -0
  13. app/code/community/Belvg/Dashboard/Helper/Data.php +34 -0
  14. app/code/community/Belvg/Dashboard/Model/Mysql4/Order/Collection.php +643 -0
  15. app/code/community/Belvg/Dashboard/controllers/DashboardController.php +69 -0
  16. app/code/community/Belvg/Dashboard/etc/adminhtml.xml +63 -0
  17. app/code/community/Belvg/Dashboard/etc/config.xml +81 -0
  18. app/code/community/Belvg/Dashboard/etc/system.xml +85 -0
  19. app/code/community/Belvg/FacebookAll/Block/Active.php +85 -0
  20. app/code/community/Belvg/FacebookAll/Block/Links.php +52 -0
  21. app/code/community/Belvg/FacebookAll/Helper/Active.php +153 -0
  22. app/code/community/Belvg/FacebookAll/Helper/Data.php +35 -0
  23. app/code/community/Belvg/FacebookAll/Model/FacebookAll.php +39 -0
  24. app/code/community/Belvg/FacebookAll/Model/Mysql4/Setup.php +34 -0
  25. app/code/community/Belvg/FacebookAll/Model/System/Config/Source/Color.php +42 -0
  26. app/code/community/Belvg/FacebookAll/Model/System/Config/Source/Font.php +46 -0
  27. app/code/community/Belvg/FacebookAll/Model/System/Config/Source/Layout.php +43 -0
  28. app/code/community/Belvg/FacebookAll/controllers/CustomerController.php +135 -0
  29. app/code/community/Belvg/FacebookAll/controllers/Wishlist/IndexController.php +138 -0
  30. app/code/community/Belvg/FacebookAll/etc/adminhtml.xml +56 -0
  31. app/code/community/Belvg/FacebookAll/etc/config.xml +146 -0
  32. app/code/community/Belvg/FacebookAll/etc/system.xml +361 -0
  33. app/code/community/Belvg/FacebookAll/sql/facebookall_setup/mysql4-install-1.0.1.php +51 -0
  34. app/code/community/Belvg/FaceboookFree/Block/Active.php +86 -0
  35. app/code/community/Belvg/FaceboookFree/Block/Links.php +52 -0
  36. app/code/community/Belvg/FaceboookFree/Helper/Active.php +86 -0
  37. app/code/community/Belvg/FaceboookFree/Helper/Data.php +35 -0
  38. app/code/community/Belvg/FaceboookFree/Model/FaceboookFree.php +39 -0
  39. app/code/community/Belvg/FaceboookFree/Model/Mysql4/Setup.php +34 -0
  40. app/code/community/Belvg/FaceboookFree/Model/System/Config/Source/Color.php +42 -0
  41. app/code/community/Belvg/FaceboookFree/Model/System/Config/Source/Layout.php +43 -0
  42. app/code/community/Belvg/FaceboookFree/controllers/CustomerController.php +136 -0
  43. app/code/community/Belvg/FaceboookFree/etc/adminhtml.xml +56 -0
  44. app/code/community/Belvg/FaceboookFree/etc/config.xml +115 -0
  45. app/code/community/Belvg/FaceboookFree/etc/system.xml +163 -0
  46. app/code/community/Belvg/FaceboookFree/sql/facebookfree_setup/mysql4-install-1.0.1.php +52 -0
  47. app/code/community/Belvg/Fullscreenzoom/etc/adminhtml.xml +56 -0
  48. app/code/community/Belvg/Fullscreenzoom/etc/config.xml +48 -0
  49. app/code/community/Belvg/Fullscreenzoom/etc/system.xml +86 -0
  50. app/code/community/Belvg/Twitter/Block/Adminhtml/Settings.php +71 -0
  51. app/code/community/Belvg/Twitter/Block/Adminhtml/Settings/Tab/General.php +174 -0
  52. app/code/community/Belvg/Twitter/Block/Adminhtml/Settings/Tabs.php +54 -0
  53. app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter.php +43 -0
  54. app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit.php +78 -0
  55. app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit/Form.php +49 -0
  56. app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit/Tab/Form.php +167 -0
  57. app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit/Tab/Settings.php +196 -0
  58. app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit/Tabs.php +59 -0
  59. app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Grid.php +148 -0
  60. app/code/community/Belvg/Twitter/Block/Twitter.php +88 -0
  61. app/code/community/Belvg/Twitter/Block/Twitterbtn.php +61 -0
  62. app/code/community/Belvg/Twitter/Helper/Data.php +36 -0
  63. app/code/community/Belvg/Twitter/Model/Ipad.php +40 -0
  64. app/code/community/Belvg/Twitter/Model/Main.php +99 -0
  65. app/code/community/Belvg/Twitter/Model/Mysql4/Twitter.php +40 -0
  66. app/code/community/Belvg/Twitter/Model/Mysql4/Twitter/Collection.php +40 -0
  67. app/code/community/Belvg/Twitter/Model/Source/Btntype.php +43 -0
  68. app/code/community/Belvg/Twitter/Model/Source/Langtype.php +47 -0
  69. app/code/community/Belvg/Twitter/Model/Status.php +45 -0
  70. app/code/community/Belvg/Twitter/Model/Twitter.php +100 -0
  71. app/code/community/Belvg/Twitter/controllers/AdminController.php +218 -0
  72. app/code/community/Belvg/Twitter/controllers/IndexController.php +45 -0
  73. app/code/community/Belvg/Twitter/controllers/UserController.php +181 -0
  74. app/code/community/Belvg/Twitter/etc/adminhtml.xml +57 -0
  75. app/code/community/Belvg/Twitter/etc/config.xml +169 -0
  76. app/code/community/Belvg/Twitter/etc/system.xml +200 -0
  77. app/code/community/Belvg/Twitter/sql/twitter_setup/mysql4-install-1.1.7.php +77 -0
  78. app/design/frontend/default/default/layout/facebookfree.xml +90 -0
  79. app/design/frontend/default/default/template/facebookfree/block.phtml +92 -0
  80. app/design/frontend/default/default/template/facebookfree/checkoutlogin.phtml +126 -0
  81. app/design/frontend/default/default/template/facebookfree/like/head.phtml +43 -0
  82. app/design/frontend/default/default/template/facebookfree/like/product/view/addto.phtml +45 -0
  83. app/design/frontend/default/default/template/facebookfree/login.phtml +87 -0
  84. app/design/frontend/default/default/template/facebookfree/top.links.phtml +48 -0
  85. app/etc/modules/Belvg_All.xml +41 -0
  86. app/etc/modules/Belvg_FacebookFree.xml +41 -0
  87. lib/Facebook/Api.php +872 -0
  88. lib/Facebook/Exception.php +83 -0
  89. lib/Facebook/fb_ca_chain_bundle.crt +121 -0
  90. package.xml +18 -0
  91. skin/frontend/default/default/css/belvg/facebookfree.css +33 -0
  92. skin/frontend/default/default/images/belvg/fb.gif +0 -0
app/code/community/Belvg/All/Helper/Data.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_All
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_All_Helper_Data extends Mage_Core_Helper_Abstract{
33
+
34
+ }
app/code/community/Belvg/All/etc/config.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_All
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <modules>
35
+ <Belvg_All>
36
+ <version>1.0.0</version>
37
+ </Belvg_All>
38
+ </modules>
39
+ <global>
40
+ <blocks>
41
+ <belvgall>
42
+ <class>Belvg_All_Block</class>
43
+ </belvgall>
44
+ </blocks>
45
+ <helpers>
46
+ <belvgall>
47
+ <class>Belvg_All_Helper</class>
48
+ </belvgall>
49
+ </helpers>
50
+ </global>
51
+ </config>
app/code/community/Belvg/All/etc/system.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_All
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <tabs>
35
+ <belvg translate="label" module="belvgall">
36
+ <label><![CDATA[<div style="background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJsAAAAUCAYAAACah0+BAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2RpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpEMjQxMjA5QTAwOTBFMDExQkJCQ0JBQTc3MUMxMUVCNCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpBODNGMkZDRjkwMjgxMUUwODNFNjgyODE1RDJCMUM1NyIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpBODNGMkZDRTkwMjgxMUUwODNFNjgyODE1RDJCMUM1NyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3MiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo3ODJEOTU4QzI4OTBFMDExQkJCQ0JBQTc3MUMxMUVCNCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpEMjQxMjA5QTAwOTBFMDExQkJCQ0JBQTc3MUMxMUVCNCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PnVxez0AAAfzSURBVHja7FpLaJRXFL5jYmTIRDJZKGqJmQk1iGkktDQVkemi6qJxUXCRRa0b7XIEKS1FRKVIaenCZiO0XVRbaBBx0aQLH5sYxActIT6QFJKJwSbERf4wpkxHm6b3wnfbL4d7//+fJGSVA4f/Mfdx7nmf809ifn5ercIqrASsWWXBKqwUVNub7e/nzSWl8aXGFxqNy0vgKiHleLdRY0njBJ73auzU2K1xxLO/WadGY9oxxu4xK95XaXxT4yaNkxrvaZyr4MytmDuqManxDY31GnuJhmZcn2osi7l1Gp/gnIY/WY2Bxhasa+B3jHuu8WEFPEuAF5IfDXg3KuSxGb9tw16jjnmnQN8ZmpsArVsxb1rjlOBjFej7C78rwRvex/JhA8ll+PGP3dNOZdOwS2MXPQc4YEHjeWK6Wfgg7otYuEPjuMY2jafx2xZc94Qo2y4IJafxBCmWOVAe92b/c7T3SdBlf+sQihIG6zQeFeezcIhoz8JQBjV+T3vbuf0ar2Ac05khZbNCNEr2Z0yevYN9DXxBSngKVzbcVtBTwPM4aLG0KRiAwjlrSIbvaVyvsUnjDN7VC4VkPh+HIqbovCyvwxrbQcsM1u7SDqxbK9yIK4ymSAiKNjIM/BSarkBME7ANTFVQGBbeMB0iDHIQ6kbxfpCYaOEtsYdZ+y4YkIqhbOylZnDWgmPcKK7tUFAl9h3CNQnhKlJCBQOawO+V8GyU7rc6eKEciv+IFMauudlxpr/JkM2YAeKhwcvgr4X7wgMrGI2EBqFoRfotrxWuyuXZ7EHHNN7C805iyHYKCWlirhn/nUNZ4sBNCGYILpi9Uzt5CQtdxPwLZFUGXtN4u4K9jZLe0VjrCNUs9FdxbhbgU1wf4/y/YB3rgR5gTQ4jcXk2iLN30HmKYkwt3RsveR3OIAcD2gplfyYciIED2MN45c81rtV4BOlE0UOLXc+VUqVJaS9pTzahFWwz5gU444SvQGin2H+FrGqbY+wQmDqL8SMVKlsZls4uX0HxenA/7ch5BnBwg7/iXUeFe2/C/FnHb+Z9H4U2BWFYwVkPOYf5ZeGhwiAuz2bgNaJgjGj5Fo4i5VEIqxRNkHEZdPRC7jl4TQktnvcL9jCKhvsp8O8qefcVqUajwuh9eNAmkbx2keUq5AGKDmOhROF+OeERrdtMnvZqyJzCMuz7B66GH2/HGL9eGFCnx4AUpUISSh6vybRkowixIVMrnVH83Rr3V9L6SBGTXbAzBjPSMSy9DeOsJVtv10Ouu+jIIWxVdAxYCTRCiVqpwmKYIOU55MhFXRBH4aN4ZhXlFmhMCY9vcycbGj8h+m9o/DginUg7ZFKMoOUyeJBwKDkb/kmtcJbezwxygVDt2SRLFZlMimVy30hMPrYISx6jw8trmGATwgqtEKK61INkQHmqSo958roMfg/o6oJACGI2pCAK45n16Lux3z7krTlqrcwj3/qSzqEQRh+FnH3OEx1kO2ZW0HIQtGSJf0lSyG7QYMac1QpnePEDK5rPswVYoI7e9VFSLKujXke1VAnMkQdJCqubDplnDn5W40fAfSSMMCiSIkXBkwrO8YLukx4lr4Rn35Byljz57nHiXYBxhz3hcbHQT6nDTo8XHEHbJCAHskErXWuUsqVRml+jJN30zN4VAitACcfgZk+IdZ5XkMPcpSKkJNoIUYxLI5lu8wjZBy2g+SsH7a72QzpmWhCm5FE8CxxhvB+9Sp+hnkNPbgw8ave0PsJyPRdwF+Aevcu5BqOBewZeTqESPsqtjzUhCeMsxX5XpVKPimaOqiu5Rtyk/RnlUTtIWX0hwLYf+iCM+kUoQZHo9oW8/eTZlaNqXkyxFMazF+L5Eoyo3tHbakZTPAHFvID8TREPfeE+iGGYJcH7HqrIGQwdzcaLaYWbR+j8mUJ702Kr0Vph6Vm1PDBFCXano9clLT+JMHIduWTa4RmWCg207m8U9jqWUI3G4ZldYx0q8fvgSyDWySOnqqU8Tib2HPKqQwoEX/O4QMXaA/E+SelMnprMbDSFONVokrTWVZ08x+HrIiwjbi43Sx4kCElg06LnpRwFwnJBi8gdh0FbJqSFkAmpOOPwjNdYCwUagtDSFMKeEp9qHG2NTQ4jXSvebaD7GkSIAQctaZLRML3fRk4hQOsjIUL0gsjmq0btNzce3EP3dRT2UqIVMUXK015hItpJjH3pGNOHKm0AIcSE3wOY26YWfo6K0/poJaYNqYUf3jtECH1CjG9SlTew4/KsH2M4Xciohd9yy8hTzfPrEPgBT77l46FRyL2Yu4eM5JqQeZcj3Qk83YQd+EPHQVceusZhAdb1XYRnsjH+joPwG1CKUbjSQ8r9Cea0xq8JGzz9NgPjxFAJN0WLoITxjVS9xYUMjMq2IswZX6EQmhHN3UniUTYix2kM2TeKZ43CyMtkgAwXia48zQmI5pKjqLmN50nkdnn1/3fbRpFH7ne0qeR69ssFO6r/Ps3xPz+qQxp+pyjunnf0r9IiTodVamnH87Qncc2FhN8yqscj1NAsgPHTSwiZRlAfoCWhRA44STmR9QpbInpYmRA+hPHspWduL/UEObSf4AQcfPvJ02tcT0WJqV4/FBW2lXOY3ObgeXOigHuINXcID3pjQWPU/lMX7i8urAvxPkuBRIym7ErBYs5YhXy35Kie465nxpl/aPyzArxIILrNLZUH2oNFb7b6t/BVWCn4V4ABAKbGYEMWkSgVAAAAAElFTkSuQmCC) no-repeat; width: 155px; height: 20px;"></div>]]></label>
37
+ <sort_order>300</sort_order>
38
+ </belvg>
39
+ </tabs>
40
+ </config>
app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Belvg_Dashboard_Block_Adminhtml_Dashboard extends Mage_Adminhtml_Block_Dashboard
28
+ {
29
+ protected $_locale;
30
+
31
+ /**
32
+ * Location of the "Enable Chart" config param
33
+ */
34
+ const XML_PATH_ENABLE_CHARTS = 'admin/dashboard/enable_charts';
35
+
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ if (Mage::getStoreConfig('dashboard/settings/enabled')) {
40
+ $this->setTemplate('adv_dashboard/index.phtml');
41
+ } else {
42
+ $this->setTemplate('dashboard/index.phtml');
43
+ }
44
+
45
+
46
+ }
47
+
48
+ protected function _prepareLayout()
49
+ {
50
+ $this->setChild('lastOrders',
51
+ $this->getLayout()->createBlock('adminhtml/dashboard_orders_grid')
52
+ );
53
+
54
+ $this->setChild('totals',
55
+ $this->getLayout()->createBlock('adminhtml/dashboard_totals')
56
+ );
57
+
58
+ $this->setChild('sales',
59
+ $this->getLayout()->createBlock('adminhtml/dashboard_sales')
60
+ );
61
+
62
+ $this->setChild('lastSearches',
63
+ $this->getLayout()->createBlock('adminhtml/dashboard_searches_last')
64
+ );
65
+
66
+ $this->setChild('topSearches',
67
+ $this->getLayout()->createBlock('adminhtml/dashboard_searches_top')
68
+ );
69
+
70
+ if (Mage::getStoreConfig(self::XML_PATH_ENABLE_CHARTS)) {
71
+ $block = $this->getLayout()->createBlock('adminhtml/dashboard_diagrams');
72
+ } else {
73
+ $block = $this->getLayout()->createBlock('adminhtml/template')
74
+ ->setTemplate('dashboard/graph/disabled.phtml')
75
+ ->setConfigUrl($this->getUrl('adminhtml/system_config/edit', array('section'=>'admin')));
76
+ }
77
+ $this->setChild('diagrams', $block);
78
+
79
+ $this->setChild('grids',
80
+ $this->getLayout()->createBlock('adminhtml/dashboard_grids')
81
+ );
82
+
83
+ parent::_prepareLayout();
84
+ }
85
+
86
+ public function getOrderCount() {
87
+ $values = Mage::getStoreConfig('dashboard/settings/orders');
88
+ $array = explode(',', $values);
89
+ foreach ($array as $k => $v) {
90
+ $array[$k] = (int)trim($v);
91
+ if ($array[$k] <= 0) {
92
+ unset($array[$k]);
93
+ }
94
+ }
95
+ sort($array);
96
+ return $array;
97
+ }
98
+ }
app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Diagrams.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard diagram tabs
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Belvg_Dashboard_Block_Adminhtml_Dashboard_Diagrams extends Mage_Adminhtml_Block_Dashboard_Diagrams
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('diagram_tab');
41
+ $this->setDestElementId('diagram_tab_content');
42
+ $this->setTemplate('widget/tabshoriz.phtml');
43
+ }
44
+
45
+ protected function _prepareLayout()
46
+ {
47
+ $this->addTab('orders', array(
48
+ 'label' => $this->__('Orders'),
49
+ 'content' => $this->getLayout()->createBlock('adminhtml/dashboard_tab_orders')->toHtml(),
50
+ 'active' => true
51
+ ));
52
+
53
+ $this->addTab('amounts', array(
54
+ 'label' => $this->__('Amounts'),
55
+ 'content' => $this->getLayout()->createBlock('adminhtml/dashboard_tab_amounts')->toHtml(),
56
+ ));
57
+ return Mage_Adminhtml_Block_Widget_Tabs::_prepareLayout();
58
+ }
59
+ }
app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Graph.php ADDED
@@ -0,0 +1,611 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Belvg_Dashboard_Block_Adminhtml_Dashboard_Graph extends Mage_Adminhtml_Block_Dashboard_Abstract
4
+ {
5
+ /**
6
+ * Api URL
7
+ */
8
+ const API_URL = 'http://chart.apis.google.com/chart';
9
+
10
+ /**
11
+ * All series
12
+ *
13
+ * @var array
14
+ */
15
+ protected $_allSeries = array();
16
+
17
+ /**
18
+ * Axis labels
19
+ *
20
+ * @var array
21
+ */
22
+ protected $_axisLabels = array();
23
+
24
+ /**
25
+ * Axis maps
26
+ *
27
+ * @var array
28
+ */
29
+ protected $_axisMaps = array();
30
+
31
+ /**
32
+ * Data rows
33
+ *
34
+ * @var array
35
+ */
36
+ protected $_dataRows = array();
37
+
38
+ /**
39
+ * Simple encoding chars
40
+ *
41
+ * @var string
42
+ */
43
+ protected $_simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
44
+
45
+ /**
46
+ * Extended encoding chars
47
+ *
48
+ * @var string
49
+ */
50
+ protected $_extendedEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.';
51
+
52
+ /**
53
+ * Chart width
54
+ *
55
+ * @var string
56
+ */
57
+ protected $_width = '587';
58
+
59
+ /**
60
+ * Chart height
61
+ *
62
+ * @var string
63
+ */
64
+ protected $_height = '300';
65
+
66
+ /**
67
+ * Google chart api data encoding
68
+ *
69
+ * @var string
70
+ */
71
+ protected $_encoding = 'e';
72
+
73
+ /**
74
+ * Html identifier
75
+ *
76
+ * @var string
77
+ */
78
+ protected $_htmlId = '';
79
+
80
+ /**
81
+ * Initialize object
82
+ *
83
+ * @return void
84
+ */
85
+ public function __construct()
86
+ {
87
+ parent::__construct();
88
+ if (Mage::getStoreConfig('dashboard/settings/enabled')) {
89
+ $this->setTemplate('adv_dashboard/graph.phtml');
90
+ } else {
91
+ $this->setTemplate('dashboard/graph.phtml');
92
+ }
93
+
94
+ }
95
+
96
+ /**
97
+ * Get tab template
98
+ *
99
+ * @return string
100
+ */
101
+ protected function _getTabTemplate()
102
+ {
103
+ if (Mage::getStoreConfig('dashboard/settings/enabled')) {
104
+ return 'adv_dashboard/graph.phtml';
105
+ } else {
106
+ return 'dashboard/graph.phtml';
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Set data rows
112
+ *
113
+ * @param mixed $rows
114
+ * @return void
115
+ */
116
+ public function setDataRows($rows)
117
+ {
118
+ $this->_dataRows = (array)$rows;
119
+ }
120
+
121
+ /**
122
+ * Add series
123
+ *
124
+ * @param string $seriesId
125
+ * @param array $options
126
+ * @return void
127
+ */
128
+ public function addSeries($seriesId, array $options)
129
+ {
130
+ $this->_allSeries[$seriesId] = $options;
131
+ }
132
+
133
+ /**
134
+ * Get series
135
+ *
136
+ * @param string $seriesId
137
+ * @return mixed
138
+ */
139
+ public function getSeries($seriesId)
140
+ {
141
+ if (isset($this->_allSeries[$seriesId])) {
142
+ return $this->_allSeries[$seriesId];
143
+ } else {
144
+ return false;
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Get all series
150
+ *
151
+ * @return array
152
+ */
153
+ public function getAllSeries()
154
+ {
155
+ return $this->_allSeries;
156
+ }
157
+
158
+ public function getChartData()
159
+ {
160
+ $params = array(
161
+ 'cht' => 'lc',
162
+ 'chf' => 'bg,s,f4f4f4|c,lg,90,ffffff,0.1,ededed,0',
163
+ 'chm' => 'B,f4d4b2,0,0,0',
164
+ 'chco' => 'db4814'
165
+ );
166
+
167
+ $this->_allSeries = $this->getRowsData($this->_dataRows);
168
+
169
+ foreach ($this->_axisMaps as $axis => $attr){
170
+ $this->setAxisLabels($axis, $this->getRowsData($attr, true));
171
+ }
172
+
173
+ $gmtOffset = Mage::getSingleton('core/date')->getGmtOffset();
174
+
175
+ $from = Mage::app()->getRequest()->getParam('from', '');
176
+ $to = Mage::app()->getRequest()->getParam('to', '');
177
+
178
+ list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
179
+ ->getDateRange($this->getDataHelper()->getParam('period'), $from, $to, true);
180
+ if (strlen($from) && strlen($to)) {
181
+ $dateStart = new Zend_Date(strtotime($from));
182
+ $dateEnd = new Zend_Date(strtotime($to));
183
+ }
184
+
185
+ $dates = array();
186
+ $datas = array();
187
+
188
+ while($dateStart->compare($dateEnd) < 0){
189
+ switch ($this->getDataHelper()->getParam('period')) {
190
+ case '24h':
191
+ $d = $dateStart->toString('yyyy-MM-dd HH:00');
192
+ $dateStart->addHour(1);
193
+ break;
194
+ case '7d':
195
+ case '1m':
196
+ $d = $dateStart->toString('yyyy-MM-dd');
197
+ $dateStart->addDay(1);
198
+ break;
199
+ case 'custom':
200
+ $d = $dateStart->toString('yyyy-MM-dd');
201
+ $dateStart->addDay(1);
202
+ break;
203
+ case '1y':
204
+ case '2y':
205
+ $d = $dateStart->toString('yyyy-MM');
206
+ $dateStart->addMonth(1);
207
+ break;
208
+ }
209
+
210
+ foreach ($this->getAllSeries() as $index=>$serie) {
211
+ if (in_array($d, $this->_axisLabels['x'])) {
212
+ $datas[$index][] = (float)array_shift($this->_allSeries[$index]);
213
+ } else {
214
+ $datas[$index][] = 0;
215
+ }
216
+ }
217
+ $dates[] = $d;
218
+ }
219
+ $result = array();
220
+ foreach (array_shift($datas) as $k => $v) {
221
+ $result[$k] = array('date'=>explode('-', $dates[$k]), 'data'=>$v);
222
+ }
223
+ return $result;
224
+ }
225
+ /**
226
+ * Get chart url
227
+ *
228
+ * @param bool $directUrl
229
+ * @return string
230
+ */
231
+ public function getChartUrl($directUrl = true)
232
+ {
233
+ $params = array(
234
+ 'cht' => 'lc',
235
+ 'chf' => 'bg,s,f4f4f4|c,lg,90,ffffff,0.1,ededed,0',
236
+ 'chm' => 'B,f4d4b2,0,0,0',
237
+ 'chco' => 'db4814'
238
+ );
239
+
240
+ $this->_allSeries = $this->getRowsData($this->_dataRows);
241
+
242
+ foreach ($this->_axisMaps as $axis => $attr){
243
+ $this->setAxisLabels($axis, $this->getRowsData($attr, true));
244
+ }
245
+
246
+ $gmtOffset = Mage::getSingleton('core/date')->getGmtOffset();
247
+
248
+ $from = Mage::app()->getRequest()->getParam('from', '');
249
+ $to = Mage::app()->getRequest()->getParam('to', '');
250
+
251
+ list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
252
+ ->getDateRange($this->getDataHelper()->getParam('period'), $from, $to, true);
253
+ if (strlen($from) && strlen($to)) {
254
+ $dateStart = new Zend_Date(strtotime($from));
255
+ $dateEnd = new Zend_Date(strtotime($to));
256
+ }
257
+
258
+ $dates = array();
259
+ $datas = array();
260
+
261
+ while($dateStart->compare($dateEnd) < 0){
262
+ switch ($this->getDataHelper()->getParam('period')) {
263
+ case '24h':
264
+ $d = $dateStart->toString('yyyy-MM-dd HH:00');
265
+ $dateStart->addHour(1);
266
+ break;
267
+ case '7d':
268
+ case '1m':
269
+ $d = $dateStart->toString('yyyy-MM-dd');
270
+ $dateStart->addDay(1);
271
+ break;
272
+ case 'custom':
273
+ $d = $dateStart->toString('yyyy-MM-dd');
274
+ $dateStart->addDay(1);
275
+ break;
276
+ case '1y':
277
+ case '2y':
278
+ $d = $dateStart->toString('yyyy-MM');
279
+ $dateStart->addMonth(1);
280
+ break;
281
+ }
282
+
283
+ foreach ($this->getAllSeries() as $index=>$serie) {
284
+ if (in_array($d, $this->_axisLabels['x'])) {
285
+ $datas[$index][] = (float)array_shift($this->_allSeries[$index]);
286
+ } else {
287
+ $datas[$index][] = 0;
288
+ }
289
+ }
290
+ $dates[] = $d;
291
+ }
292
+
293
+ /**
294
+ * setting skip step
295
+ */
296
+ if (count($dates) > 8 && count($dates) < 15) {
297
+ $c = 1;
298
+ } else if (count($dates) >= 15){
299
+ $c = 2;
300
+ } else {
301
+ $c = 0;
302
+ }
303
+ /**
304
+ * skipping some x labels for good reading
305
+ */
306
+ $i=0;
307
+ foreach ($dates as $k => $d) {
308
+ if ($i == $c) {
309
+ $dates[$k] = $d;
310
+ $i = 0;
311
+ } else {
312
+ $dates[$k] = '';
313
+ $i++;
314
+ }
315
+ }
316
+
317
+ $this->_axisLabels['x'] = $dates;
318
+ $this->_allSeries = $datas;
319
+
320
+ //Google encoding values
321
+ if ($this->_encoding == "s") {
322
+ // simple encoding
323
+ $params['chd'] = "s:";
324
+ $dataDelimiter = "";
325
+ $dataSetdelimiter = ",";
326
+ $dataMissing = "_";
327
+ } else {
328
+ // extended encoding
329
+ $params['chd'] = "e:";
330
+ $dataDelimiter = "";
331
+ $dataSetdelimiter = ",";
332
+ $dataMissing = "__";
333
+ }
334
+
335
+ // process each string in the array, and find the max length
336
+ foreach ($this->getAllSeries() as $index => $serie) {
337
+ $localmaxlength[$index] = sizeof($serie);
338
+ $localmaxvalue[$index] = max($serie);
339
+ $localminvalue[$index] = min($serie);
340
+ }
341
+
342
+ if (is_numeric($this->_max)) {
343
+ $maxvalue = $this->_max;
344
+ } else {
345
+ $maxvalue = max($localmaxvalue);
346
+ }
347
+ if (is_numeric($this->_min)) {
348
+ $minvalue = $this->_min;
349
+ } else {
350
+ $minvalue = min($localminvalue);
351
+ }
352
+
353
+ // default values
354
+ $yrange = 0;
355
+ $yLabels = array();
356
+ $miny = 0;
357
+ $maxy = 0;
358
+ $yorigin = 0;
359
+
360
+ $maxlength = max($localmaxlength);
361
+ if ($minvalue >= 0 && $maxvalue >= 0) {
362
+ $miny = 0;
363
+ if ($maxvalue > 10) {
364
+ $p = pow(10, $this->_getPow($maxvalue));
365
+ $maxy = (ceil($maxvalue/$p))*$p;
366
+ $yLabels = range($miny, $maxy, $p);
367
+ } else {
368
+ $maxy = ceil($maxvalue+1);
369
+ $yLabels = range($miny, $maxy, 1);
370
+ }
371
+ $yrange = $maxy;
372
+ $yorigin = 0;
373
+ }
374
+
375
+ $chartdata = array();
376
+
377
+ foreach ($this->getAllSeries() as $index => $serie) {
378
+ $thisdataarray = $serie;
379
+ if ($this->_encoding == "s") {
380
+ // SIMPLE ENCODING
381
+ for ($j = 0; $j < sizeof($thisdataarray); $j++) {
382
+ $currentvalue = $thisdataarray[$j];
383
+ if (is_numeric($currentvalue)) {
384
+ $ylocation = round((strlen($this->_simpleEncoding)-1) * ($yorigin + $currentvalue) / $yrange);
385
+ array_push($chartdata, substr($this->_simpleEncoding, $ylocation, 1) . $dataDelimiter);
386
+ } else {
387
+ array_push($chartdata, $dataMissing . $dataDelimiter);
388
+ }
389
+ }
390
+ // END SIMPLE ENCODING
391
+ } else {
392
+ // EXTENDED ENCODING
393
+ for ($j = 0; $j < sizeof($thisdataarray); $j++) {
394
+ $currentvalue = $thisdataarray[$j];
395
+ if (is_numeric($currentvalue)) {
396
+ if ($yrange) {
397
+ $ylocation = (4095 * ($yorigin + $currentvalue) / $yrange);
398
+ } else {
399
+ $ylocation = 0;
400
+ }
401
+ $firstchar = floor($ylocation / 64);
402
+ $secondchar = $ylocation % 64;
403
+ $mappedchar = substr($this->_extendedEncoding, $firstchar, 1)
404
+ . substr($this->_extendedEncoding, $secondchar, 1);
405
+ array_push($chartdata, $mappedchar . $dataDelimiter);
406
+ } else {
407
+ array_push($chartdata, $dataMissing . $dataDelimiter);
408
+ }
409
+ }
410
+ // ============= END EXTENDED ENCODING =============
411
+ }
412
+ array_push($chartdata, $dataSetdelimiter);
413
+ }
414
+
415
+ $buffer = implode('', $chartdata);
416
+
417
+ $buffer = rtrim($buffer, $dataSetdelimiter);
418
+ $buffer = rtrim($buffer, $dataDelimiter);
419
+ $buffer = str_replace(($dataDelimiter . $dataSetdelimiter), $dataSetdelimiter, $buffer);
420
+
421
+ $params['chd'] .= $buffer;
422
+
423
+ $labelBuffer = "";
424
+ $valueBuffer = array();
425
+ $rangeBuffer = "";
426
+
427
+ if (sizeof($this->_axisLabels) > 0) {
428
+ $params['chxt'] = implode(',', array_keys($this->_axisLabels));
429
+ $indexid = 0;
430
+ foreach ($this->_axisLabels as $idx=>$labels){
431
+ if ($idx == 'x') {
432
+ /**
433
+ * Format date
434
+ */
435
+ foreach ($this->_axisLabels[$idx] as $_index=>$_label) {
436
+ if ($_label != '') {
437
+ switch ($this->getDataHelper()->getParam('period')) {
438
+ case '24h':
439
+ $this->_axisLabels[$idx][$_index] = $this->formatTime($_label, 'short', false);
440
+ break;
441
+ case '7d':
442
+ case '1m':
443
+ $this->_axisLabels[$idx][$_index] = $this->formatDate($_label);
444
+ break;
445
+ case '1y':
446
+ case '2y':
447
+ $formats = Mage::app()->getLocale()->getTranslationList('datetime');
448
+ $format = isset($formats['yyMM']) ? $formats['yyMM'] : 'MM/yyyy';
449
+ $format = str_replace(array("yyyy", "yy", "MM"), array("Y", "y", "m"), $format);
450
+ $this->_axisLabels[$idx][$_index] = date($format, strtotime($_label));
451
+ break;
452
+ }
453
+ } else {
454
+ $this->_axisLabels[$idx][$_index] = '';
455
+ }
456
+
457
+ }
458
+
459
+ $tmpstring = implode('|', $this->_axisLabels[$idx]);
460
+
461
+ $valueBuffer[] = $indexid . ":|" . $tmpstring;
462
+ if (sizeof($this->_axisLabels[$idx]) > 1) {
463
+ $deltaX = 100/(sizeof($this->_axisLabels[$idx])-1);
464
+ } else {
465
+ $deltaX = 100;
466
+ }
467
+ } else if ($idx == 'y') {
468
+ $valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
469
+ if (sizeof($yLabels)-1) {
470
+ $deltaY = 100/(sizeof($yLabels)-1);
471
+ } else {
472
+ $deltaY = 100;
473
+ }
474
+ // setting range values for y axis
475
+ $rangeBuffer = $indexid . "," . $miny . "," . $maxy . "|";
476
+ }
477
+ $indexid++;
478
+ }
479
+ $params['chxl'] = implode('|', $valueBuffer);
480
+ };
481
+
482
+ // chart size
483
+ $params['chs'] = $this->getWidth().'x'.$this->getHeight();
484
+
485
+ if (isset($deltaX) && isset($deltaY)) {
486
+ $params['chg'] = $deltaX . ',' . $deltaY . ',1,0';
487
+ }
488
+
489
+ // return the encoded data
490
+ if ($directUrl) {
491
+ $p = array();
492
+ foreach ($params as $name => $value) {
493
+ $p[] = $name . '=' .urlencode($value);
494
+ }
495
+ return self::API_URL . '?' . implode('&', $p);
496
+ } else {
497
+ $gaData = urlencode(base64_encode(serialize($params)));
498
+ $gaHash = Mage::helper('adminhtml/dashboard_data')->getChartDataHash($gaData);
499
+ $params = array('ga' => $gaData, 'h' => $gaHash);
500
+ return $this->getUrl('*/*/tunnel', array('_query' => $params));
501
+ }
502
+ }
503
+
504
+ /**
505
+ * Get rows data
506
+ *
507
+ * @param array $attributes
508
+ * @param bool $single
509
+ * @return array
510
+ */
511
+ protected function getRowsData($attributes, $single = false)
512
+ {
513
+ $items = $this->getCollection()->getItems();
514
+
515
+ $options = array();
516
+ foreach ($items as $item){
517
+ if ($single) {
518
+ $options[] = $item->getData($attributes);
519
+ } else {
520
+ foreach ((array)$attributes as $attr){
521
+ $options[$attr][] = $item->getData($attr);
522
+ }
523
+ }
524
+ }
525
+ return $options;
526
+ }
527
+
528
+ /**
529
+ * Set axis labels
530
+ *
531
+ * @param string $axis
532
+ * @param array $labels
533
+ * @return void
534
+ */
535
+ public function setAxisLabels($axis, $labels)
536
+ {
537
+ $this->_axisLabels[$axis] = $labels;
538
+ }
539
+
540
+ /**
541
+ * Set html id
542
+ *
543
+ * @param string $htmlId
544
+ * @return void
545
+ */
546
+ public function setHtmlId($htmlId)
547
+ {
548
+ $this->_htmlId = $htmlId;
549
+ }
550
+
551
+ /**
552
+ * Get html id
553
+ *
554
+ * @return string
555
+ */
556
+ public function getHtmlId()
557
+ {
558
+ return $this->_htmlId;
559
+ }
560
+
561
+ /**
562
+ * Return pow
563
+ *
564
+ * @param int $number
565
+ * @return int
566
+ */
567
+ protected function _getPow($number)
568
+ {
569
+ $pow = 0;
570
+ while ($number >= 10) {
571
+ $number = $number/10;
572
+ $pow++;
573
+ }
574
+ return $pow;
575
+ }
576
+
577
+ /**
578
+ * Return chart width
579
+ *
580
+ * @return string
581
+ */
582
+ protected function getWidth()
583
+ {
584
+ return $this->_width;
585
+ }
586
+
587
+ /**
588
+ * Return chart height
589
+ *
590
+ * @return string
591
+ */
592
+ protected function getHeight()
593
+ {
594
+ return $this->_height;
595
+ }
596
+
597
+ /**
598
+ * Prepare chart data
599
+ *
600
+ * @return void
601
+ */
602
+ protected function _prepareData()
603
+ {
604
+ $availablePeriods = array_keys($this->helper('adminhtml/dashboard_data')->getDatePeriods());
605
+ $period = $this->getRequest()->getParam('period');
606
+
607
+ $this->getDataHelper()->setParam('period',
608
+ ($period && (in_array($period, $availablePeriods) || $period=='custom')) ? $period : '24h'
609
+ );
610
+ }
611
+ }
app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Orders/Grid.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Belvg_Dashboard_Block_Adminhtml_Dashboard_Orders_Grid extends Mage_Adminhtml_Block_Dashboard_Orders_Grid
5
+ {
6
+
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setId('lastOrdersGrid');
11
+ if (Mage::getStoreConfig('dashboard/settings/enabled')) {
12
+ $this->setTemplate('adv_dashboard/grid.phtml');
13
+ } else {
14
+ $this->setTemplate('dashboard/grid.phtml');
15
+ }
16
+
17
+ $this->setDefaultLimit($this->getRequest()->getParam('order', 5));
18
+ }
19
+
20
+ protected function _prepareCollection()
21
+ {
22
+ $collection = Mage::getResourceModel('reports/order_collection')
23
+ ->addItemCountExpr()
24
+ ->joinCustomerName('customer')
25
+ ->orderByCreatedAt();
26
+
27
+ if($this->getParam('store') || $this->getParam('website') || $this->getParam('group')) {
28
+ if ($this->getParam('store')) {
29
+ $collection->addAttributeToFilter('store_id', $this->getParam('store'));
30
+ } else if ($this->getParam('website')){
31
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
32
+ $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
33
+ } else if ($this->getParam('group')){
34
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
35
+ $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
36
+ }
37
+
38
+ $collection->addRevenueToSelect();
39
+ } else {
40
+ $collection->addRevenueToSelect(true);
41
+ }
42
+
43
+ $this->setCollection($collection);
44
+
45
+ return parent::_prepareCollection();
46
+ }
47
+
48
+ /**
49
+ * Prepares page sizes for dashboard grid with las 5 orders
50
+ *
51
+ * @return void
52
+ */
53
+ protected function _preparePage()
54
+ {
55
+ $this->getCollection()->setPageSize($this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
56
+ // Remove count of total orders $this->getCollection()->setCurPage($this->getParam($this->getVarNamePage(), $this->_defaultPage));
57
+ }
58
+
59
+ protected function _prepareColumns()
60
+ {
61
+ $this->addColumn('increment_id', array(
62
+ 'header' => $this->__('Number'),
63
+ 'sortable' => false,
64
+ 'index' => 'increment_id',
65
+ 'width' => '40px',
66
+ ));
67
+
68
+ $this->addColumn('customer', array(
69
+ 'header' => $this->__('Customer'),
70
+ 'sortable' => false,
71
+ 'index' => 'customer',
72
+ 'default' => $this->__('Guest'),
73
+ 'width' => '40px',
74
+ ));
75
+
76
+ $this->addColumn('items', array(
77
+ 'header' => $this->__('Items'),
78
+ 'align' => 'right',
79
+ 'type' => 'number',
80
+ 'width' => '40px',
81
+ 'sortable' => false,
82
+ 'index' => 'items_count'
83
+ ));
84
+
85
+ $baseCurrencyCode = Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
86
+
87
+ $this->addColumn('total', array(
88
+ 'header' => $this->__('Grand Total'),
89
+ 'align' => 'right',
90
+ 'sortable' => false,
91
+ 'type' => 'currency',
92
+ 'currency_code' => $baseCurrencyCode,
93
+ 'index' => 'revenue'
94
+ ));
95
+
96
+ $this->addColumn('status', array(
97
+ 'header' => $this->__('Status'),
98
+ 'sortable' => false,
99
+ 'index' => 'status',
100
+ 'type' => 'options',
101
+ 'width' => '70px',
102
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
103
+ ));
104
+
105
+ $this->setFilterVisibility(false);
106
+ $this->setPagerVisibility(false);
107
+
108
+ return parent::_prepareColumns();
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/sales_order/view', array('order_id'=>$row->getId()));
114
+ }
115
+ }
app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Sales.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Belvg_Dashboard_Block_Adminhtml_Dashboard_Sales extends Mage_Adminhtml_Block_Dashboard_Sales
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ if (Mage::getStoreConfig('dashboard/settings/enabled')) {
9
+ $this->setTemplate('adv_dashboard/salebar.phtml');
10
+ } else {
11
+ $this->setTemplate('dashboard/salebar.phtml');
12
+ }
13
+
14
+
15
+
16
+ }
17
+
18
+ protected function _prepareLayout()
19
+ {
20
+ $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
21
+
22
+ $collection = Mage::getResourceModel('reports/order_collection')
23
+ ->calculateSales($isFilter);
24
+
25
+ if ($this->getRequest()->getParam('store')) {
26
+ $collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
27
+ } else if ($this->getRequest()->getParam('website')){
28
+ $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
29
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
30
+ } else if ($this->getRequest()->getParam('group')){
31
+ $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
32
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
33
+ }
34
+
35
+ $collection->load();
36
+ $sales = $collection->getFirstItem();
37
+
38
+ $this->addTotal($this->__('Lifetime Sales'), $sales->getLifetime());
39
+ $this->addTotal($this->__('Average Orders'), $sales->getAverage());
40
+
41
+ if (Mage::getStoreConfig('dashboard/settings/enabled')) {
42
+ $this->addTotal($this->__('Daily Sales'), $sales->getDay());
43
+ }
44
+ }
45
+ }
app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Tab/Amounts.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Belvg_Dashboard_Block_Adminhtml_Dashboard_Tab_Amounts extends Belvg_Dashboard_Block_Adminhtml_Dashboard_Graph
3
+ {
4
+ /**
5
+ * Initialize object
6
+ *
7
+ * @return void
8
+ */
9
+ public function __construct()
10
+ {
11
+ $this->setHtmlId('amounts');
12
+ parent::__construct();
13
+ }
14
+
15
+ /**
16
+ * Prepare chart data
17
+ *
18
+ * @return void
19
+ */
20
+ protected function _prepareData()
21
+ {
22
+ $this->setDataHelperName('adminhtml/dashboard_order');
23
+ $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store'));
24
+ $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website'));
25
+ $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group'));
26
+
27
+ $this->setDataRows('revenue');
28
+ $this->_axisMaps = array(
29
+ 'x' => 'range',
30
+ 'y' => 'revenue'
31
+ );
32
+
33
+ parent::_prepareData();
34
+ }
35
+ }
36
+
app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Tab/Orders.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Belvg_Dashboard_Block_Adminhtml_Dashboard_Tab_Orders extends Belvg_Dashboard_Block_Adminhtml_Dashboard_Graph
3
+ {
4
+ /**
5
+ * Initialize object
6
+ *
7
+ * @return void
8
+ */
9
+ public function __construct()
10
+ {
11
+ $this->setHtmlId('orders');
12
+ parent::__construct();
13
+ }
14
+
15
+ /**
16
+ * Prepare chart data
17
+ *
18
+ * @return void
19
+ */
20
+ protected function _prepareData()
21
+ {
22
+ $this->setDataHelperName('adminhtml/dashboard_order');
23
+ $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store'));
24
+ $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website'));
25
+ $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group'));
26
+
27
+ $this->setDataRows('quantity');
28
+ $this->_axisMaps = array(
29
+ 'x' => 'range',
30
+ 'y' => 'quantity'
31
+ );
32
+
33
+ parent::_prepareData();
34
+ }
35
+ }
app/code/community/Belvg/Dashboard/Block/Adminhtml/Dashboard/Totals.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Belvg_Dashboard_Block_Adminhtml_Dashboard_Totals extends Mage_Adminhtml_Block_Dashboard_Totals
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+
9
+ $this->setTemplate('dashboard/totalbar.phtml');
10
+ }
11
+
12
+ protected function _prepareLayout()
13
+ {
14
+ $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
15
+ $period = $this->getRequest()->getParam('period', '24h');
16
+
17
+ /* @var $collection Mage_Reports_Model_Mysql4_Order_Collection */
18
+ $collection = Mage::getResourceModel('reports/order_collection')
19
+ ->addCreateAtPeriodFilter($period)
20
+ ->calculateTotals($isFilter);
21
+
22
+ if ($this->getRequest()->getParam('store')) {
23
+ $collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
24
+ } else if ($this->getRequest()->getParam('website')){
25
+ $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
26
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
27
+ } else if ($this->getRequest()->getParam('group')){
28
+ $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
29
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
30
+ } elseif (!$collection->isLive()) {
31
+ $collection->addFieldToFilter('store_id',
32
+ array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
33
+ );
34
+ }
35
+
36
+ $collection->load();
37
+
38
+ $totals = $collection->getFirstItem();
39
+
40
+ $this->addTotal($this->__('Revenue'), $totals->getRevenue());
41
+ $this->addTotal($this->__('Tax'), $totals->getTax());
42
+ $this->addTotal($this->__('Shipping'), $totals->getShipping());
43
+ $this->addTotal($this->__('Quantity'), $totals->getQuantity()*1, true);
44
+ }
45
+ }
app/code/community/Belvg/Dashboard/Helper/Dashboard/Order.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard helper for orders
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Belvg_Dashboard_Helper_Dashboard_Order extends Mage_Adminhtml_Helper_Dashboard_Order
35
+ {
36
+
37
+ protected function _initCollection()
38
+ {
39
+ $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
40
+
41
+ $from = Mage::app()->getRequest()->getParam('from', 0);
42
+ $to = Mage::app()->getRequest()->getParam('to', 0);
43
+ $this->_collection = Mage::getResourceSingleton('reports/order_collection')
44
+ ->prepareSummary($this->getParam('period'), $from, $to, $isFilter);
45
+
46
+ if ($this->getParam('store')) {
47
+ $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
48
+ } else if ($this->getParam('website')){
49
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
50
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
51
+ } else if ($this->getParam('group')){
52
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
53
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
54
+ } elseif (!$this->_collection->isLive()) {
55
+ $this->_collection->addFieldToFilter('store_id',
56
+ array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
57
+ );
58
+ }
59
+
60
+ $this->_collection->load();
61
+ }
62
+
63
+ }
app/code/community/Belvg/Dashboard/Helper/Data.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ * *************************************** */
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ * *************************************** */
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ * ****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_Dashboard
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+
33
+ class Belvg_Dashboard_Helper_Data extends Mage_Core_Helper_Abstract {
34
+ }
app/code/community/Belvg/Dashboard/Model/Mysql4/Order/Collection.php ADDED
@@ -0,0 +1,643 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Reports
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Reports orders collection
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Reports
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Belvg_Dashboard_Model_Mysql4_Order_Collection extends Mage_Reports_Model_Mysql4_Order_Collection
36
+ {
37
+ protected $_isLive = false;
38
+
39
+ /**
40
+ * Check range for live mode
41
+ *
42
+ * @param $range
43
+ * @return boolean
44
+ */
45
+ public function checkIsLive($range)
46
+ {
47
+ $this->_isLive = !Mage::getStoreConfig('sales/dashboard/use_aggregated_data');
48
+ return $this;
49
+ }
50
+
51
+ /**
52
+ * Retrieve is live flag for rep
53
+ *
54
+ * @return boolean
55
+ */
56
+ public function isLive()
57
+ {
58
+ return $this->_isLive;
59
+ }
60
+
61
+ /**
62
+ * Prepare report summary
63
+ *
64
+ * @param string $range
65
+ * @param mixed $customStart
66
+ * @param mixed $customEnd
67
+ * @param int $isFilter
68
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
69
+ */
70
+ public function prepareSummary($range, $customStart, $customEnd, $isFilter=0)
71
+ {
72
+ $this->checkIsLive($range);
73
+ if ($this->_isLive) {
74
+ $this->_prepareSummaryLive($range, $customStart, $customEnd, $isFilter);
75
+ } else {
76
+ $this->_prepareSummaryAggregated($range, $customStart, $customEnd, $isFilter);
77
+ }
78
+
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Prepare report summary from live data
84
+ *
85
+ * @param string $range
86
+ * @param mixed $customStart
87
+ * @param mixed $customEnd
88
+ * @param int $isFilter
89
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
90
+ */
91
+ protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilter=0)
92
+ {
93
+ $this->setMainTable('sales/order');
94
+ if ($isFilter==0) {
95
+ $this->getSelect()->columns(array(
96
+ 'revenue' => 'SUM(main_table.base_grand_total*main_table.base_to_global_rate)'
97
+ ));
98
+ } else{
99
+ $this->getSelect()->columns(array(
100
+ 'revenue' => 'SUM(main_table.base_grand_total)'
101
+ ));
102
+ }
103
+
104
+ $this->getSelect()->columns(array(
105
+ 'quantity' => 'COUNT(main_table.entity_id)',
106
+ 'range' => $this->_getRangeExpressionForAttribute($range, 'created_at'),
107
+ ))->order('range', 'asc')
108
+ ->group('range');
109
+
110
+ $this->addFieldToFilter('created_at', $this->getDateRange($range, $customStart, $customEnd))
111
+ ->addFieldToFilter('state', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED));
112
+ return $this;
113
+ }
114
+
115
+ /**
116
+ * Prepare report summary from aggregated data
117
+ *
118
+ * @param string $range
119
+ * @param mixed $customStart
120
+ * @param mixed $customEnd
121
+ * @param int $isFilter
122
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
123
+ */
124
+ protected function _prepareSummaryAggregated($range, $customStart, $customEnd)
125
+ {
126
+ $this->setMainTable('sales/order_aggregated_created');
127
+ $this->getSelect()->columns(array(
128
+ 'revenue' => 'SUM(main_table.total_revenue_amount)',
129
+ 'quantity' => 'SUM(main_table.orders_count)',
130
+ 'range' => $this->_getRangeExpressionForAttribute($range, 'main_table.period'),
131
+ ))->order('range', 'asc')
132
+ ->group('range');
133
+
134
+ $this->getSelect()->where(
135
+ $this->_getConditionSql('main_table.period', $this->getDateRange($range, $customStart, $customEnd))
136
+ );
137
+
138
+ $statuses = Mage::getSingleton('sales/config')
139
+ ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
140
+
141
+ if (empty($statuses)) {
142
+ $statuses = array(0);
143
+ }
144
+
145
+ $this->getSelect()->where('main_table.order_status NOT IN(?)', $statuses);
146
+ return $this;
147
+ }
148
+
149
+ protected function _getRangeExpression($range)
150
+ {
151
+ // dont need of this offset bc we are format date in block
152
+ //$timeZoneOffset = Mage::getModel('core/date')->getGmtOffset();
153
+
154
+ switch ($range)
155
+ {
156
+ case '24h':
157
+ $expression = 'DATE_FORMAT({{attribute}}, \'%Y-%m-%d %H:00\')';
158
+
159
+ break;
160
+ case '7d':
161
+ case '1m':
162
+ $expression = 'DATE_FORMAT({{attribute}}, \'%Y-%m-%d\')';
163
+ break;
164
+ case 'custom':
165
+ $expression = 'DATE_FORMAT({{attribute}}, \'%Y-%m-%d\')';
166
+ break;
167
+ case '1y':
168
+ case '2y':
169
+ default:
170
+ $expression = 'DATE_FORMAT({{attribute}}, \'%Y-%m\')';
171
+ break;
172
+ }
173
+
174
+ return $expression;
175
+ }
176
+
177
+ /**
178
+ * Retriev range exression adapteted for attribute
179
+ *
180
+ * @param string $range
181
+ * @param unknown_type $attribute
182
+ */
183
+ protected function _getRangeExpressionForAttribute($range, $attribute)
184
+ {
185
+ $expression = $this->_getRangeExpression($range);
186
+ return str_replace('{{attribute}}', $this->getConnection()->quoteIdentifier($attribute), $expression);
187
+ }
188
+
189
+ public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
190
+ {
191
+ $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
192
+ $dateStart = clone $dateEnd;
193
+
194
+ // go to the end of a day
195
+ $dateEnd->setHour(23);
196
+ $dateEnd->setMinute(59);
197
+ $dateEnd->setSecond(59);
198
+
199
+ $dateStart->setHour(0);
200
+ $dateStart->setMinute(0);
201
+ $dateStart->setSecond(0);
202
+
203
+ switch ($range)
204
+ {
205
+ case '24h':
206
+ $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
207
+ $dateEnd->addHour(1);
208
+ $dateStart = clone $dateEnd;
209
+ $dateStart->subDay(1);
210
+ break;
211
+
212
+ case '7d':
213
+ // substract 6 days we need to include
214
+ // only today and not hte last one from range
215
+ $dateStart->subDay(6);
216
+ break;
217
+
218
+ case '1m':
219
+ $dateStart->setDay(Mage::getStoreConfig('reports/dashboard/mtd_start'));
220
+ break;
221
+
222
+ case 'custom':
223
+ $dateStart = $customStart ? (new Zend_Date(strtotime($customStart))) : $dateEnd;
224
+ $dateEnd = $customEnd ? (new Zend_Date(strtotime($customEnd))) : $dateEnd;
225
+ break;
226
+
227
+ case '1y':
228
+ case '2y':
229
+ $startMonthDay = explode(',', Mage::getStoreConfig('reports/dashboard/ytd_start'));
230
+ $startMonth = isset($startMonthDay[0]) ? (int)$startMonthDay[0] : 1;
231
+ $startDay = isset($startMonthDay[1]) ? (int)$startMonthDay[1] : 1;
232
+ $dateStart->setMonth($startMonth);
233
+ $dateStart->setDay($startDay);
234
+ if ($range == '2y') {
235
+ $dateStart->subYear(1);
236
+ }
237
+ break;
238
+ }
239
+
240
+ if ($returnObjects) {
241
+ return array($dateStart, $dateEnd);
242
+ } else {
243
+ return array('from'=>$dateStart, 'to'=>$dateEnd, 'datetime'=>true);
244
+ }
245
+ }
246
+
247
+ public function addItemCountExpr()
248
+ {
249
+ // $orderItemEntityTypeId = Mage::getResourceSingleton('sales/order_item')->getTypeId();
250
+ // $this->getSelect()->join(
251
+ // array('items'=>Mage::getResourceSingleton('sales/order_item')->getEntityTable()),
252
+ // 'items.parent_id=e.entity_id and items.entity_type_id='.$orderItemEntityTypeId,
253
+ // array('items_count'=>new Zend_Db_Expr('COUNT(items.entity_id)'))
254
+ // )
255
+ // ->group('e.entity_id');
256
+ $this->getSelect()->columns(array('items_count'=>'total_item_count'), 'main_table');
257
+ return $this;
258
+ }
259
+
260
+ /**
261
+ * Calculate totals report
262
+ *
263
+ * @param int $isFilter
264
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
265
+ */
266
+ public function calculateTotals($isFilter = 0)
267
+ {
268
+ if ($this->isLive()) {
269
+ $this->_calculateTotalsLive($isFilter);
270
+ } else {
271
+ $this->_calculateTotalsAggregated($isFilter);
272
+ }
273
+
274
+ return $this;
275
+ }
276
+
277
+ /**
278
+ * Calculate totals live report
279
+ *
280
+ * @param int $isFilter
281
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
282
+ */
283
+ protected function _calculateTotalsLive($isFilter = 0)
284
+ {
285
+ $this->setMainTable('sales/order');
286
+ $this->removeAllFieldsFromSelect();
287
+
288
+ if ($isFilter == 0) {
289
+ $this->getSelect()->columns(array(
290
+ 'revenue' => 'SUM((main_table.base_subtotal-IFNULL(main_table.base_subtotal_refunded,0)-IFNULL(main_table.base_subtotal_canceled,0)-ABS(IFNULL(main_table.base_discount_amount,0))+IFNULL(main_table.base_discount_refunded,0))*main_table.base_to_global_rate)',
291
+ 'tax' => 'SUM((main_table.base_tax_amount-IFNULL(main_table.base_tax_refunded,0)-IFNULL(main_table.base_tax_canceled,0))*main_table.base_to_global_rate)',
292
+ 'shipping' => 'SUM((main_table.base_shipping_amount-IFNULL(main_table.base_shipping_refunded,0)-IFNULL(main_table.base_shipping_canceled,0))*main_table.base_to_global_rate)',
293
+ ));
294
+ } else {
295
+ $this->getSelect()->columns(array(
296
+ 'revenue' => 'SUM((main_table.base_subtotal-IFNULL(main_table.base_subtotal_refunded,0)-IFNULL(main_table.base_subtotal_canceled,0)-ABS(IFNULL(main_table.base_discount_amount,0))+IFNULL(main_table.base_discount_refunded,0)))',
297
+ 'tax' => 'SUM((main_table.base_tax_amount-IFNULL(main_table.base_tax_refunded,0)-IFNULL(main_table.base_tax_canceled,0)))',
298
+ 'shipping' => 'SUM((main_table.base_shipping_amount-IFNULL(main_table.base_shipping_refunded,0)-IFNULL(main_table.base_shipping_canceled,0)))',
299
+ ));
300
+ }
301
+
302
+ $this->getSelect()->columns(array(
303
+ 'quantity' => 'COUNT(main_table.entity_id)',
304
+ ));
305
+
306
+ $this->addFieldToFilter('state', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED));
307
+
308
+ return $this;
309
+ }
310
+
311
+ /**
312
+ * Calculate totals agregated report
313
+ *
314
+ * @param int $isFilter
315
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
316
+ */
317
+ protected function _calculateTotalsAggregated($isFilter = 0)
318
+ {
319
+ $this->setMainTable('sales/order_aggregated_created');
320
+ $this->removeAllFieldsFromSelect();
321
+
322
+ $this->getSelect()->columns(array(
323
+ 'revenue' => 'SUM(main_table.total_revenue_amount)',
324
+ 'tax' => 'SUM(main_table.total_tax_amount_actual)',
325
+ 'shipping' => 'SUM(main_table.total_shipping_amount_actual)',
326
+ 'quantity' => 'SUM(orders_count)',
327
+ ));
328
+
329
+ $statuses = Mage::getSingleton('sales/config')
330
+ ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
331
+
332
+ if (empty($statuses)) {
333
+ $statuses = array(0);
334
+ }
335
+
336
+ $this->getSelect()->where('main_table.order_status NOT IN(?)', $statuses);
337
+
338
+ return $this;
339
+ }
340
+
341
+ /**
342
+ * Calculate lifitime sales
343
+ *
344
+ * @param int $isFilter
345
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
346
+ */
347
+ public function calculateSales($isFilter = 0)
348
+ {
349
+ $statuses = Mage::getSingleton('sales/config')
350
+ ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
351
+
352
+ if (empty($statuses)) {
353
+ $statuses = array(0);
354
+ }
355
+
356
+ if (Mage::getStoreConfig('sales/dashboard/use_aggregated_data')) {
357
+ $this->setMainTable('sales/order_aggregated_created');
358
+ $this->removeAllFieldsFromSelect();
359
+
360
+ $this->getSelect()->columns(array(
361
+ 'lifetime' => 'SUM(main_table.total_revenue_amount)',
362
+ 'average' => "IF(SUM(main_table.orders_count) > 0, SUM(main_table.total_revenue_amount)/SUM(main_table.orders_count), 0)",
363
+ 'day' => "(SELECT SUM(grand_total) FROM {$this->getMainTable()} WHERE DATE(created_at) = DATE(NOW()) AND status NOT IN ('".implode('\',\'', $statuses)."'))"
364
+ ));
365
+
366
+ if (!$isFilter) {
367
+ $this->addFieldToFilter('store_id',
368
+ array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
369
+ );
370
+ }
371
+ $this->getSelect()->where('main_table.order_status NOT IN(?)', $statuses);
372
+ } else {
373
+ $this->setMainTable('sales/order');
374
+ $this->removeAllFieldsFromSelect();
375
+ $expr = 'IFNULL(main_table.base_subtotal, 0) - IFNULL(main_table.base_subtotal_refunded, 0)'
376
+ . ' - IFNULL(main_table.base_subtotal_canceled, 0) - ABS(IFNULL(main_table.base_discount_amount, 0))'
377
+ . ' + IFNULL(main_table.base_discount_refunded, 0)';
378
+
379
+ $this->getSelect()->columns(array(
380
+ 'lifetime' => "SUM({$expr})",
381
+ 'average' => "AVG({$expr})",
382
+ 'day' => "(SELECT SUM(grand_total) FROM {$this->getMainTable()} WHERE DATE(created_at) = DATE(NOW()) AND status NOT IN ('".implode('\',\'', $statuses)."'))"
383
+ ));
384
+ $this->getSelect()->where('main_table.status NOT IN(?)', $statuses)
385
+ ->where('main_table.state NOT IN(?)', array(Mage_Sales_Model_Order::STATE_NEW, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT));
386
+ }
387
+ return $this;
388
+ }
389
+
390
+ public function setDateRange($from, $to)
391
+ {
392
+ $this->_reset()
393
+ ->addFieldToFilter('created_at', array('from' => $from, 'to' => $to))
394
+ ->addFieldToFilter('state', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED))
395
+ ->getSelect()
396
+ ->columns(array('orders'=>'COUNT(DISTINCT(main_table.entity_id))'))
397
+ ->group('("*")');
398
+
399
+ /**
400
+ * getting qty count for each order
401
+ */
402
+
403
+ // $orderItem = Mage::getResourceSingleton('sales/order_item');
404
+ // /* @var $orderItem Mage_Sales_Model_Entity_Quote */
405
+ // $attr = $orderItem->getAttribute('parent_id');
406
+ // /* @var $attr Mage_Eav_Model_Entity_Attribute_Abstract */
407
+ // $attrId = $attr->getAttributeId();
408
+ // $tableName = $attr->getBackend()->getTable();
409
+ //
410
+ // $this->getSelect()
411
+ // ->joinLeft(array("order_items" => $tableName),
412
+ // "order_items.parent_id = e.entity_id and order_items.entity_type_id=".$orderItem->getTypeId(), array());
413
+ //
414
+ // $attr = $orderItem->getAttribute('qty_ordered');
415
+ // /* @var $attr Mage_Eav_Model_Entity_Attribute_Abstract */
416
+ // $attrId = $attr->getAttributeId();
417
+ // $tableName = $attr->getBackend()->getTable();
418
+ // $fieldName = $attr->getBackend()->isStatic() ? 'qty_ordered' : 'value';
419
+ //
420
+ // $this->getSelect()
421
+ // ->joinLeft(array("order_items2" => $tableName),
422
+ // "order_items2.entity_id = `order_items`.entity_id and order_items2.attribute_id = {$attrId}", array())
423
+ // ->columns(array("items" => "sum(order_items2.{$fieldName})"));
424
+
425
+ $this->getSelect()->columns(array("items" => 'SUM(' . $this->getConnection()->quoteIdentifier('main_table.total_qty_ordered') . ')'));
426
+
427
+ return $this;
428
+ }
429
+
430
+ /**
431
+ * Set store filter collection
432
+ * @param array $storeIds
433
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
434
+ */
435
+ public function setStoreIds($storeIds)
436
+ {
437
+ if ($storeIds) {
438
+ $this->getSelect()->columns(array(
439
+ 'subtotal' => 'SUM(main_table.base_subtotal)',
440
+ 'tax' => 'SUM(main_table.base_tax_amount)',
441
+ 'shipping' => 'SUM(main_table.base_shipping_amount)',
442
+ 'discount' => 'SUM(main_table.base_discount_amount)',
443
+ 'total' => 'SUM(main_table.base_grand_total)',
444
+ 'invoiced' => 'SUM(main_table.base_total_paid)',
445
+ 'refunded' => 'SUM(main_table.base_total_refunded)',
446
+ 'profit' => 'SUM(IFNULL(main_table.base_subtotal_invoiced, 0)) + SUM(IFNULL(main_table.base_discount_refunded, 0)) - SUM(IFNULL(main_table.base_subtotal_refunded, 0)) - SUM(IFNULL(main_table.base_discount_invoiced, 0)) - SUM(IFNULL(main_table.base_total_invoiced_cost, 0))',
447
+ ));
448
+ } else {
449
+ $this->getSelect()->columns(array(
450
+ 'subtotal' => 'SUM(main_table.base_subtotal * main_table.base_to_global_rate)',
451
+ 'tax' => 'SUM(main_table.base_tax_amount * main_table.base_to_global_rate)',
452
+ 'shipping' => 'SUM(main_table.base_shipping_amount * main_table.base_to_global_rate)',
453
+ 'discount' => 'SUM(main_table.base_discount_amount * main_table.base_to_global_rate)',
454
+ 'total' => 'SUM(main_table.base_grand_total * main_table.base_to_global_rate)',
455
+ 'invoiced' => 'SUM(main_table.base_total_paid * main_table.base_to_global_rate)',
456
+ 'refunded' => 'SUM(main_table.base_total_refunded * main_table.base_to_global_rate)',
457
+ 'profit' => 'SUM(IFNULL(main_table.base_subtotal_invoiced, 0)* main_table.base_to_global_rate) + SUM(IFNULL(main_table.base_discount_refunded, 0)* main_table.base_to_global_rate) - SUM(IFNULL(main_table.base_subtotal_refunded, 0)* main_table.base_to_global_rate) - SUM(IFNULL(main_table.base_discount_invoiced, 0)* main_table.base_to_global_rate) - SUM(IFNULL(main_table.base_total_invoiced_cost, 0)* main_table.base_to_global_rate)',
458
+ ));
459
+ }
460
+
461
+ return $this;
462
+ }
463
+
464
+ /**
465
+ * Add group By customer attribute
466
+ *
467
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
468
+ */
469
+ public function groupByCustomer()
470
+ {
471
+ $this->getSelect()->group('main_table.customer_id');
472
+
473
+ return $this;
474
+ }
475
+
476
+ /**
477
+ * Join Customer Name (concat)
478
+ *
479
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
480
+ */
481
+ public function joinCustomerName($alias = 'name')
482
+ {
483
+ $this->getSelect()->columns(array($alias => 'CONCAT(main_table.customer_firstname," ", main_table.customer_lastname)'));
484
+ return $this;
485
+ }
486
+
487
+ /**
488
+ * Add Order count field to select
489
+ *
490
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
491
+ */
492
+ public function addOrdersCount()
493
+ {
494
+ $this->addFieldToFilter('state', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED));
495
+ $this->getSelect()
496
+ ->columns(array("orders_count" => "COUNT(main_table.entity_id)"));
497
+
498
+ return $this;
499
+ }
500
+
501
+ /**
502
+ * Add revenue
503
+ *
504
+ * @param boolean $convertCurrency
505
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
506
+ */
507
+ public function addRevenueToSelect($convertCurrency = false)
508
+ {
509
+ if ($convertCurrency) {
510
+ $this->getSelect()->columns(array(
511
+ 'revenue' => '(main_table.base_grand_total * main_table.base_to_global_rate)'
512
+ ));
513
+ } else {
514
+ $this->getSelect()->columns(array(
515
+ 'revenue' => 'base_grand_total'
516
+ ));
517
+ }
518
+
519
+ return $this;
520
+ }
521
+
522
+ /**
523
+ * Add summary average totals
524
+ *
525
+ * @param int $storeId
526
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
527
+ */
528
+ public function addSumAvgTotals($storeId = 0)
529
+ {
530
+ /**
531
+ * calculate average and total amount
532
+ */
533
+ $expr = ($storeId == 0)
534
+ ? '(main_table.base_subtotal
535
+ - IFNULL(main_table.base_subtotal_refunded, 0)
536
+ - IFNULL(main_table.base_subtotal_canceled, 0)
537
+ - ABS(main_table.base_discount_amount)
538
+ - IFNULL(main_table.base_discount_canceled, 0)
539
+ ) * main_table.base_to_global_rate'
540
+ : 'main_table.base_subtotal
541
+ - IFNULL(main_table.base_subtotal_canceled, 0)
542
+ - IFNULL(main_table.base_subtotal_refunded, 0)
543
+ - ABS(main_table.base_discount_amount)
544
+ - IFNULL(main_table.base_discount_canceled, 0)';
545
+
546
+ $this->getSelect()
547
+ ->columns(array("orders_avg_amount" => "AVG({$expr})"))
548
+ ->columns(array("orders_sum_amount" => "SUM({$expr})"));
549
+
550
+ return $this;
551
+ }
552
+
553
+ /**
554
+ * Sort order by total amount
555
+ *
556
+ * @param string $dir
557
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
558
+ */
559
+ public function orderByTotalAmount($dir = 'desc')
560
+ {
561
+ $this->getSelect()
562
+ ->order("orders_sum_amount {$dir}");
563
+ return $this;
564
+ }
565
+
566
+ public function orderByOrdersCount($dir = 'desc')
567
+ {
568
+ $this->getSelect()
569
+ ->order("orders_count {$dir}");
570
+ return $this;
571
+ }
572
+
573
+ public function orderByCustomerRegistration($dir = 'desc')
574
+ {
575
+ $this->setOrder('customer_id', $dir);
576
+ return $this;
577
+ }
578
+
579
+ /**
580
+ * Sort order by order created_at date
581
+ * @param string $dir
582
+ */
583
+ public function orderByCreatedAt($dir = 'desc')
584
+ {
585
+ $this->setOrder('created_at', $dir);
586
+ return $this;
587
+ }
588
+
589
+ public function getSelectCountSql()
590
+ {
591
+ $countSelect = clone $this->getSelect();
592
+ $countSelect->reset(Zend_Db_Select::ORDER);
593
+ $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
594
+ $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
595
+ $countSelect->reset(Zend_Db_Select::COLUMNS);
596
+ $countSelect->reset(Zend_Db_Select::GROUP);
597
+ $countSelect->reset(Zend_Db_Select::HAVING);
598
+ $countSelect->columns("count(DISTINCT main_table.entity_id)");
599
+
600
+ $sql = $countSelect->__toString();
601
+
602
+ return $sql;
603
+ }
604
+
605
+ /**
606
+ * Initialize initial fields to select
607
+ *
608
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
609
+ */
610
+ protected function _initInitialFieldsToSelect()
611
+ {
612
+ // No fields should be initialized
613
+ return $this;
614
+ }
615
+
616
+ /**
617
+ * Add period filter by created_at attribute
618
+ *
619
+ * @param string $period
620
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
621
+ */
622
+ public function addCreateAtPeriodFilter($period)
623
+ {
624
+ $_from = Mage::app()->getRequest()->getParam('from', 0);
625
+ $_to = Mage::app()->getRequest()->getParam('to', 0);
626
+ list($from, $to) = $this->getDateRange($period, $_from, $_to, true);
627
+
628
+ $this->checkIsLive($period);
629
+
630
+ if ($this->isLive()) {
631
+ $fieldToFilter = 'created_at';
632
+ } else {
633
+ $fieldToFilter = 'period';
634
+ }
635
+
636
+ $this->addFieldToFilter($fieldToFilter, array(
637
+ 'from' => $from->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
638
+ 'to' => $to->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
639
+ ));
640
+
641
+ return $this;
642
+ }
643
+ }
app/code/community/Belvg/Dashboard/controllers/DashboardController.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Belvg_Dashboard_DashboardController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->_title($this->__('Dashboard'));
8
+
9
+ $this->loadLayout();
10
+ $this->_setActiveMenu('dashboard');
11
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Dashboard'), Mage::helper('adminhtml')->__('Dashboard'));
12
+ $this->renderLayout();
13
+ }
14
+
15
+ public function productsViewedAction()
16
+ {
17
+ $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/dashboard_tab_products_viewed')->toHtml());
18
+ }
19
+
20
+ public function customersNewestAction()
21
+ {
22
+ $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/dashboard_tab_customers_newest')->toHtml());
23
+ }
24
+
25
+ public function customersMostAction()
26
+ {
27
+ $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/dashboard_tab_customers_most')->toHtml());
28
+ }
29
+
30
+ public function ajaxBlockAction()
31
+ {
32
+ $output = '';
33
+ $blockTab = $this->getRequest()->getParam('block');
34
+ if (in_array($blockTab, array('tab_orders', 'tab_amounts', 'totals'))) {
35
+ $output = $this->getLayout()->createBlock('adminhtml/dashboard_' . $blockTab)->toHtml();
36
+ }
37
+ $this->getResponse()->setBody($output);
38
+ return;
39
+ }
40
+
41
+ public function tunnelAction()
42
+ {
43
+ $httpClient = new Varien_Http_Client();
44
+ $gaData = $this->getRequest()->getParam('ga');
45
+ $gaHash = $this->getRequest()->getParam('h');
46
+ if ($gaData && $gaHash) {
47
+ $newHash = Mage::helper('adminhtml/dashboard_data')->getChartDataHash($gaData);
48
+ if ($newHash == $gaHash) {
49
+ if ($params = unserialize(base64_decode(urldecode($gaData)))) {
50
+ $response = $httpClient->setUri(Mage_Adminhtml_Block_Dashboard_Graph::API_URL)
51
+ ->setParameterGet($params)
52
+ ->setConfig(array('timeout' => 5))
53
+ ->request('GET');
54
+
55
+ $headers = $response->getHeaders();
56
+
57
+ $this->getResponse()
58
+ ->setHeader('Content-type', $headers['Content-type'])
59
+ ->setBody($response->getBody());
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ protected function _isAllowed()
66
+ {
67
+ return Mage::getSingleton('admin/session')->isAllowed('dashboard');
68
+ }
69
+ }
app/code/community/Belvg/Dashboard/etc/adminhtml.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_Dashboard
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <acl>
35
+ <resources>
36
+ <all>
37
+ <title>Allow Everything</title>
38
+ </all>
39
+ <admin>
40
+ <children>
41
+ <system>
42
+ <children>
43
+ <config>
44
+ <children>
45
+ <dashboard translate="title">
46
+ <title>Advanced Dashboard</title>
47
+ </dashboard>
48
+ </children>
49
+ </config>
50
+ </children>
51
+ </system>
52
+ </children>
53
+ </admin>
54
+ </resources>
55
+ </acl>
56
+ <layout>
57
+ <updates>
58
+ <dashboard>
59
+ <file>adv_dashboard.xml</file>
60
+ </dashboard>
61
+ </updates>
62
+ </layout>
63
+ </config>
app/code/community/Belvg/Dashboard/etc/config.xml ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_Dashboard
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <modules>
35
+ <Belvg_Dashboard>
36
+ <version>1.0.1</version>
37
+ </Belvg_Dashboard>
38
+ </modules>
39
+ <global>
40
+ <helpers>
41
+ <dashboard>
42
+ <class>Belvg_Dashboard_Helper</class>
43
+ </dashboard>
44
+ <adminhtml>
45
+ <rewrite>
46
+ <dashboard_order>Belvg_Dashboard_Helper_Dashboard_Order</dashboard_order>
47
+ </rewrite>
48
+ </adminhtml>
49
+ </helpers>
50
+ <blocks>
51
+ <adminhtml>
52
+ <rewrite>
53
+ <dashboard>Belvg_Dashboard_Block_Adminhtml_Dashboard</dashboard>
54
+ <dashboard_orders_grid>Belvg_Dashboard_Block_Adminhtml_Dashboard_Orders_Grid</dashboard_orders_grid>
55
+ <dashboard_graph>Belvg_Dashboard_Block_Adminhtml_Dashboard_Graph</dashboard_graph>
56
+ <dashboard_totals>Belvg_Dashboard_Block_Adminhtml_Dashboard_Totals</dashboard_totals>
57
+ <dashboard_diagrams>Belvg_Dashboard_Block_Adminhtml_Dashboard_Diagrams</dashboard_diagrams>
58
+ <dashboard_sales>Belvg_Dashboard_Block_Adminhtml_Dashboard_Sales</dashboard_sales>
59
+ <dashboard_tab_orders>Belvg_Dashboard_Block_Adminhtml_Dashboard_Tab_Orders</dashboard_tab_orders>
60
+ <dashboard_tab_amounts>Belvg_Dashboard_Block_Adminhtml_Dashboard_Tab_Amounts</dashboard_tab_amounts>
61
+ </rewrite>
62
+ </adminhtml>
63
+ </blocks>
64
+ <models>
65
+ <reports_mysql4>
66
+ <rewrite>
67
+ <order_collection>Belvg_Dashboard_Model_Mysql4_Order_Collection</order_collection>
68
+ </rewrite>
69
+ </reports_mysql4>
70
+ </models>
71
+ </global>
72
+ <default>
73
+ <dashboard>
74
+ <settings>
75
+ <enabled>0</enabled>
76
+ <orders><![CDATA[1,5,10,15,20]]></orders>
77
+ </settings>
78
+ </dashboard>
79
+ </default>
80
+ </config>
81
+
app/code/community/Belvg/Dashboard/etc/system.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_Dashboard
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <sections>
35
+ <dashboard translate="label">
36
+ <label>Advanced Dashboard</label>
37
+ <tab>belvg</tab>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>1000</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <groups>
44
+ <settings translate="label">
45
+ <label>Settings</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>100</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <comment>
52
+ <![CDATA[
53
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
54
+ This module was developed by <a href="http://www.belvg.com" target="_blank">www.BelVG.com</a>.
55
+ For docs & examples refer to the BelVG <a href="http://www.belvg.com" target="_blank">web site</a>.
56
+ <br/>We have the largest selections of <a href="http://store.belvg.com/extensions.html" target="_blank">extensions</a> and <a href="http://store.belvg.com/themes.html" target="_blank">themes</a> on Magento.
57
+ </div>
58
+ ]]>
59
+ </comment>
60
+ <fields>
61
+ <enabled translate="label comment">
62
+ <label>Enabled</label>
63
+ <!-- <comment><![CDATA[]]></comment> -->
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
66
+ <sort_order>10</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
+ </enabled>
71
+ <orders translate="label comment">
72
+ <label>Orders on Dashboard Grid</label>
73
+ <comment><![CDATA[Comma-separated.]]></comment>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>11</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </orders>
80
+ </fields>
81
+ </settings>
82
+ </groups>
83
+ </dashboard>
84
+ </sections>
85
+ </config>
app/code/community/Belvg/FacebookAll/Block/Active.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Block_Active extends Mage_Core_Block_Template {
33
+
34
+ public function getAppId()
35
+ {
36
+ return Mage::getStoreConfig('facebookall/settings/appid');
37
+ }
38
+
39
+ public function getSecretKey()
40
+ {
41
+ return Mage::getStoreConfig('facebookall/settings/secret');
42
+ }
43
+
44
+ public function isActiveLike()
45
+ {
46
+ return Mage::getStoreConfig('facebookall/like/enabled');
47
+ }
48
+
49
+ public function isFacesLikeActive()
50
+ {
51
+ return Mage::getStoreConfig('facebookall/like/faces')?'true':'false';
52
+ }
53
+
54
+ public function getLikeWidth()
55
+ {
56
+ return Mage::getStoreConfig('facebookall/like/width');
57
+ }
58
+
59
+ public function getLikeColor()
60
+ {
61
+ return Mage::getStoreConfig('facebookall/like/color');
62
+ }
63
+
64
+ public function getLikeLayout()
65
+ {
66
+ return Mage::getStoreConfig('facebookall/like/layout');
67
+ }
68
+
69
+ public function checkFbUser()
70
+ {
71
+ $user_id = Mage::getSingleton('customer/session')->getCustomer()->getId();
72
+ $uid = 0;
73
+ $db_read = Mage::getSingleton('core/resource')->getConnection('facebookall_read');
74
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
75
+ $sql = 'SELECT `fb_id`
76
+ FROM `'.$tablePrefix.'belvg_facebook_customer`
77
+ WHERE `customer_id` = '.$user_id.'
78
+ LIMIT 1';
79
+ $data = $db_read->fetchRow($sql);
80
+ if (count($data)) {
81
+ $uid = $data['fb_id'];
82
+ }
83
+ return $uid;
84
+ }
85
+ }
app/code/community/Belvg/FacebookAll/Block/Links.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Block_Links extends Mage_Core_Block_Template
33
+ {
34
+
35
+ public function addFbLink() {
36
+ if ($parentBlock = $this->getParentBlock()) {
37
+ $count = $this->helper('checkout/cart')->getSummaryCount();
38
+
39
+ if ($count == 1) {
40
+ $text = $this->__('My Cart (%s item)', $count);
41
+ } elseif ($count > 0) {
42
+ $text = $this->__('My Cart (%s items)', $count);
43
+ } else {
44
+ $text = $this->__('My Cart');
45
+ }
46
+
47
+ //$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 90, null, 'class="top-link-cart"');
48
+ }
49
+ return $this;
50
+ }
51
+
52
+ }
app/code/community/Belvg/FacebookAll/Helper/Active.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Helper_Active extends Mage_Core_Helper_Abstract
33
+ {
34
+ public function getAppId()
35
+ {
36
+ return Mage::getStoreConfig('facebookall/settings/appid');
37
+ }
38
+
39
+ public function getSecretKey()
40
+ {
41
+ return Mage::getStoreConfig('facebookall/settings/secret');
42
+ }
43
+
44
+ public function isActiveLike()
45
+ {
46
+ return Mage::getStoreConfig('facebookall/like/enabled');
47
+ }
48
+
49
+ public function isActiveComments()
50
+ {
51
+ return Mage::getStoreConfig('facebookall/comments/enabled');
52
+ }
53
+
54
+ public function isActiveActivity()
55
+ {
56
+ return Mage::getStoreConfig('facebookall/activity/enabled');
57
+ }
58
+
59
+ public function getActivityWidth()
60
+ {
61
+ return Mage::getStoreConfig('facebookall/activity/width');
62
+ }
63
+
64
+ public function getActivityHeight()
65
+ {
66
+ return Mage::getStoreConfig('facebookall/activity/height');
67
+ }
68
+
69
+ public function getActivityHeader()
70
+ {
71
+ return Mage::getStoreConfig('facebookall/activity/header')?'true':'false';
72
+ }
73
+
74
+ public function getActivityColor()
75
+ {
76
+ return Mage::getStoreConfig('facebookall/activity/color');
77
+ }
78
+
79
+ public function getActivityFont()
80
+ {
81
+ return Mage::getStoreConfig('facebookall/activity/font');
82
+ }
83
+
84
+ public function getActivityRecommendations()
85
+ {
86
+ return Mage::getStoreConfig('facebookall/activity/recommendations')?'true':'false';
87
+ }
88
+
89
+ public function getActivityMaxage()
90
+ {
91
+ return Mage::getStoreConfig('facebookall/activity/maxage');
92
+ }
93
+
94
+ public function isFacesLikeActive()
95
+ {
96
+ return Mage::getStoreConfig('facebookall/like/faces')?'true':'false';
97
+ }
98
+
99
+ public function getLikeWidth()
100
+ {
101
+ return Mage::getStoreConfig('facebookall/like/width');
102
+ }
103
+
104
+ public function getLikeColor()
105
+ {
106
+ return Mage::getStoreConfig('facebookall/like/color');
107
+ }
108
+
109
+ public function getLikeLayout()
110
+ {
111
+ return Mage::getStoreConfig('facebookall/like/layout');
112
+ }
113
+
114
+ public function getProducts($order)
115
+ {
116
+ $db_read = Mage::getSingleton('core/resource')->getConnection('facebookall_read');
117
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
118
+
119
+ $sql = 'SELECT `product_id` FROM `'.$tablePrefix.'sales_flat_order_item` as i
120
+ LEFT JOIN `'.$tablePrefix.'sales_flat_order` as o ON o.`increment_id` = "'.$order.'"
121
+ WHERE i.`order_id` = o.`entity_id` AND i.`parent_item_id` IS NULL';
122
+ $data = $db_read->fetchAll($sql);
123
+ return $data;
124
+ }
125
+
126
+ public function getLoginImg()
127
+ {
128
+ $img = Mage::getStoreConfig('facebookall/settings/imglogin');
129
+ if (empty($img)) {
130
+ $img = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).
131
+ 'frontend/default/default/images/belvg/fb.gif';
132
+ } else {
133
+ $img = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
134
+ 'facebookall/'.$img;
135
+ }
136
+ return $img;
137
+ }
138
+
139
+ public function isActiveShare()
140
+ {
141
+ return Mage::getStoreConfig('facebookall/share/enabled');
142
+ }
143
+
144
+ public function getShareColor()
145
+ {
146
+ return Mage::getStoreConfig('facebookall/share/color');
147
+ }
148
+
149
+ public function getShareFont()
150
+ {
151
+ return Mage::getStoreConfig('facebookall/share/font');
152
+ }
153
+ }
app/code/community/Belvg/FacebookAll/Helper/Data.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Helper_Data extends Mage_Core_Helper_Abstract
33
+ {
34
+
35
+ }
app/code/community/Belvg/FacebookAll/Model/FacebookAll.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Model_FacebookConnect extends Mage_Core_Model_Abstract
33
+ {
34
+ public function _construct()
35
+ {
36
+ parent::_construct();
37
+ $this->_init('facebookall/facebookall');
38
+ }
39
+ }
app/code/community/Belvg/FacebookAll/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
33
+ {
34
+ }
app/code/community/Belvg/FacebookAll/Model/System/Config/Source/Color.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Model_System_Config_Source_Color
33
+ {
34
+ public function toOptionArray()
35
+ {
36
+ return array(
37
+ //array('value'=>'', 'label'=>''),
38
+ array('value'=>'light', 'label'=>Mage::helper('facebookall')->__('Light')),
39
+ array('value'=>'dark', 'label'=>Mage::helper('facebookall')->__('Dark')),
40
+ );
41
+ }
42
+ }
app/code/community/Belvg/FacebookAll/Model/System/Config/Source/Font.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Model_System_Config_Source_Font
33
+ {
34
+ public function toOptionArray()
35
+ {
36
+ return array(
37
+ //array('value'=>'', 'label'=>''),
38
+ array('value'=>'arial', 'label'=>Mage::helper('facebookall')->__('Arial')),
39
+ array('value'=>'lucida grande', 'label'=>Mage::helper('facebookall')->__('Lucida Grande')),
40
+ array('value'=>'segoe ui', 'label'=>Mage::helper('facebookall')->__('Segoe Ui')),
41
+ array('value'=>'tahoma', 'label'=>Mage::helper('facebookall')->__('Tahoma')),
42
+ array('value'=>'trebuchet ms', 'label'=>Mage::helper('facebookall')->__('Trebuchet MS')),
43
+ array('value'=>'verdana', 'label'=>Mage::helper('facebookall')->__('Verdana')),
44
+ );
45
+ }
46
+ }
app/code/community/Belvg/FacebookAll/Model/System/Config/Source/Layout.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookConnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_Model_System_Config_Source_Layout
33
+ {
34
+ public function toOptionArray()
35
+ {
36
+ return array(
37
+ //array('value'=>'', 'label'=>''),
38
+ array('value'=>'standart', 'label'=>Mage::helper('facebookall')->__('Standart')),
39
+ array('value'=>'button_count', 'label'=>Mage::helper('facebookall')->__('Button Count')),
40
+ array('value'=>'box_count', 'label'=>Mage::helper('facebookall')->__('Box Count')),
41
+ );
42
+ }
43
+ }
app/code/community/Belvg/FacebookAll/controllers/CustomerController.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FacebookAll_CustomerController extends Mage_Core_Controller_Front_Action{
33
+ public function LoginAction() {
34
+
35
+ $facebook = new Facebook_Api(array(
36
+ 'appId' => Mage::getStoreConfig('facebookall/settings/appid'),
37
+ 'secret' => Mage::getStoreConfig('facebookall/settings/secret'),
38
+ 'cookie' => true,
39
+ ));
40
+ $fb_session = $facebook->getSession();
41
+
42
+ $me = null;
43
+ // Session based API call.
44
+ if ($fb_session) {
45
+ try {
46
+ $uid = $facebook->getUser();
47
+ $me = $facebook->api('/me');
48
+ } catch (Facebook_Exception $e) {
49
+ error_log($e);
50
+ }
51
+ }
52
+
53
+ if (is_array($me)) {
54
+ $session = Mage::getSingleton('customer/session');
55
+
56
+ $db_read = Mage::getSingleton('core/resource')->getConnection('facebookall_read');
57
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
58
+ $sql = 'SELECT `customer_id`
59
+ FROM `'.$tablePrefix.'belvg_facebook_customer`
60
+ WHERE `fb_id` = '.$me['id'].'
61
+ LIMIT 1';
62
+ $data = $db_read->fetchRow($sql);
63
+
64
+ if ($data) {
65
+ $session->loginById($data['customer_id']);
66
+ } else {
67
+ $sql = 'SELECT `entity_id`
68
+ FROM `'.$tablePrefix.'customer_entity`
69
+ WHERE email = "'.$me['email'].'"
70
+ LIMIT 1';
71
+ $r = $db_read->fetchRow($sql);
72
+
73
+ if ($r) {
74
+ $db_write = Mage::getSingleton('core/resource')->getConnection('facebookall_write');
75
+ $sql = 'INSERT INTO `'.$tablePrefix.'belvg_facebook_customer`
76
+ VALUES ('.$r['entity_id'].', '.$me['id'].')';
77
+ $db_write->query($sql);
78
+ $session->loginById($r['entity_id']);
79
+ } else {
80
+ $this->_registerCustomer($me, $session);
81
+ }
82
+ }
83
+ $this->_loginPostRedirect($session);
84
+ }
85
+ }
86
+
87
+ public function LogoutAction() {
88
+ $session = Mage::getSingleton('customer/session');
89
+ $session->logout()
90
+ ->setBeforeAuthUrl(Mage::getUrl());
91
+
92
+ $this->_redirect('customer/account/logoutSuccess');
93
+ }
94
+
95
+ private function _registerCustomer($data, &$session)
96
+ {
97
+ $customer = Mage::getModel('customer/customer')->setId(null);
98
+ $customer->setData('firstname', $data['first_name']);
99
+ $customer->setData('lastname', $data['last_name']);
100
+ $customer->setData('email', $data['email']);
101
+ $customer->setData('password', md5(time().$data['id'].$data['locale']));
102
+ $customer->setData('is_active', 1);
103
+ $customer->setData('confirmation', null);
104
+ $customer->setConfirmation(null);
105
+ $customer->getGroupId();
106
+ $customer->save();
107
+
108
+ Mage::getModel('customer/customer')->load($customer->getId())->setConfirmation(null)->save();
109
+ $customer->setConfirmation(null);
110
+ $session->setCustomerAsLoggedIn($customer);
111
+ $customer_id = $session->getCustomerId();
112
+ $db_write = Mage::getSingleton('core/resource')->getConnection('facebookall_write');
113
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
114
+ $sql = 'INSERT INTO `'.$tablePrefix.'belvg_facebook_customer`
115
+ VALUES ('.$customer_id.', '.$data['id'].')';
116
+ $db_write->query($sql);
117
+ }
118
+
119
+ private function _loginPostRedirect(&$session)
120
+ {
121
+
122
+ if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) {
123
+ $referer = Mage::helper('core')->urlDecode($referer);
124
+ if ((strpos($referer, Mage::app()->getStore()->getBaseUrl()) === 0)
125
+ || (strpos($referer, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)) === 0)) {
126
+ $session->setBeforeAuthUrl($referer);
127
+ } else {
128
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
129
+ }
130
+ } else {
131
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
132
+ }
133
+ $this->_redirectUrl($session->getBeforeAuthUrl(true));
134
+ }
135
+ }
app/code/community/Belvg/FacebookAll/controllers/Wishlist/IndexController.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ include_once("Mage/Wishlist/controllers/IndexController.php");
33
+
34
+ class Belvg_FacebookAll_Wishlist_IndexController extends Mage_Wishlist_IndexController
35
+ {
36
+ /**
37
+ * Adding new item
38
+ */
39
+
40
+ public function addAction()
41
+ {
42
+ $session = Mage::getSingleton('customer/session');
43
+ $wishlist = $this->_getWishlist();
44
+ if (!$wishlist) {
45
+ $this->_redirect('*/');
46
+ return;
47
+ }
48
+
49
+ $productId = (int) $this->getRequest()->getParam('product');
50
+ if (!$productId) {
51
+ $this->_redirect('*/');
52
+ return;
53
+ }
54
+
55
+ $product = Mage::getModel('catalog/product')->load($productId);
56
+ if (!$product->getId() || !$product->isVisibleInCatalog()) {
57
+ $session->addError($this->__('Cannot specify product.'));
58
+ $this->_redirect('*/');
59
+ return;
60
+ }
61
+
62
+ try {
63
+ $buyRequest = new Varien_Object($this->getRequest()->getParams());
64
+
65
+ $result = $wishlist->addNewItem($product, $buyRequest);
66
+ if (is_string($result)) {
67
+ Mage::throwException($result);
68
+ }
69
+ $wishlist->save();
70
+
71
+ Mage::dispatchEvent(
72
+ 'wishlist_add_product',
73
+ array(
74
+ 'wishlist' => $wishlist,
75
+ 'product' => $product,
76
+ 'item' => $result
77
+ )
78
+ );
79
+
80
+ $referer = $session->getBeforeWishlistUrl();
81
+ if ($referer) {
82
+ $session->setBeforeWishlistUrl(null);
83
+ } else {
84
+ $referer = $this->_getRefererUrl();
85
+ }
86
+
87
+ /**
88
+ * Set referer to avoid referring to the compare popup window
89
+ */
90
+ $session->setAddActionReferer($referer);
91
+
92
+ Mage::helper('wishlist')->calculate();
93
+
94
+ $message = $this->__('%1$s has been added to your wishlist. Click <a href="%2$s">here</a> to continue shopping', $product->getName(), $referer);
95
+ $session->addSuccess($message);
96
+
97
+ /***/
98
+ if (Mage::getStoreConfig('facebookall/wishlist/enabled')) {
99
+ $facebook = new Facebook_Api(array(
100
+ 'appId' => Mage::getStoreConfig('facebookall/settings/appid'),
101
+ 'secret' => Mage::getStoreConfig('facebookall/settings/secret'),
102
+ 'cookie' => true,
103
+ ));
104
+ $fb_session = $facebook->getSession();
105
+
106
+ $me = null;
107
+ if ($fb_session) {
108
+ try {
109
+ $uid = $facebook->getUser();
110
+ $message = str_replace('{product}', $product->getName(), Mage::getStoreConfig('facebookall/wishlist/note'));
111
+ $feed_data = array('message'=>$message,
112
+ 'link'=>$product->getProductUrl(),
113
+ 'picture'=> $product->getImageUrl(),
114
+ 'name'=>$product->getName(),
115
+ 'caption'=>'',
116
+ 'description'=>$product->getShortDescription(),
117
+ 'access_token'=>$facebook->getAccessToken);
118
+
119
+ $me = $facebook->api('/me/feed/','post', $feed_data);
120
+ } catch (Facebook_Exception $e) {
121
+ error_log($e);
122
+ }
123
+ }
124
+ }
125
+ /****/
126
+ }
127
+ catch (Mage_Core_Exception $e) {
128
+ $session->addError($this->__('An error occurred while adding item to wishlist: %s', $e->getMessage()));
129
+ }
130
+ catch (Exception $e) {
131
+ mage::log($e->getMessage());
132
+ $session->addError($this->__('An error occurred while adding item to wishlist.'));
133
+ }
134
+
135
+ $this->_redirect('*');
136
+ }
137
+
138
+ }
app/code/community/Belvg/FacebookAll/etc/adminhtml.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FacebookAll
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <acl>
35
+ <resources>
36
+ <all>
37
+ <title>Allow Everything</title>
38
+ </all>
39
+ <admin>
40
+ <children>
41
+ <system>
42
+ <children>
43
+ <config>
44
+ <children>
45
+ <facebookall translate="title">
46
+ <title>Facebook All in One</title>
47
+ </facebookall>
48
+ </children>
49
+ </config>
50
+ </children>
51
+ </system>
52
+ </children>
53
+ </admin>
54
+ </resources>
55
+ </acl>
56
+ </config>
app/code/community/Belvg/FacebookAll/etc/config.xml ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FacebookAll
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <modules>
35
+ <Belvg_FacebookAll>
36
+ <version>1.0.1</version>
37
+ </Belvg_FacebookAll>
38
+ </modules>
39
+ <frontend>
40
+ <routers>
41
+ <facebookall>
42
+ <use>standard</use>
43
+ <args>
44
+ <module>Belvg_FacebookAll</module>
45
+ <frontName>facebookall</frontName>
46
+ </args>
47
+ </facebookall>
48
+ </routers>
49
+ <layout>
50
+ <updates>
51
+ <facebookall>
52
+ <file>FB-Twitter-Connect.xml</file>
53
+ </facebookall>
54
+ </updates>
55
+ </layout>
56
+ </frontend>
57
+ <global>
58
+ <models>
59
+ <facebookall>
60
+ <class>Belvg_FacebookAll_Model</class>
61
+ <resourceModel>facebookall_mysql4</resourceModel>
62
+ </facebookall>
63
+ <facebookall_mysql4>
64
+ <class>Belvg_FacebookAll_Model</class>
65
+ <entities>
66
+ <facebookall>
67
+ <table>belvg_facebook_customer</table>
68
+ </facebookall>
69
+ </entities>
70
+ </facebookall_mysql4>
71
+ </models>
72
+ <resources>
73
+ <facebookall_setup>
74
+ <setup>
75
+ <module>Belvg_FacebookAll</module>
76
+ </setup>
77
+ <connection>
78
+ <use>core_setup</use>
79
+ </connection>
80
+ </facebookall_setup>
81
+ <facebookall_write>
82
+ <connection>
83
+ <use>core_write</use>
84
+ </connection>
85
+ </facebookall_write>
86
+ <facebookall_read>
87
+ <connection>
88
+ <use>core_read</use>
89
+ </connection>
90
+ </facebookall_read>
91
+ </resources>
92
+ <blocks>
93
+ <facebookall>
94
+ <class>Belvg_FacebookAll_Block</class>
95
+ </facebookall>
96
+ </blocks>
97
+ <helpers>
98
+ <facebookall>
99
+ <class>Belvg_FacebookAll_Helper</class>
100
+ </facebookall>
101
+ </helpers>
102
+ <rewrite>
103
+ <Belvg_FacebookAll_Wishlist_Index>
104
+ <from><![CDATA[#^/wishlist/index/#]]>
105
+ </from>
106
+ <to>/facebookall/wishlist_index/</to>
107
+ </Belvg_FacebookAll_Wishlist_Index>
108
+ </rewrite>
109
+ </global>
110
+ <default>
111
+ <facebookall>
112
+ <like>
113
+ <enabled>0</enabled>
114
+ <faces>0</faces>
115
+ <width>450</width>
116
+ <color>light</color>
117
+ <layout>standart</layout>
118
+ <enabled>0</enabled>
119
+ </like>
120
+ <share>
121
+ <enabled>0</enabled>
122
+ <color>light</color>
123
+ <font>arial</font>
124
+ </share>
125
+ <comments>
126
+ <enabled>0</enabled>
127
+ <color>light</color>
128
+ <posts>5</posts>
129
+ <width>500</width>
130
+ </comments>
131
+ <activity>
132
+ <enabled>0</enabled>
133
+ <width>200</width>
134
+ <height>300</height>
135
+ <header>1</header>
136
+ <color>light</color>
137
+ <font>arial</font>
138
+ <recommendations>1</recommendations>
139
+ <maxage>0</maxage>
140
+ </activity>
141
+ <wishlist>
142
+ <note>I have added {product} to my wishlist.</note>
143
+ </wishlist>
144
+ </facebookall>
145
+ </default>
146
+ </config>
app/code/community/Belvg/FacebookAll/etc/system.xml ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FacebookAll
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <sections>
35
+ <facebookall translate="label">
36
+ <label>Facebook All in One</label>
37
+ <tab>belvg</tab>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>1000</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <groups>
44
+ <settings translate="label">
45
+ <label>Settings</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>100</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <comment>
52
+ <![CDATA[
53
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
54
+ This module was developed by <a href="http://www.belvg.com" target="_blank">www.BelVG.com</a>.
55
+ For docs & examples refer to the BelVG <a href="http://www.belvg.com" target="_blank">web site</a>.
56
+ <br/>We have the largest selections of <a href="http://store.belvg.com/extensions.html" target="_blank">extensions</a> and <a href="http://store.belvg.com/themes.html" target="_blank">themes</a> on Magento.
57
+ </div>
58
+ ]]>
59
+ </comment>
60
+ <fields>
61
+ <enabled translate="label comment">
62
+ <label>Enabled</label>
63
+ <!-- <comment><![CDATA[]]></comment> -->
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
66
+ <sort_order>10</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
+ </enabled>
71
+ <appid translate="label comment">
72
+ <label>Application Id</label>
73
+ <!-- <comment><![CDATA[]]></comment> -->
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>11</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </appid>
80
+ <secret translate="label comment">
81
+ <label>Secret Key</label>
82
+ <!-- <comment><![CDATA[]]></comment> -->
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>12</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </secret>
89
+ <imglogin translate="label comment">
90
+ <label>Login Button</label>
91
+ <!-- <comment><![CDATA[]]></comment> -->
92
+ <frontend_type>image</frontend_type>
93
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
94
+ <upload_dir config="system/filesystem/media" scope_info="1">facebookall</upload_dir>
95
+ <base_url type="media" scope_info="1">facebookall</base_url>
96
+ <sort_order>13</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ </imglogin>
101
+ </fields>
102
+ </settings>
103
+ <like translate="label">
104
+ <label>Like Button</label>
105
+ <frontend_type>text</frontend_type>
106
+ <sort_order>110</sort_order>
107
+ <show_in_default>1</show_in_default>
108
+ <show_in_website>1</show_in_website>
109
+ <show_in_store>1</show_in_store>
110
+ <fields>
111
+ <enabled translate="label comment">
112
+ <label>Enabled</label>
113
+ <!-- <comment><![CDATA[]]></comment> -->
114
+ <frontend_type>select</frontend_type>
115
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
116
+ <sort_order>10</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </enabled>
121
+ <faces translate="label comment">
122
+ <label>Show faces</label>
123
+ <!-- <comment><![CDATA[]]></comment> -->
124
+ <frontend_type>select</frontend_type>
125
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
126
+ <sort_order>11</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ </faces>
131
+ <layout translate="label">
132
+ <label>Layout Style</label>
133
+ <frontend_type>select</frontend_type>
134
+ <source_model>facebookall/system_config_source_layout</source_model>
135
+ <sort_order>12</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>1</show_in_store>
139
+ </layout>
140
+ <color translate="label">
141
+ <label>Color Scheme</label>
142
+ <frontend_type>select</frontend_type>
143
+ <source_model>facebookall/system_config_source_color</source_model>
144
+ <sort_order>12</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ </color>
149
+ <width translate="label comment">
150
+ <label>Width</label>
151
+ <comment>in px</comment>
152
+ <frontend_type>text</frontend_type>
153
+ <sort_order>13</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
+ </width>
158
+ </fields>
159
+ </like>
160
+ <share translate="label">
161
+ <label>Share Button</label>
162
+ <frontend_type>text</frontend_type>
163
+ <sort_order>120</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ <fields>
168
+ <enabled translate="label comment">
169
+ <label>Enabled</label>
170
+ <!-- <comment><![CDATA[]]></comment> -->
171
+ <frontend_type>select</frontend_type>
172
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
173
+ <sort_order>10</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ </enabled>
178
+ <color translate="label">
179
+ <label>Color Scheme</label>
180
+ <frontend_type>select</frontend_type>
181
+ <source_model>facebookall/system_config_source_color</source_model>
182
+ <sort_order>11</sort_order>
183
+ <show_in_default>1</show_in_default>
184
+ <show_in_website>1</show_in_website>
185
+ <show_in_store>1</show_in_store>
186
+ </color>
187
+ <font translate="label comment">
188
+ <label>Font</label>
189
+ <frontend_type>select</frontend_type>
190
+ <source_model>facebookall/system_config_source_font</source_model>
191
+ <sort_order>12</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>1</show_in_store>
195
+ </font>
196
+ </fields>
197
+ </share>
198
+ <comments translate="label">
199
+ <label>Comments</label>
200
+ <frontend_type>text</frontend_type>
201
+ <sort_order>130</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ <fields>
206
+ <enabled translate="label comment">
207
+ <label>Enabled</label>
208
+ <!-- <comment><![CDATA[]]></comment> -->
209
+ <frontend_type>select</frontend_type>
210
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
211
+ <sort_order>10</sort_order>
212
+ <show_in_default>1</show_in_default>
213
+ <show_in_website>1</show_in_website>
214
+ <show_in_store>1</show_in_store>
215
+ </enabled>
216
+ <posts translate="label">
217
+ <label>Number of posts</label>
218
+ <frontend_type>text</frontend_type>
219
+ <sort_order>11</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>1</show_in_website>
222
+ <show_in_store>1</show_in_store>
223
+ </posts>
224
+ <width translate="label comment">
225
+ <label>Width</label>
226
+ <comment>in px</comment>
227
+ <frontend_type>text</frontend_type>
228
+ <sort_order>13</sort_order>
229
+ <show_in_default>1</show_in_default>
230
+ <show_in_website>1</show_in_website>
231
+ <show_in_store>1</show_in_store>
232
+ </width>
233
+ <color translate="label">
234
+ <label>Color Scheme</label>
235
+ <frontend_type>select</frontend_type>
236
+ <source_model>facebookall/system_config_source_color</source_model>
237
+ <sort_order>11</sort_order>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>1</show_in_store>
241
+ </color>
242
+ </fields>
243
+ </comments>
244
+ <activity translate="label">
245
+ <label>Activity</label>
246
+ <frontend_type>text</frontend_type>
247
+ <sort_order>130</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ <fields>
252
+ <enabled translate="label comment">
253
+ <label>Enabled</label>
254
+ <!-- <comment><![CDATA[]]></comment> -->
255
+ <frontend_type>select</frontend_type>
256
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
257
+ <sort_order>10</sort_order>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>1</show_in_website>
260
+ <show_in_store>1</show_in_store>
261
+ </enabled>
262
+ <width translate="label comment">
263
+ <label>Width</label>
264
+ <comment>in px</comment>
265
+ <frontend_type>text</frontend_type>
266
+ <sort_order>11</sort_order>
267
+ <show_in_default>1</show_in_default>
268
+ <show_in_website>1</show_in_website>
269
+ <show_in_store>1</show_in_store>
270
+ </width>
271
+ <height translate="label comment">
272
+ <label>Height</label>
273
+ <comment>in px</comment>
274
+ <frontend_type>text</frontend_type>
275
+ <sort_order>12</sort_order>
276
+ <show_in_default>1</show_in_default>
277
+ <show_in_website>1</show_in_website>
278
+ <show_in_store>1</show_in_store>
279
+ </height>
280
+ <header translate="label comment">
281
+ <label>Show Header</label>
282
+ <!-- <comment><![CDATA[]]></comment> -->
283
+ <frontend_type>select</frontend_type>
284
+ <source_model>adminhtml/system_config_source_yesno</source_model>
285
+ <sort_order>13</sort_order>
286
+ <show_in_default>1</show_in_default>
287
+ <show_in_website>1</show_in_website>
288
+ <show_in_store>1</show_in_store>
289
+ </header>
290
+ <color translate="label">
291
+ <label>Color Scheme</label>
292
+ <frontend_type>select</frontend_type>
293
+ <source_model>facebookall/system_config_source_color</source_model>
294
+ <sort_order>14</sort_order>
295
+ <show_in_default>1</show_in_default>
296
+ <show_in_website>1</show_in_website>
297
+ <show_in_store>1</show_in_store>
298
+ </color>
299
+ <font translate="label comment">
300
+ <label>Font</label>
301
+ <frontend_type>select</frontend_type>
302
+ <source_model>facebookall/system_config_source_font</source_model>
303
+ <sort_order>15</sort_order>
304
+ <show_in_default>1</show_in_default>
305
+ <show_in_website>1</show_in_website>
306
+ <show_in_store>1</show_in_store>
307
+ </font>
308
+ <recommendations translate="label comment">
309
+ <label>Add recommendations</label>
310
+ <!-- <comment><![CDATA[]]></comment> -->
311
+ <frontend_type>select</frontend_type>
312
+ <source_model>adminhtml/system_config_source_yesno</source_model>
313
+ <sort_order>16</sort_order>
314
+ <show_in_default>1</show_in_default>
315
+ <show_in_website>1</show_in_website>
316
+ <show_in_store>1</show_in_store>
317
+ </recommendations>
318
+ <maxage translate="label comment">
319
+ <label>Max Age</label>
320
+ <comment>The default is 0 (we don’t take age into account). Otherwise the valid values are 1-180, which specifies the number of days. For example, if you specify '7' the plugin will only show URLs which were created in the past week.</comment>
321
+ <frontend_type>text</frontend_type>
322
+ <sort_order>17</sort_order>
323
+ <show_in_default>1</show_in_default>
324
+ <show_in_website>1</show_in_website>
325
+ <show_in_store>1</show_in_store>
326
+ </maxage>
327
+
328
+ </fields>
329
+ </activity>
330
+ <wishlist translate="label">
331
+ <label>Wishlist</label>
332
+ <frontend_type>text</frontend_type>
333
+ <sort_order>150</sort_order>
334
+ <show_in_default>1</show_in_default>
335
+ <show_in_website>1</show_in_website>
336
+ <show_in_store>1</show_in_store>
337
+ <fields>
338
+ <enabled translate="label comment">
339
+ <label>Post product to user's feed</label>
340
+ <!-- <comment><![CDATA[]]></comment> -->
341
+ <frontend_type>select</frontend_type>
342
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
343
+ <sort_order>10</sort_order>
344
+ <show_in_default>1</show_in_default>
345
+ <show_in_website>1</show_in_website>
346
+ <show_in_store>1</show_in_store>
347
+ </enabled>
348
+ <note translate="label comment">
349
+ <label>Note</label>
350
+ <frontend_type>text</frontend_type>
351
+ <sort_order>13</sort_order>
352
+ <show_in_default>1</show_in_default>
353
+ <show_in_website>1</show_in_website>
354
+ <show_in_store>1</show_in_store>
355
+ </note>
356
+ </fields>
357
+ </wishlist>
358
+ </groups>
359
+ </facebookall>
360
+ </sections>
361
+ </config>
app/code/community/Belvg/FacebookAll/sql/facebookall_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookAll
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ $installer = $this;
33
+
34
+ $installer->startSetup();
35
+
36
+ $installer->run("
37
+ CREATE TABLE IF NOT EXISTS {$this->getTable('belvg_facebook_customer')} (
38
+ `customer_id` int(10) NOT NULL,
39
+ `fb_id` bigint(20) NOT NULL,
40
+ UNIQUE KEY `FB_CUSTOMER` (`customer_id`,`fb_id`)
41
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
42
+
43
+ ALTER TABLE `{$this->getTable('belvg_facebook_customer')}`
44
+ CHANGE `customer_id` `customer_id` INT( 10 ) UNSIGNED NOT NULL;
45
+
46
+ ALTER TABLE `{$this->getTable('belvg_facebook_customer')}`
47
+ ADD FOREIGN KEY ( `customer_id` ) REFERENCES `{$this->getTable('customer_entity')}` (
48
+ `entity_id`
49
+ ) ON DELETE CASCADE ;
50
+ ");
51
+ $installer->endSetup();
app/code/community/Belvg/FaceboookFree/Block/Active.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FaceboookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FaceboookFree_Block_Active extends Mage_Core_Block_Template {
33
+
34
+ public function getAppId()
35
+ {
36
+ return Mage::getStoreConfig('facebookfree/settings/appid');
37
+ }
38
+
39
+ public function getSecretKey()
40
+ {
41
+ return Mage::getStoreConfig('facebookfree/settings/secret');
42
+ }
43
+
44
+ public function isActiveLike()
45
+ {
46
+ return Mage::getStoreConfig('facebookfree/like/enabled');
47
+ }
48
+
49
+ public function isFacesLikeActive()
50
+ {
51
+ return Mage::getStoreConfig('facebookfree/like/faces')?'true':'false';
52
+ }
53
+
54
+ public function getLikeWidth()
55
+ {
56
+ return Mage::getStoreConfig('facebookfree/like/width');
57
+ }
58
+
59
+ public function getLikeColor()
60
+ {
61
+ return Mage::getStoreConfig('facebookfree/like/color');
62
+ }
63
+
64
+ public function getLikeLayout()
65
+ {
66
+ return Mage::getStoreConfig('facebookfree/like/layout');
67
+ }
68
+
69
+ public function checkFbUser()
70
+ {
71
+ $user_id = Mage::getSingleton('customer/session')->getCustomer()->getId();
72
+ $uid = 0;
73
+ $db_read = Mage::getSingleton('core/resource')->getConnection('facebookfree_read');
74
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
75
+
76
+ $sql = 'SELECT `fb_id`
77
+ FROM `'.$tablePrefix.'belvg_facebook_customer`
78
+ WHERE `customer_id` = '.$user_id.'
79
+ LIMIT 1';
80
+ $data = $db_read->fetchRow($sql);
81
+ if (count($data)) {
82
+ $uid = $data['fb_id'];
83
+ }
84
+ return $uid;
85
+ }
86
+ }
app/code/community/Belvg/FaceboookFree/Block/Links.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FaceboookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FaceboookFree_Block_Links extends Mage_Core_Block_Template
33
+ {
34
+
35
+ public function addFbLink() {
36
+ if ($parentBlock = $this->getParentBlock()) {
37
+ $count = $this->helper('checkout/cart')->getSummaryCount();
38
+
39
+ if ($count == 1) {
40
+ $text = $this->__('My Cart (%s item)', $count);
41
+ } elseif ($count > 0) {
42
+ $text = $this->__('My Cart (%s items)', $count);
43
+ } else {
44
+ $text = $this->__('My Cart');
45
+ }
46
+
47
+ //$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 90, null, 'class="top-link-cart"');
48
+ }
49
+ return $this;
50
+ }
51
+
52
+ }
app/code/community/Belvg/FaceboookFree/Helper/Active.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ * *************************************** */
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ * *************************************** */
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ * ****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FaceboookFree
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+
33
+ class Belvg_FaceboookFree_Helper_Active extends Mage_Core_Helper_Abstract {
34
+
35
+ public function getAppId() {
36
+ return Mage::getStoreConfig('facebookfree/settings/appid');
37
+ }
38
+
39
+ public function getSecretKey() {
40
+ return Mage::getStoreConfig('facebookfree/settings/secret');
41
+ }
42
+
43
+ public function isActiveLike() {
44
+ return Mage::getStoreConfig('facebookfree/like/enabled');
45
+ }
46
+
47
+ public function isFacesLikeActive() {
48
+ return Mage::getStoreConfig('facebookfree/like/faces') ? 'true' : 'false';
49
+ }
50
+
51
+ public function getLikeWidth() {
52
+ return Mage::getStoreConfig('facebookfree/like/width');
53
+ }
54
+
55
+ public function getLikeColor() {
56
+ return Mage::getStoreConfig('facebookfree/like/color');
57
+ }
58
+
59
+ public function getLikeLayout() {
60
+ return Mage::getStoreConfig('facebookfree/like/layout');
61
+ }
62
+
63
+ public function getProducts($order) {
64
+ $db_read = Mage::getSingleton('core/resource')->getConnection('facebookfree_read');
65
+ $tablePrefix = (string) Mage::getConfig()->getTablePrefix();
66
+
67
+ $sql = 'SELECT `product_id` FROM `' . $tablePrefix . 'sales_flat_order_item` as i
68
+ LEFT JOIN `' . $tablePrefix . 'sales_flat_order` as o ON o.`increment_id` = "' . $order . '"
69
+ WHERE i.`order_id` = o.`entity_id` AND i.`parent_item_id` IS NULL';
70
+ $data = $db_read->fetchAll($sql);
71
+ return $data;
72
+ }
73
+
74
+ public function getLoginImg() {
75
+ $img = Mage::getStoreConfig('facebookfree/settings/imglogin');
76
+ if (empty($img)) {
77
+ $img = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) .
78
+ 'frontend/default/default/images/belvg/fb.gif';
79
+ } else {
80
+ $img = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) .
81
+ 'facebookfree/' . $img;
82
+ }
83
+ return $img;
84
+ }
85
+
86
+ }
app/code/community/Belvg/FaceboookFree/Helper/Data.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FaceboookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FaceboookFree_Helper_Data extends Mage_Core_Helper_Abstract
33
+ {
34
+
35
+ }
app/code/community/Belvg/FaceboookFree/Model/FaceboookFree.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FaceboookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FaceboookFree_Model_FacebookFree extends Mage_Core_Model_Abstract
33
+ {
34
+ public function _construct()
35
+ {
36
+ parent::_construct();
37
+ $this->_init('facebookfree/facebookfree');
38
+ }
39
+ }
app/code/community/Belvg/FaceboookFree/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FaceboookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FaceboookFree_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
33
+ {
34
+ }
app/code/community/Belvg/FaceboookFree/Model/System/Config/Source/Color.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FaceboookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FaceboookFree_Model_System_Config_Source_Color
33
+ {
34
+ public function toOptionArray()
35
+ {
36
+ return array(
37
+ //array('value'=>'', 'label'=>''),
38
+ array('value'=>'light', 'label'=>Mage::helper('facebookfree')->__('Light')),
39
+ array('value'=>'dark', 'label'=>Mage::helper('facebookfree')->__('Dark')),
40
+ );
41
+ }
42
+ }
app/code/community/Belvg/FaceboookFree/Model/System/Config/Source/Layout.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FaceboookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+
32
+ class Belvg_FaceboookFree_Model_System_Config_Source_Layout
33
+ {
34
+ public function toOptionArray()
35
+ {
36
+ return array(
37
+ //array('value'=>'', 'label'=>''),
38
+ array('value'=>'standart', 'label'=>Mage::helper('facebookfree')->__('Standart')),
39
+ array('value'=>'button_count', 'label'=>Mage::helper('facebookfree')->__('Button Count')),
40
+ array('value'=>'box_count', 'label'=>Mage::helper('facebookfree')->__('Box Count')),
41
+ );
42
+ }
43
+ }
app/code/community/Belvg/FaceboookFree/controllers/CustomerController.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ * *************************************** */
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ * *************************************** */
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ * ****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FaceboookFree
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+
33
+ class Belvg_FaceboookFree_CustomerController extends Mage_Core_Controller_Front_Action {
34
+
35
+ public function LoginAction() {
36
+
37
+ $facebook = new Facebook_Api(array(
38
+ 'appId' => Mage::getStoreConfig('facebookfree/settings/appid'),
39
+ 'secret' => Mage::getStoreConfig('facebookfree/settings/secret'),
40
+ 'cookie' => true,
41
+ ));
42
+ $fb_session = $facebook->getSession();
43
+
44
+ $me = null;
45
+ // Session based API call.
46
+ if ($fb_session) {
47
+ try {
48
+ $uid = $facebook->getUser();
49
+ $me = $facebook->api('/me');
50
+ } catch (Facebook_Exception $e) {
51
+ error_log($e);
52
+ }
53
+ }
54
+
55
+ if (is_array($me)) {
56
+ $session = Mage::getSingleton('customer/session');
57
+
58
+ $db_read = Mage::getSingleton('core/resource')->getConnection('facebookfree_read');
59
+ $tablePrefix = (string) Mage::getConfig()->getTablePrefix();
60
+ $sql = 'SELECT `customer_id`
61
+ FROM `' . $tablePrefix . 'belvg_facebook_customer`
62
+ WHERE `fb_id` = ' . $me['id'] . '
63
+ LIMIT 1';
64
+ $data = $db_read->fetchRow($sql);
65
+
66
+ if ($data) {
67
+ $session->loginById($data['customer_id']);
68
+ } else {
69
+ $sql = 'SELECT `entity_id`
70
+ FROM `' . $tablePrefix . 'customer_entity`
71
+ WHERE email = "' . $me['email'] . '"
72
+ LIMIT 1';
73
+ $r = $db_read->fetchRow($sql);
74
+
75
+ if ($r) {
76
+ $db_write = Mage::getSingleton('core/resource')->getConnection('facebookfree_write');
77
+ $sql = 'INSERT INTO `' . $tablePrefix . 'belvg_facebook_customer`
78
+ VALUES (' . $r['entity_id'] . ', ' . $me['id'] . ')';
79
+ $db_write->query($sql);
80
+ $session->loginById($r['entity_id']);
81
+ } else {
82
+ $this->_registerCustomer($me, $session);
83
+ }
84
+ }
85
+ $this->_loginPostRedirect($session);
86
+ }
87
+ }
88
+
89
+ public function LogoutAction() {
90
+ $session = Mage::getSingleton('customer/session');
91
+ $session->logout()
92
+ ->setBeforeAuthUrl(Mage::getUrl());
93
+
94
+ $this->_redirect('customer/account/logoutSuccess');
95
+ }
96
+
97
+ private function _registerCustomer($data, &$session) {
98
+ $customer = Mage::getModel('customer/customer')->setId(null);
99
+ $customer->setData('firstname', $data['first_name']);
100
+ $customer->setData('lastname', $data['last_name']);
101
+ $customer->setData('email', $data['email']);
102
+ $customer->setData('password', md5(time() . $data['id'] . $data['locale']));
103
+ $customer->setData('is_active', 1);
104
+ $customer->setData('confirmation', null);
105
+ $customer->setConfirmation(null);
106
+ $customer->getGroupId();
107
+ $customer->save();
108
+
109
+ Mage::getModel('customer/customer')->load($customer->getId())->setConfirmation(null)->save();
110
+ $customer->setConfirmation(null);
111
+ $session->setCustomerAsLoggedIn($customer);
112
+ $customer_id = $session->getCustomerId();
113
+ $db_write = Mage::getSingleton('core/resource')->getConnection('facebookfree_write');
114
+ $tablePrefix = (string) Mage::getConfig()->getTablePrefix();
115
+ $sql = 'INSERT INTO `' . $tablePrefix . 'belvg_facebook_customer`
116
+ VALUES (' . $customer_id . ', ' . $data['id'] . ')';
117
+ $db_write->query($sql);
118
+ }
119
+
120
+ private function _loginPostRedirect(&$session) {
121
+
122
+ if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) {
123
+ $referer = Mage::helper('core')->urlDecode($referer);
124
+ if ((strpos($referer, Mage::app()->getStore()->getBaseUrl()) === 0)
125
+ || (strpos($referer, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)) === 0)) {
126
+ $session->setBeforeAuthUrl($referer);
127
+ } else {
128
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
129
+ }
130
+ } else {
131
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
132
+ }
133
+ $this->_redirectUrl($session->getBeforeAuthUrl(true));
134
+ }
135
+
136
+ }
app/code/community/Belvg/FaceboookFree/etc/adminhtml.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FaceboookFree
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <acl>
35
+ <resources>
36
+ <all>
37
+ <title>Allow Everything</title>
38
+ </all>
39
+ <admin>
40
+ <children>
41
+ <system>
42
+ <children>
43
+ <config>
44
+ <children>
45
+ <facebookfree translate="title">
46
+ <title>Faceboook Connect and Like Free</title>
47
+ </facebookfree>
48
+ </children>
49
+ </config>
50
+ </children>
51
+ </system>
52
+ </children>
53
+ </admin>
54
+ </resources>
55
+ </acl>
56
+ </config>
app/code/community/Belvg/FaceboookFree/etc/config.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FaceboookFree
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <modules>
35
+ <Belvg_FaceboookFree>
36
+ <version>1.0.2</version>
37
+ </Belvg_FaceboookFree>
38
+ </modules>
39
+ <frontend>
40
+ <routers>
41
+ <facebookfree>
42
+ <use>standard</use>
43
+ <args>
44
+ <module>Belvg_FaceboookFree</module>
45
+ <frontName>facebookfree</frontName>
46
+ </args>
47
+ </facebookfree>
48
+ </routers>
49
+ <layout>
50
+ <updates>
51
+ <facebookfree>
52
+ <file>facebookfree.xml</file>
53
+ </facebookfree>
54
+ </updates>
55
+ </layout>
56
+ </frontend>
57
+ <global>
58
+ <models>
59
+ <facebookfree>
60
+ <class>Belvg_FaceboookFree_Model</class>
61
+ <resourceModel>facebookfree_mysql4</resourceModel>
62
+ </facebookfree>
63
+ <facebookfree_mysql4>
64
+ <class>Belvg_FaceboookFree_Model</class>
65
+ <entities>
66
+ <facebookfree>
67
+ <table>belvg_facebook_customer</table>
68
+ </facebookfree>
69
+ </entities>
70
+ </facebookfree_mysql4>
71
+ </models>
72
+ <resources>
73
+ <facebookfree_setup>
74
+ <setup>
75
+ <module>Belvg_FaceboookFree</module>
76
+ </setup>
77
+ <connection>
78
+ <use>core_setup</use>
79
+ </connection>
80
+ </facebookfree_setup>
81
+ <facebookfree_write>
82
+ <connection>
83
+ <use>core_write</use>
84
+ </connection>
85
+ </facebookfree_write>
86
+ <facebookfree_read>
87
+ <connection>
88
+ <use>core_read</use>
89
+ </connection>
90
+ </facebookfree_read>
91
+ </resources>
92
+ <blocks>
93
+ <facebookfree>
94
+ <class>Belvg_FaceboookFree_Block</class>
95
+ </facebookfree>
96
+ </blocks>
97
+ <helpers>
98
+ <facebookfree>
99
+ <class>Belvg_FaceboookFree_Helper</class>
100
+ </facebookfree>
101
+ </helpers>
102
+ </global>
103
+ <default>
104
+ <facebookfree>
105
+ <like>
106
+ <enabled>0</enabled>
107
+ <faces>0</faces>
108
+ <width>450</width>
109
+ <color>light</color>
110
+ <layout>standart</layout>
111
+ <enabled>0</enabled>
112
+ </like>
113
+ </facebookfree>
114
+ </default>
115
+ </config>
app/code/community/Belvg/FaceboookFree/etc/system.xml ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FaceboookFree
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <sections>
35
+ <facebookfree translate="label">
36
+ <label>Facebook Connect and Like Free</label>
37
+ <tab>belvg</tab>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>1000</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <groups>
44
+ <settings translate="label">
45
+ <label>Settings</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>100</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <comment>
52
+ <![CDATA[
53
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
54
+ This module was developed by <a href="http://www.belvg.com" target="_blank">www.BelVG.com</a>.
55
+ For docs & examples refer to the BelVG <a href="http://www.belvg.com" target="_blank">web site</a>.
56
+ <br/>We have the largest selections of <a href="http://store.belvg.com/extensions.html" target="_blank">extensions</a> and <a href="http://store.belvg.com/themes.html" target="_blank">themes</a> on Magento.
57
+ </div>
58
+ ]]>
59
+ </comment>
60
+ <fields>
61
+ <enabled translate="label comment">
62
+ <label>Enabled</label>
63
+ <!-- <comment><![CDATA[]]></comment> -->
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
66
+ <sort_order>10</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
+ </enabled>
71
+ <appid translate="label comment">
72
+ <label>Application Id</label>
73
+ <!-- <comment><![CDATA[]]></comment> -->
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>11</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </appid>
80
+ <secret translate="label comment">
81
+ <label>Secret Key</label>
82
+ <!-- <comment><![CDATA[]]></comment> -->
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>12</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </secret>
89
+ <imglogin translate="label comment">
90
+ <label>Login Button</label>
91
+ <!-- <comment><![CDATA[]]></comment> -->
92
+ <frontend_type>image</frontend_type>
93
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
94
+ <upload_dir config="system/filesystem/media" scope_info="1">facebookfree</upload_dir>
95
+ <base_url type="media" scope_info="1">facebookfree</base_url>
96
+ <sort_order>13</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ </imglogin>
101
+ </fields>
102
+ </settings>
103
+ <like translate="label">
104
+ <label>Like Button</label>
105
+ <frontend_type>text</frontend_type>
106
+ <sort_order>110</sort_order>
107
+ <show_in_default>1</show_in_default>
108
+ <show_in_website>1</show_in_website>
109
+ <show_in_store>1</show_in_store>
110
+ <fields>
111
+ <enabled translate="label comment">
112
+ <label>Enabled</label>
113
+ <!-- <comment><![CDATA[]]></comment> -->
114
+ <frontend_type>select</frontend_type>
115
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
116
+ <sort_order>10</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </enabled>
121
+ <faces translate="label comment">
122
+ <label>Show faces</label>
123
+ <!-- <comment><![CDATA[]]></comment> -->
124
+ <frontend_type>select</frontend_type>
125
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
126
+ <sort_order>11</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ </faces>
131
+ <layout translate="label">
132
+ <label>Layout Style</label>
133
+ <frontend_type>select</frontend_type>
134
+ <source_model>facebookfree/system_config_source_layout</source_model>
135
+ <sort_order>12</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>1</show_in_store>
139
+ </layout>
140
+ <color translate="label">
141
+ <label>Color Scheme</label>
142
+ <frontend_type>select</frontend_type>
143
+ <source_model>facebookfree/system_config_source_color</source_model>
144
+ <sort_order>12</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ </color>
149
+ <width translate="label comment">
150
+ <label>Width</label>
151
+ <comment>in px</comment>
152
+ <frontend_type>text</frontend_type>
153
+ <sort_order>13</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
+ </width>
158
+ </fields>
159
+ </like>
160
+ </groups>
161
+ </facebookfree>
162
+ </sections>
163
+ </config>
app/code/community/Belvg/FaceboookFree/sql/facebookfree_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ * *************************************** */
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ * *************************************** */
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ * ****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FacebookAll
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+
37
+ $installer->run("
38
+ CREATE TABLE IF NOT EXISTS {$this->getTable('belvg_facebook_customer')} (
39
+ `customer_id` int(10) NOT NULL,
40
+ `fb_id` bigint(20) NOT NULL,
41
+ UNIQUE KEY `FB_CUSTOMER` (`customer_id`,`fb_id`)
42
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
43
+
44
+ ALTER TABLE `{$this->getTable('belvg_facebook_customer')}`
45
+ CHANGE `customer_id` `customer_id` INT( 10 ) UNSIGNED NOT NULL;
46
+
47
+ ALTER TABLE `{$this->getTable('belvg_facebook_customer')}`
48
+ ADD FOREIGN KEY ( `customer_id` ) REFERENCES `{$this->getTable('customer_entity')}` (
49
+ `entity_id`
50
+ ) ON DELETE CASCADE ;
51
+ ");
52
+ $installer->endSetup();
app/code/community/Belvg/Fullscreenzoom/etc/adminhtml.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FullscreenZoom
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <acl>
35
+ <resources>
36
+ <all>
37
+ <title>Allow Everything</title>
38
+ </all>
39
+ <admin>
40
+ <children>
41
+ <system>
42
+ <children>
43
+ <config>
44
+ <children>
45
+ <fullscreenzoom translate="title">
46
+ <title>Fullscreen zoom</title>
47
+ </fullscreenzoom>
48
+ </children>
49
+ </config>
50
+ </children>
51
+ </system>
52
+ </children>
53
+ </admin>
54
+ </resources>
55
+ </acl>
56
+ </config>
app/code/community/Belvg/Fullscreenzoom/etc/config.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FullscreenZoom
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <modules>
35
+ <Belvg_Fullscreenzoom>
36
+ <version>1.0.1</version>
37
+ </Belvg_Fullscreenzoom>
38
+ </modules>
39
+ <frontend>
40
+ <layout>
41
+ <updates>
42
+ <fullscreenzoom>
43
+ <file>fullscreenzoom.xml</file>
44
+ </fullscreenzoom>
45
+ </updates>
46
+ </layout>
47
+ </frontend>
48
+ </config>
app/code/community/Belvg/Fullscreenzoom/etc/system.xml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FullscreenZoom
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <sections>
35
+ <fullscreenzoom translate="label">
36
+ <label>Fullscreen zoom</label>
37
+ <tab>belvg</tab>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>1000</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <groups>
44
+ <settings translate="label">
45
+ <label>Settings</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>100</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <comment>
52
+ <![CDATA[
53
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
54
+ This module was developed by <a href="http://www.belvg.com" target="_blank">www.BelVG.com</a>.
55
+ For docs & examples refer to the BelVG <a href="http://www.belvg.com" target="_blank">web site</a>.
56
+ <br/>We have the largest selections of <a href="http://store.belvg.com/extensions.html" target="_blank">extensions</a> and <a href="http://store.belvg.com/themes.html" target="_blank">themes</a> on Magento.
57
+ </div>
58
+ ]]>
59
+ </comment>
60
+ <fields>
61
+ <enabled translate="label comment">
62
+ <label>Enabled</label>
63
+ <!-- <comment><![CDATA[]]></comment> -->
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
66
+ <sort_order>10</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
+ </enabled>
71
+ <logo translate="label comment">
72
+ <label>Show shop logo</label>
73
+ <!-- <comment><![CDATA[]]></comment> -->
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>adminhtml/system_config_source_yesno</source_model>
76
+ <sort_order>11</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </logo>
81
+ </fields>
82
+ </settings>
83
+ </groups>
84
+ </fullscreenzoom>
85
+ </sections>
86
+ </config>
app/code/community/Belvg/Twitter/Block/Adminhtml/Settings.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+ class Belvg_Twitter_Block_Adminhtml_Settings extends Mage_Adminhtml_Block_Widget_Form_Container
33
+ {
34
+ public function __construct()
35
+ {
36
+ parent::__construct();
37
+
38
+ $this->_objectId = 'id';
39
+ $this->_blockGroup = 'twitter';
40
+ $this->_controller = 'adminhtml_twitter';
41
+
42
+ $this->_updateButton('save', 'label', Mage::helper('twitter')->__('Save Item'));
43
+ $this->_updateButton('delete', 'label', Mage::helper('twitter')->__('Delete Item'));
44
+
45
+ $this->_formScripts[] = "
46
+ function toggleEditor() {
47
+ if (tinyMCE.getInstanceById('twitter_content') == null) {
48
+ tinyMCE.execCommand('mceAddControl', false, 'twitter_content');
49
+ } else {
50
+ tinyMCE.execCommand('mceRemoveControl', false, 'twitter_content');
51
+ }
52
+ }
53
+
54
+ function saveAndContinueEdit(){
55
+ editForm.submit($('edit_form').action+'back/edit/');
56
+ }
57
+ ";
58
+ }
59
+
60
+ public function getHeaderText()
61
+ {
62
+ if( Mage::registry('twitter_data') && Mage::registry('twitter_data')->getId() ) {
63
+ return Mage::helper('twitter')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('twitter_data')->getTitle()));
64
+ } else {
65
+ return Mage::helper('twitter')->__('Add Item');
66
+ }
67
+ }
68
+
69
+
70
+
71
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Settings/Tab/General.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Block_Adminhtml_Settings_Tab_General extends Mage_Adminhtml_Block_Widget_Form
34
+ {
35
+ protected function _prepareForm()
36
+ {
37
+ $form = new Varien_Data_Form();
38
+ $news_id = $this->getRequest()->getParam('id');
39
+ $fieldset = $form->addFieldset('general', array('legend'=>Mage::helper('core')->__('General Settings')));
40
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(
41
+ array('tab_id' => 'page_tabs')
42
+ );
43
+
44
+ $fieldset->addField('user_name', 'text', array(
45
+ 'label' => Mage::helper('core')->__('User Name'),
46
+ 'title' => Mage::helper('core')->__('User Name'),
47
+ 'name' => 'user_name',
48
+ 'width' => '50px',
49
+ 'required' => true,
50
+ ));
51
+ $fieldset->addField('title', 'text', array(
52
+ 'label' => Mage::helper('core')->__('Title'),
53
+ 'title' => Mage::helper('core')->__('Title'),
54
+ 'name' => 'title',
55
+ 'width' => '50px',
56
+ 'required' => true,
57
+ ));
58
+ $fieldset->addField('subject', 'text', array(
59
+ 'label' => Mage::helper('core')->__('Subject'),
60
+ 'title' => Mage::helper('core')->__('Subject'),
61
+ 'name' => 'subject',
62
+ 'width' => '50px',
63
+ 'required' => true,
64
+ ));
65
+ $fieldset->addField('width', 'text', array(
66
+ 'label' => Mage::helper('core')->__('Width'),
67
+ 'title' => Mage::helper('core')->__('Width'),
68
+ 'name' => 'width',
69
+ 'width' => '50px',
70
+ 'required' => true,
71
+ ));
72
+ $fieldset->addField('height', 'text', array(
73
+ 'label' => Mage::helper('core')->__('Height'),
74
+ 'title' => Mage::helper('core')->__('Height'),
75
+ 'name' => 'height',
76
+ 'width' => '50px',
77
+ 'required' => true,
78
+ ));
79
+ $fieldset->addField('shell_bg', 'text', array(
80
+ 'label' => Mage::helper('core')->__('Shell Background'),
81
+ 'title' => Mage::helper('core')->__('Shell Background'),
82
+ 'name' => 'shell_bg',
83
+ 'width' => '50px',
84
+ 'required' => true,
85
+ ));
86
+ $fieldset->addField('shell_color', 'text', array(
87
+ 'label' => Mage::helper('core')->__('Shell Color'),
88
+ 'title' => Mage::helper('core')->__('Shell Color'),
89
+ 'name' => 'shell_color',
90
+ 'width' => '50px',
91
+ 'required' => true,
92
+ ));
93
+ $fieldset->addField('tweets_bg', 'text', array(
94
+ 'label' => Mage::helper('core')->__('Tweets Background'),
95
+ 'title' => Mage::helper('core')->__('Tweets Background'),
96
+ 'name' => 'tweets_bg',
97
+ 'width' => '50px',
98
+ 'required' => true,
99
+ ));
100
+ $fieldset->addField('tweets_color', 'text', array(
101
+ 'label' => Mage::helper('core')->__('Tweets Color'),
102
+ 'title' => Mage::helper('core')->__('Tweets Color'),
103
+ 'name' => 'tweets_color',
104
+ 'width' => '50px',
105
+ 'required' => true,
106
+ ));
107
+ $fieldset->addField('tweets_link', 'text', array(
108
+ 'label' => Mage::helper('core')->__('Tweets Link'),
109
+ 'title' => Mage::helper('core')->__('Tweets Link'),
110
+ 'name' => 'tweets_link',
111
+ 'width' => '50px',
112
+ 'required' => true,
113
+ ));
114
+
115
+ $fieldset->addField('pages', 'multiselect', array(
116
+ 'name' => 'pages[]',
117
+ 'label' => Mage::helper('core')->__('Pages'),
118
+ 'title' => Mage::helper('core')->__('Pages'),
119
+ 'required' => true,
120
+ 'values' => $this->getCmsPages()
121
+ ));
122
+ $fieldset->addField('position', 'select', array(
123
+ 'label' => Mage::helper('twitter')->__('Position'),
124
+ 'name' => 'position',
125
+ 'values' => array(
126
+ array(
127
+ 'value' => 0,
128
+ 'label' => Mage::helper('twitter')->__('None'),
129
+ ),
130
+
131
+ array(
132
+ 'value' => 1,
133
+ 'label' => Mage::helper('twitter')->__('Left'),
134
+ ),
135
+
136
+ array(
137
+ 'value' => 2,
138
+ 'label' => Mage::helper('twitter')->__('Right'),
139
+ ),
140
+ ),
141
+ ));
142
+ $fieldset->addField('status', 'select', array(
143
+ 'label' => Mage::helper('twitter')->__('Status'),
144
+ 'name' => 'status',
145
+ 'values' => array(
146
+ array(
147
+ 'value' => 0,
148
+ 'label' => Mage::helper('twitter')->__('Enabled'),
149
+ ),
150
+
151
+ array(
152
+ 'value' => 1,
153
+ 'label' => Mage::helper('twitter')->__('Disabled'),
154
+ )
155
+ ),
156
+ ));
157
+
158
+ $formData = Mage::getModel('twitter/twitter')->getSettings();
159
+ $form->addValues($formData);
160
+ $form->setFieldNameSuffix('design');
161
+ $this->setForm($form);
162
+ }
163
+
164
+ protected function getCmsPages(){
165
+ $pages = array();
166
+ $collection = Mage::getModel('cms/page')->getCollection();
167
+ foreach ($collection as $_page){
168
+ $pages[] = array('value'=>$_page->getId(),'label'=>$_page->getTitle());
169
+ }
170
+ $pages[] = array('value'=>'777','label'=> 'Categories');
171
+ $pages[] = array('value'=>'555','label'=> 'Products');
172
+ return $pages;
173
+ }
174
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Settings/Tabs.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Block_Adminhtml_Settings_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
34
+ {
35
+
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setId('design_tabs');
40
+ $this->setDestElementId('design_edit_form');
41
+ $this->setTitle(Mage::helper('core')->__('Twitter Settings'));
42
+ }
43
+
44
+ protected function _prepareLayout()
45
+ {
46
+ $this->addTab('general', array(
47
+ 'label' => Mage::helper('core')->__('General'),
48
+ 'content' => $this->getLayout()->createBlock('twitter/adminhtml_settings_tab_general')->toHtml(),
49
+ ));
50
+
51
+
52
+ return parent::_prepareLayout();
53
+ }
54
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+ class Belvg_Twitter_Block_Adminhtml_Twitter extends Mage_Adminhtml_Block_Widget_Grid_Container
33
+ {
34
+ public function __construct()
35
+ {
36
+ $this->_controller = 'adminhtml_twitter';
37
+ $this->_blockGroup = 'twitter';
38
+ $this->_headerText = Mage::helper('twitter')->__('Item Manager');
39
+ $this->_addButtonLabel = Mage::helper('twitter')->__('Add Item');
40
+ parent::__construct();
41
+ }
42
+
43
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Block_Adminhtml_Twitter_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
34
+ {
35
+ public function __construct()
36
+ {
37
+ parent::__construct();
38
+
39
+ $this->_objectId = 'id';
40
+ $this->_blockGroup = 'twitter';
41
+ $this->_controller = 'adminhtml_twitter';
42
+
43
+ $this->_updateButton('save', 'label', Mage::helper('twitter')->__('Save Item'));
44
+ $this->_updateButton('delete', 'label', Mage::helper('twitter')->__('Delete Item'));
45
+
46
+ $this->_addButton('saveandcontinue', array(
47
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
48
+ 'onclick' => 'saveAndContinueEdit()',
49
+ 'class' => 'save',
50
+ ), -100);
51
+
52
+ $this->_formScripts[] = "
53
+ function toggleEditor() {
54
+ if (tinyMCE.getInstanceById('twitter_content') == null) {
55
+ tinyMCE.execCommand('mceAddControl', false, 'twitter_content');
56
+ } else {
57
+ tinyMCE.execCommand('mceRemoveControl', false, 'twitter_content');
58
+ }
59
+ }
60
+
61
+ function saveAndContinueEdit(){
62
+ editForm.submit($('edit_form').action+'back/edit/');
63
+ }
64
+ ";
65
+ }
66
+
67
+ public function getHeaderText()
68
+ {
69
+ if( Mage::registry('twitter_data') && Mage::registry('twitter_data')->getId() ) {
70
+ return Mage::helper('twitter')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('twitter_data')->getTitle()));
71
+ } else {
72
+ return Mage::helper('twitter')->__('Add Item');
73
+ }
74
+ }
75
+ protected function _toHtml(){
76
+ return Mage::app()->getLayout()->createBlock('adminhtml/store_switcher')->toHtml().parent::_toHtml();
77
+ }
78
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit/Form.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Block_Adminhtml_Twitter_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
34
+ {
35
+ protected function _prepareForm()
36
+ {
37
+ $form = new Varien_Data_Form(array(
38
+ 'id' => 'edit_form',
39
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
40
+ 'method' => 'post',
41
+ 'enctype' => 'multipart/form-data'
42
+ )
43
+ );
44
+
45
+ $form->setUseContainer(true);
46
+ $this->setForm($form);
47
+ return parent::_prepareForm();
48
+ }
49
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit/Tab/Form.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Block_Adminhtml_Twitter_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
34
+ {
35
+ protected function _prepareForm()
36
+ {
37
+ $form = new Varien_Data_Form();
38
+ $this->setForm($form);
39
+ $fieldset = $form->addFieldset('twitter_form', array('legend'=>Mage::helper('twitter')->__('Item information')));
40
+ $_store = 0;
41
+ if ($this->getRequest()->getParam('store')) $_store = $this->getRequest()->getParam('store');
42
+ $fieldset->addField('type', 'select', array(
43
+ 'label' => Mage::helper('core')->__('Type'),
44
+ 'title' => Mage::helper('core')->__('Type'),
45
+ 'name' => 'type',
46
+ 'values' => array(
47
+ array(
48
+ 'value' => 'faves',
49
+ 'label' => Mage::helper('twitter')->__('Favorites'),
50
+ ),
51
+
52
+ array(
53
+ 'value' => 'profile',
54
+ 'label' => Mage::helper('twitter')->__('Profile'),
55
+ )
56
+ ),
57
+ 'required' => true,
58
+ ));
59
+ $fieldset->addField('user_name', 'text', array(
60
+ 'label' => Mage::helper('core')->__('User Name'),
61
+ 'title' => Mage::helper('core')->__('User Name'),
62
+ 'name' => 'user_name',
63
+ 'width' => '50px',
64
+ 'required' => true,
65
+ ));
66
+ $fieldset->addField('store', 'hidden', array(
67
+ 'label' => Mage::helper('core')->__('Store'),
68
+ 'title' => Mage::helper('core')->__('Store'),
69
+ 'name' => 'store',
70
+ 'width' => '50px',
71
+ ));
72
+ $fieldset->addField('title', 'text', array(
73
+ 'label' => Mage::helper('core')->__('Title'),
74
+ 'title' => Mage::helper('core')->__('Title'),
75
+ 'name' => 'title',
76
+ 'width' => '50px',
77
+ 'required' => true,
78
+ ));
79
+ $fieldset->addField('subject', 'text', array(
80
+ 'label' => Mage::helper('core')->__('Subject'),
81
+ 'title' => Mage::helper('core')->__('Subject'),
82
+ 'name' => 'subject',
83
+ 'width' => '50px',
84
+ 'required' => true,
85
+ ));
86
+
87
+
88
+ $fieldset->addField('pages', 'multiselect', array(
89
+ 'name' => 'pages[]',
90
+ 'label' => Mage::helper('core')->__('Pages'),
91
+ 'title' => Mage::helper('core')->__('Pages'),
92
+ 'required' => true,
93
+ 'values' => $this->getCmsPages()
94
+ ));
95
+ $fieldset->addField('position', 'select', array(
96
+ 'label' => Mage::helper('twitter')->__('Position'),
97
+ 'name' => 'position',
98
+ 'values' => array(
99
+ array(
100
+ 'value' => 0,
101
+ 'label' => Mage::helper('twitter')->__('None'),
102
+ ),
103
+
104
+ array(
105
+ 'value' => 1,
106
+ 'label' => Mage::helper('twitter')->__('Left'),
107
+ ),
108
+
109
+ array(
110
+ 'value' => 2,
111
+ 'label' => Mage::helper('twitter')->__('Right'),
112
+ ),
113
+ array(
114
+ 'value' => 3,
115
+ 'label' => Mage::helper('twitter')->__('Content'),
116
+ ),
117
+
118
+ array(
119
+ 'value' => 5,
120
+ 'label' => Mage::helper('twitter')->__('Footer'),
121
+ ),
122
+ ),
123
+ ));
124
+ $fieldset->addField('status', 'select', array(
125
+ 'label' => Mage::helper('twitter')->__('Status'),
126
+ 'name' => 'status',
127
+ 'values' => array(
128
+ array(
129
+ 'value' => 0,
130
+ 'label' => Mage::helper('twitter')->__('Enabled'),
131
+ ),
132
+
133
+ array(
134
+ 'value' => 1,
135
+ 'label' => Mage::helper('twitter')->__('Disabled'),
136
+ )
137
+ ),
138
+ ));
139
+
140
+ $form->setFieldNameSuffix('design');
141
+ if ( Mage::getSingleton('adminhtml/session')->getTwitterData() )
142
+ {
143
+ $_data = Mage::getSingleton('adminhtml/session')->getTwitterData();
144
+ $_data['store'] = $_store;
145
+ $form->setValues($_data);
146
+ Mage::getSingleton('adminhtml/session')->setTwitterData(null);
147
+ } elseif ( Mage::registry('twitter_data') ) {
148
+ $_data = Mage::registry('twitter_data')->getData();
149
+ $_data['store'] = $_store;
150
+ $form->setValues($_data);
151
+ }
152
+ return parent::_prepareForm();
153
+ }
154
+
155
+ protected function getCmsPages(){
156
+ $pages = array();
157
+ $collection = Mage::getModel('cms/page')->getCollection();
158
+ foreach ($collection as $_page){
159
+ $pages[] = array('value'=>$_page->getId(),'label'=>$_page->getTitle());
160
+ }
161
+ $pages[] = array('value'=>'777','label'=> 'Categories');
162
+ $pages[] = array('value'=>'555','label'=> 'Products');
163
+ return $pages;
164
+ }
165
+
166
+
167
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit/Tab/Settings.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Block_Adminhtml_Twitter_Edit_Tab_Settings extends Mage_Adminhtml_Block_Widget_Form
34
+ {
35
+ protected function _prepareForm()
36
+ {
37
+ $form = new Varien_Data_Form();
38
+ $this->setForm($form);
39
+ $fieldset = $form->addFieldset('twitter_form', array('legend'=>Mage::helper('twitter')->__('Item information')));
40
+ $_store = 0;
41
+ if ($this->getRequest()->getParam('store')) $_store = $this->getRequest()->getParam('store');
42
+
43
+ $fieldset->addField('width', 'text', array(
44
+ 'label' => Mage::helper('core')->__('Width'),
45
+ 'title' => Mage::helper('core')->__('Width'),
46
+ 'name' => 'width',
47
+ 'width' => '50px',
48
+ 'required' => true,
49
+ ));
50
+ $fieldset->addField('height', 'text', array(
51
+ 'label' => Mage::helper('core')->__('Height'),
52
+ 'title' => Mage::helper('core')->__('Height'),
53
+ 'name' => 'height',
54
+ 'width' => '50px',
55
+ 'required' => true,
56
+ ));
57
+ $fieldset->addField('interval', 'text', array(
58
+ 'label' => Mage::helper('core')->__('Interval'),
59
+ 'title' => Mage::helper('core')->__('Interval'),
60
+ 'name' => 'interval',
61
+ 'width' => '50px',
62
+ 'required' => true,
63
+ ));
64
+ $fieldset->addField('timestamp', 'select', array(
65
+ 'label' => Mage::helper('core')->__('Show timestamp'),
66
+ 'title' => Mage::helper('core')->__('Show timestamp'),
67
+ 'name' => 'timestamp',
68
+ 'values' => array(
69
+ array(
70
+ 'value' => 'true',
71
+ 'label' => Mage::helper('twitter')->__('Yes'),
72
+ ),
73
+
74
+ array(
75
+ 'value' => 'false',
76
+ 'label' => Mage::helper('twitter')->__('No'),
77
+ )
78
+ ),
79
+ 'required' => true,
80
+ ));
81
+ $fieldset->addField('avatars', 'select', array(
82
+ 'label' => Mage::helper('core')->__('Show avatars'),
83
+ 'title' => Mage::helper('core')->__('Show avatars'),
84
+ 'name' => 'avatars',
85
+ 'values' => array(
86
+ array(
87
+ 'value' => 'true',
88
+ 'label' => Mage::helper('twitter')->__('Yes'),
89
+ ),
90
+
91
+ array(
92
+ 'value' => 'false',
93
+ 'label' => Mage::helper('twitter')->__('No'),
94
+ )
95
+ ),
96
+ 'required' => true,
97
+ ));
98
+ $fieldset->addField('hashtags', 'select', array(
99
+ 'label' => Mage::helper('core')->__('Show hashtags'),
100
+ 'title' => Mage::helper('core')->__('Show hashtags'),
101
+ 'name' => 'hashtags',
102
+ 'values' => array(
103
+ array(
104
+ 'value' => 'true',
105
+ 'label' => Mage::helper('twitter')->__('Yes'),
106
+ ),
107
+
108
+ array(
109
+ 'value' => 'false',
110
+ 'label' => Mage::helper('twitter')->__('No'),
111
+ )
112
+ ),
113
+ 'required' => true,
114
+ ));
115
+ $fieldset->addField('scrollbar', 'select', array(
116
+ 'label' => Mage::helper('core')->__('Show scrollbar'),
117
+ 'title' => Mage::helper('core')->__('Show scrollbar'),
118
+ 'name' => 'scrollbar',
119
+ 'values' => array(
120
+ array(
121
+ 'value' => 'true',
122
+ 'label' => Mage::helper('twitter')->__('Yes'),
123
+ ),
124
+
125
+ array(
126
+ 'value' => 'false',
127
+ 'label' => Mage::helper('twitter')->__('No'),
128
+ )
129
+ ),
130
+ 'required' => true,
131
+ ));
132
+ $fieldset->addField('shell_bg', 'text', array(
133
+ 'label' => Mage::helper('core')->__('Shell Background'),
134
+ 'title' => Mage::helper('core')->__('Shell Background'),
135
+ 'name' => 'shell_bg',
136
+ 'width' => '50px',
137
+ 'required' => true,
138
+ ));
139
+ $fieldset->addField('shell_color', 'text', array(
140
+ 'label' => Mage::helper('core')->__('Shell Color'),
141
+ 'title' => Mage::helper('core')->__('Shell Color'),
142
+ 'name' => 'shell_color',
143
+ 'width' => '50px',
144
+ 'required' => true,
145
+ ));
146
+ $fieldset->addField('tweets_bg', 'text', array(
147
+ 'label' => Mage::helper('core')->__('Tweets Background'),
148
+ 'title' => Mage::helper('core')->__('Tweets Background'),
149
+ 'name' => 'tweets_bg',
150
+ 'width' => '50px',
151
+ 'required' => true,
152
+ ));
153
+ $fieldset->addField('tweets_color', 'text', array(
154
+ 'label' => Mage::helper('core')->__('Tweets Color'),
155
+ 'title' => Mage::helper('core')->__('Tweets Color'),
156
+ 'name' => 'tweets_color',
157
+ 'width' => '50px',
158
+ 'required' => true,
159
+ ));
160
+ $fieldset->addField('tweets_link', 'text', array(
161
+ 'label' => Mage::helper('core')->__('Tweets Link'),
162
+ 'title' => Mage::helper('core')->__('Tweets Link'),
163
+ 'name' => 'tweets_link',
164
+ 'width' => '50px',
165
+ 'required' => true,
166
+ ));
167
+
168
+
169
+ $form->setFieldNameSuffix('design');
170
+ if ( Mage::getSingleton('adminhtml/session')->getTwitterData() )
171
+ {
172
+ $_data = Mage::getSingleton('adminhtml/session')->getTwitterData();
173
+ $_data['store'] = $_store;
174
+ $form->setValues($_data);
175
+ Mage::getSingleton('adminhtml/session')->setTwitterData(null);
176
+ } elseif ( Mage::registry('twitter_data') ) {
177
+ $_data = Mage::registry('twitter_data')->getData();
178
+ $_data['store'] = $_store;
179
+ $form->setValues($_data);
180
+ }
181
+ return parent::_prepareForm();
182
+ }
183
+
184
+ protected function getCmsPages(){
185
+ $pages = array();
186
+ $collection = Mage::getModel('cms/page')->getCollection();
187
+ foreach ($collection as $_page){
188
+ $pages[] = array('value'=>$_page->getId(),'label'=>$_page->getTitle());
189
+ }
190
+ $pages[] = array('value'=>'777','label'=> 'Categories');
191
+ $pages[] = array('value'=>'555','label'=> 'Products');
192
+ return $pages;
193
+ }
194
+
195
+
196
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Edit/Tabs.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Block_Adminhtml_Twitter_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
34
+ {
35
+
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setId('twitter_tabs');
40
+ $this->setDestElementId('edit_form');
41
+ $this->setTitle(Mage::helper('twitter')->__('Item Information'));
42
+ }
43
+
44
+ protected function _beforeToHtml()
45
+ {
46
+ $this->addTab('form_section', array(
47
+ 'label' => Mage::helper('twitter')->__('Item Information'),
48
+ 'title' => Mage::helper('twitter')->__('Item Information'),
49
+ 'content' => $this->getLayout()->createBlock('twitter/adminhtml_twitter_edit_tab_form')->toHtml(),
50
+ ));
51
+ $this->addTab('settings_section', array(
52
+ 'label' => Mage::helper('twitter')->__('Item Settings'),
53
+ 'title' => Mage::helper('twitter')->__('Item InforSettingsmation'),
54
+ 'content' => $this->getLayout()->createBlock('twitter/adminhtml_twitter_edit_tab_settings')->toHtml(),
55
+ ));
56
+
57
+ return parent::_beforeToHtml();
58
+ }
59
+ }
app/code/community/Belvg/Twitter/Block/Adminhtml/Twitter/Grid.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Block_Adminhtml_Twitter_Grid extends Mage_Adminhtml_Block_Widget_Grid
34
+ {
35
+ public function __construct()
36
+ {
37
+
38
+ parent::__construct();
39
+ $this->setId('twitterGrid');
40
+ $this->setDefaultSort('twitter_id');
41
+ $this->setDefaultDir('ASC');
42
+ $this->setSaveParametersInSession(true);
43
+ }
44
+
45
+ protected function _prepareCollection()
46
+ {
47
+ $collection = Mage::getModel('twitter/twitter')->getCollection();
48
+ $this->setCollection($collection);
49
+ return parent::_prepareCollection();
50
+ }
51
+
52
+ protected function _prepareColumns()
53
+ {
54
+ $this->addColumn('twitter_id', array(
55
+ 'header' => Mage::helper('twitter')->__('ID'),
56
+ 'align' =>'right',
57
+ 'width' => '50px',
58
+ 'index' => 'twitter_id',
59
+ ));
60
+
61
+ $this->addColumn('title', array(
62
+ 'header' => Mage::helper('twitter')->__('Title'),
63
+ 'align' =>'left',
64
+ 'index' => 'title',
65
+ ));
66
+
67
+ /*
68
+ $this->addColumn('content', array(
69
+ 'header' => Mage::helper('twitter')->__('Item Content'),
70
+ 'width' => '150px',
71
+ 'index' => 'content',
72
+ ));
73
+ */
74
+
75
+ $this->addColumn('status', array(
76
+ 'header' => Mage::helper('twitter')->__('Status'),
77
+ 'align' => 'left',
78
+ 'width' => '80px',
79
+ 'index' => 'status',
80
+ 'type' => 'options',
81
+ 'options' => array(
82
+ 0 => 'Enabled',
83
+ 1 => 'Disabled',
84
+ ),
85
+ ));
86
+
87
+ $this->addColumn('action',
88
+ array(
89
+ 'header' => Mage::helper('twitter')->__('Action'),
90
+ 'width' => '100',
91
+ 'type' => 'action',
92
+ 'getter' => 'getId',
93
+ 'actions' => array(
94
+ array(
95
+ 'caption' => Mage::helper('twitter')->__('Edit'),
96
+ 'url' => array('base'=> '*/*/edit/'),
97
+ 'field' => 'id'
98
+ )
99
+ ),
100
+ 'filter' => false,
101
+ 'sortable' => false,
102
+ 'index' => 'stores',
103
+ 'is_system' => true,
104
+ ));
105
+
106
+ $this->addExportType('*/*/exportCsv', Mage::helper('twitter')->__('CSV'));
107
+ $this->addExportType('*/*/exportXml', Mage::helper('twitter')->__('XML'));
108
+
109
+ return parent::_prepareColumns();
110
+ }
111
+
112
+ protected function _prepareMassaction()
113
+ {
114
+ $this->setMassactionIdField('twitter_id');
115
+ $this->getMassactionBlock()->setFormFieldName('twitter');
116
+
117
+ $this->getMassactionBlock()->addItem('delete', array(
118
+ 'label' => Mage::helper('twitter')->__('Delete'),
119
+ 'url' => $this->getUrl('*/*/massDelete'),
120
+ 'confirm' => Mage::helper('twitter')->__('Are you sure?')
121
+ ));
122
+
123
+ $statuses = Mage::getSingleton('twitter/status')->getOptionArray();
124
+
125
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
126
+ $this->getMassactionBlock()->addItem('status', array(
127
+ 'label'=> Mage::helper('twitter')->__('Change status'),
128
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
129
+ 'additional' => array(
130
+ 'visibility' => array(
131
+ 'name' => 'status',
132
+ 'type' => 'select',
133
+ 'class' => 'required-entry',
134
+ 'label' => Mage::helper('twitter')->__('Status'),
135
+ 'values' => $statuses
136
+ )
137
+ )
138
+ ));
139
+ return $this;
140
+ }
141
+
142
+ public function getRowUrl($row)
143
+ {
144
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
145
+ }
146
+
147
+
148
+ }
app/code/community/Belvg/Twitter/Block/Twitter.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+ class Belvg_Twitter_Block_Twitter extends Mage_Core_Block_Template
33
+ {
34
+ public function _prepareLayout()
35
+ {
36
+ return parent::_prepareLayout();
37
+ }
38
+
39
+ public function getTwitter()
40
+ {
41
+ if (!$this->hasData('twitter')) {
42
+ $this->setData('twitter', Mage::registry('twitter'));
43
+ }
44
+ return $this->getData('twitter');
45
+
46
+ }
47
+
48
+ public function getSettings(){
49
+ $result = array();
50
+ $page_id = $this->checkType(Mage::app()->getRequest());
51
+ $_data = Mage::getModel('twitter/twitter')->getSettings();
52
+
53
+ foreach ($_data as $dt){
54
+ if (in_array($page_id, $dt['pages']) and $this->isEnabled($dt) and $this->inStore($dt))
55
+ $result[] = $dt;
56
+ }
57
+ return $result;
58
+
59
+ }
60
+ protected function checkType($request){
61
+ $type = 1;
62
+ if ($request->getModuleName() == 'catalog'){
63
+ switch ($request->getControllerName()){
64
+ case 'category': $type = 777; break;
65
+ case 'product': $type = 555; break;
66
+ default: break;
67
+ }
68
+ }elseif($request->getModuleName() == 'cms'){
69
+
70
+ if ($request->getParams('page_id'))
71
+ $type = $request->getParam('page_id');
72
+ if ($request->getControllerName() == 'index' && $request->getActionName() == 'index')
73
+ $type = 2;
74
+ }
75
+ return $type;
76
+ }
77
+ protected function isEnabled($data){
78
+ if ($data['status'] == 0)
79
+ return true;
80
+ else
81
+ return false;
82
+ }
83
+
84
+ protected function inStore($data){
85
+ if ($data['store'] == Mage::app()->getStore()->getId() or $data['store'] == 0) return true;
86
+ return false;
87
+ }
88
+ }
app/code/community/Belvg/Twitter/Block/Twitterbtn.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+ class Belvg_Twitter_Block_Twitterbtn extends Mage_Core_Block_Template
33
+ {
34
+ public function getEnabled(){
35
+ if (Mage::getStoreConfig('twitter/tweetbtn/enabled') == 0)
36
+ return false;
37
+ return true;
38
+
39
+ }
40
+
41
+ public function getDataCount(){
42
+ return Mage::getStoreConfig('twitter/tweetbtn/type');
43
+ }
44
+
45
+
46
+ public function getDataVia(){
47
+ if (Mage::getStoreConfig('twitter/tweetbtn/recommend') != '')
48
+ return ' data-via="'.Mage::getStoreConfig('twitter/tweetbtn/recommend').'"';
49
+ return '';
50
+ }
51
+
52
+ public function getDataText(){
53
+ if (Mage::getStoreConfig('twitter/tweetbtn/ttext') != '')
54
+ return ' data-text="'.Mage::getStoreConfig('twitter/tweetbtn/ttext').'"';
55
+ return '';
56
+ }
57
+
58
+ public function getDataLang(){
59
+ return Mage::getStoreConfig('twitter/tweetbtn/lang');
60
+ }
61
+ }
app/code/community/Belvg/Twitter/Helper/Data.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Helper_Data extends Mage_Core_Helper_Abstract
34
+ {
35
+
36
+ }
app/code/community/Belvg/Twitter/Model/Ipad.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Model_Ipad extends Mage_Core_Model_Abstract
34
+ {
35
+ public function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_init('twitter/ipad');
39
+ }
40
+ }
app/code/community/Belvg/Twitter/Model/Main.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Model_Main extends Mage_Core_Model_Abstract
34
+ {
35
+ protected $_table = 'belvg_twitter_settings';
36
+
37
+ public function _construct()
38
+ {
39
+ parent::_construct();
40
+ }
41
+
42
+ public function getSettings(){
43
+
44
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
45
+ $result = $oDb->query("SELECT * FROM ".$this->_table);
46
+ $arr = array();
47
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)){
48
+ $row['pages'] = explode(",",$row['pages']);
49
+ $arr[] = $row;
50
+ }
51
+ return $arr;
52
+ }
53
+
54
+ public function saveSettings($aDBInfo){
55
+ $aDBInfo['pages'] = implode(",",$aDBInfo['pages']);
56
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
57
+ if (Mage::app()->getRequest()->getParam('id'))
58
+ $resu = $oDb->update($this->_table,$aDBInfo,array('twitter_id = '.Mage::app()->getRequest()->getParam('id')));
59
+ else $oDb->insert($this->_table,$aDBInfo);
60
+ return $resu;
61
+ }
62
+
63
+
64
+ public function checkExist($id){
65
+ $_table = 'belvg_twitter_users';
66
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
67
+ $result = $oDb->query("SELECT * FROM ".$_table." WHERE twitter_id = ".$id);
68
+ $return = false;
69
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)){
70
+ $return = true;
71
+ }
72
+ return $return;
73
+ }
74
+
75
+ public function addTwitterAccount($uid,$tid){
76
+ $_table = 'belvg_twitter_users';
77
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
78
+ $aDBInfo = array(
79
+ 'twitter_id' => $tid,
80
+ 'user_id' => $uid,
81
+ );
82
+ $oDb->insert($_table,$aDBInfo);
83
+ }
84
+
85
+
86
+ public function getTwitterRel($id){
87
+ $_table = 'belvg_twitter_users';
88
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
89
+ $result = $oDb->query("SELECT * FROM ".$_table." WHERE twitter_id = ".$id);
90
+ $return = array();
91
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)){
92
+ $return = $row;
93
+ }
94
+ return $return;
95
+ }
96
+
97
+
98
+
99
+ }
app/code/community/Belvg/Twitter/Model/Mysql4/Twitter.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Model_Mysql4_Twitter extends Mage_Core_Model_Mysql4_Abstract
34
+ {
35
+ public function _construct()
36
+ {
37
+ // Note that the twitter_id refers to the key field in your database table.
38
+ $this->_init('twitter/twitter', 'twitter_id');
39
+ }
40
+ }
app/code/community/Belvg/Twitter/Model/Mysql4/Twitter/Collection.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Model_Mysql4_Twitter_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
34
+ {
35
+ public function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_init('twitter/twitter');
39
+ }
40
+ }
app/code/community/Belvg/Twitter/Model/Source/Btntype.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Model_Source_Btntype extends Mage_Core_Model_Abstract
34
+ {
35
+ public function toOptionArray()
36
+ {
37
+ return array(
38
+ array('value'=>'vertical', 'label'=>Mage::helper('twitter')->__('Vertical count')),
39
+ array('value'=>'horizontal', 'label'=>Mage::helper('twitter')->__('Horizontal count')),
40
+ array('value'=>'none', 'label'=>Mage::helper('twitter')->__('No count'))
41
+ );
42
+ }
43
+ }
app/code/community/Belvg/Twitter/Model/Source/Langtype.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Model_Source_Langtype extends Mage_Core_Model_Abstract
34
+ {
35
+ public function toOptionArray()
36
+ {
37
+ return array(
38
+ array('value'=>'en', 'label'=>Mage::helper('twitter')->__('English')),
39
+ array('value'=>'fr', 'label'=>Mage::helper('twitter')->__('French')),
40
+ array('value'=>'de', 'label'=>Mage::helper('twitter')->__('German')),
41
+ array('value'=>'it', 'label'=>Mage::helper('twitter')->__('Italian')),
42
+ array('value'=>'es', 'label'=>Mage::helper('twitter')->__('Spanish')),
43
+ array('value'=>'ko', 'label'=>Mage::helper('twitter')->__('Korean')),
44
+ array('value'=>'ja', 'label'=>Mage::helper('twitter')->__('Japanese'))
45
+ );
46
+ }
47
+ }
app/code/community/Belvg/Twitter/Model/Status.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Model_Status extends Varien_Object
34
+ {
35
+ const STATUS_ENABLED = 1;
36
+ const STATUS_DISABLED = 2;
37
+
38
+ static public function getOptionArray()
39
+ {
40
+ return array(
41
+ self::STATUS_ENABLED => Mage::helper('twitter')->__('Enabled'),
42
+ self::STATUS_DISABLED => Mage::helper('twitter')->__('Disabled')
43
+ );
44
+ }
45
+ }
app/code/community/Belvg/Twitter/Model/Twitter.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_Model_Twitter extends Mage_Core_Model_Abstract
34
+ {
35
+ protected $_table = 'belvg_twitter_settings';
36
+
37
+ public function _construct()
38
+ {
39
+ parent::_construct();
40
+ $this->_init('twitter/twitter');
41
+ }
42
+
43
+ public function getSettings(){
44
+
45
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
46
+ $result = $oDb->query("SELECT * FROM ".$this->_table);
47
+ $arr = array();
48
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)){
49
+ $row['pages'] = explode(",",$row['pages']);
50
+ $arr[] = $row;
51
+ }
52
+ return $arr;
53
+ }
54
+
55
+ public function saveSettings($aDBInfo){
56
+ $aDBInfo['pages'] = implode(",",$aDBInfo['pages']);
57
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
58
+ if (Mage::app()->getRequest()->getParam('id'))
59
+ $resu = $oDb->update($this->_table,$aDBInfo,array('twitter_id = '.Mage::app()->getRequest()->getParam('id')));
60
+ else $oDb->insert($this->_table,$aDBInfo);
61
+ return $resu;
62
+ }
63
+
64
+
65
+ public function checkExist($id){
66
+ $_table = 'belvg_twitter_users';
67
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
68
+ $result = $oDb->query("SELECT * FROM ".$_table." WHERE twitter_id = ".$id);
69
+ $return = false;
70
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)){
71
+ $return = true;
72
+ }
73
+ return $return;
74
+ }
75
+
76
+ public function addTwitterAccount($uid,$tid){
77
+ $_table = 'belvg_twitter_users';
78
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
79
+ $aDBInfo = array(
80
+ 'twitter_id' => $tid,
81
+ 'user_id' => $uid,
82
+ );
83
+ $oDb->insert($_table,$aDBInfo);
84
+ }
85
+
86
+
87
+ public function getTwitterRel($id){
88
+ $_table = 'belvg_twitter_users';
89
+ $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
90
+ $result = $oDb->query("SELECT * FROM ".$_table." WHERE twitter_id = ".$id);
91
+ $return = array();
92
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)){
93
+ $return = $row;
94
+ }
95
+ return $return;
96
+ }
97
+
98
+
99
+
100
+ }
app/code/community/Belvg/Twitter/controllers/AdminController.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ class Belvg_Twitter_AdminController extends Mage_Adminhtml_Controller_action
34
+ {
35
+
36
+ protected function _initAction() {
37
+ $this->loadLayout()
38
+ ->_setActiveMenu('twitter/items')
39
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
40
+
41
+ return $this;
42
+ }
43
+
44
+ public function indexAction() {
45
+ $this->_initAction()
46
+ ->renderLayout();
47
+ }
48
+
49
+ public function settingsAction() {
50
+ $this->loadLayout();
51
+ $this->_setActiveMenu('twitter/items');
52
+
53
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
54
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
55
+
56
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
57
+
58
+ $this->_addContent($this->getLayout()->createBlock('twitter/adminhtml_twitter_edit'))
59
+ ->_addLeft($this->getLayout()->createBlock('twitter/adminhtml_twitter_edit_tabs'));
60
+
61
+ $this->renderLayout();
62
+ }
63
+
64
+ public function settings_saveAction() {
65
+ $data = $this->getRequest()->getParam('design');
66
+ try {
67
+ $result = Mage::getModel('twitter/twitter')->saveSettings($data);
68
+ if ($result) Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('twitter')->__('Settings successfully saved'));
69
+ }catch(Exception $e){
70
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('twitter')->__('Item does not exist'));
71
+ }
72
+ $this->_redirect('*/admin/settings/');
73
+ }
74
+
75
+ public function editAction() {
76
+ $id = $this->getRequest()->getParam('id');
77
+ $model = Mage::getModel('twitter/twitter')->load($id);
78
+
79
+ if ($model->getId() || $id == 0) {
80
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
81
+ if (!empty($data)) {
82
+ $model->setData($data);
83
+ }
84
+
85
+ Mage::register('twitter_data', $model);
86
+
87
+ $this->loadLayout();
88
+ $this->_setActiveMenu('twitter/items');
89
+
90
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
91
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
92
+
93
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
94
+
95
+ $this->_addContent($this->getLayout()->createBlock('twitter/adminhtml_twitter_edit'))
96
+ ->_addLeft($this->getLayout()->createBlock('twitter/adminhtml_twitter_edit_tabs'));
97
+
98
+ $this->renderLayout();
99
+ } else {
100
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('twitter')->__('Item does not exist'));
101
+ $this->_redirect('*/*/');
102
+ }
103
+ }
104
+
105
+ public function newAction() {
106
+ $this->_forward('edit');
107
+ }
108
+
109
+ public function saveAction() {
110
+ $data = $this->getRequest()->getParam('design');
111
+ try {
112
+ $result = Mage::getModel('twitter/twitter')->saveSettings($data);
113
+ if ($result) Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('twitter')->__('Settings successfully saved'));
114
+ }catch(Exception $e){
115
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('twitter')->__('Item does not exist'));
116
+ }
117
+ $this->_redirect('*/*/');
118
+ }
119
+
120
+
121
+ public function deleteAction() {
122
+ if( $this->getRequest()->getParam('id') > 0 ) {
123
+ try {
124
+ $model = Mage::getModel('twitter/twitter');
125
+
126
+ $model->setId($this->getRequest()->getParam('id'))
127
+ ->delete();
128
+
129
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
130
+ $this->_redirect('*/*/');
131
+ } catch (Exception $e) {
132
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
133
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
134
+ }
135
+ }
136
+ $this->_redirect('*/*/');
137
+ }
138
+
139
+ public function massDeleteAction() {
140
+ $twitterIds = $this->getRequest()->getParam('twitter');
141
+ if(!is_array($twitterIds)) {
142
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
143
+ } else {
144
+ try {
145
+ foreach ($twitterIds as $twitterId) {
146
+ $twitter = Mage::getModel('twitter/twitter')->load($twitterId);
147
+ $twitter->delete();
148
+ }
149
+ Mage::getSingleton('adminhtml/session')->addSuccess(
150
+ Mage::helper('adminhtml')->__(
151
+ 'Total of %d record(s) were successfully deleted', count($twitterIds)
152
+ )
153
+ );
154
+ } catch (Exception $e) {
155
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
156
+ }
157
+ }
158
+ $this->_redirect('*/*/index');
159
+ }
160
+
161
+ public function massStatusAction()
162
+ {
163
+ $twitterIds = $this->getRequest()->getParam('twitter');
164
+ if(!is_array($twitterIds)) {
165
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
166
+ } else {
167
+ try {
168
+ foreach ($twitterIds as $twitterId) {
169
+ $twitter = Mage::getSingleton('twitter/twitter')
170
+ ->load($twitterId)
171
+ ->setStatus($this->getRequest()->getParam('status'))
172
+ ->setIsMassupdate(true)
173
+ ->save();
174
+ }
175
+ $this->_getSession()->addSuccess(
176
+ $this->__('Total of %d record(s) were successfully updated', count($twitterIds))
177
+ );
178
+ } catch (Exception $e) {
179
+ $this->_getSession()->addError($e->getMessage());
180
+ }
181
+ }
182
+ $this->_redirect('*/*/index');
183
+ }
184
+
185
+ public function exportCsvAction()
186
+ {
187
+ $fileName = 'twitter.csv';
188
+ $content = $this->getLayout()->createBlock('twitter/adminhtml_twitter_grid')
189
+ ->getCsv();
190
+
191
+ $this->_sendUploadResponse($fileName, $content);
192
+ }
193
+
194
+ public function exportXmlAction()
195
+ {
196
+ $fileName = 'twitter.xml';
197
+ $content = $this->getLayout()->createBlock('twitter/adminhtml_twitter_grid')
198
+ ->getXml();
199
+
200
+ $this->_sendUploadResponse($fileName, $content);
201
+ }
202
+
203
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
204
+ {
205
+ $response = $this->getResponse();
206
+ $response->setHeader('HTTP/1.1 200 OK','');
207
+ $response->setHeader('Pragma', 'public', true);
208
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
209
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
210
+ $response->setHeader('Last-Modified', date('r'));
211
+ $response->setHeader('Accept-Ranges', 'bytes');
212
+ $response->setHeader('Content-Length', strlen($content));
213
+ $response->setHeader('Content-type', $contentType);
214
+ $response->setBody($content);
215
+ $response->sendResponse();
216
+ die;
217
+ }
218
+ }
app/code/community/Belvg/Twitter/controllers/IndexController.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+ class Belvg_Twitter_IndexController extends Mage_Core_Controller_Front_Action
33
+ {
34
+ public function indexAction(){
35
+ $this->loadLayout();
36
+ $this->renderLayout();
37
+ }
38
+ public function ipadAction(){
39
+ $this->loadLayout();
40
+ $this->getLayout()->getBlock('root')->setTemplate('page/ipad.phtml');
41
+ $ipadBlock = $this->getLayout()->createBlock('twitter/ipad')->setTemplate('twitter/ipad.phtml');
42
+ $this->getLayout()->getBlock('content')->append($ipadBlock);
43
+ $this->renderLayout();
44
+ }
45
+ }
app/code/community/Belvg/Twitter/controllers/UserController.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+
34
+
35
+
36
+ class Belvg_Twitter_UserController extends Mage_Core_Controller_Front_Action
37
+ {
38
+
39
+ private $consumer_key;
40
+ private $consumer_secret;
41
+ private $oauth_callback;
42
+
43
+ public function _init(){
44
+ $this->consumer_secret = Mage::getStoreConfig('twitter/userauth/conssecret');
45
+ $this->consumer_key = Mage::getStoreConfig('twitter/userauth/conskey');
46
+ $this->oauth_callback = Mage::getStoreConfig('twitter/userauth/oauthcallback');
47
+ require_once(getcwd().'/lib/twitteroauth/twitteroauth.php');
48
+ }
49
+
50
+ public function indexAction(){
51
+ $this->loadLayout();
52
+ $this->renderLayout();
53
+ }
54
+
55
+ public function loginAction(){
56
+ $this->_init();
57
+ if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
58
+ $this->_redirect('*/*/clearsession/');
59
+ }
60
+ /* Get user access tokens out of the session. */
61
+ $access_token = $_SESSION['access_token'];
62
+
63
+ /* Create a TwitterOauth object with consumer/user tokens. */
64
+ $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $access_token['oauth_token'], $access_token['oauth_token_secret']);
65
+
66
+ /* If method is set change API call made. Test is called by default. */
67
+ $content = $connection->get('account/verify_credentials');
68
+ if ($content->id){
69
+ $this->userLog($content);
70
+ echo '<script>window.opener.location.href=window.opener.location .href;
71
+ window.opener.focus();
72
+ window.close();</script>';
73
+ }
74
+
75
+ }
76
+
77
+ public function clearsessionAction(){
78
+ //unset($_SESSION['access_token']);
79
+ $this->_redirect('*/*/connect/');
80
+ }
81
+
82
+ public function connectAction(){
83
+ $this->_init();
84
+ if ($this->consumer_key === '' || $this->consumer_secret === '') {
85
+ echo 'You need a consumer key and secret to test the sample code. Get one from <a href="https://twitter.com/apps">https://twitter.com/apps</a>';
86
+ exit;
87
+ }
88
+
89
+ $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret);
90
+
91
+ /* Get temporary credentials. */
92
+ $request_token = $connection->getRequestToken();
93
+ /* Save temporary credentials to session. */
94
+ $_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
95
+ $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
96
+
97
+ /* If last connection failed don't display authorization link. */
98
+ switch ($connection->http_code) {
99
+ case 200:
100
+ /* Build authorize URL and redirect user to Twitter. */
101
+ $url = $connection->getAuthorizeURL($token);
102
+ $this->_redirectUrl($url);
103
+ break;
104
+ default:
105
+ /* Show notification if something went wrong. */
106
+ echo 'Could not connect to Twitter. Refresh the page or try again later.';
107
+ }
108
+ }
109
+
110
+ public function callbackAction(){
111
+ $this->_init();
112
+ /* If the oauth_token is old redirect to the connect page. */
113
+ if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) {
114
+ $_SESSION['oauth_status'] = 'oldtoken';
115
+ $this->_redirect('*/*/clearsession/');
116
+ }
117
+
118
+ /* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
119
+ $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
120
+
121
+ /* Request access tokens from twitter */
122
+ $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
123
+
124
+ /* Save the access tokens. Normally these would be saved in a database for future use. */
125
+ $_SESSION['access_token'] = $access_token;
126
+
127
+ /* Remove no longer needed request tokens */
128
+ unset($_SESSION['oauth_token']);
129
+ unset($_SESSION['oauth_token_secret']);
130
+
131
+ /* If HTTP response is 200 continue otherwise send to connect page to retry */
132
+ if (200 == $connection->http_code) {
133
+ /* The user has been verified and the access tokens can be saved for future use */
134
+ $_SESSION['status'] = 'verified';
135
+ $this->_redirect('*/*/login/');
136
+ } else {
137
+ /* Save HTTP status for error dialog on connnect page.*/
138
+ $this->_redirect('*/*/clearsession/');
139
+ }
140
+ }
141
+
142
+ private function userLog($_data){
143
+ $result = Mage::getModel('twitter/main')->checkExist($_data->id);
144
+ if (!$result)
145
+ $this->createTwitterUser($_data);
146
+ else
147
+ $this->loginTwitterUser($_data);
148
+
149
+ }
150
+
151
+ private function createTwitterUser($_data){
152
+ $customer = Mage::getModel('customer/customer');
153
+ $password = '';
154
+ $email = $_data->screen_name;
155
+
156
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
157
+ $customer->setEmail($email);
158
+ $customer->setFirstname($_data->name);
159
+ $customer->setLastname('');
160
+ $customer->setPassword($password);
161
+ try {
162
+ $customer->save();
163
+ $customer->setConfirmation(null);
164
+ $customer->save();
165
+ Mage::getModel('twitter/main')->addTwitterAccount($customer->getId(),$_data->id);
166
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
167
+ }
168
+ catch (Exception $ex) {
169
+ echo $ex->getMessage();die;
170
+ }
171
+ }
172
+
173
+ private function loginTwitterUser($_data){
174
+ $rel = Mage::getModel('twitter/main')->getTwitterRel($_data->id);
175
+ if ($rel['user_id'])
176
+ Mage::getSingleton('customer/session')->loginById($rel['user_id']);
177
+ else
178
+ $this->createTwitterUser ($_data);
179
+ }
180
+
181
+ }
app/code/community/Belvg/Twitter/etc/adminhtml.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_Twitterconnect
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+
34
+ <config>
35
+ <acl>
36
+ <resources>
37
+ <all>
38
+ <title>Allow Everything</title>
39
+ </all>
40
+ <admin>
41
+ <children>
42
+ <system>
43
+ <children>
44
+ <config>
45
+ <children>
46
+ <twitter translate="title">
47
+ <title>Twitter</title>
48
+ </twitter>
49
+ </children>
50
+ </config>
51
+ </children>
52
+ </system>
53
+ </children>
54
+ </admin>
55
+ </resources>
56
+ </acl>
57
+ </config>
app/code/community/Belvg/Twitter/etc/config.xml ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_Twitterconnect
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */-->
32
+ <config>
33
+ <modules>
34
+ <Belvg_Twitter>
35
+ <version>1.1.7</version>
36
+ </Belvg_Twitter>
37
+ </modules>
38
+ <frontend>
39
+ <routers>
40
+ <twitter>
41
+ <use>standard</use>
42
+ <args>
43
+ <module>Belvg_Twitter</module>
44
+ <frontName>twitter</frontName>
45
+ </args>
46
+ </twitter>
47
+ </routers>
48
+ <layout>
49
+ <updates>
50
+ <twitter>
51
+ <file>FB-Twitter-Connect.xml</file>
52
+ </twitter>
53
+ </updates>
54
+ </layout>
55
+ </frontend>
56
+ <admin>
57
+ <routers>
58
+ <twitter>
59
+ <use>admin</use>
60
+ <args>
61
+ <module>Belvg_Twitter</module>
62
+ <frontName>twitter</frontName>
63
+ </args>
64
+ </twitter>
65
+ </routers>
66
+ </admin>
67
+ <adminhtml>
68
+ <layout>
69
+ <updates>
70
+ <twitter>
71
+ <file>twitter.xml</file>
72
+ </twitter>
73
+ </updates>
74
+ </layout>
75
+ <menu>
76
+ <cms translate="title" module="cms">
77
+ <children>
78
+ <twitter translate="title">
79
+ <title>Twitter</title>
80
+ <children>
81
+ <twitter_tweets translate="title">
82
+ <title>Accounts</title>
83
+ <action>twitter/admin/index</action>
84
+ <sort_order>100</sort_order>
85
+ </twitter_tweets>
86
+ </children>
87
+
88
+ </twitter>
89
+ </children>
90
+ </cms>
91
+
92
+ </menu>
93
+ <acl>
94
+ <resources>
95
+ <all>
96
+ <title>Allow Everything</title>
97
+ </all>
98
+ <admin>
99
+ <children>
100
+ <twitter>
101
+ <title>Twitter Module</title>
102
+ <sort_order>200</sort_order>
103
+ </twitter>
104
+ </children>
105
+ </admin>
106
+ </resources>
107
+ </acl>
108
+ </adminhtml>
109
+ <global>
110
+ <rewrite>
111
+ <twitter_index_ipad>
112
+ <from><![CDATA[#^/ipad/#]]></from>
113
+ <to>/twitter/index/ipad/</to>
114
+ </twitter_index_ipad>
115
+ <twitter_admin>
116
+ <from><![CDATA[#^/twitter_admin/#]]></from>
117
+ <to>/twitter/admin/</to>
118
+ </twitter_admin>
119
+ <twitter_index_ipad>
120
+ <from><![CDATA[#^/ipad#]]></from>
121
+ <to>/twitter/index/ipad/</to>
122
+ </twitter_index_ipad>
123
+ </rewrite>
124
+ <models>
125
+ <twitter>
126
+ <class>Belvg_Twitter_Model</class>
127
+ <resourceModel>twitter_mysql4</resourceModel>
128
+ </twitter>
129
+ <twitter_mysql4>
130
+ <class>Belvg_Twitter_Model_Mysql4</class>
131
+ <entities>
132
+ <twitter>
133
+ <table>belvg_twitter_settings</table>
134
+ </twitter>
135
+ </entities>
136
+ </twitter_mysql4>
137
+ </models>
138
+ <resources>
139
+ <twitter_setup>
140
+ <setup>
141
+ <module>Belvg_Twitter</module>
142
+ </setup>
143
+ <connection>
144
+ <use>core_setup</use>
145
+ </connection>
146
+ </twitter_setup>
147
+ <twitter_write>
148
+ <connection>
149
+ <use>core_write</use>
150
+ </connection>
151
+ </twitter_write>
152
+ <twitter_read>
153
+ <connection>
154
+ <use>core_read</use>
155
+ </connection>
156
+ </twitter_read>
157
+ </resources>
158
+ <blocks>
159
+ <twitter>
160
+ <class>Belvg_Twitter_Block</class>
161
+ </twitter>
162
+ </blocks>
163
+ <helpers>
164
+ <twitter>
165
+ <class>Belvg_Twitter_Helper</class>
166
+ </twitter>
167
+ </helpers>
168
+ </global>
169
+ </config>
app/code/community/Belvg/Twitter/etc/system.xml ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_Twitterconnect
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */-->
32
+
33
+ <config>
34
+ <sections>
35
+ <twitter translate="label">
36
+ <label>Twitter</label>
37
+ <tab>belvg</tab>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>1000</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <groups>
44
+ <settings translate="label">
45
+ <label>Settings</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>100</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <comment>
52
+ <![CDATA[
53
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
54
+ This module was developed by <a href="http://www.belvg.com" target="_blank">www.BelVG.com</a>.
55
+ For docs & examples refer to the BelVG <a href="http://www.belvg.com" target="_blank">web site</a>.
56
+ <br/>We have the largest selections of <a href="http://store.belvg.com/extensions.html" target="_blank">extensions</a> and <a href="http://store.belvg.com/themes.html" target="_blank">themes</a> on Magento.
57
+ </div>
58
+ ]]>
59
+ </comment>
60
+ <fields>
61
+ <enabled translate="label comment">
62
+ <label>Enabled</label>
63
+ <!-- <comment><![CDATA[]]></comment> -->
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
66
+ <sort_order>10</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
+ </enabled>
71
+ </fields>
72
+ </settings>
73
+ <tweetbtn translate="label">
74
+ <label>Tweet Button Settings</label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>110</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ <comment>
81
+ <![CDATA[
82
+ ]]>
83
+ </comment>
84
+ <fields>
85
+ <enabled translate="label comment">
86
+ <label>Enabled</label>
87
+ <!-- <comment><![CDATA[]]></comment> -->
88
+ <frontend_type>select</frontend_type>
89
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
90
+ <sort_order>9</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>1</show_in_store>
94
+ </enabled>
95
+ <type translate="label comment">
96
+ <label>Button type</label>
97
+ <!-- <comment><![CDATA[]]></comment> -->
98
+ <frontend_type>select</frontend_type>
99
+ <source_model>twitter/source_btntype</source_model>
100
+ <sort_order>10</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </type>
105
+ <recommend translate="label comment">
106
+ <label>Recommend people to follow</label>
107
+ <comment><![CDATA[
108
+ Recommend Twitter account for user to follow after they share content from your website.
109
+ ]]>
110
+ </comment>
111
+ <frontend_type>text</frontend_type>
112
+ <!-- <source_model>twitter/source_btntype</source_model>-->
113
+ <sort_order>11</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </recommend>
118
+ <ttext translate="label comment">
119
+ <label>Tweet text</label>
120
+ <comment><![CDATA[
121
+ This is the text that people will include in their Tweet when they share from your website.If you want to use the title of the page the button is on ,leave this field empty.
122
+ ]]>
123
+ </comment>
124
+ <frontend_type>text</frontend_type>
125
+ <!-- <source_model>twitter/source_btntype</source_model>-->
126
+ <sort_order>12</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ </ttext>
131
+ <lang translate="label comment">
132
+ <label>Language</label>
133
+ <comment><![CDATA[
134
+ ]]>
135
+ </comment>
136
+ <frontend_type>select</frontend_type>
137
+ <source_model>twitter/source_langtype</source_model>
138
+ <sort_order>13</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>1</show_in_store>
142
+ </lang>
143
+
144
+ </fields>
145
+ </tweetbtn>
146
+ <userauth translate="label">
147
+ <label>User Login Settings</label>
148
+ <frontend_type>text</frontend_type>
149
+ <sort_order>120</sort_order>
150
+ <show_in_default>1</show_in_default>
151
+ <show_in_website>1</show_in_website>
152
+ <show_in_store>1</show_in_store>
153
+ <comment>
154
+ <![CDATA[
155
+ ]]>
156
+ </comment>
157
+ <fields>
158
+ <enabled translate="label comment">
159
+ <label>Enabled</label>
160
+ <!-- <comment><![CDATA[]]></comment> -->
161
+ <frontend_type>select</frontend_type>
162
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
163
+ <sort_order>9</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ </enabled>
168
+ <conskey translate="label comment">
169
+ <label>Consumer key</label>
170
+ <!-- <comment><![CDATA[]]></comment> -->
171
+ <frontend_type>text</frontend_type>
172
+ <sort_order>10</sort_order>
173
+ <show_in_default>1</show_in_default>
174
+ <show_in_website>1</show_in_website>
175
+ <show_in_store>1</show_in_store>
176
+ </conskey>
177
+ <conssecret translate="label comment">
178
+ <label>Consumer secret</label>
179
+ <!-- <comment><![CDATA[]]></comment> -->
180
+ <frontend_type>text</frontend_type>
181
+ <sort_order>11</sort_order>
182
+ <show_in_default>1</show_in_default>
183
+ <show_in_website>1</show_in_website>
184
+ <show_in_store>1</show_in_store>
185
+ </conssecret>
186
+ <oauthcallback translate="label comment">
187
+ <label>oAuth callback</label>
188
+ <!-- <comment><![CDATA[]]></comment> -->
189
+ <frontend_type>text</frontend_type>
190
+ <sort_order>12</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>1</show_in_store>
194
+ </oauthcallback>
195
+ </fields>
196
+ </userauth>
197
+ </groups>
198
+ </twitter>
199
+ </sections>
200
+ </config>
app/code/community/Belvg/Twitter/sql/twitter_setup/mysql4-install-1.1.7.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_Twitterconnect
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */?>
31
+ <?php
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+
37
+ $installer->run("
38
+ CREATE TABLE IF NOT EXISTS {$this->getTable('belvg_twitter_settings')} (
39
+ `user_name` varchar(111) character set utf8 NOT NULL,
40
+ `title` varchar(111) character set utf8 NOT NULL,
41
+ `subject` varchar(111) character set utf8 NOT NULL,
42
+ `width` int(11) NOT NULL,
43
+ `height` int(11) NOT NULL,
44
+ `shell_bg` varchar(111) character set utf8 NOT NULL,
45
+ `shell_color` varchar(111) character set utf8 NOT NULL,
46
+ `tweets_bg` varchar(111) character set utf8 NOT NULL,
47
+ `tweets_color` varchar(111) character set utf8 NOT NULL,
48
+ `tweets_link` varchar(111) character set utf8 NOT NULL,
49
+ `position` int(11) NOT NULL,
50
+ `pages` varchar(1111) character set utf8 NOT NULL,
51
+ `status` int(11) NOT NULL,
52
+ `store` int(11) NOT NULL,
53
+ `twitter_id` int(11) NOT NULL auto_increment,
54
+ `type` varchar(111) character set utf8 NOT NULL,
55
+ `interval` int(11) NOT NULL,
56
+ `timestamp` varchar(111) NOT NULL,
57
+ `avatars` varchar(111) NOT NULL,
58
+ `hashtags` varchar(111) NOT NULL,
59
+ `scrollbar` varchar(111) NOT NULL,
60
+ PRIMARY KEY (`twitter_id`)
61
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
62
+
63
+
64
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('belvg_twitter_users')}` (
65
+ `id` int(11) NOT NULL AUTO_INCREMENT,
66
+ `twitter_id` int(11) NOT NULL,
67
+ `user_id` int(11) unsigned NOT NULL,
68
+ PRIMARY KEY (`id`),
69
+ UNIQUE KEY `user_id` (`user_id`)
70
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
71
+
72
+
73
+ ALTER TABLE `{$this->getTable('belvg_twitter_users')}`
74
+ ADD CONSTRAINT `belvg_twitter_users_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `{$this->getTable('customer_entity')}` (`entity_id`) ON DELETE CASCADE;
75
+ ");
76
+
77
+ $installer->endSetup();
app/design/frontend/default/default/layout/facebookfree.xml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FaceboookFree
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <layout version="0.1.0">
34
+ <default>
35
+ <reference name="head">
36
+ <action method="addItem" ifconfig="facebookfree/settings/enabled" ifvalue="1">
37
+ <type>skin_css</type>
38
+ <name>css/belvg/facebookfree.css</name>
39
+ <params />
40
+ </action>
41
+ </reference>
42
+ <reference name="top.links">
43
+ <action method="setTemplate" ifconfig="facebookfree/settings/enabled" ifvalue="1">
44
+ <template>facebookfree/top.links.phtml</template>
45
+ </action>
46
+ </reference>
47
+ <reference name="before_body_end">
48
+ <block type="facebookfree/active" name="belvg.facebookfree.block">
49
+ <action method="setTemplate" ifconfig="facebookfree/settings/enabled" ifvalue="1">
50
+ <template>facebookfree/block.phtml</template>
51
+ </action>
52
+ </block>
53
+ </reference>
54
+ </default>
55
+
56
+ <catalog_product_view>
57
+ <reference name="head">
58
+ <block type="facebookfree/active" name="facebookfree_meta" before="-">
59
+ <action method="setTemplate" ifconfig="facebookfree/settings/enabled" ifvalue="1">
60
+ <template>facebookfree/like/head.phtml</template>
61
+ </action>
62
+ </block>
63
+ </reference>
64
+ <reference name="product.info.addto">
65
+ <action method="setTemplate" ifconfig="facebookfree/settings/enabled" ifvalue="1">
66
+ <template>facebookfree/like/product/view/addto.phtml</template>
67
+ </action>
68
+ </reference>
69
+ </catalog_product_view>
70
+
71
+ <customer_account_login translate="label">
72
+ <reference name="customer_form_login">
73
+ <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml">
74
+ <action method="setTemplate" ifconfig="facebookfree/settings/enabled" ifvalue="1">
75
+ <template>facebookfree/login.phtml</template>
76
+ </action>
77
+ </block>
78
+ </reference>
79
+ </customer_account_login>
80
+
81
+ <checkout_onepage_index translate="label">
82
+ <reference name="checkout.onepage">
83
+ <block type="checkout/onepage_login" name="checkout.onepage.login" as="login" template="checkout/onepage/login.phtml">
84
+ <action method="setTemplate" ifconfig="facebookfree/settings/enabled" ifvalue="1">
85
+ <template>facebookfree/checkoutlogin.phtml</template>
86
+ </action>
87
+ </block>
88
+ </reference>
89
+ </checkout_onepage_index>
90
+ </layout>
app/design/frontend/default/default/template/facebookfree/block.phtml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+ ?>
32
+ <script language="JavaScript" type="text/javascript">
33
+ /*<![CDATA[*/
34
+ window.fbAsyncInit = function() {
35
+ FB.init({appId: '<?php echo $this->getAppId()?>', status: true, cookie: true, xfbml: true});
36
+ FB.Event.subscribe('auth.login', function(response) {
37
+ login();
38
+ });
39
+ FB.Event.subscribe('auth.logout', function(response) {
40
+ logout();
41
+ });
42
+ FB.getLoginStatus(function(response) {
43
+ if (response.session) {
44
+ <?php if (Mage::getSingleton('customer/session')->isLoggedIn() && $uid = $this->checkFbUser()):?>
45
+ greet('<?php echo $uid?>');
46
+ <?php endif?>
47
+ }
48
+ <?php if (Mage::getSingleton('customer/session')->isLoggedIn()):?>
49
+ else {
50
+ $$('.quick-access a.fb_button')[0].remove();
51
+ }
52
+ <?php endif?>
53
+ });
54
+ };
55
+ (function() {
56
+ var e = document.createElement('script');
57
+ e.type = 'text/javascript';
58
+ e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
59
+ e.async = true;
60
+ document.getElementById('fb-root').appendChild(e);
61
+ }());
62
+
63
+ function login(){
64
+ document.location.href="<?php echo $this->getUrl('facebookfree/customer/login')?>?referer=<?php echo Mage::helper('core')->urlEncode($this->helper('core/url')->getCurrentUrl())?>";
65
+ }
66
+ function logout(){
67
+ document.location.href="<?php echo $this->getUrl('facebookfree/customer/logout')?>";
68
+ }
69
+ function greet(id){
70
+ FB.api('/me', function(response) {
71
+ var src = 'https://graph.facebook.com/'+id+'/picture';
72
+ $$('.welcome-msg')[0].insert('<img height="20" src="'+src+'"/>');
73
+ });
74
+ <?php /*if (Mage::getSingleton('customer/session')->isLoggedIn()):?>
75
+ var lis = $$('.quick-access li');
76
+ lis[lis.length-1].remove();
77
+ <?php endif */?>
78
+ }
79
+
80
+ function fblogin(){
81
+ FB.login(function(response) {
82
+ if (response.session) {
83
+ login();
84
+ } else {
85
+ // user is not logged in
86
+ window.location.reload();
87
+ }
88
+ }, {perms:'email,publish_stream'});
89
+ return false;
90
+ }
91
+ /*]]>*/
92
+ </script>
app/design/frontend/default/default/template/facebookfree/checkoutlogin.phtml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+ ?>
32
+ <div class="col2-set">
33
+ <?php echo $this->getChildHtml('login_before')?>
34
+ <div class="col-1">
35
+ <h3><?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?><?php echo $this->__('Checkout as a Guest or Register') ?><?php else: ?><?php echo $this->__('Register to Create an Account') ?><?php endif; ?></h3>
36
+ <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
37
+ <p><?php echo $this->__('Register with us for future convenience:') ?></p>
38
+ <?php else: ?>
39
+ <p><strong><?php echo $this->__('Register and save time!') ?></strong><br />
40
+ <?php echo $this->__('Register with us for future convenience:') ?></p>
41
+ <ul>
42
+ <li><?php echo $this->__('Fast and easy check out') ?></li>
43
+ <li><?php echo $this->__('Easy access to your order history and status') ?></li>
44
+ </ul>
45
+ <?php endif; ?>
46
+ <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
47
+ <ul class="form-list">
48
+ <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
49
+ <li class="control">
50
+ <input type="radio" name="checkout_method" id="login:guest" value="guest"<?php if($this->getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_GUEST): ?> checked="checked"<?php endif; ?> class="radio" /><label for="login:guest"><?php echo $this->__('Checkout as Guest') ?></label>
51
+ </li>
52
+ <?php endif; ?>
53
+ <li class="control">
54
+ <input type="radio" name="checkout_method" id="login:register" value="register"<?php if($this->getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->getQuote()->isAllowedGuestCheckout()): ?> checked="checked"<?php endif ?> class="radio" /><label for="login:register"><?php echo $this->__('Register') ?></label>
55
+ </li>
56
+ </ul>
57
+ <h4><?php echo $this->__('Register and save time!') ?></h4>
58
+ <p><?php echo $this->__('Register with us for future convenience:') ?></p>
59
+ <ul class="ul">
60
+ <li><?php echo $this->__('Fast and easy check out') ?></li>
61
+ <li><?php echo $this->__('Easy access to your order history and status') ?></li>
62
+ </ul>
63
+ <?php else: ?>
64
+ <input type="hidden" name="checkout_method" id="login:register" value="register" checked="checked" />
65
+ <?php endif; ?>
66
+ </div>
67
+ <div class="col-2">
68
+ <h3><?php echo $this->__('Login') ?></h3>
69
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
70
+ <form id="login-form" action="<?php echo $this->getPostAction() ?>" method="post">
71
+ <fieldset>
72
+ <h4><?php echo $this->__('Already registered?') ?></h4>
73
+ <p><?php echo $this->__('Please log in below:') ?></p>
74
+ <ul class="form-list">
75
+ <li>
76
+ <label for="login-email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
77
+ <div class="input-box">
78
+ <input type="text" class="input-text required-entry validate-email" id="login-email" name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>" />
79
+ </div>
80
+ </li>
81
+ <li>
82
+ <label for="login-password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
83
+ <div class="input-box">
84
+ <input type="password" class="input-text required-entry" id="login-password" name="login[password]" />
85
+ </div>
86
+ </li>
87
+ </ul>
88
+ </fieldset>
89
+ </form>
90
+ </div>
91
+ </div>
92
+ <div class="col2-set">
93
+ <div class="col-1">
94
+ <div class="buttons-set">
95
+ <p class="required">&nbsp;</p>
96
+ <button type="button" class="button" onclick="checkout.setMethod();"><span><span><?php echo ($this->getQuote()->isAllowedGuestCheckout() ? $this->__('Continue') : $this->__('Register')) ?></span></span></button>
97
+ </div>
98
+ </div>
99
+ <div class="col-2">
100
+ <div class="buttons-set">
101
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
102
+ <a href="<?php echo $this->getUrl('customer/account/forgotpassword') ?>" class="f-left"><?php echo $this->__('Forgot your password?') ?></a>
103
+ <button type="submit" class="button" onclick="onepageLogin(this)"><span><span><?php echo $this->__('Login') ?></span></span></button>
104
+ <a href="#" onclick="return fblogin();" class="fb_button_ps"><img src="<?php echo $this->helper('facebookfree/active')->getLoginImg()?>" alt="<?php echo $this->__('Connect with Facebook')?>" /></a>
105
+ </div>
106
+ </div>
107
+ </div>
108
+ <script type="text/javascript">
109
+ //<![CDATA[
110
+ var loginForm = new VarienForm('login-form', true);
111
+ $('login-email').observe('keypress', bindLoginPost);
112
+ $('login-password').observe('keypress', bindLoginPost);
113
+ function bindLoginPost(evt){
114
+ if (evt.keyCode == Event.KEY_RETURN) {
115
+ loginForm.submit();
116
+ }
117
+ }
118
+ function onepageLogin(button)
119
+ {
120
+ if(loginForm.validator && loginForm.validator.validate()){
121
+ button.disabled = true;
122
+ loginForm.submit();
123
+ }
124
+ }
125
+ //]]>
126
+ </script>
app/design/frontend/default/default/template/facebookfree/like/head.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+ ?>
32
+
33
+ <?php if($this->isActiveLike()):?>
34
+ <?php $product = Mage::registry('current_product'); ?>
35
+
36
+ <meta property="fb:app_id" content="<?php echo $this->getAppId()?>"/>
37
+ <?php if ($product): ?>
38
+ <meta property="og:title" content="<?php echo htmlspecialchars(trim($product->getName())); ?>"/>
39
+ <meta property="og:image" content="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')?>"/>
40
+ <?php endif; ?>
41
+ <meta property="og:url" content="<?php echo $this->helper('core/url')->getCurrentUrl();?>"/>
42
+ <meta property="og:type" content="product"/>
43
+ <?php endif?>
app/design/frontend/default/default/template/facebookfree/like/product/view/addto.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+ ?>
32
+
33
+ <?php $_product = $this->getProduct() ?>
34
+ <ul class="add-to-links">
35
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
36
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
37
+ <?php endif; ?>
38
+ <?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ): ?>
39
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
40
+ <?php endif; ?>
41
+ </ul>
42
+ <br />
43
+ <?php if($this->helper('facebookfree/active')->isActiveLike()):?>
44
+ <fb:like href="<?php echo $this->helper('core/url')->getCurrentUrl()?>" layout="<?php echo $this->helper('facebookfree/active')->getLikeLayout()?>" show_faces="<?php echo $this->helper('facebookfree/active')->isFacesLikeActive()?>" width="<?php echo $this->helper('facebookfree/active')->getLikeWidth()?>" colorscheme="<?php echo $this->helper('facebookfree/active')->getLikeColor()?>"></fb:like>
45
+ <?php endif?>
app/design/frontend/default/default/template/facebookfree/login.phtml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+ ?>
32
+ <div class="account-login">
33
+ <div class="page-title">
34
+ <h1><?php echo $this->__('Login or Create an Account') ?></h1>
35
+ </div>
36
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
37
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="login-form">
38
+ <div class="col2-set">
39
+ <div class="col-1 new-users">
40
+ <div class="content">
41
+ <h2><?php echo $this->__('New Customers') ?></h2>
42
+ <p><?php echo $this->__('By creating an account with our store, you will be able to move through the checkout process faster, store multiple shipping addresses, view and track your orders in your account and more.') ?></p>
43
+ </div>
44
+ </div>
45
+ <div class="col-2 registered-users">
46
+ <div class="content">
47
+ <h2><?php echo $this->__('Registered Customers') ?></h2>
48
+ <p><?php echo $this->__('If you have an account with us, please log in.') ?></p>
49
+ <ul class="form-list">
50
+ <li>
51
+ <label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
52
+ <div class="input-box">
53
+ <input type="text" name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>" id="email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
54
+ </div>
55
+ </li>
56
+ <li>
57
+ <label for="pass" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
58
+ <div class="input-box">
59
+ <input type="password" name="login[password]" class="input-text required-entry validate-password" id="pass" title="<?php echo $this->__('Password') ?>" />
60
+ </div>
61
+ </li>
62
+ </ul>
63
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ <div class="col2-set">
68
+ <div class="col-1 new-users">
69
+ <div class="buttons-set">
70
+ <button type="button" title="<?php echo $this->__('Create an Account') ?>" class="button" onclick="window.location='<?php echo $this->getCreateAccountUrl() ?>';"><span><span><?php echo $this->__('Create an Account') ?></span></span></button>
71
+ </div>
72
+ </div>
73
+ <div class="col-2 registered-users">
74
+ <div class="buttons-set">
75
+ <a href="<?php echo $this->getForgotPasswordUrl() ?>" class="f-left"><?php echo $this->__('Forgot Your Password?') ?></a>
76
+ <button type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2"><span><span><?php echo $this->__('Login') ?></span></span></button>
77
+ <a href="#" onclick="return fblogin();" class="fb_button_ps"><img src="<?php echo $this->helper('facebookfree/active')->getLoginImg()?>" alt="<?php echo $this->__('Connect with Facebook')?>" /></a>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </form>
82
+ <script type="text/javascript">
83
+ //<![CDATA[
84
+ var dataForm = new VarienForm('login-form', true);
85
+ //]]>
86
+ </script>
87
+ </div>
app/design/frontend/default/default/template/facebookfree/top.links.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BelVG LLC.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the EULA
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
11
+ *
12
+ /***************************************
13
+ * MAGENTO EDITION USAGE NOTICE *
14
+ *****************************************/
15
+ /* This package designed for Magento COMMUNITY edition
16
+ * BelVG does not guarantee correct work of this extension
17
+ * on any other Magento edition except Magento COMMUNITY edition.
18
+ * BelVG does not provide extension support in case of
19
+ * incorrect edition usage.
20
+ /***************************************
21
+ * DISCLAIMER *
22
+ *****************************************/
23
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
24
+ * versions in the future.
25
+ *****************************************************
26
+ * @category Belvg
27
+ * @package Belvg_FacebookFree
28
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
29
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
30
+ */
31
+ ?>
32
+
33
+ <?php $_links = $this->getLinks(); ?>
34
+ <div id="fb-root"></div>
35
+ <?php if(!Mage::getSingleton('customer/session')->isLoggedIn()):?>
36
+ <a href="#" onclick="return fblogin();" class="fb_button_ps"><img src="<?php echo $this->helper('facebookfree/active')->getLoginImg()?>" alt="<?php echo $this->__('Connect with Facebook')?>" /></a>
37
+ <?php endif?>
38
+ <?php if(count($_links)>0): ?>
39
+ <ul class="links"<?php if($this->getName()): ?> id="<?php echo $this->getName() ?>"<?php endif;?>>
40
+ <?php foreach($_links as $_link): ?>
41
+ <li<?php if($_link->getIsFirst()||$_link->getIsLast()): ?> class="<?php if($_link->getIsFirst()): ?>first<?php endif; ?><?php if($_link->getIsLast()): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_link->getLiParams() ?>><?php echo $_link->getBeforeText() ?><a href="<?php echo $_link->getUrl() ?>" title="<?php echo $_link->getTitle() ?>" <?php echo $_link->getAParams() ?>><?php echo $_link->getLabel() ?></a><?php echo $_link->getAfterText() ?></li>
42
+ <?php endforeach; ?>
43
+ </ul>
44
+ <?php endif; ?>
45
+
46
+
47
+
48
+
app/etc/modules/Belvg_All.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_All
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <modules>
35
+ <Belvg_All>
36
+ <active>true</active>
37
+ <codePool>community</codePool>
38
+ <version>1.0</version>
39
+ </Belvg_All>
40
+ </modules>
41
+ </config>
app/etc/modules/Belvg_FacebookFree.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BelVG LLC.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
12
+ *
13
+ /***************************************
14
+ * MAGENTO EDITION USAGE NOTICE *
15
+ *****************************************/
16
+ /* This package designed for Magento COMMUNITY edition
17
+ * BelVG does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * BelVG does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ /***************************************
22
+ * DISCLAIMER *
23
+ *****************************************/
24
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
25
+ * versions in the future.
26
+ *****************************************************
27
+ * @category Belvg
28
+ * @package Belvg_FaceboookFree
29
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
30
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
31
+ */
32
+ -->
33
+ <config>
34
+ <modules>
35
+ <Belvg_FaceboookFree>
36
+ <active>true</active>
37
+ <codePool>community</codePool>
38
+ <version>1.0.2</version>
39
+ </Belvg_FaceboookFree>
40
+ </modules>
41
+ </config>
lib/Facebook/Api.php ADDED
@@ -0,0 +1,872 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Provides access to the Facebook Platform.
4
+ *
5
+ * @author Naitik Shah <naitik@facebook.com>
6
+ */
7
+ class Facebook_Api
8
+ {
9
+ /**
10
+ * Version.
11
+ */
12
+ const VERSION = '2.1.2';
13
+
14
+ /**
15
+ * Default options for curl.
16
+ */
17
+ public static $CURL_OPTS = array(
18
+ CURLOPT_CONNECTTIMEOUT => 10,
19
+ CURLOPT_RETURNTRANSFER => true,
20
+ CURLOPT_TIMEOUT => 60,
21
+ CURLOPT_USERAGENT => 'facebook-php-2.0',
22
+ );
23
+
24
+ /**
25
+ * List of query parameters that get automatically dropped when rebuilding
26
+ * the current URL.
27
+ */
28
+ protected static $DROP_QUERY_PARAMS = array(
29
+ 'session',
30
+ 'signed_request',
31
+ );
32
+
33
+ /**
34
+ * Maps aliases to Facebook domains.
35
+ */
36
+ public static $DOMAIN_MAP = array(
37
+ 'api' => 'https://api.facebook.com/',
38
+ 'api_read' => 'https://api-read.facebook.com/',
39
+ 'graph' => 'https://graph.facebook.com/',
40
+ 'www' => 'https://www.facebook.com/',
41
+ );
42
+
43
+ /**
44
+ * The Application ID.
45
+ */
46
+ protected $appId;
47
+
48
+ /**
49
+ * The Application API Secret.
50
+ */
51
+ protected $apiSecret;
52
+
53
+ /**
54
+ * The active user session, if one is available.
55
+ */
56
+ protected $session;
57
+
58
+ /**
59
+ * The data from the signed_request token.
60
+ */
61
+ protected $signedRequest;
62
+
63
+ /**
64
+ * Indicates that we already loaded the session as best as we could.
65
+ */
66
+ protected $sessionLoaded = false;
67
+
68
+ /**
69
+ * Indicates if Cookie support should be enabled.
70
+ */
71
+ protected $cookieSupport = false;
72
+
73
+ /**
74
+ * Base domain for the Cookie.
75
+ */
76
+ protected $baseDomain = '';
77
+
78
+ /**
79
+ * Indicates if the CURL based @ syntax for file uploads is enabled.
80
+ */
81
+ protected $fileUploadSupport = false;
82
+
83
+ /**
84
+ * Initialize a Facebook Application.
85
+ *
86
+ * The configuration:
87
+ * - appId: the application ID
88
+ * - secret: the application secret
89
+ * - cookie: (optional) boolean true to enable cookie support
90
+ * - domain: (optional) domain for the cookie
91
+ * - fileUpload: (optional) boolean indicating if file uploads are enabled
92
+ *
93
+ * @param Array $config the application configuration
94
+ */
95
+ public function __construct($config) {
96
+ $this->setAppId($config['appId']);
97
+ $this->setApiSecret($config['secret']);
98
+ if (isset($config['cookie'])) {
99
+ $this->setCookieSupport($config['cookie']);
100
+ }
101
+ if (isset($config['domain'])) {
102
+ $this->setBaseDomain($config['domain']);
103
+ }
104
+ if (isset($config['fileUpload'])) {
105
+ $this->setFileUploadSupport($config['fileUpload']);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Set the Application ID.
111
+ *
112
+ * @param String $appId the Application ID
113
+ */
114
+ public function setAppId($appId) {
115
+ $this->appId = $appId;
116
+ return $this;
117
+ }
118
+
119
+ /**
120
+ * Get the Application ID.
121
+ *
122
+ * @return String the Application ID
123
+ */
124
+ public function getAppId() {
125
+ return $this->appId;
126
+ }
127
+
128
+ /**
129
+ * Set the API Secret.
130
+ *
131
+ * @param String $appId the API Secret
132
+ */
133
+ public function setApiSecret($apiSecret) {
134
+ $this->apiSecret = $apiSecret;
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * Get the API Secret.
140
+ *
141
+ * @return String the API Secret
142
+ */
143
+ public function getApiSecret() {
144
+ return $this->apiSecret;
145
+ }
146
+
147
+ /**
148
+ * Set the Cookie Support status.
149
+ *
150
+ * @param Boolean $cookieSupport the Cookie Support status
151
+ */
152
+ public function setCookieSupport($cookieSupport) {
153
+ $this->cookieSupport = $cookieSupport;
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * Get the Cookie Support status.
159
+ *
160
+ * @return Boolean the Cookie Support status
161
+ */
162
+ public function useCookieSupport() {
163
+ return $this->cookieSupport;
164
+ }
165
+
166
+ /**
167
+ * Set the base domain for the Cookie.
168
+ *
169
+ * @param String $domain the base domain
170
+ */
171
+ public function setBaseDomain($domain) {
172
+ $this->baseDomain = $domain;
173
+ return $this;
174
+ }
175
+
176
+ /**
177
+ * Get the base domain for the Cookie.
178
+ *
179
+ * @return String the base domain
180
+ */
181
+ public function getBaseDomain() {
182
+ return $this->baseDomain;
183
+ }
184
+
185
+ /**
186
+ * Set the file upload support status.
187
+ *
188
+ * @param String $domain the base domain
189
+ */
190
+ public function setFileUploadSupport($fileUploadSupport) {
191
+ $this->fileUploadSupport = $fileUploadSupport;
192
+ return $this;
193
+ }
194
+
195
+ /**
196
+ * Get the file upload support status.
197
+ *
198
+ * @return String the base domain
199
+ */
200
+ public function useFileUploadSupport() {
201
+ return $this->fileUploadSupport;
202
+ }
203
+
204
+ /**
205
+ * Get the data from a signed_request token
206
+ *
207
+ * @return String the base domain
208
+ */
209
+ public function getSignedRequest() {
210
+ if (!$this->signedRequest) {
211
+ if (isset($_REQUEST['signed_request'])) {
212
+ $this->signedRequest = $this->parseSignedRequest(
213
+ $_REQUEST['signed_request']);
214
+ }
215
+ }
216
+ return $this->signedRequest;
217
+ }
218
+
219
+ /**
220
+ * Set the Session.
221
+ *
222
+ * @param Array $session the session
223
+ * @param Boolean $write_cookie indicate if a cookie should be written. this
224
+ * value is ignored if cookie support has been disabled.
225
+ */
226
+ public function setSession($session=null, $write_cookie=true) {
227
+ $session = $this->validateSessionObject($session);
228
+ $this->sessionLoaded = true;
229
+ $this->session = $session;
230
+ if ($write_cookie) {
231
+ $this->setCookieFromSession($session);
232
+ }
233
+ return $this;
234
+ }
235
+
236
+ /**
237
+ * Get the session object. This will automatically look for a signed session
238
+ * sent via the signed_request, Cookie or Query Parameters if needed.
239
+ *
240
+ * @return Array the session
241
+ */
242
+ public function getSession() {
243
+ if (!$this->sessionLoaded) {
244
+ $session = null;
245
+ $write_cookie = true;
246
+
247
+ // try loading session from signed_request in $_REQUEST
248
+ $signedRequest = $this->getSignedRequest();
249
+ if ($signedRequest) {
250
+ // sig is good, use the signedRequest
251
+ $session = $this->createSessionFromSignedRequest($signedRequest);
252
+ }
253
+
254
+ // try loading session from $_REQUEST
255
+ if (!$session && isset($_REQUEST['session'])) {
256
+ $session = json_decode(
257
+ get_magic_quotes_gpc()
258
+ ? stripslashes($_REQUEST['session'])
259
+ : $_REQUEST['session'],
260
+ true
261
+ );
262
+ $session = $this->validateSessionObject($session);
263
+ }
264
+
265
+ // try loading session from cookie if necessary
266
+ if (!$session && $this->useCookieSupport()) {
267
+ $cookieName = $this->getSessionCookieName();
268
+ if (isset($_COOKIE[$cookieName])) {
269
+ $session = array();
270
+ parse_str(trim(
271
+ get_magic_quotes_gpc()
272
+ ? stripslashes($_COOKIE[$cookieName])
273
+ : $_COOKIE[$cookieName],
274
+ '"'
275
+ ), $session);
276
+ $session = $this->validateSessionObject($session);
277
+ // write only if we need to delete a invalid session cookie
278
+ $write_cookie = empty($session);
279
+ }
280
+ }
281
+
282
+ $this->setSession($session, $write_cookie);
283
+ }
284
+
285
+ return $this->session;
286
+ }
287
+
288
+ /**
289
+ * Get the UID from the session.
290
+ *
291
+ * @return String the UID if available
292
+ */
293
+ public function getUser() {
294
+ $session = $this->getSession();
295
+ return $session ? $session['uid'] : null;
296
+ }
297
+
298
+ /**
299
+ * Gets a OAuth access token.
300
+ *
301
+ * @return String the access token
302
+ */
303
+ public function getAccessToken() {
304
+ $session = $this->getSession();
305
+ // either user session signed, or app signed
306
+ if ($session) {
307
+ return $session['access_token'];
308
+ } else {
309
+ return $this->getAppId() .'|'. $this->getApiSecret();
310
+ }
311
+ }
312
+
313
+ /**
314
+ * Get a Login URL for use with redirects. By default, full page redirect is
315
+ * assumed. If you are using the generated URL with a window.open() call in
316
+ * JavaScript, you can pass in display=popup as part of the $params.
317
+ *
318
+ * The parameters:
319
+ * - next: the url to go to after a successful login
320
+ * - cancel_url: the url to go to after the user cancels
321
+ * - req_perms: comma separated list of requested extended perms
322
+ * - display: can be "page" (default, full page) or "popup"
323
+ *
324
+ * @param Array $params provide custom parameters
325
+ * @return String the URL for the login flow
326
+ */
327
+ public function getLoginUrl($params=array()) {
328
+ $currentUrl = $this->getCurrentUrl();
329
+ return $this->getUrl(
330
+ 'www',
331
+ 'login.php',
332
+ array_merge(array(
333
+ 'api_key' => $this->getAppId(),
334
+ 'cancel_url' => $currentUrl,
335
+ 'display' => 'page',
336
+ 'fbconnect' => 1,
337
+ 'next' => $currentUrl,
338
+ 'return_session' => 1,
339
+ 'session_version' => 3,
340
+ 'v' => '1.0',
341
+ ), $params)
342
+ );
343
+ }
344
+
345
+ /**
346
+ * Get a Logout URL suitable for use with redirects.
347
+ *
348
+ * The parameters:
349
+ * - next: the url to go to after a successful logout
350
+ *
351
+ * @param Array $params provide custom parameters
352
+ * @return String the URL for the logout flow
353
+ */
354
+ public function getLogoutUrl($params=array()) {
355
+ return $this->getUrl(
356
+ 'www',
357
+ 'logout.php',
358
+ array_merge(array(
359
+ 'next' => $this->getCurrentUrl(),
360
+ 'access_token' => $this->getAccessToken(),
361
+ ), $params)
362
+ );
363
+ }
364
+
365
+ /**
366
+ * Get a login status URL to fetch the status from facebook.
367
+ *
368
+ * The parameters:
369
+ * - ok_session: the URL to go to if a session is found
370
+ * - no_session: the URL to go to if the user is not connected
371
+ * - no_user: the URL to go to if the user is not signed into facebook
372
+ *
373
+ * @param Array $params provide custom parameters
374
+ * @return String the URL for the logout flow
375
+ */
376
+ public function getLoginStatusUrl($params=array()) {
377
+ return $this->getUrl(
378
+ 'www',
379
+ 'extern/login_status.php',
380
+ array_merge(array(
381
+ 'api_key' => $this->getAppId(),
382
+ 'no_session' => $this->getCurrentUrl(),
383
+ 'no_user' => $this->getCurrentUrl(),
384
+ 'ok_session' => $this->getCurrentUrl(),
385
+ 'session_version' => 3,
386
+ ), $params)
387
+ );
388
+ }
389
+
390
+ /**
391
+ * Make an API call.
392
+ *
393
+ * @param Array $params the API call parameters
394
+ * @return the decoded response
395
+ */
396
+ public function api(/* polymorphic */) {
397
+ $args = func_get_args();
398
+ if (is_array($args[0])) {
399
+ return $this->_restserver($args[0]);
400
+ } else {
401
+ return call_user_func_array(array($this, '_graph'), $args);
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Invoke the old restserver.php endpoint.
407
+ *
408
+ * @param Array $params method call object
409
+ * @return the decoded response object
410
+ * @throws Facebook_Exception
411
+ */
412
+ protected function _restserver($params) {
413
+ // generic application level parameters
414
+ $params['api_key'] = $this->getAppId();
415
+ $params['format'] = 'json-strings';
416
+
417
+ $result = json_decode($this->_oauthRequest(
418
+ $this->getApiUrl($params['method']),
419
+ $params
420
+ ), true);
421
+
422
+ // results are returned, errors are thrown
423
+ if (is_array($result) && isset($result['error_code'])) {
424
+ throw new Facebook_Exception($result);
425
+ }
426
+ return $result;
427
+ }
428
+
429
+ /**
430
+ * Invoke the Graph API.
431
+ *
432
+ * @param String $path the path (required)
433
+ * @param String $method the http method (default 'GET')
434
+ * @param Array $params the query/post data
435
+ * @return the decoded response object
436
+ * @throws Facebook_Exception
437
+ */
438
+ protected function _graph($path, $method='GET', $params=array()) {
439
+ if (is_array($method) && empty($params)) {
440
+ $params = $method;
441
+ $method = 'GET';
442
+ }
443
+ $params['method'] = $method; // method override as we always do a POST
444
+
445
+ $result = json_decode($this->_oauthRequest(
446
+ $this->getUrl('graph', $path),
447
+ $params
448
+ ), true);
449
+
450
+ // results are returned, errors are thrown
451
+ if (is_array($result) && isset($result['error'])) {
452
+ $e = new Facebook_Exception($result);
453
+ switch ($e->getType()) {
454
+ // OAuth 2.0 Draft 00 style
455
+ case 'OAuthException':
456
+ // OAuth 2.0 Draft 10 style
457
+ case 'invalid_token':
458
+ $this->setSession(null);
459
+ }
460
+ throw $e;
461
+ }
462
+ return $result;
463
+ }
464
+
465
+ /**
466
+ * Make a OAuth Request
467
+ *
468
+ * @param String $path the path (required)
469
+ * @param Array $params the query/post data
470
+ * @return the decoded response object
471
+ * @throws Facebook_Exception
472
+ */
473
+ protected function _oauthRequest($url, $params) {
474
+ if (!isset($params['access_token'])) {
475
+ $params['access_token'] = $this->getAccessToken();
476
+ }
477
+
478
+ // json_encode all params values that are not strings
479
+ foreach ($params as $key => $value) {
480
+ if (!is_string($value)) {
481
+ $params[$key] = json_encode($value);
482
+ }
483
+ }
484
+ return $this->makeRequest($url, $params);
485
+ }
486
+
487
+ /**
488
+ * Makes an HTTP request. This method can be overriden by subclasses if
489
+ * developers want to do fancier things or use something other than curl to
490
+ * make the request.
491
+ *
492
+ * @param String $url the URL to make the request to
493
+ * @param Array $params the parameters to use for the POST body
494
+ * @param CurlHandler $ch optional initialized curl handle
495
+ * @return String the response text
496
+ */
497
+ protected function makeRequest($url, $params, $ch=null) {
498
+ if (!$ch) {
499
+ $ch = curl_init();
500
+ }
501
+
502
+ $opts = self::$CURL_OPTS;
503
+ if ($this->useFileUploadSupport()) {
504
+ $opts[CURLOPT_POSTFIELDS] = $params;
505
+ } else {
506
+ $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
507
+ }
508
+ $opts[CURLOPT_URL] = $url;
509
+
510
+ // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
511
+ // for 2 seconds if the server does not support this header.
512
+ if (isset($opts[CURLOPT_HTTPHEADER])) {
513
+ $existing_headers = $opts[CURLOPT_HTTPHEADER];
514
+ $existing_headers[] = 'Expect:';
515
+ $opts[CURLOPT_HTTPHEADER] = $existing_headers;
516
+ } else {
517
+ $opts[CURLOPT_HTTPHEADER] = array('Expect:');
518
+ }
519
+
520
+ curl_setopt_array($ch, $opts);
521
+ $result = curl_exec($ch);
522
+
523
+ if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
524
+ self::errorLog('Invalid or no certificate authority found, using bundled information');
525
+ curl_setopt($ch, CURLOPT_CAINFO,
526
+ dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
527
+ $result = curl_exec($ch);
528
+ }
529
+
530
+ if ($result === false) {
531
+ $e = new Facebook_Exception(array(
532
+ 'error_code' => curl_errno($ch),
533
+ 'error' => array(
534
+ 'message' => curl_error($ch),
535
+ 'type' => 'CurlException',
536
+ ),
537
+ ));
538
+ curl_close($ch);
539
+ throw $e;
540
+ }
541
+ curl_close($ch);
542
+ return $result;
543
+ }
544
+
545
+ /**
546
+ * The name of the Cookie that contains the session.
547
+ *
548
+ * @return String the cookie name
549
+ */
550
+ protected function getSessionCookieName() {
551
+ return 'fbs_' . $this->getAppId();
552
+ }
553
+
554
+ /**
555
+ * Set a JS Cookie based on the _passed in_ session. It does not use the
556
+ * currently stored session -- you need to explicitly pass it in.
557
+ *
558
+ * @param Array $session the session to use for setting the cookie
559
+ */
560
+ protected function setCookieFromSession($session=null) {
561
+ if (!$this->useCookieSupport()) {
562
+ return;
563
+ }
564
+
565
+ $cookieName = $this->getSessionCookieName();
566
+ $value = 'deleted';
567
+ $expires = time() - 3600;
568
+ $domain = $this->getBaseDomain();
569
+ if ($session) {
570
+ $value = '"' . http_build_query($session, null, '&') . '"';
571
+ if (isset($session['base_domain'])) {
572
+ $domain = $session['base_domain'];
573
+ }
574
+ $expires = $session['expires'];
575
+ }
576
+
577
+ // prepend dot if a domain is found
578
+ if ($domain) {
579
+ $domain = '.' . $domain;
580
+ }
581
+
582
+ // if an existing cookie is not set, we dont need to delete it
583
+ if ($value == 'deleted' && empty($_COOKIE[$cookieName])) {
584
+ return;
585
+ }
586
+
587
+ if (headers_sent()) {
588
+ self::errorLog('Could not set cookie. Headers already sent.');
589
+
590
+ // ignore for code coverage as we will never be able to setcookie in a CLI
591
+ // environment
592
+ // @codeCoverageIgnoreStart
593
+ } else {
594
+ setcookie($cookieName, $value, $expires, '/', $domain);
595
+ }
596
+ // @codeCoverageIgnoreEnd
597
+ }
598
+
599
+ /**
600
+ * Validates a session_version=3 style session object.
601
+ *
602
+ * @param Array $session the session object
603
+ * @return Array the session object if it validates, null otherwise
604
+ */
605
+ protected function validateSessionObject($session) {
606
+ // make sure some essential fields exist
607
+ if (is_array($session) &&
608
+ isset($session['uid']) &&
609
+ isset($session['access_token']) &&
610
+ isset($session['sig'])) {
611
+ // validate the signature
612
+ $session_without_sig = $session;
613
+ unset($session_without_sig['sig']);
614
+ $expected_sig = self::generateSignature(
615
+ $session_without_sig,
616
+ $this->getApiSecret()
617
+ );
618
+ if ($session['sig'] != $expected_sig) {
619
+ self::errorLog('Got invalid session signature in cookie.');
620
+ $session = null;
621
+ }
622
+ // check expiry time
623
+ } else {
624
+ $session = null;
625
+ }
626
+ return $session;
627
+ }
628
+
629
+ /**
630
+ * Returns something that looks like our JS session object from the
631
+ * signed token's data
632
+ *
633
+ * TODO: Nuke this once the login flow uses OAuth2
634
+ *
635
+ * @param Array the output of getSignedRequest
636
+ * @return Array Something that will work as a session
637
+ */
638
+ protected function createSessionFromSignedRequest($data) {
639
+ if (!isset($data['oauth_token'])) {
640
+ return null;
641
+ }
642
+
643
+ $session = array(
644
+ 'uid' => $data['user_id'],
645
+ 'access_token' => $data['oauth_token'],
646
+ 'expires' => $data['expires'],
647
+ );
648
+
649
+ // put a real sig, so that validateSignature works
650
+ $session['sig'] = self::generateSignature(
651
+ $session,
652
+ $this->getApiSecret()
653
+ );
654
+
655
+ return $session;
656
+ }
657
+
658
+ /**
659
+ * Parses a signed_request and validates the signature.
660
+ * Then saves it in $this->signed_data
661
+ *
662
+ * @param String A signed token
663
+ * @param Boolean Should we remove the parts of the payload that
664
+ * are used by the algorithm?
665
+ * @return Array the payload inside it or null if the sig is wrong
666
+ */
667
+ protected function parseSignedRequest($signed_request) {
668
+ list($encoded_sig, $payload) = explode('.', $signed_request, 2);
669
+
670
+ // decode the data
671
+ $sig = self::base64UrlDecode($encoded_sig);
672
+ $data = json_decode(self::base64UrlDecode($payload), true);
673
+
674
+ if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
675
+ self::errorLog('Unknown algorithm. Expected HMAC-SHA256');
676
+ return null;
677
+ }
678
+
679
+ // check sig
680
+ $expected_sig = hash_hmac('sha256', $payload,
681
+ $this->getApiSecret(), $raw = true);
682
+ if ($sig !== $expected_sig) {
683
+ self::errorLog('Bad Signed JSON signature!');
684
+ return null;
685
+ }
686
+
687
+ return $data;
688
+ }
689
+
690
+ /**
691
+ * Build the URL for api given parameters.
692
+ *
693
+ * @param $method String the method name.
694
+ * @return String the URL for the given parameters
695
+ */
696
+ protected function getApiUrl($method) {
697
+ static $READ_ONLY_CALLS =
698
+ array('admin.getallocation' => 1,
699
+ 'admin.getappproperties' => 1,
700
+ 'admin.getbannedusers' => 1,
701
+ 'admin.getlivestreamvialink' => 1,
702
+ 'admin.getmetrics' => 1,
703
+ 'admin.getrestrictioninfo' => 1,
704
+ 'application.getpublicinfo' => 1,
705
+ 'auth.getapppublickey' => 1,
706
+ 'auth.getsession' => 1,
707
+ 'auth.getsignedpublicsessiondata' => 1,
708
+ 'comments.get' => 1,
709
+ 'connect.getunconnectedfriendscount' => 1,
710
+ 'dashboard.getactivity' => 1,
711
+ 'dashboard.getcount' => 1,
712
+ 'dashboard.getglobalnews' => 1,
713
+ 'dashboard.getnews' => 1,
714
+ 'dashboard.multigetcount' => 1,
715
+ 'dashboard.multigetnews' => 1,
716
+ 'data.getcookies' => 1,
717
+ 'events.get' => 1,
718
+ 'events.getmembers' => 1,
719
+ 'fbml.getcustomtags' => 1,
720
+ 'feed.getappfriendstories' => 1,
721
+ 'feed.getregisteredtemplatebundlebyid' => 1,
722
+ 'feed.getregisteredtemplatebundles' => 1,
723
+ 'fql.multiquery' => 1,
724
+ 'fql.query' => 1,
725
+ 'friends.arefriends' => 1,
726
+ 'friends.get' => 1,
727
+ 'friends.getappusers' => 1,
728
+ 'friends.getlists' => 1,
729
+ 'friends.getmutualfriends' => 1,
730
+ 'gifts.get' => 1,
731
+ 'groups.get' => 1,
732
+ 'groups.getmembers' => 1,
733
+ 'intl.gettranslations' => 1,
734
+ 'links.get' => 1,
735
+ 'notes.get' => 1,
736
+ 'notifications.get' => 1,
737
+ 'pages.getinfo' => 1,
738
+ 'pages.isadmin' => 1,
739
+ 'pages.isappadded' => 1,
740
+ 'pages.isfan' => 1,
741
+ 'permissions.checkavailableapiaccess' => 1,
742
+ 'permissions.checkgrantedapiaccess' => 1,
743
+ 'photos.get' => 1,
744
+ 'photos.getalbums' => 1,
745
+ 'photos.gettags' => 1,
746
+ 'profile.getinfo' => 1,
747
+ 'profile.getinfooptions' => 1,
748
+ 'stream.get' => 1,
749
+ 'stream.getcomments' => 1,
750
+ 'stream.getfilters' => 1,
751
+ 'users.getinfo' => 1,
752
+ 'users.getloggedinuser' => 1,
753
+ 'users.getstandardinfo' => 1,
754
+ 'users.hasapppermission' => 1,
755
+ 'users.isappuser' => 1,
756
+ 'users.isverified' => 1,
757
+ 'video.getuploadlimits' => 1);
758
+ $name = 'api';
759
+ if (isset($READ_ONLY_CALLS[strtolower($method)])) {
760
+ $name = 'api_read';
761
+ }
762
+ return self::getUrl($name, 'restserver.php');
763
+ }
764
+
765
+ /**
766
+ * Build the URL for given domain alias, path and parameters.
767
+ *
768
+ * @param $name String the name of the domain
769
+ * @param $path String optional path (without a leading slash)
770
+ * @param $params Array optional query parameters
771
+ * @return String the URL for the given parameters
772
+ */
773
+ protected function getUrl($name, $path='', $params=array()) {
774
+ $url = self::$DOMAIN_MAP[$name];
775
+ if ($path) {
776
+ if ($path[0] === '/') {
777
+ $path = substr($path, 1);
778
+ }
779
+ $url .= $path;
780
+ }
781
+ if ($params) {
782
+ $url .= '?' . http_build_query($params, null, '&');
783
+ }
784
+ return $url;
785
+ }
786
+
787
+ /**
788
+ * Returns the Current URL, stripping it of known FB parameters that should
789
+ * not persist.
790
+ *
791
+ * @return String the current URL
792
+ */
793
+ protected function getCurrentUrl() {
794
+ $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'
795
+ ? 'https://'
796
+ : 'http://';
797
+ $currentUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
798
+ $parts = parse_url($currentUrl);
799
+
800
+ // drop known fb params
801
+ $query = '';
802
+ if (!empty($parts['query'])) {
803
+ $params = array();
804
+ parse_str($parts['query'], $params);
805
+ foreach(self::$DROP_QUERY_PARAMS as $key) {
806
+ unset($params[$key]);
807
+ }
808
+ if (!empty($params)) {
809
+ $query = '?' . http_build_query($params, null, '&');
810
+ }
811
+ }
812
+
813
+ // use port if non default
814
+ $port =
815
+ isset($parts['port']) &&
816
+ (($protocol === 'http://' && $parts['port'] !== 80) ||
817
+ ($protocol === 'https://' && $parts['port'] !== 443))
818
+ ? ':' . $parts['port'] : '';
819
+
820
+ // rebuild
821
+ return $protocol . $parts['host'] . $port . $parts['path'] . $query;
822
+ }
823
+
824
+ /**
825
+ * Generate a signature for the given params and secret.
826
+ *
827
+ * @param Array $params the parameters to sign
828
+ * @param String $secret the secret to sign with
829
+ * @return String the generated signature
830
+ */
831
+ protected static function generateSignature($params, $secret) {
832
+ // work with sorted data
833
+ ksort($params);
834
+
835
+ // generate the base string
836
+ $base_string = '';
837
+ foreach($params as $key => $value) {
838
+ $base_string .= $key . '=' . $value;
839
+ }
840
+ $base_string .= $secret;
841
+
842
+ return md5($base_string);
843
+ }
844
+
845
+ /**
846
+ * Prints to the error log if you aren't in command line mode.
847
+ *
848
+ * @param String log message
849
+ */
850
+ protected static function errorLog($msg) {
851
+ // disable error log if we are running in a CLI environment
852
+ // @codeCoverageIgnoreStart
853
+ if (php_sapi_name() != 'cli') {
854
+ error_log($msg);
855
+ }
856
+ // uncomment this if you want to see the errors on the page
857
+ // print 'error_log: '.$msg."\n";
858
+ // @codeCoverageIgnoreEnd
859
+ }
860
+
861
+ /**
862
+ * Base64 encoding that doesn't need to be urlencode()ed.
863
+ * Exactly the same as base64_encode except it uses
864
+ * - instead of +
865
+ * _ instead of /
866
+ *
867
+ * @param String base64UrlEncodeded string
868
+ */
869
+ protected static function base64UrlDecode($input) {
870
+ return base64_decode(strtr($input, '-_', '+/'));
871
+ }
872
+ }
lib/Facebook/Exception.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Thrown when an API call returns an exception.
4
+ *
5
+ * @author Naitik Shah <naitik@facebook.com>
6
+ */
7
+ class Facebook_Exception extends Exception
8
+ {
9
+ /**
10
+ * The result from the API server that represents the exception information.
11
+ */
12
+ protected $result;
13
+
14
+ /**
15
+ * Make a new API Exception with the given result.
16
+ *
17
+ * @param Array $result the result from the API server
18
+ */
19
+ public function __construct($result) {
20
+ $this->result = $result;
21
+
22
+ $code = isset($result['error_code']) ? $result['error_code'] : 0;
23
+
24
+ if (isset($result['error_description'])) {
25
+ // OAuth 2.0 Draft 10 style
26
+ $msg = $result['error_description'];
27
+ } else if (isset($result['error']) && is_array($result['error'])) {
28
+ // OAuth 2.0 Draft 00 style
29
+ $msg = $result['error']['message'];
30
+ } else if (isset($result['error_msg'])) {
31
+ // Rest server style
32
+ $msg = $result['error_msg'];
33
+ } else {
34
+ $msg = 'Unknown Error. Check getResult()';
35
+ }
36
+
37
+ parent::__construct($msg, $code);
38
+ }
39
+
40
+ /**
41
+ * Return the associated result object returned by the API server.
42
+ *
43
+ * @returns Array the result from the API server
44
+ */
45
+ public function getResult() {
46
+ return $this->result;
47
+ }
48
+
49
+ /**
50
+ * Returns the associated type for the error. This will default to
51
+ * 'Exception' when a type is not available.
52
+ *
53
+ * @return String
54
+ */
55
+ public function getType() {
56
+ if (isset($this->result['error'])) {
57
+ $error = $this->result['error'];
58
+ if (is_string($error)) {
59
+ // OAuth 2.0 Draft 10 style
60
+ return $error;
61
+ } else if (is_array($error)) {
62
+ // OAuth 2.0 Draft 00 style
63
+ if (isset($error['type'])) {
64
+ return $error['type'];
65
+ }
66
+ }
67
+ }
68
+ return 'Exception';
69
+ }
70
+
71
+ /**
72
+ * To make debugging easier.
73
+ *
74
+ * @returns String the string representation of the error
75
+ */
76
+ public function __toString() {
77
+ $str = $this->getType() . ': ';
78
+ if ($this->code != 0) {
79
+ $str .= $this->code . ': ';
80
+ }
81
+ return $str . $this->message;
82
+ }
83
+ }
lib/Facebook/fb_ca_chain_bundle.crt ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFgjCCBGqgAwIBAgIQDKKbZcnESGaLDuEaVk6fQjANBgkqhkiG9w0BAQUFADBm
3
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
4
+ d3cuZGlnaWNlcnQuY29tMSUwIwYDVQQDExxEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
5
+ ZSBDQS0zMB4XDTEwMDExMzAwMDAwMFoXDTEzMDQxMTIzNTk1OVowaDELMAkGA1UE
6
+ BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExEjAQBgNVBAcTCVBhbG8gQWx0bzEX
7
+ MBUGA1UEChMORmFjZWJvb2ssIEluYy4xFzAVBgNVBAMUDiouZmFjZWJvb2suY29t
8
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9rzj7QIuLM3sdHu1HcI1VcR3g
9
+ b5FExKNV646agxSle1aQ/sJev1mh/u91ynwqd2BQmM0brZ1Hc3QrfYyAaiGGgEkp
10
+ xbhezyfeYhAyO0TKAYxPnm2cTjB5HICzk6xEIwFbA7SBJ2fSyW1CFhYZyo3tIBjj
11
+ 19VjKyBfpRaPkzLmRwIDAQABo4ICrDCCAqgwHwYDVR0jBBgwFoAUUOpzidsp+xCP
12
+ nuUBINTeeZlIg/cwHQYDVR0OBBYEFPp+tsFBozkjrHlEnZ9J4cFj2eM0MA4GA1Ud
13
+ DwEB/wQEAwIFoDAMBgNVHRMBAf8EAjAAMF8GA1UdHwRYMFYwKaAnoCWGI2h0dHA6
14
+ Ly9jcmwzLmRpZ2ljZXJ0LmNvbS9jYTMtZmIuY3JsMCmgJ6AlhiNodHRwOi8vY3Js
15
+ NC5kaWdpY2VydC5jb20vY2EzLWZiLmNybDCCAcYGA1UdIASCAb0wggG5MIIBtQYL
16
+ YIZIAYb9bAEDAAEwggGkMDoGCCsGAQUFBwIBFi5odHRwOi8vd3d3LmRpZ2ljZXJ0
17
+ LmNvbS9zc2wtY3BzLXJlcG9zaXRvcnkuaHRtMIIBZAYIKwYBBQUHAgIwggFWHoIB
18
+ UgBBAG4AeQAgAHUAcwBlACAAbwBmACAAdABoAGkAcwAgAEMAZQByAHQAaQBmAGkA
19
+ YwBhAHQAZQAgAGMAbwBuAHMAdABpAHQAdQB0AGUAcwAgAGEAYwBjAGUAcAB0AGEA
20
+ bgBjAGUAIABvAGYAIAB0AGgAZQAgAEQAaQBnAGkAQwBlAHIAdAAgAEMAUAAvAEMA
21
+ UABTACAAYQBuAGQAIAB0AGgAZQAgAFIAZQBsAHkAaQBuAGcAIABQAGEAcgB0AHkA
22
+ IABBAGcAcgBlAGUAbQBlAG4AdAAgAHcAaABpAGMAaAAgAGwAaQBtAGkAdAAgAGwA
23
+ aQBhAGIAaQBsAGkAdAB5ACAAYQBuAGQAIABhAHIAZQAgAGkAbgBjAG8AcgBwAG8A
24
+ cgBhAHQAZQBkACAAaABlAHIAZQBpAG4AIABiAHkAIAByAGUAZgBlAHIAZQBuAGMA
25
+ ZQAuMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjANBgkqhkiG9w0BAQUF
26
+ AAOCAQEACOkTIdxMy11+CKrbGNLBSg5xHaTvu/v1wbyn3dO/mf68pPfJnX6ShPYy
27
+ 4XM4Vk0x4uaFaU4wAGke+nCKGi5dyg0Esg7nemLNKEJaFAJZ9enxZm334lSCeARy
28
+ wlDtxULGOFRyGIZZPmbV2eNq5xdU/g3IuBEhL722mTpAye9FU/J8Wsnw54/gANyO
29
+ Gzkewigua8ip8Lbs9Cht399yAfbfhUP1DrAm/xEcnHrzPr3cdCtOyJaM6SRPpRqH
30
+ ITK5Nc06tat9lXVosSinT3KqydzxBYua9gCFFiR3x3DgZfvXkC6KDdUlDrNcJUub
31
+ a1BHnLLP4mxTHL6faAXYd05IxNn/IA==
32
+ -----END CERTIFICATE-----
33
+ -----BEGIN CERTIFICATE-----
34
+ MIIGVTCCBT2gAwIBAgIQCFH5WYFBRcq94CTiEsnCDjANBgkqhkiG9w0BAQUFADBs
35
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
36
+ d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
37
+ ZSBFViBSb290IENBMB4XDTA3MDQwMzAwMDAwMFoXDTIyMDQwMzAwMDAwMFowZjEL
38
+ MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3
39
+ LmRpZ2ljZXJ0LmNvbTElMCMGA1UEAxMcRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug
40
+ Q0EtMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9hCikQH17+NDdR
41
+ CPge+yLtYb4LDXBMUGMmdRW5QYiXtvCgFbsIYOBC6AUpEIc2iihlqO8xB3RtNpcv
42
+ KEZmBMcqeSZ6mdWOw21PoF6tvD2Rwll7XjZswFPPAAgyPhBkWBATaccM7pxCUQD5
43
+ BUTuJM56H+2MEb0SqPMV9Bx6MWkBG6fmXcCabH4JnudSREoQOiPkm7YDr6ictFuf
44
+ 1EutkozOtREqqjcYjbTCuNhcBoz4/yO9NV7UfD5+gw6RlgWYw7If48hl66l7XaAs
45
+ zPw82W3tzPpLQ4zJ1LilYRyyQLYoEt+5+F/+07LJ7z20Hkt8HEyZNp496+ynaF4d
46
+ 32duXvsCAwEAAaOCAvcwggLzMA4GA1UdDwEB/wQEAwIBhjCCAcYGA1UdIASCAb0w
47
+ ggG5MIIBtQYLYIZIAYb9bAEDAAIwggGkMDoGCCsGAQUFBwIBFi5odHRwOi8vd3d3
48
+ LmRpZ2ljZXJ0LmNvbS9zc2wtY3BzLXJlcG9zaXRvcnkuaHRtMIIBZAYIKwYBBQUH
49
+ AgIwggFWHoIBUgBBAG4AeQAgAHUAcwBlACAAbwBmACAAdABoAGkAcwAgAEMAZQBy
50
+ AHQAaQBmAGkAYwBhAHQAZQAgAGMAbwBuAHMAdABpAHQAdQB0AGUAcwAgAGEAYwBj
51
+ AGUAcAB0AGEAbgBjAGUAIABvAGYAIAB0AGgAZQAgAEQAaQBnAGkAQwBlAHIAdAAg
52
+ AEMAUAAvAEMAUABTACAAYQBuAGQAIAB0AGgAZQAgAFIAZQBsAHkAaQBuAGcAIABQ
53
+ AGEAcgB0AHkAIABBAGcAcgBlAGUAbQBlAG4AdAAgAHcAaABpAGMAaAAgAGwAaQBt
54
+ AGkAdAAgAGwAaQBhAGIAaQBsAGkAdAB5ACAAYQBuAGQAIABhAHIAZQAgAGkAbgBj
55
+ AG8AcgBwAG8AcgBhAHQAZQBkACAAaABlAHIAZQBpAG4AIABiAHkAIAByAGUAZgBl
56
+ AHIAZQBuAGMAZQAuMA8GA1UdEwEB/wQFMAMBAf8wNAYIKwYBBQUHAQEEKDAmMCQG
57
+ CCsGAQUFBzABhhhodHRwOi8vb2NzcC5kaWdpY2VydC5jb20wgY8GA1UdHwSBhzCB
58
+ hDBAoD6gPIY6aHR0cDovL2NybDMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0SGlnaEFz
59
+ c3VyYW5jZUVWUm9vdENBLmNybDBAoD6gPIY6aHR0cDovL2NybDQuZGlnaWNlcnQu
60
+ Y29tL0RpZ2lDZXJ0SGlnaEFzc3VyYW5jZUVWUm9vdENBLmNybDAfBgNVHSMEGDAW
61
+ gBSxPsNpA/i/RwHUmCYaCALvY2QrwzAdBgNVHQ4EFgQUUOpzidsp+xCPnuUBINTe
62
+ eZlIg/cwDQYJKoZIhvcNAQEFBQADggEBAF1PhPGoiNOjsrycbeUpSXfh59bcqdg1
63
+ rslx3OXb3J0kIZCmz7cBHJvUV5eR13UWpRLXuT0uiT05aYrWNTf58SHEW0CtWakv
64
+ XzoAKUMncQPkvTAyVab+hA4LmzgZLEN8rEO/dTHlIxxFVbdpCJG1z9fVsV7un5Tk
65
+ 1nq5GMO41lJjHBC6iy9tXcwFOPRWBW3vnuzoYTYMFEuFFFoMg08iXFnLjIpx2vrF
66
+ EIRYzwfu45DC9fkpx1ojcflZtGQriLCnNseaIGHr+k61rmsb5OPs4tk8QUmoIKRU
67
+ 9ZKNu8BVIASm2LAXFszj0Mi0PeXZhMbT9m5teMl5Q+h6N/9cNUm/ocU=
68
+ -----END CERTIFICATE-----
69
+ -----BEGIN CERTIFICATE-----
70
+ MIIEQjCCA6ugAwIBAgIEQoclDjANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC
71
+ VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u
72
+ ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc
73
+ KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u
74
+ ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEy
75
+ MjIxNTI3MjdaFw0xNDA3MjIxNTU3MjdaMGwxCzAJBgNVBAYTAlVTMRUwEwYDVQQK
76
+ EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xKzApBgNV
77
+ BAMTIkRpZ2lDZXJ0IEhpZ2ggQXNzdXJhbmNlIEVWIFJvb3QgQ0EwggEiMA0GCSqG
78
+ SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGzOVz5vvUu+UtLTKm3+WBP8nNJUm2cSrD
79
+ 1ZQ0Z6IKHLBfaaZAscS3so/QmKSpQVk609yU1jzbdDikSsxNJYL3SqVTEjju80lt
80
+ cZF+Y7arpl/DpIT4T2JRvvjF7Ns4kuMG5QiRDMQoQVX7y1qJFX5x6DW/TXIJPb46
81
+ OFBbdzEbjbPHJEWap6xtABRaBLe6E+tRCphBQSJOZWGHgUFQpnlcid4ZSlfVLuZd
82
+ HFMsfpjNGgYWpGhz0DQEE1yhcdNafFXbXmThN4cwVgTlEbQpgBLxeTmIogIRfCdm
83
+ t4i3ePLKCqg4qwpkwr9mXZWEwaElHoddGlALIBLMQbtuC1E4uEvLAgMBAAGjggET
84
+ MIIBDzASBgNVHRMBAf8ECDAGAQH/AgEBMCcGA1UdJQQgMB4GCCsGAQUFBwMBBggr
85
+ BgEFBQcDAgYIKwYBBQUHAwQwMwYIKwYBBQUHAQEEJzAlMCMGCCsGAQUFBzABhhdo
86
+ dHRwOi8vb2NzcC5lbnRydXN0Lm5ldDAzBgNVHR8ELDAqMCigJqAkhiJodHRwOi8v
87
+ Y3JsLmVudHJ1c3QubmV0L3NlcnZlcjEuY3JsMB0GA1UdDgQWBBSxPsNpA/i/RwHU
88
+ mCYaCALvY2QrwzALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8BdiE1U9s/8KAGv7
89
+ UISX8+1i0BowGQYJKoZIhvZ9B0EABAwwChsEVjcuMQMCAIEwDQYJKoZIhvcNAQEF
90
+ BQADgYEAUuVY7HCc/9EvhaYzC1rAIo348LtGIiMduEl5Xa24G8tmJnDioD2GU06r
91
+ 1kjLX/ktCdpdBgXadbjtdrZXTP59uN0AXlsdaTiFufsqVLPvkp5yMnqnuI3E2o6p
92
+ NpAkoQSbB6kUCNnXcW26valgOjDLZFOnr241QiwdBAJAAE/rRa8=
93
+ -----END CERTIFICATE-----
94
+ -----BEGIN CERTIFICATE-----
95
+ MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC
96
+ VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u
97
+ ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc
98
+ KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u
99
+ ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1
100
+ MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE
101
+ ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j
102
+ b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF
103
+ bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg
104
+ U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA
105
+ A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/
106
+ I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3
107
+ wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC
108
+ AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb
109
+ oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5
110
+ BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p
111
+ dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk
112
+ MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp
113
+ b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu
114
+ dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0
115
+ MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi
116
+ E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa
117
+ MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI
118
+ hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN
119
+ 95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd
120
+ 2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=
121
+ -----END CERTIFICATE-----
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>facebookfreebelvg</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt">BelVG EULA</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Facebook connect and publish extension allows to login into store using Facebook credentials. Allows to add configurable iLike button to the product page.</summary>
10
+ <description>Facebook connect and publish extension allows to login into store using Facebook credentials. Allows to add configurable iLike button to the product page.</description>
11
+ <notes>Please, feel free to contact us at store@belvg.com</notes>
12
+ <authors><author><name>Belvg</name><user>auto-converted</user><email>store@belvg.com</email></author></authors>
13
+ <date>2011-10-28</date>
14
+ <time>16:30:09</time>
15
+ <contents><target name="magecommunity"><dir name="Belvg"><dir name="All"><dir name="Helper"><file name="Data.php" hash="c508c83bfba72a300592b1b373f41758"/></dir><dir name="etc"><file name="config.xml" hash="8353012d959534a6afd3d75bfc5d9b83"/><file name="system.xml" hash="20d31eefd3bc699d1db1f78cd2b8f4d2"/></dir></dir><dir name="Dashboard"><dir name="Block"><dir name="Adminhtml"><dir name="Dashboard"><dir name="Orders"><file name="Grid.php" hash="39fef1b298c868d2015e3fe886845339"/></dir><dir name="Tab"><file name="Amounts.php" hash="51c67e16a8993765778a904ea6f2e47e"/><file name="Orders.php" hash="b8a6ce28fea099f87eb60f264e090888"/></dir><file name="Diagrams.php" hash="d4e737ea10ab61556bc5c95bbca66eb3"/><file name="Graph.php" hash="77fd945f17f7247d3f2c3f0dcf8d09af"/><file name="Sales.php" hash="0338e229d1c0cd63f70e7ad18849d46d"/><file name="Totals.php" hash="4bf0be09fea916096f6e11aabbb8cf69"/></dir><file name="Dashboard.php" hash="faf358055a11cac4c508c34fcf73d55c"/></dir></dir><dir name="Helper"><dir name="Dashboard"><file name="Order.php" hash="17fcbeb9ca2bee6e19c75d6bdccd8a86"/></dir><file name="Data.php" hash="b35151f456b11a7bc32c9499459eb157"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Order"><file name="Collection.php" hash="4b34a230b0957a0eb2d92a2cd0c4ce64"/></dir></dir></dir><dir name="controllers"><file name="DashboardController.php" hash="624ee618718148c844bf43a145a9819f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8ebd1eec317615d547fb9dac39d4dfcb"/><file name="config.xml" hash="d5c451ea1363f3bad4db15612500892d"/><file name="system.xml" hash="2cf952ba99cfe126350471b0b2bc0215"/></dir></dir><dir name="FacebookAll"><dir name="Block"><file name="Active.php" hash="a1f22f64b65e5fea4bcb325be8796b98"/><file name="Links.php" hash="be308e916b8b45ef551bef7fc0c2cb35"/></dir><dir name="Helper"><file name="Active.php" hash="a48718b45133391f6faad11f59d0e3d7"/><file name="Data.php" hash="ea3228d2855d530bfd25f694239e7d6b"/></dir><dir name="Model"><dir name="Mysql4"><file name="Setup.php" hash="a099e45d0d6ef1eb7a635bb28ee526e1"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Color.php" hash="2542dbcebe51ea510bff0ab800a9f286"/><file name="Font.php" hash="cc55fbb2a26b63a3b356efa3bd923da7"/><file name="Layout.php" hash="c0be1fcb79c13453e525a8b8eeb7a851"/></dir></dir></dir><file name="FacebookAll.php" hash="9b441ca4e3fb548500de0942f4244ce8"/></dir><dir name="controllers"><dir name="Wishlist"><file name="IndexController.php" hash="dcd436076724c77f306a762893f8dd22"/></dir><file name="CustomerController.php" hash="6508688bf3de62d43aa5b41dd5e74583"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4abb5f481b36ecac7d937f405e09c085"/><file name="config.xml" hash="7de291f9a47767a6b54bcb80953b3ad0"/><file name="system.xml" hash="981f9b8fb4c131ffb8e49d6717fd102f"/></dir><dir name="sql"><dir name="facebookall_setup"><file name="mysql4-install-1.0.1.php" hash="6441b95ea239971b38e2aa8b2e1c499f"/></dir></dir></dir><dir name="FaceboookFree"><dir name="Block"><file name="Active.php" hash="813d46911f6500338c30fa5c179e12d3"/><file name="Links.php" hash="a850aed6d41f7e377b1603b5791805e7"/></dir><dir name="Helper"><file name="Active.php" hash="c973b678b89d21748fed2f880e36cf55"/><file name="Data.php" hash="1825805274bce0784ec27ce9bcd1f525"/></dir><dir name="Model"><dir name="Mysql4"><file name="Setup.php" hash="5d7ef9e98a18c04c0d8d1457c96492aa"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Color.php" hash="bd27002596a4bc6018a52618a60b4fcc"/><file name="Layout.php" hash="d8b4cd4c2bb3ae2d40b0a43e84b2812f"/></dir></dir></dir><file name="FaceboookFree.php" hash="6ae1b5b8f461794a42960af5694a0540"/></dir><dir name="controllers"><file name="CustomerController.php" hash="39bbf23fec2e96d3c8d86f4074cd3e5e"/></dir><dir name="etc"><file name="adminhtml.xml" hash="918c2b409a939f35b4e28ce8d1a8d2e9"/><file name="config.xml" hash="c4da62015dc38f2ef44cef3456fdacac"/><file name="system.xml" hash="c493ed694d2f9b87f5ecbf5bfcbc628f"/></dir><dir name="sql"><dir name="facebookfree_setup"><file name="mysql4-install-1.0.1.php" hash="4fb61d52de12359987c0f4975093d4b2"/></dir></dir></dir><dir name="Fullscreenzoom"><dir name="etc"><file name="adminhtml.xml" hash="fbd81897cfd14e089ec000a2f6312eef"/><file name="config.xml" hash="223c7d1c711e12842ffce5757bd5aeaf"/><file name="system.xml" hash="6f7a0d109abde1d2198f6d5e3b8b4566"/></dir></dir><dir name="Twitter"><dir name="Block"><dir name="Adminhtml"><dir name="Settings"><dir name="Tab"><file name="General.php" hash="b87601834cb0b47af54fca61df4b96ca"/></dir><file name="Tabs.php" hash="04d75a30dccc9ea40d7ad2eccb78823f"/></dir><dir name="Twitter"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="87db2f0e0677a98e19e779aa3ca60627"/><file name="Settings.php" hash="79ccd7dfd7dc5193376f5a8cbbe4ff14"/></dir><file name="Form.php" hash="7ea4bddeb76058dfe41941777c6b0c72"/><file name="Tabs.php" hash="6401460f177c5adcc33eba5fb3e9dfc8"/></dir><file name="Edit.php" hash="2facc2aad001cb1ae1ea0b69c23ef0eb"/><file name="Grid.php" hash="6c6a20156e297258e4c5033d76e46c19"/></dir><file name="Settings.php" hash="c38e98ffef0f404fbdbffa8796d27996"/><file name="Twitter.php" hash="1eee9774ee5046893c7509aec474feaf"/></dir><file name="Twitter.php" hash="0824438e589cbd7a2904f4db827b9318"/><file name="Twitterbtn.php" hash="82169219bd2711e33eccadc75fc24abd"/></dir><dir name="Helper"><file name="Data.php" hash="95f53518a585f73d1dc0d9b03c0452e3"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Twitter"><file name="Collection.php" hash="8c27bc29744b82e024be880c3489bf51"/></dir><file name="Twitter.php" hash="2c4206f7e33212508371005f93320f79"/></dir><dir name="Source"><file name="Btntype.php" hash="abf577d82fedce841872fb4bc1e74072"/><file name="Langtype.php" hash="c97ef7816e605878179aa0da43780840"/></dir><file name="Ipad.php" hash="7a5a7a8caf124ab49f258230f97e0919"/><file name="Main.php" hash="85a8f20b9a74c90d9fa60a3dc25baac9"/><file name="Status.php" hash="38e4aefa92ef766ac7095e115b76ed48"/><file name="Twitter.php" hash="9791f5edbf008c3fdb26aa46ea9b5cf2"/></dir><dir name="controllers"><file name="AdminController.php" hash="3a29ddc53b0730f41af2094d255b5039"/><file name="IndexController.php" hash="f607fc80137d391bb2c997b882723fad"/><file name="UserController.php" hash="fbf874afb7873f6a8782d78dda13721a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="b3c433a8388a051579fee280ece528ee"/><file name="config.xml" hash="68f2f2f842c8c6ace25e6b3613b8f45e"/><file name="system.xml" hash="5b83b943241c000089f18515c85c5118"/></dir><dir name="sql"><dir name="twitter_setup"><file name="mysql4-install-1.1.7.php" hash="2137fdf5e3f0db46d410c273bd3d767d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="facebookfree.xml" hash="a4f91867847b391dd2c833907863b0bb"/></dir><dir name="template"><dir name="facebookfree"><dir name="like"><dir name="product"><dir name="view"><file name="addto.phtml" hash="2587002138a3be0944e98079309e8524"/></dir></dir><file name="head.phtml" hash="b618691ffc33a0e71ecf82c8137829e4"/></dir><file name="block.phtml" hash="b0758bf0166b421dfa2bf667cbe44263"/><file name="checkoutlogin.phtml" hash="3f2fbfe2b973338bd595b1664f67d0b4"/><file name="login.phtml" hash="d229b7c2f3e704e1b51616f235024d0c"/><file name="top.links.phtml" hash="4b2e33ac3ab51f53c0616c09da1150ee"/></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Facebook"><file name="Api.php" hash="daf56a2b2c80b069f92ce7e4bee1782f"/><file name="Exception.php" hash="6992e5cc68e456c0841a002cbd92a12b"/><file name="fb_ca_chain_bundle.crt" hash="c3055d03e94bbee13c7c6cc3a76083d9"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><dir name="belvg"><file name="facebookfree.css" hash="c211abe25deeef7c6c31059efa58d701"/></dir></dir><dir name="images"><dir name="belvg"><file name="fb.gif" hash="865312ef4436675a9c79bacb7c97407f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Belvg_All.xml" hash="d322d1671821c290a5fa099381431b2d"/><file name="Belvg_FacebookFree.xml" hash="7417b00b0dd8cd38d0fbba18b891370c"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/frontend/default/default/css/belvg/facebookfree.css ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * BelVG LLC.
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the EULA
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
10
+ *
11
+ /***************************************
12
+ * MAGENTO EDITION USAGE NOTICE *
13
+ *****************************************/
14
+ /* This package designed for Magento COMMUNITY edition
15
+ * BelVG does not guarantee correct work of this extension
16
+ * on any other Magento edition except Magento COMMUNITY edition.
17
+ * BelVG does not provide extension support in case of
18
+ * incorrect edition usage.
19
+ /***************************************
20
+ * DISCLAIMER *
21
+ *****************************************/
22
+ /* Do not edit or add to this file if you wish to upgrade Magento to newer
23
+ * versions in the future.
24
+ *****************************************************
25
+ * @category Belvg
26
+ * @package Belvg_FacebookFree
27
+ * @copyright Copyright (c) 2010 - 2011 BelVG LLC. (http://www.belvg.com)
28
+ * @license http://store.belvg.com/BelVG-LICENSE-COMMUNITY.txt
29
+ */
30
+
31
+
32
+ .fb_button_ps { float: right; margin-left: 5px; }
33
+ .welcome-msg img { margin-left: 5px; }
skin/frontend/default/default/images/belvg/fb.gif ADDED
Binary file