Sumankcdotcom_Advinstagram - Version 1.0.0

Version Notes

Initial release

Download this release

Release Info

Developer Suman K.C
Extension Sumankcdotcom_Advinstagram
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (31) hide show
  1. app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post.php +42 -0
  2. app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit.php +82 -0
  3. app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit/Form.php +52 -0
  4. app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit/Tab/Form.php +121 -0
  5. app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit/Tab/Stores.php +58 -0
  6. app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit/Tabs.php +87 -0
  7. app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Grid.php +267 -0
  8. app/code/local/Sumankcdotcom/AdvInstagram/Block/Post/List.php +69 -0
  9. app/code/local/Sumankcdotcom/AdvInstagram/Controller/Adminhtml/AdvInstagram.php +60 -0
  10. app/code/local/Sumankcdotcom/AdvInstagram/Helper/Data.php +45 -0
  11. app/code/local/Sumankcdotcom/AdvInstagram/Helper/Post.php +53 -0
  12. app/code/local/Sumankcdotcom/AdvInstagram/Model/Adminhtml/Search/Post.php +60 -0
  13. app/code/local/Sumankcdotcom/AdvInstagram/Model/Options.php +16 -0
  14. app/code/local/Sumankcdotcom/AdvInstagram/Model/Post.php +104 -0
  15. app/code/local/Sumankcdotcom/AdvInstagram/Model/Resolutions.php +17 -0
  16. app/code/local/Sumankcdotcom/AdvInstagram/Model/Resource/Post.php +134 -0
  17. app/code/local/Sumankcdotcom/AdvInstagram/Model/Resource/Post/Collection.php +136 -0
  18. app/code/local/Sumankcdotcom/AdvInstagram/Model/Resource/Setup.php +26 -0
  19. app/code/local/Sumankcdotcom/AdvInstagram/controllers/Adminhtml/Advinstagram/PostController.php +328 -0
  20. app/code/local/Sumankcdotcom/AdvInstagram/controllers/PostController.php +64 -0
  21. app/code/local/Sumankcdotcom/AdvInstagram/etc/adminhtml.xml +70 -0
  22. app/code/local/Sumankcdotcom/AdvInstagram/etc/config.xml +134 -0
  23. app/code/local/Sumankcdotcom/AdvInstagram/etc/system.xml +194 -0
  24. app/code/local/Sumankcdotcom/AdvInstagram/sql/sumankcdotcom_advinstagram_setup/install-1.0.0.php +142 -0
  25. app/design/adminhtml/default/default/layout/sumankcdotcom_advinstagram.xml +57 -0
  26. app/design/adminhtml/default/default/template/advinstagram/select.phtml +93 -0
  27. app/design/frontend/base/default/layout/sumankcdotcom_advinstagram.xml +36 -0
  28. app/design/frontend/base/default/template/sumankcdotcom_advinstagram/post/list.phtml +112 -0
  29. app/etc/modules/Sumankcdotcom_AdvInstagram.xml +29 -0
  30. js/advinstagram/instafeed.min.js +2 -0
  31. package.xml +18 -0
app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post admin block
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post extends Mage_Adminhtml_Block_Widget_Grid_Container
25
+ {
26
+ /**
27
+ * constructor
28
+ *
29
+ * @access public
30
+ * @return void
31
+ * @author Suman K.C [SUMANKC.COM]
32
+ */
33
+ public function __construct()
34
+ {
35
+ $this->_controller = 'adminhtml_post';
36
+ $this->_blockGroup = 'sumankcdotcom_advinstagram';
37
+ parent::__construct();
38
+ $this->_headerText = Mage::helper('sumankcdotcom_advinstagram')->__('Post');
39
+ $this->_updateButton('add', 'label', Mage::helper('sumankcdotcom_advinstagram')->__('Add Post'));
40
+
41
+ }
42
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post admin edit form
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
25
+ {
26
+ /**
27
+ * constructor
28
+ *
29
+ * @access public
30
+ * @return void
31
+ * @author Suman K.C [SUMANKC.COM]
32
+ */
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+ $this->_blockGroup = 'sumankcdotcom_advinstagram';
37
+ $this->_controller = 'adminhtml_post';
38
+ $this->_updateButton(
39
+ 'save',
40
+ 'label',
41
+ Mage::helper('sumankcdotcom_advinstagram')->__('Save Post')
42
+ );
43
+ $this->_updateButton(
44
+ 'delete',
45
+ 'label',
46
+ Mage::helper('sumankcdotcom_advinstagram')->__('Delete Post')
47
+ );
48
+ $this->_addButton(
49
+ 'saveandcontinue',
50
+ array(
51
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Save And Continue Edit'),
52
+ 'onclick' => 'saveAndContinueEdit()',
53
+ 'class' => 'save',
54
+ ),
55
+ -100
56
+ );
57
+ $this->_formScripts[] = "
58
+ function saveAndContinueEdit() {
59
+ editForm.submit($('edit_form').action+'back/edit/');
60
+ }
61
+ ";
62
+ }
63
+
64
+ /**
65
+ * get the edit form header
66
+ *
67
+ * @access public
68
+ * @return string
69
+ * @author Suman K.C [SUMANKC.COM]
70
+ */
71
+ public function getHeaderText()
72
+ {
73
+ if (Mage::registry('current_post') && Mage::registry('current_post')->getId()) {
74
+ return Mage::helper('sumankcdotcom_advinstagram')->__(
75
+ "Edit Post '%s'",
76
+ $this->escapeHtml(Mage::registry('current_post')->getMediaId())
77
+ );
78
+ } else {
79
+ return Mage::helper('sumankcdotcom_advinstagram')->__('Add Post');
80
+ }
81
+ }
82
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit/Form.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post edit form
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
25
+ {
26
+ /**
27
+ * prepare form
28
+ *
29
+ * @access protected
30
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit_Form
31
+ * @author Suman K.C [SUMANKC.COM]
32
+ */
33
+ protected function _prepareForm()
34
+ {
35
+ $form = new Varien_Data_Form(
36
+ array(
37
+ 'id' => 'edit_form',
38
+ 'action' => $this->getUrl(
39
+ '*/*/save',
40
+ array(
41
+ 'id' => $this->getRequest()->getParam('id')
42
+ )
43
+ ),
44
+ 'method' => 'post',
45
+ 'enctype' => 'multipart/form-data'
46
+ )
47
+ );
48
+ $form->setUseContainer(true);
49
+ $this->setForm($form);
50
+ return parent::_prepareForm();
51
+ }
52
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit/Tab/Form.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post edit form tab
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
25
+ {
26
+ /**
27
+ * prepare the form
28
+ *
29
+ * @access protected
30
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit_Tab_Form
31
+ * @author Suman K.C [SUMANKC.COM]
32
+ */
33
+ protected function _prepareForm()
34
+ {
35
+ $form = new Varien_Data_Form();
36
+ $form->setHtmlIdPrefix('post_');
37
+ $form->setFieldNameSuffix('post');
38
+ $this->setForm($form);
39
+ $fieldset = $form->addFieldset(
40
+ 'post_form',
41
+ array('legend' => Mage::helper('sumankcdotcom_advinstagram')->__('Post'))
42
+ );
43
+
44
+ $fieldset->addField(
45
+ 'media_id',
46
+ 'text',
47
+ array(
48
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Media Id'),
49
+ 'name' => 'media_id',
50
+ 'required' => true,
51
+ 'class' => 'required-entry',
52
+
53
+ )
54
+ );
55
+
56
+ $fieldset->addField(
57
+ 'username',
58
+ 'text',
59
+ array(
60
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Link'),
61
+ 'name' => 'username',
62
+ 'required' => true,
63
+ 'class' => 'required-entry',
64
+
65
+ )
66
+ );
67
+
68
+ $fieldset->addField(
69
+ 'caption',
70
+ 'text',
71
+ array(
72
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Caption'),
73
+ 'name' => 'caption',
74
+ 'required' => true,
75
+ 'class' => 'required-entry',
76
+
77
+ )
78
+ );
79
+ $fieldset->addField(
80
+ 'status',
81
+ 'select',
82
+ array(
83
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Status'),
84
+ 'name' => 'status',
85
+ 'values' => array(
86
+ array(
87
+ 'value' => 1,
88
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Enabled'),
89
+ ),
90
+ array(
91
+ 'value' => 0,
92
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Disabled'),
93
+ ),
94
+ ),
95
+ )
96
+ );
97
+ if (Mage::app()->isSingleStoreMode()) {
98
+ $fieldset->addField(
99
+ 'store_id',
100
+ 'hidden',
101
+ array(
102
+ 'name' => 'stores[]',
103
+ 'value' => Mage::app()->getStore(true)->getId()
104
+ )
105
+ );
106
+ Mage::registry('current_post')->setStoreId(Mage::app()->getStore(true)->getId());
107
+ }
108
+ $formValues = Mage::registry('current_post')->getDefaultValues();
109
+ if (!is_array($formValues)) {
110
+ $formValues = array();
111
+ }
112
+ if (Mage::getSingleton('adminhtml/session')->getPostData()) {
113
+ $formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getPostData());
114
+ Mage::getSingleton('adminhtml/session')->setPostData(null);
115
+ } elseif (Mage::registry('current_post')) {
116
+ $formValues = array_merge($formValues, Mage::registry('current_post')->getData());
117
+ }
118
+ $form->setValues($formValues);
119
+ return parent::_prepareForm();
120
+ }
121
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit/Tab/Stores.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * store selection tab
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
25
+ {
26
+ /**
27
+ * prepare the form
28
+ *
29
+ * @access protected
30
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit_Tab_Stores
31
+ * @author Suman K.C [SUMANKC.COM]
32
+ */
33
+ protected function _prepareForm()
34
+ {
35
+ $form = new Varien_Data_Form();
36
+ $form->setFieldNameSuffix('post');
37
+ $this->setForm($form);
38
+ $fieldset = $form->addFieldset(
39
+ 'post_stores_form',
40
+ array('legend' => Mage::helper('sumankcdotcom_advinstagram')->__('Store views'))
41
+ );
42
+ $field = $fieldset->addField(
43
+ 'store_id',
44
+ 'multiselect',
45
+ array(
46
+ 'name' => 'stores[]',
47
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Store Views'),
48
+ 'title' => Mage::helper('sumankcdotcom_advinstagram')->__('Store Views'),
49
+ 'required' => true,
50
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
51
+ )
52
+ );
53
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
54
+ $field->setRenderer($renderer);
55
+ $form->addValues(Mage::registry('current_post')->getData());
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Edit/Tabs.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post admin edit tabs
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
25
+ {
26
+ /**
27
+ * Initialize Tabs
28
+ *
29
+ * @access public
30
+ * @author Suman K.C [SUMANKC.COM]
31
+ */
32
+ public function __construct()
33
+ {
34
+ parent::__construct();
35
+ $this->setId('post_tabs');
36
+ $this->setDestElementId('edit_form');
37
+ $this->setTitle(Mage::helper('sumankcdotcom_advinstagram')->__('Post'));
38
+ }
39
+
40
+ /**
41
+ * before render html
42
+ *
43
+ * @access protected
44
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Edit_Tabs
45
+ * @author Suman K.C [SUMANKC.COM]
46
+ */
47
+ protected function _beforeToHtml()
48
+ {
49
+ $this->addTab(
50
+ 'form_post',
51
+ array(
52
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Post'),
53
+ 'title' => Mage::helper('sumankcdotcom_advinstagram')->__('Post'),
54
+ 'content' => $this->getLayout()->createBlock(
55
+ 'sumankcdotcom_advinstagram/adminhtml_post_edit_tab_form'
56
+ )
57
+ ->toHtml(),
58
+ )
59
+ );
60
+ if (!Mage::app()->isSingleStoreMode()) {
61
+ $this->addTab(
62
+ 'form_store_post',
63
+ array(
64
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Store views'),
65
+ 'title' => Mage::helper('sumankcdotcom_advinstagram')->__('Store views'),
66
+ 'content' => $this->getLayout()->createBlock(
67
+ 'sumankcdotcom_advinstagram/adminhtml_post_edit_tab_stores'
68
+ )
69
+ ->toHtml(),
70
+ )
71
+ );
72
+ }
73
+ return parent::_beforeToHtml();
74
+ }
75
+
76
+ /**
77
+ * Retrieve post entity
78
+ *
79
+ * @access public
80
+ * @return Sumankcdotcom_AdvInstagram_Model_Post
81
+ * @author Suman K.C [SUMANKC.COM]
82
+ */
83
+ public function getPost()
84
+ {
85
+ return Mage::registry('current_post');
86
+ }
87
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Block/Adminhtml/Post/Grid.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post admin grid block
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Grid extends Mage_Adminhtml_Block_Widget_Grid
25
+ {
26
+ /**
27
+ * constructor
28
+ *
29
+ * @access public
30
+ * @author Suman K.C [SUMANKC.COM]
31
+ */
32
+ public function __construct()
33
+ {
34
+ parent::__construct();
35
+ $this->setId('postGrid');
36
+ $this->setDefaultSort('entity_id');
37
+ $this->setDefaultDir('ASC');
38
+ $this->setSaveParametersInSession(true);
39
+ $this->setUseAjax(true);
40
+ }
41
+
42
+ /**
43
+ * prepare collection
44
+ *
45
+ * @access protected
46
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Grid
47
+ * @author Suman K.C [SUMANKC.COM]
48
+ */
49
+ protected function _prepareCollection()
50
+ {
51
+ $collection = Mage::getModel('sumankcdotcom_advinstagram/post')
52
+ ->getCollection();
53
+
54
+ $this->setCollection($collection);
55
+ return parent::_prepareCollection();
56
+ }
57
+
58
+ /**
59
+ * prepare grid collection
60
+ *
61
+ * @access protected
62
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Grid
63
+ * @author Suman K.C [SUMANKC.COM]
64
+ */
65
+ protected function _prepareColumns()
66
+ {
67
+ $this->addColumn(
68
+ 'entity_id',
69
+ array(
70
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Id'),
71
+ 'index' => 'entity_id',
72
+ 'type' => 'number'
73
+ )
74
+ );
75
+ $this->addColumn(
76
+ 'media_id',
77
+ array(
78
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Media Id'),
79
+ 'align' => 'left',
80
+ 'index' => 'media_id',
81
+ )
82
+ );
83
+
84
+ $this->addColumn(
85
+ 'status',
86
+ array(
87
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Status'),
88
+ 'index' => 'status',
89
+ 'type' => 'options',
90
+ 'options' => array(
91
+ '1' => Mage::helper('sumankcdotcom_advinstagram')->__('Enabled'),
92
+ '0' => Mage::helper('sumankcdotcom_advinstagram')->__('Disabled'),
93
+ )
94
+ )
95
+ );
96
+ $this->addColumn(
97
+ 'username',
98
+ array(
99
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Link'),
100
+ 'index' => 'username',
101
+ 'type'=> 'text',
102
+
103
+ )
104
+ );
105
+ $this->addColumn(
106
+ 'caption',
107
+ array(
108
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Caption'),
109
+ 'index' => 'caption',
110
+ 'type'=> 'text',
111
+
112
+ )
113
+ );
114
+ if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
115
+ $this->addColumn(
116
+ 'store_id',
117
+ array(
118
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Store Views'),
119
+ 'index' => 'store_id',
120
+ 'type' => 'store',
121
+ 'store_all' => true,
122
+ 'store_view' => true,
123
+ 'sortable' => false,
124
+ 'filter_condition_callback'=> array($this, '_filterStoreCondition'),
125
+ )
126
+ );
127
+ }
128
+ $this->addColumn(
129
+ 'created_at',
130
+ array(
131
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Created at'),
132
+ 'index' => 'created_at',
133
+ 'width' => '120px',
134
+ 'type' => 'datetime',
135
+ )
136
+ );
137
+ $this->addColumn(
138
+ 'updated_at',
139
+ array(
140
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Updated at'),
141
+ 'index' => 'updated_at',
142
+ 'width' => '120px',
143
+ 'type' => 'datetime',
144
+ )
145
+ );
146
+ $this->addColumn(
147
+ 'action',
148
+ array(
149
+ 'header' => Mage::helper('sumankcdotcom_advinstagram')->__('Action'),
150
+ 'width' => '100',
151
+ 'type' => 'action',
152
+ 'getter' => 'getId',
153
+ 'actions' => array(
154
+ array(
155
+ 'caption' => Mage::helper('sumankcdotcom_advinstagram')->__('Edit'),
156
+ 'url' => array('base'=> '*/*/edit'),
157
+ 'field' => 'id'
158
+ )
159
+ ),
160
+ 'filter' => false,
161
+ 'is_system' => true,
162
+ 'sortable' => false,
163
+ )
164
+ );
165
+ $this->addExportType('*/*/exportCsv', Mage::helper('sumankcdotcom_advinstagram')->__('CSV'));
166
+ $this->addExportType('*/*/exportExcel', Mage::helper('sumankcdotcom_advinstagram')->__('Excel'));
167
+ $this->addExportType('*/*/exportXml', Mage::helper('sumankcdotcom_advinstagram')->__('XML'));
168
+ return parent::_prepareColumns();
169
+ }
170
+
171
+ /**
172
+ * prepare mass action
173
+ *
174
+ * @access protected
175
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Grid
176
+ * @author Suman K.C [SUMANKC.COM]
177
+ */
178
+ protected function _prepareMassaction()
179
+ {
180
+ $this->setMassactionIdField('entity_id');
181
+ $this->getMassactionBlock()->setFormFieldName('post');
182
+ $this->getMassactionBlock()->addItem(
183
+ 'delete',
184
+ array(
185
+ 'label'=> Mage::helper('sumankcdotcom_advinstagram')->__('Delete'),
186
+ 'url' => $this->getUrl('*/*/massDelete'),
187
+ 'confirm' => Mage::helper('sumankcdotcom_advinstagram')->__('Are you sure?')
188
+ )
189
+ );
190
+ $this->getMassactionBlock()->addItem(
191
+ 'status',
192
+ array(
193
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Change status'),
194
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
195
+ 'additional' => array(
196
+ 'status' => array(
197
+ 'name' => 'status',
198
+ 'type' => 'select',
199
+ 'class' => 'required-entry',
200
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Status'),
201
+ 'values' => array(
202
+ '1' => Mage::helper('sumankcdotcom_advinstagram')->__('Enabled'),
203
+ '0' => Mage::helper('sumankcdotcom_advinstagram')->__('Disabled'),
204
+ )
205
+ )
206
+ )
207
+ )
208
+ );
209
+ return $this;
210
+ }
211
+
212
+ /**
213
+ * get the row url
214
+ *
215
+ * @access public
216
+ * @param Sumankcdotcom_AdvInstagram_Model_Post
217
+ * @return string
218
+ * @author Suman K.C [SUMANKC.COM]
219
+ */
220
+ public function getRowUrl($row)
221
+ {
222
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
223
+ }
224
+
225
+ /**
226
+ * get the grid url
227
+ *
228
+ * @access public
229
+ * @return string
230
+ * @author Suman K.C [SUMANKC.COM]
231
+ */
232
+ public function getGridUrl()
233
+ {
234
+ return $this->getUrl('*/*/grid', array('_current'=>true));
235
+ }
236
+
237
+ /**
238
+ * after collection load
239
+ *
240
+ * @access protected
241
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Grid
242
+ * @author Suman K.C [SUMANKC.COM]
243
+ */
244
+ protected function _afterLoadCollection()
245
+ {
246
+ $this->getCollection()->walk('afterLoad');
247
+ parent::_afterLoadCollection();
248
+ }
249
+
250
+ /**
251
+ * filter store column
252
+ *
253
+ * @access protected
254
+ * @param Sumankcdotcom_AdvInstagram_Model_Resource_Post_Collection $collection
255
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
256
+ * @return Sumankcdotcom_AdvInstagram_Block_Adminhtml_Post_Grid
257
+ * @author Suman K.C [SUMANKC.COM]
258
+ */
259
+ protected function _filterStoreCondition($collection, $column)
260
+ {
261
+ if (!$value = $column->getFilter()->getValue()) {
262
+ return;
263
+ }
264
+ $collection->addStoreFilter($value);
265
+ return $this;
266
+ }
267
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Block/Post/List.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post list block
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Block_Post_List extends Mage_Core_Block_Template
25
+ {
26
+ /**
27
+ * initialize
28
+ *
29
+ * @access public
30
+ * @author Suman K.C [SUMANKC.COM]
31
+ */
32
+ public function _construct()
33
+ {
34
+ parent::_construct();
35
+ $posts = Mage::getResourceModel('sumankcdotcom_advinstagram/post_collection')
36
+ ->addStoreFilter(Mage::app()->getStore())
37
+ ->addFieldToFilter('status', 1)
38
+ ->setPageSize(100)
39
+ ->setOrder('created_at', 'desc');
40
+ $posts->setOrder('media_id', 'asc');
41
+ $this->setPosts($posts);
42
+ }
43
+
44
+ /**
45
+ * prepare the layout
46
+ *
47
+ * @access protected
48
+ * @return Sumankcdotcom_AdvInstagram_Block_Post_List
49
+ * @author Suman K.C [SUMANKC.COM]
50
+ */
51
+ protected function _prepareLayout()
52
+ {
53
+ parent::_prepareLayout();
54
+ $this->getPosts()->load();
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * get the pager html
60
+ *
61
+ * @access public
62
+ * @return string
63
+ * @author Suman K.C [SUMANKC.COM]
64
+ */
65
+ public function getPagerHtml()
66
+ {
67
+ return $this->getChildHtml('pager');
68
+ }
69
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Controller/Adminhtml/AdvInstagram.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * module base admin controller
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Controller_Adminhtml_AdvInstagram extends Mage_Adminhtml_Controller_Action
25
+ {
26
+ /**
27
+ * upload file and get the uploaded name
28
+ *
29
+ * @access public
30
+ * @param string $input
31
+ * @param string $destinationFolder
32
+ * @param array $data
33
+ * @return string
34
+ * @author Suman K.C [SUMANKC.COM]
35
+ */
36
+ protected function _uploadAndGetName($input, $destinationFolder, $data)
37
+ {
38
+ try {
39
+ if (isset($data[$input]['delete'])) {
40
+ return '';
41
+ } else {
42
+ $uploader = new Varien_File_Uploader($input);
43
+ $uploader->setAllowRenameFiles(true);
44
+ $uploader->setFilesDispersion(true);
45
+ $uploader->setAllowCreateFolders(true);
46
+ $result = $uploader->save($destinationFolder);
47
+ return $result['file'];
48
+ }
49
+ } catch (Exception $e) {
50
+ if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
51
+ throw $e;
52
+ } else {
53
+ if (isset($data[$input]['value'])) {
54
+ return $data[$input]['value'];
55
+ }
56
+ }
57
+ }
58
+ return '';
59
+ }
60
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Helper/Data.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * AdvInstagram default helper
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Helper_Data extends Mage_Core_Helper_Abstract
25
+ {
26
+ /**
27
+ * convert array to options
28
+ *
29
+ * @access public
30
+ * @param $options
31
+ * @return array
32
+ * @author Suman K.C [SUMANKC.COM]
33
+ */
34
+ public function convertOptions($options)
35
+ {
36
+ $converted = array();
37
+ foreach ($options as $option) {
38
+ if (isset($option['value']) && !is_array($option['value']) &&
39
+ isset($option['label']) && !is_array($option['label'])) {
40
+ $converted[$option['value']] = $option['label'];
41
+ }
42
+ }
43
+ return $converted;
44
+ }
45
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Helper/Post.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post helper
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Helper_Post extends Mage_Core_Helper_Abstract
25
+ {
26
+
27
+ /**
28
+ * get the url to the posts list page
29
+ *
30
+ * @access public
31
+ * @return string
32
+ * @author Suman K.C [SUMANKC.COM]
33
+ */
34
+ public function getPostsUrl()
35
+ {
36
+ if ($listKey = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/url_rewrite_list')) {
37
+ return Mage::getUrl('', array('_direct'=>$listKey));
38
+ }
39
+ return Mage::getUrl('sumankcdotcom_advinstagram/post/index');
40
+ }
41
+
42
+ /**
43
+ * check if breadcrumbs can be used
44
+ *
45
+ * @access public
46
+ * @return bool
47
+ * @author Suman K.C [SUMANKC.COM]
48
+ */
49
+ public function getUseBreadcrumbs()
50
+ {
51
+ return Mage::getStoreConfigFlag('sumankcdotcom_advinstagram/post/breadcrumbs');
52
+ }
53
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Model/Adminhtml/Search/Post.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Admin search model
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Model_Adminhtml_Search_Post extends Varien_Object
25
+ {
26
+ /**
27
+ * Load search results
28
+ *
29
+ * @access public
30
+ * @return Sumankcdotcom_AdvInstagram_Model_Adminhtml_Search_Post
31
+ * @author Suman K.C [SUMANKC.COM]
32
+ */
33
+ public function load()
34
+ {
35
+ $arr = array();
36
+ if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
37
+ $this->setResults($arr);
38
+ return $this;
39
+ }
40
+ $collection = Mage::getResourceModel('sumankcdotcom_advinstagram/post_collection')
41
+ ->addFieldToFilter('media_id', array('like' => $this->getQuery().'%'))
42
+ ->setCurPage($this->getStart())
43
+ ->setPageSize($this->getLimit())
44
+ ->load();
45
+ foreach ($collection->getItems() as $post) {
46
+ $arr[] = array(
47
+ 'id' => 'post/1/'.$post->getId(),
48
+ 'type' => Mage::helper('sumankcdotcom_advinstagram')->__('Post'),
49
+ 'name' => $post->getMediaId(),
50
+ 'description' => $post->getMediaId(),
51
+ 'url' => Mage::helper('adminhtml')->getUrl(
52
+ '*/advinstagram_post/edit',
53
+ array('id'=>$post->getId())
54
+ ),
55
+ );
56
+ }
57
+ $this->setResults($arr);
58
+ return $this;
59
+ }
60
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Model/Options.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Sumankcdotcom_AdvInstagram_Model_Options
3
+ {
4
+ /**
5
+ * Provide available options as a value/label array
6
+ *
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ return array(
12
+ array('value'=>'account', 'label'=>'User account'),
13
+ array('value'=>'hashtag', 'label'=>'Hashtagged')
14
+ );
15
+ }
16
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Model/Post.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post model
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Model_Post extends Mage_Core_Model_Abstract
25
+ {
26
+ /**
27
+ * Entity code.
28
+ * Can be used as part of method name for entity processing
29
+ */
30
+ const ENTITY = 'sumankcdotcom_advinstagram_post';
31
+ const CACHE_TAG = 'sumankcdotcom_advinstagram_post';
32
+
33
+ /**
34
+ * Prefix of model events names
35
+ *
36
+ * @var string
37
+ */
38
+ protected $_eventPrefix = 'sumankcdotcom_advinstagram_post';
39
+
40
+ /**
41
+ * Parameter name in event
42
+ *
43
+ * @var string
44
+ */
45
+ protected $_eventObject = 'post';
46
+
47
+ /**
48
+ * constructor
49
+ *
50
+ * @access public
51
+ * @return void
52
+ * @author Suman K.C [SUMANKC.COM]
53
+ */
54
+ public function _construct()
55
+ {
56
+ parent::_construct();
57
+ $this->_init('sumankcdotcom_advinstagram/post');
58
+ }
59
+
60
+ /**
61
+ * before save post
62
+ *
63
+ * @access protected
64
+ * @return Sumankcdotcom_AdvInstagram_Model_Post
65
+ * @author Suman K.C [SUMANKC.COM]
66
+ */
67
+ protected function _beforeSave()
68
+ {
69
+ parent::_beforeSave();
70
+ $now = Mage::getSingleton('core/date')->gmtDate();
71
+ if ($this->isObjectNew()) {
72
+ $this->setCreatedAt($now);
73
+ }
74
+ $this->setUpdatedAt($now);
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * save post relation
80
+ *
81
+ * @access public
82
+ * @return Sumankcdotcom_AdvInstagram_Model_Post
83
+ * @author Suman K.C [SUMANKC.COM]
84
+ */
85
+ protected function _afterSave()
86
+ {
87
+ return parent::_afterSave();
88
+ }
89
+
90
+ /**
91
+ * get default values
92
+ *
93
+ * @access public
94
+ * @return array
95
+ * @author Suman K.C [SUMANKC.COM]
96
+ */
97
+ public function getDefaultValues()
98
+ {
99
+ $values = array();
100
+ $values['status'] = 1;
101
+ return $values;
102
+ }
103
+
104
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Model/Resolutions.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Sumankcdotcom_AdvInstagram_Model_Resolutions
3
+ {
4
+ /**
5
+ * Provide available options as a value/label array
6
+ *
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ return array(
12
+ array('value'=>'thumbnail', 'label'=>'thumbnail (default) - 150x150'),
13
+ array('value'=>'low_resolution', 'label'=>'low_resolution - 306x306'),
14
+ array('value'=>'standard_resolution', 'label'=>'standard_resolution - 612x612'),
15
+ );
16
+ }
17
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Model/Resource/Post.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post resource model
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Model_Resource_Post extends Mage_Core_Model_Resource_Db_Abstract
25
+ {
26
+
27
+ /**
28
+ * constructor
29
+ *
30
+ * @access public
31
+ * @author Suman K.C [SUMANKC.COM]
32
+ */
33
+ public function _construct()
34
+ {
35
+ $this->_init('sumankcdotcom_advinstagram/post', 'entity_id');
36
+ }
37
+
38
+ /**
39
+ * Get store ids to which specified item is assigned
40
+ *
41
+ * @access public
42
+ * @param int $postId
43
+ * @return array
44
+ * @author Suman K.C [SUMANKC.COM]
45
+ */
46
+ public function lookupStoreIds($postId)
47
+ {
48
+ $adapter = $this->_getReadAdapter();
49
+ $select = $adapter->select()
50
+ ->from($this->getTable('sumankcdotcom_advinstagram/post_store'), 'store_id')
51
+ ->where('post_id = ?', (int)$postId);
52
+ return $adapter->fetchCol($select);
53
+ }
54
+
55
+ /**
56
+ * Perform operations after object load
57
+ *
58
+ * @access public
59
+ * @param Mage_Core_Model_Abstract $object
60
+ * @return Sumankcdotcom_AdvInstagram_Model_Resource_Post
61
+ * @author Suman K.C [SUMANKC.COM]
62
+ */
63
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
64
+ {
65
+ if ($object->getId()) {
66
+ $stores = $this->lookupStoreIds($object->getId());
67
+ $object->setData('store_id', $stores);
68
+ }
69
+ return parent::_afterLoad($object);
70
+ }
71
+
72
+ /**
73
+ * Retrieve select object for load object data
74
+ *
75
+ * @param string $field
76
+ * @param mixed $value
77
+ * @param Sumankcdotcom_AdvInstagram_Model_Post $object
78
+ * @return Zend_Db_Select
79
+ */
80
+ protected function _getLoadSelect($field, $value, $object)
81
+ {
82
+ $select = parent::_getLoadSelect($field, $value, $object);
83
+ if ($object->getStoreId()) {
84
+ $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
85
+ $select->join(
86
+ array('advinstagram_post_store' => $this->getTable('sumankcdotcom_advinstagram/post_store')),
87
+ $this->getMainTable() . '.entity_id = advinstagram_post_store.post_id',
88
+ array()
89
+ )
90
+ ->where('advinstagram_post_store.store_id IN (?)', $storeIds)
91
+ ->order('advinstagram_post_store.store_id DESC')
92
+ ->limit(1);
93
+ }
94
+ return $select;
95
+ }
96
+
97
+ /**
98
+ * Assign post to store views
99
+ *
100
+ * @access protected
101
+ * @param Mage_Core_Model_Abstract $object
102
+ * @return Sumankcdotcom_AdvInstagram_Model_Resource_Post
103
+ * @author Suman K.C [SUMANKC.COM]
104
+ */
105
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
106
+ {
107
+ $oldStores = $this->lookupStoreIds($object->getId());
108
+ $newStores = (array)$object->getStores();
109
+ if (empty($newStores)) {
110
+ $newStores = (array)$object->getStoreId();
111
+ }
112
+ $table = $this->getTable('sumankcdotcom_advinstagram/post_store');
113
+ $insert = array_diff($newStores, $oldStores);
114
+ $delete = array_diff($oldStores, $newStores);
115
+ if ($delete) {
116
+ $where = array(
117
+ 'post_id = ?' => (int) $object->getId(),
118
+ 'store_id IN (?)' => $delete
119
+ );
120
+ $this->_getWriteAdapter()->delete($table, $where);
121
+ }
122
+ if ($insert) {
123
+ $data = array();
124
+ foreach ($insert as $storeId) {
125
+ $data[] = array(
126
+ 'post_id' => (int) $object->getId(),
127
+ 'store_id' => (int) $storeId
128
+ );
129
+ }
130
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
131
+ }
132
+ return parent::_afterSave($object);
133
+ }
134
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Model/Resource/Post/Collection.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post collection resource model
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Model_Resource_Post_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
25
+ {
26
+ protected $_joinedFields = array();
27
+
28
+ /**
29
+ * constructor
30
+ *
31
+ * @access public
32
+ * @return void
33
+ * @author Suman K.C [SUMANKC.COM]
34
+ */
35
+ protected function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_init('sumankcdotcom_advinstagram/post');
39
+ $this->_map['fields']['store'] = 'store_table.store_id';
40
+ }
41
+
42
+ /**
43
+ * Add filter by store
44
+ *
45
+ * @access public
46
+ * @param int|Mage_Core_Model_Store $store
47
+ * @param bool $withAdmin
48
+ * @return Sumankcdotcom_AdvInstagram_Model_Resource_Post_Collection
49
+ * @author Suman K.C [SUMANKC.COM]
50
+ */
51
+ public function addStoreFilter($store, $withAdmin = true)
52
+ {
53
+ if (!isset($this->_joinedFields['store'])) {
54
+ if ($store instanceof Mage_Core_Model_Store) {
55
+ $store = array($store->getId());
56
+ }
57
+ if (!is_array($store)) {
58
+ $store = array($store);
59
+ }
60
+ if ($withAdmin) {
61
+ $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
62
+ }
63
+ $this->addFilter('store', array('in' => $store), 'public');
64
+ $this->_joinedFields['store'] = true;
65
+ }
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * Join store relation table if there is store filter
71
+ *
72
+ * @access protected
73
+ * @return Sumankcdotcom_AdvInstagram_Model_Resource_Post_Collection
74
+ * @author Suman K.C [SUMANKC.COM]
75
+ */
76
+ protected function _renderFiltersBefore()
77
+ {
78
+ if ($this->getFilter('store')) {
79
+ $this->getSelect()->join(
80
+ array('store_table' => $this->getTable('sumankcdotcom_advinstagram/post_store')),
81
+ 'main_table.entity_id = store_table.post_id',
82
+ array()
83
+ )
84
+ ->group('main_table.entity_id');
85
+ /*
86
+ * Allow analytic functions usage because of one field grouping
87
+ */
88
+ $this->_useAnalyticFunction = true;
89
+ }
90
+ return parent::_renderFiltersBefore();
91
+ }
92
+
93
+ /**
94
+ * get posts as array
95
+ *
96
+ * @access protected
97
+ * @param string $valueField
98
+ * @param string $labelField
99
+ * @param array $additional
100
+ * @return array
101
+ * @author Suman K.C [SUMANKC.COM]
102
+ */
103
+ protected function _toOptionArray($valueField='entity_id', $labelField='media_id', $additional=array())
104
+ {
105
+ return parent::_toOptionArray($valueField, $labelField, $additional);
106
+ }
107
+
108
+ /**
109
+ * get options hash
110
+ *
111
+ * @access protected
112
+ * @param string $valueField
113
+ * @param string $labelField
114
+ * @return array
115
+ * @author Suman K.C [SUMANKC.COM]
116
+ */
117
+ protected function _toOptionHash($valueField='entity_id', $labelField='media_id')
118
+ {
119
+ return parent::_toOptionHash($valueField, $labelField);
120
+ }
121
+
122
+ /**
123
+ * Get SQL for get record count.
124
+ * Extra GROUP BY strip added.
125
+ *
126
+ * @access public
127
+ * @return Varien_Db_Select
128
+ * @author Suman K.C [SUMANKC.COM]
129
+ */
130
+ public function getSelectCountSql()
131
+ {
132
+ $countSelect = parent::getSelectCountSql();
133
+ $countSelect->reset(Zend_Db_Select::GROUP);
134
+ return $countSelect;
135
+ }
136
+ }
app/code/local/Sumankcdotcom/AdvInstagram/Model/Resource/Setup.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * AdvInstagram setup
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
25
+ {
26
+ }
app/code/local/Sumankcdotcom/AdvInstagram/controllers/Adminhtml/Advinstagram/PostController.php ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post admin controller
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_Adminhtml_Advinstagram_PostController extends Sumankcdotcom_AdvInstagram_Controller_Adminhtml_AdvInstagram
25
+ {
26
+ /**
27
+ * init the post
28
+ *
29
+ * @access protected
30
+ * @return Sumankcdotcom_AdvInstagram_Model_Post
31
+ */
32
+ protected function _initPost()
33
+ {
34
+ $postId = (int) $this->getRequest()->getParam('id');
35
+ $post = Mage::getModel('sumankcdotcom_advinstagram/post');
36
+ if ($postId) {
37
+ $post->load($postId);
38
+ }
39
+ Mage::register('current_post', $post);
40
+ return $post;
41
+ }
42
+
43
+ /**
44
+ * default action
45
+ *
46
+ * @access public
47
+ * @return void
48
+ * @author Suman K.C [SUMANKC.COM]
49
+ */
50
+ public function indexAction()
51
+ {
52
+ $this->loadLayout();
53
+ $this->_title(Mage::helper('sumankcdotcom_advinstagram')->__('Instagram'))
54
+ ->_title(Mage::helper('sumankcdotcom_advinstagram')->__('Posts'));
55
+ $this->renderLayout();
56
+ }
57
+
58
+ /**
59
+ * grid action
60
+ *
61
+ * @access public
62
+ * @return void
63
+ * @author Suman K.C [SUMANKC.COM]
64
+ */
65
+ public function gridAction()
66
+ {
67
+ $this->loadLayout()->renderLayout();
68
+ }
69
+
70
+ /**
71
+ * edit post - action
72
+ *
73
+ * @access public
74
+ * @return void
75
+ * @author Suman K.C [SUMANKC.COM]
76
+ */
77
+ public function editAction()
78
+ {
79
+ $postId = $this->getRequest()->getParam('id');
80
+ $post = $this->_initPost();
81
+ if ($postId && !$post->getId()) {
82
+ $this->_getSession()->addError(
83
+ Mage::helper('sumankcdotcom_advinstagram')->__('This post no longer exists.')
84
+ );
85
+ $this->_redirect('*/*/');
86
+ return;
87
+ }
88
+ $data = Mage::getSingleton('adminhtml/session')->getPostData(true);
89
+ if (!empty($data)) {
90
+ $post->setData($data);
91
+ }
92
+ Mage::register('post_data', $post);
93
+ $this->loadLayout();
94
+ $this->_title(Mage::helper('sumankcdotcom_advinstagram')->__('Instagram'))
95
+ ->_title(Mage::helper('sumankcdotcom_advinstagram')->__('Posts'));
96
+ if ($post->getId()) {
97
+ $this->_title($post->getMediaId());
98
+ } else {
99
+ $this->_title(Mage::helper('sumankcdotcom_advinstagram')->__('Add post'));
100
+ }
101
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
102
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
103
+ }
104
+ $this->renderLayout();
105
+ }
106
+
107
+ /**
108
+ * new post action
109
+ *
110
+ * @access public
111
+ * @return void
112
+ * @author Suman K.C [SUMANKC.COM]
113
+ */
114
+ public function newAction()
115
+ {
116
+ $this->_forward('edit');
117
+ }
118
+
119
+ /**
120
+ * save post - action
121
+ *
122
+ * @access public
123
+ * @return void
124
+ * @author Suman K.C [SUMANKC.COM]
125
+ */
126
+ public function saveAction()
127
+ {
128
+ if ($data = $this->getRequest()->getPost('post')) {
129
+ try {
130
+ $post = $this->_initPost();
131
+ $post->addData($data);
132
+ $post->save();
133
+ Mage::getSingleton('adminhtml/session')->addSuccess(
134
+ Mage::helper('sumankcdotcom_advinstagram')->__('Post was successfully saved')
135
+ );
136
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
137
+ if ($this->getRequest()->getParam('back')) {
138
+ $this->_redirect('*/*/edit', array('id' => $post->getId()));
139
+ return;
140
+ }
141
+ $this->_redirect('*/*/');
142
+ return;
143
+ } catch (Mage_Core_Exception $e) {
144
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
145
+ Mage::getSingleton('adminhtml/session')->setPostData($data);
146
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
147
+ return;
148
+ } catch (Exception $e) {
149
+ Mage::logException($e);
150
+ Mage::getSingleton('adminhtml/session')->addError(
151
+ Mage::helper('sumankcdotcom_advinstagram')->__('There was a problem saving the post.')
152
+ );
153
+ Mage::getSingleton('adminhtml/session')->setPostData($data);
154
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
155
+ return;
156
+ }
157
+ }
158
+ Mage::getSingleton('adminhtml/session')->addError(
159
+ Mage::helper('sumankcdotcom_advinstagram')->__('Unable to find post to save.')
160
+ );
161
+ $this->_redirect('*/*/');
162
+ }
163
+
164
+ /**
165
+ * delete post - action
166
+ *
167
+ * @access public
168
+ * @return void
169
+ * @author Suman K.C [SUMANKC.COM]
170
+ */
171
+ public function deleteAction()
172
+ {
173
+ if ( $this->getRequest()->getParam('id') > 0) {
174
+ try {
175
+ $post = Mage::getModel('sumankcdotcom_advinstagram/post');
176
+ $post->setId($this->getRequest()->getParam('id'))->delete();
177
+ Mage::getSingleton('adminhtml/session')->addSuccess(
178
+ Mage::helper('sumankcdotcom_advinstagram')->__('Post was successfully deleted.')
179
+ );
180
+ $this->_redirect('*/*/');
181
+ return;
182
+ } catch (Mage_Core_Exception $e) {
183
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
184
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
185
+ } catch (Exception $e) {
186
+ Mage::getSingleton('adminhtml/session')->addError(
187
+ Mage::helper('sumankcdotcom_advinstagram')->__('There was an error deleting post.')
188
+ );
189
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
190
+ Mage::logException($e);
191
+ return;
192
+ }
193
+ }
194
+ Mage::getSingleton('adminhtml/session')->addError(
195
+ Mage::helper('sumankcdotcom_advinstagram')->__('Could not find post to delete.')
196
+ );
197
+ $this->_redirect('*/*/');
198
+ }
199
+
200
+ /**
201
+ * mass delete post - action
202
+ *
203
+ * @access public
204
+ * @return void
205
+ * @author Suman K.C [SUMANKC.COM]
206
+ */
207
+ public function massDeleteAction()
208
+ {
209
+ $postIds = $this->getRequest()->getParam('post');
210
+ if (!is_array($postIds)) {
211
+ Mage::getSingleton('adminhtml/session')->addError(
212
+ Mage::helper('sumankcdotcom_advinstagram')->__('Please select posts to delete.')
213
+ );
214
+ } else {
215
+ try {
216
+ foreach ($postIds as $postId) {
217
+ $post = Mage::getModel('sumankcdotcom_advinstagram/post');
218
+ $post->setId($postId)->delete();
219
+ }
220
+ Mage::getSingleton('adminhtml/session')->addSuccess(
221
+ Mage::helper('sumankcdotcom_advinstagram')->__('Total of %d posts were successfully deleted.', count($postIds))
222
+ );
223
+ } catch (Mage_Core_Exception $e) {
224
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
225
+ } catch (Exception $e) {
226
+ Mage::getSingleton('adminhtml/session')->addError(
227
+ Mage::helper('sumankcdotcom_advinstagram')->__('There was an error deleting posts.')
228
+ );
229
+ Mage::logException($e);
230
+ }
231
+ }
232
+ $this->_redirect('*/*/index');
233
+ }
234
+
235
+ /**
236
+ * mass status change - action
237
+ *
238
+ * @access public
239
+ * @return void
240
+ * @author Suman K.C [SUMANKC.COM]
241
+ */
242
+ public function massStatusAction()
243
+ {
244
+ $postIds = $this->getRequest()->getParam('post');
245
+ if (!is_array($postIds)) {
246
+ Mage::getSingleton('adminhtml/session')->addError(
247
+ Mage::helper('sumankcdotcom_advinstagram')->__('Please select posts.')
248
+ );
249
+ } else {
250
+ try {
251
+ foreach ($postIds as $postId) {
252
+ $post = Mage::getSingleton('sumankcdotcom_advinstagram/post')->load($postId)
253
+ ->setStatus($this->getRequest()->getParam('status'))
254
+ ->setIsMassupdate(true)
255
+ ->save();
256
+ }
257
+ $this->_getSession()->addSuccess(
258
+ $this->__('Total of %d posts were successfully updated.', count($postIds))
259
+ );
260
+ } catch (Mage_Core_Exception $e) {
261
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
262
+ } catch (Exception $e) {
263
+ Mage::getSingleton('adminhtml/session')->addError(
264
+ Mage::helper('sumankcdotcom_advinstagram')->__('There was an error updating posts.')
265
+ );
266
+ Mage::logException($e);
267
+ }
268
+ }
269
+ $this->_redirect('*/*/index');
270
+ }
271
+
272
+ /**
273
+ * export as csv - action
274
+ *
275
+ * @access public
276
+ * @return void
277
+ * @author Suman K.C [SUMANKC.COM]
278
+ */
279
+ public function exportCsvAction()
280
+ {
281
+ $fileName = 'post.csv';
282
+ $content = $this->getLayout()->createBlock('sumankcdotcom_advinstagram/adminhtml_post_grid')
283
+ ->getCsv();
284
+ $this->_prepareDownloadResponse($fileName, $content);
285
+ }
286
+
287
+ /**
288
+ * export as MsExcel - action
289
+ *
290
+ * @access public
291
+ * @return void
292
+ * @author Suman K.C [SUMANKC.COM]
293
+ */
294
+ public function exportExcelAction()
295
+ {
296
+ $fileName = 'post.xls';
297
+ $content = $this->getLayout()->createBlock('sumankcdotcom_advinstagram/adminhtml_post_grid')
298
+ ->getExcelFile();
299
+ $this->_prepareDownloadResponse($fileName, $content);
300
+ }
301
+
302
+ /**
303
+ * export as xml - action
304
+ *
305
+ * @access public
306
+ * @return void
307
+ * @author Suman K.C [SUMANKC.COM]
308
+ */
309
+ public function exportXmlAction()
310
+ {
311
+ $fileName = 'post.xml';
312
+ $content = $this->getLayout()->createBlock('sumankcdotcom_advinstagram/adminhtml_post_grid')
313
+ ->getXml();
314
+ $this->_prepareDownloadResponse($fileName, $content);
315
+ }
316
+
317
+ /**
318
+ * Check if admin has permissions to visit related pages
319
+ *
320
+ * @access protected
321
+ * @return boolean
322
+ * @author Suman K.C [SUMANKC.COM]
323
+ */
324
+ protected function _isAllowed()
325
+ {
326
+ return Mage::getSingleton('admin/session')->isAllowed('sumankcdotcom_advinstagram/post');
327
+ }
328
+ }
app/code/local/Sumankcdotcom/AdvInstagram/controllers/PostController.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post front contrller
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ class Sumankcdotcom_AdvInstagram_PostController extends Mage_Core_Controller_Front_Action
25
+ {
26
+
27
+ /**
28
+ * default action
29
+ *
30
+ * @access public
31
+ * @return void
32
+ * @author Suman K.C [SUMANKC.COM]
33
+ */
34
+ public function indexAction()
35
+ {
36
+ $this->loadLayout();
37
+ $this->_initLayoutMessages('catalog/session');
38
+ $this->_initLayoutMessages('customer/session');
39
+ $this->_initLayoutMessages('checkout/session');
40
+ if (Mage::helper('sumankcdotcom_advinstagram/post')->getUseBreadcrumbs()) {
41
+ if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')) {
42
+ $breadcrumbBlock->addCrumb(
43
+ 'home',
44
+ array(
45
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Home'),
46
+ 'link' => Mage::getUrl(),
47
+ )
48
+ );
49
+ $breadcrumbBlock->addCrumb(
50
+ 'posts',
51
+ array(
52
+ 'label' => Mage::helper('sumankcdotcom_advinstagram')->__('Posts'),
53
+ 'link' => '',
54
+ )
55
+ );
56
+ }
57
+ }
58
+ $headBlock = $this->getLayout()->getBlock('head');
59
+ if ($headBlock) {
60
+ $headBlock->addLinkRel('canonical', Mage::helper('sumankcdotcom_advinstagram/post')->getPostsUrl());
61
+ }
62
+ $this->renderLayout();
63
+ }
64
+ }
app/code/local/Sumankcdotcom/AdvInstagram/etc/adminhtml.xml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Sumankcdotcom_AdvInstagram extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
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://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Sumankcdotcom
14
+ * @package Sumankcdotcom_AdvInstagram
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <sumankcdotcom_advinstagram translate="title" module="sumankcdotcom_advinstagram">
29
+ <title>AdvInstagram</title>
30
+ </sumankcdotcom_advinstagram>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ <sumankcdotcom_advinstagram translate="title" module="sumankcdotcom_advinstagram">
36
+ <title>Instagram</title>
37
+ <children>
38
+ <post translate="title" module="sumankcdotcom_advinstagram">
39
+ <title>Manage Posts</title>
40
+ <sort_order>0</sort_order>
41
+ </post>
42
+ <setting translate="title" module="sumankcdotcom_advinstagram">
43
+ <title>Settings</title>
44
+ <sort_order>10</sort_order>
45
+ </setting>
46
+ </children>
47
+ </sumankcdotcom_advinstagram>
48
+ </children>
49
+ </admin>
50
+ </resources>
51
+ </acl>
52
+ <menu>
53
+ <sumankcdotcom_advinstagram translate="title" module="sumankcdotcom_advinstagram">
54
+ <title>Instagram</title>
55
+ <sort_order>70</sort_order>
56
+ <children>
57
+ <post translate="title" module="sumankcdotcom_advinstagram">
58
+ <title>Manage Posts</title>
59
+ <action>adminhtml/advinstagram_post</action>
60
+ <sort_order>0</sort_order>
61
+ </post>
62
+ <setting translate="title" module="sumankcdotcom_advinstagram">
63
+ <title>Settings</title>
64
+ <action>adminhtml/system_config/edit/section/sumankcdotcom_advinstagram</action>
65
+ <sort_order>10</sort_order>
66
+ </setting>
67
+ </children>
68
+ </sumankcdotcom_advinstagram>
69
+ </menu>
70
+ </config>
app/code/local/Sumankcdotcom/AdvInstagram/etc/config.xml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Sumankcdotcom_AdvInstagram extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
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://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Sumankcdotcom
14
+ * @package Sumankcdotcom_AdvInstagram
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Sumankcdotcom_AdvInstagram>
22
+ <version>1.0.0</version>
23
+ </Sumankcdotcom_AdvInstagram>
24
+ </modules>
25
+ <global>
26
+ <resources>
27
+ <sumankcdotcom_advinstagram_setup>
28
+ <setup>
29
+ <module>Sumankcdotcom_AdvInstagram</module>
30
+ <class>Sumankcdotcom_AdvInstagram_Model_Resource_Setup</class>
31
+ </setup>
32
+ </sumankcdotcom_advinstagram_setup>
33
+ </resources>
34
+ <blocks>
35
+ <sumankcdotcom_advinstagram>
36
+ <class>Sumankcdotcom_AdvInstagram_Block</class>
37
+ </sumankcdotcom_advinstagram>
38
+ </blocks>
39
+ <helpers>
40
+ <sumankcdotcom_advinstagram>
41
+ <class>Sumankcdotcom_AdvInstagram_Helper</class>
42
+ </sumankcdotcom_advinstagram>
43
+ </helpers>
44
+ <models>
45
+ <advinstagram>
46
+ <class>Sumankcdotcom_AdvInstagram_Model</class>
47
+ </advinstagram>
48
+ <sumankcdotcom_advinstagram>
49
+ <class>Sumankcdotcom_AdvInstagram_Model</class>
50
+ <resourceModel>sumankcdotcom_advinstagram_resource</resourceModel>
51
+ </sumankcdotcom_advinstagram>
52
+ <sumankcdotcom_advinstagram_resource>
53
+ <class>Sumankcdotcom_AdvInstagram_Model_Resource</class>
54
+ <entities>
55
+ <post>
56
+ <table>sumankcdotcom_advinstagram_post</table>
57
+ </post>
58
+ <post_store>
59
+ <table>sumankcdotcom_advinstagram_post_store</table>
60
+ </post_store>
61
+ </entities>
62
+ </sumankcdotcom_advinstagram_resource>
63
+ </models>
64
+ </global>
65
+ <adminhtml>
66
+ <layout>
67
+ <updates>
68
+ <sumankcdotcom_advinstagram>
69
+ <file>sumankcdotcom_advinstagram.xml</file>
70
+ </sumankcdotcom_advinstagram>
71
+ </updates>
72
+ </layout>
73
+ <translate>
74
+ <modules>
75
+ <Sumankcdotcom_AdvInstagram>
76
+ <files>
77
+ <default>Sumankcdotcom_AdvInstagram.csv</default>
78
+ </files>
79
+ </Sumankcdotcom_AdvInstagram>
80
+ </modules>
81
+ </translate>
82
+ <global_search>
83
+ <post>
84
+ <class>sumankcdotcom_advinstagram/adminhtml_search_post</class>
85
+ <acl>sumankcdotcom_advinstagram</acl>
86
+ </post>
87
+ </global_search>
88
+ </adminhtml>
89
+ <admin>
90
+ <routers>
91
+ <adminhtml>
92
+ <args>
93
+ <modules>
94
+ <Sumankcdotcom_AdvInstagram before="Mage_Adminhtml">Sumankcdotcom_AdvInstagram_Adminhtml</Sumankcdotcom_AdvInstagram>
95
+ </modules>
96
+ </args>
97
+ </adminhtml>
98
+ </routers>
99
+ </admin>
100
+ <frontend>
101
+ <routers>
102
+ <sumankcdotcom_advinstagram>
103
+ <use>standard</use>
104
+ <args>
105
+ <module>Sumankcdotcom_AdvInstagram</module>
106
+ <frontName>advinstagram</frontName>
107
+ </args>
108
+ </sumankcdotcom_advinstagram>
109
+ </routers>
110
+ <layout>
111
+ <updates>
112
+ <sumankcdotcom_advinstagram>
113
+ <file>sumankcdotcom_advinstagram.xml</file>
114
+ </sumankcdotcom_advinstagram>
115
+ </updates>
116
+ </layout>
117
+ <translate>
118
+ <modules>
119
+ <Sumankcdotcom_AdvInstagram>
120
+ <files>
121
+ <default>Sumankcdotcom_AdvInstagram.csv</default>
122
+ </files>
123
+ </Sumankcdotcom_AdvInstagram>
124
+ </modules>
125
+ </translate>
126
+ </frontend>
127
+ <default>
128
+ <sumankcdotcom_advinstagram>
129
+ <post>
130
+ <breadcrumbs>1</breadcrumbs>
131
+ </post>
132
+ </sumankcdotcom_advinstagram>
133
+ </default>
134
+ </config>
app/code/local/Sumankcdotcom/AdvInstagram/etc/system.xml ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Sumankcdotcom_AdvInstagram extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
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://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Sumankcdotcom
14
+ * @package Sumankcdotcom_AdvInstagram
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <tabs>
21
+ <sumankcdotcom translate="label" module="sumankcdotcom_advinstagram">
22
+ <label>Sumankcdotcom</label>
23
+ <sort_order>2000</sort_order>
24
+ </sumankcdotcom>
25
+ </tabs>
26
+ <sections>
27
+ <sumankcdotcom_advinstagram translate="label" module="sumankcdotcom_advinstagram">
28
+ <class>separator-top</class>
29
+ <label>Instagram</label>
30
+ <tab>sumankcdotcom</tab>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>100</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <groups>
37
+ <post translate="label" module="sumankcdotcom_advinstagram">
38
+ <label>Instagram Post Configurations</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>20</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <fields>
45
+ <breadcrumbs translate="label">
46
+ <label>Use Breadcrumbs</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>10</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </breadcrumbs>
54
+ <post_type>
55
+ <label>Post source</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>advinstagram/options</source_model>
58
+ <sort_order>20</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </post_type>
63
+ <user_id>
64
+ <label>User ID</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>30</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
+ <comment><![CDATA[ <a href="http://tinyurl.com/ne389y6" target="_blank">Username to user id</a> | <a target="_blank" href="https://google.com/search?q=What%20is%20my%20Instagram%20account%20ID%3F">What is my Instagram account ID?</a> ]]></comment>
71
+ <depends><post_type>account</post_type></depends>
72
+ </user_id>
73
+ <access_token>
74
+ <label>Access Token</label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>40</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></comment>
81
+ <depends><post_type>account</post_type></depends>
82
+ </access_token>
83
+ <tag_name>
84
+ <label>Tag Name (hashtag)</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>50</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <comment>without hastag sign</comment>
91
+ <depends><post_type>hashtag</post_type></depends>
92
+ </tag_name>
93
+ <client_id>
94
+ <label>Client ID</label>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>60</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
+ <comment>from instagram developers account</comment>
101
+ <depends><post_type>hashtag</post_type></depends>
102
+ </client_id>
103
+ <filter_posts>
104
+ <label>Filter posts</label>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>adminhtml/system_config_source_yesno</source_model>
107
+ <sort_order>70</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>1</show_in_store>
111
+ <comment><![CDATA[ Select posts from top menu <strong>"Instagram > Post"</strong> to post selected posts only]]></comment>
112
+ </filter_posts>
113
+ <access_token2>
114
+ <label>Access Token</label>
115
+ <frontend_type>text</frontend_type>
116
+ <sort_order>80</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
+ <comment></comment>
121
+ <depends><post_type>hashtag</post_type><filter_post>1</filter_post></depends>
122
+ </access_token2>
123
+ <limit>
124
+ <label>Limit</label>
125
+ <frontend_type>text</frontend_type>
126
+ <sort_order>90</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
+ <comment>How many posts to retrieve ? default is 20</comment>
131
+ <depends><filter_posts>0</filter_posts></depends>
132
+ </limit>
133
+ </fields>
134
+ </post>
135
+ <post_features translate="label" module="sumankcdotcom_advinstagram">
136
+ <label>More Configurations</label>
137
+ <frontend_type>text</frontend_type>
138
+ <sort_order>30</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
+ <fields>
143
+ <link_posts>
144
+ <label>Link Posts</label>
145
+ <frontend_type>select</frontend_type>
146
+ <source_model>adminhtml/system_config_source_yesno</source_model>
147
+ <sort_order>100</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>1</show_in_store>
151
+ <comment>Link posts to instagram post</comment>
152
+ </link_posts>
153
+ <resolution>
154
+ <label>Choose resolution</label>
155
+ <frontend_type>select</frontend_type>
156
+ <source_model>advinstagram/resolutions</source_model>
157
+ <sort_order>105</sort_order>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>1</show_in_website>
160
+ <show_in_store>1</show_in_store>
161
+ </resolution>
162
+ <caption>
163
+ <label>Show Caption</label>
164
+ <frontend_type>select</frontend_type>
165
+ <source_model>adminhtml/system_config_source_yesno</source_model>
166
+ <sort_order>110</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>1</show_in_store>
170
+ </caption>
171
+ <likes_count>
172
+ <label>Show Likes count</label>
173
+ <frontend_type>select</frontend_type>
174
+ <source_model>adminhtml/system_config_source_yesno</source_model>
175
+ <sort_order>120</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ </likes_count>
180
+ <comment_count>
181
+ <label>Show Comment count</label>
182
+ <frontend_type>select</frontend_type>
183
+ <source_model>adminhtml/system_config_source_yesno</source_model>
184
+ <sort_order>130</sort_order>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>1</show_in_website>
187
+ <show_in_store>1</show_in_store>
188
+ </comment_count>
189
+ </fields>
190
+ </post_features>
191
+ </groups>
192
+ </sumankcdotcom_advinstagram>
193
+ </sections>
194
+ </config>
app/code/local/Sumankcdotcom/AdvInstagram/sql/sumankcdotcom_advinstagram_setup/install-1.0.0.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * AdvInstagram module install script
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman K.C [SUMANKC.COM]
23
+ */
24
+ $this->startSetup();
25
+ $table = $this->getConnection()
26
+ ->newTable($this->getTable('sumankcdotcom_advinstagram/post'))
27
+ ->addColumn(
28
+ 'entity_id',
29
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
30
+ null,
31
+ array(
32
+ 'identity' => true,
33
+ 'nullable' => false,
34
+ 'primary' => true,
35
+ ),
36
+ 'Post ID'
37
+ )
38
+ ->addColumn(
39
+ 'media_id',
40
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255,
41
+ array(
42
+ 'nullable' => false,
43
+ ),
44
+ 'Media Id'
45
+ )
46
+ ->addColumn(
47
+ 'username',
48
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255,
49
+ array(
50
+ 'nullable' => false,
51
+ ),
52
+ 'Username'
53
+ )
54
+ ->addColumn(
55
+ 'caption',
56
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255,
57
+ array(
58
+ 'nullable' => false,
59
+ ),
60
+ 'Caption'
61
+ )
62
+ ->addColumn(
63
+ 'status',
64
+ Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
65
+ array(),
66
+ 'Enabled'
67
+ )
68
+ ->addColumn(
69
+ 'updated_at',
70
+ Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
71
+ null,
72
+ array(),
73
+ 'Post Modification Time'
74
+ )
75
+ ->addColumn(
76
+ 'created_at',
77
+ Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
78
+ null,
79
+ array(),
80
+ 'Post Creation Time'
81
+ )
82
+ ->setComment('Post Table');
83
+ $this->getConnection()->createTable($table);
84
+ $table = $this->getConnection()
85
+ ->newTable($this->getTable('sumankcdotcom_advinstagram/post_store'))
86
+ ->addColumn(
87
+ 'post_id',
88
+ Varien_Db_Ddl_Table::TYPE_SMALLINT,
89
+ null,
90
+ array(
91
+ 'nullable' => false,
92
+ 'primary' => true,
93
+ ),
94
+ 'Post ID'
95
+ )
96
+ ->addColumn(
97
+ 'store_id',
98
+ Varien_Db_Ddl_Table::TYPE_SMALLINT,
99
+ null,
100
+ array(
101
+ 'unsigned' => true,
102
+ 'nullable' => false,
103
+ 'primary' => true,
104
+ ),
105
+ 'Store ID'
106
+ )
107
+ ->addIndex(
108
+ $this->getIdxName(
109
+ 'sumankcdotcom_advinstagram/post_store',
110
+ array('store_id')
111
+ ),
112
+ array('store_id')
113
+ )
114
+ ->addForeignKey(
115
+ $this->getFkName(
116
+ 'sumankcdotcom_advinstagram/post_store',
117
+ 'post_id',
118
+ 'sumankcdotcom_advinstagram/post',
119
+ 'entity_id'
120
+ ),
121
+ 'post_id',
122
+ $this->getTable('sumankcdotcom_advinstagram/post'),
123
+ 'entity_id',
124
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
125
+ Varien_Db_Ddl_Table::ACTION_CASCADE
126
+ )
127
+ ->addForeignKey(
128
+ $this->getFkName(
129
+ 'sumankcdotcom_advinstagram/post_store',
130
+ 'store_id',
131
+ 'core/store',
132
+ 'store_id'
133
+ ),
134
+ 'store_id',
135
+ $this->getTable('core/store'),
136
+ 'store_id',
137
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
138
+ Varien_Db_Ddl_Table::ACTION_CASCADE
139
+ )
140
+ ->setComment('Posts To Store Linkage Table');
141
+ $this->getConnection()->createTable($table);
142
+ $this->endSetup();
app/design/adminhtml/default/default/layout/sumankcdotcom_advinstagram.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Sumankcdotcom_AdvInstagram extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
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://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Sumankcdotcom
14
+ * @package Sumankcdotcom_AdvInstagram
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <adminhtml_advinstagram_post_index>
21
+ <reference name="menu">
22
+ <action method="setActive">
23
+ <menupath>sumankcdotcom_advinstagram/post</menupath>
24
+ </action>
25
+ </reference>
26
+ <reference name="content">
27
+ <block type="sumankcdotcom_advinstagram/adminhtml_post" name="post" />
28
+
29
+ </reference>
30
+ </adminhtml_advinstagram_post_index>
31
+ <adminhtml_advinstagram_post_grid>
32
+ <block type="core/text_list" name="root" output="toHtml">
33
+ <block type="sumankcdotcom_advinstagram/adminhtml_post_grid" name="post_grid"/>
34
+ </block>
35
+ </adminhtml_advinstagram_post_grid>
36
+ <!-- Post add/edit action -->
37
+ <adminhtml_advinstagram_post_edit>
38
+ <reference name="head">
39
+ <action method="addJs"><script>instagram/jquery.min.js</script></action>
40
+ <action method="addJs"><script>instagram/instafeed.min.js</script></action>
41
+ </reference>
42
+ <update handle="editor"/>
43
+ <reference name="menu">
44
+ <action method="setActive">
45
+ <menupath>sumankcdotcom_advinstagram/post</menupath>
46
+ </action>
47
+ </reference>
48
+ <reference name="content">
49
+ <block type="core/template" template="advinstagram/select.phtml"></block>
50
+ <block type="sumankcdotcom_advinstagram/adminhtml_post_edit" name="post_edit"></block>
51
+ </reference>
52
+ <reference name="left">
53
+ <block type="sumankcdotcom_advinstagram/adminhtml_post_edit_tabs" name="post_tabs"></block>
54
+ </reference>
55
+ </adminhtml_advinstagram_post_edit>
56
+
57
+ </layout>
app/design/adminhtml/default/default/template/advinstagram/select.phtml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ -->
18
+ <style type="text/css">
19
+ #instafeed a.selected {
20
+ background: #d34704 none repeat scroll 0 0;
21
+ }
22
+ </style>
23
+ <div class="content-header">
24
+ <h3 class="icon-head head-adminhtml-post">Select from the post appearing below (Click to select)</h3>
25
+ </div>
26
+ <div id="instafeed"></div>
27
+ <br/><button id="load-more">load more</button>
28
+ <br/><br/><br/><br/>
29
+ <?php
30
+ $post_type = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/post_type');
31
+ $user_id = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/user_id');
32
+ $access_token = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/access_token');
33
+ $tagname = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/tag_name');
34
+ $client_id = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/client_id');
35
+ ?>
36
+ <?php if($post_type=='hashtag'): ?>
37
+ <script type="text/javascript">
38
+ jQuery(function($){
39
+ var loadButton = document.getElementById('load-more');
40
+ var feed = new Instafeed({
41
+ get: 'tagged',
42
+ tagName: "<?php echo $tagname;?>",
43
+ clientId: "<?php echo $client_id;?>",
44
+ limit: 14,
45
+ template: '<a href="#"><img data-attr="{{id}}" src="{{image}}" alt="{{caption}}" data-username="{{link}}" /></a>',
46
+ after: function() {
47
+ if (!this.hasNext()) {
48
+ loadButton.setAttribute('disabled', 'disabled');
49
+ }
50
+ },
51
+ });
52
+ if(loadButton){
53
+ loadButton.addEventListener('click', function() {
54
+ feed.next();
55
+ });
56
+ }
57
+ feed.run();
58
+ });
59
+ </script>
60
+ <?php elseif($post_type=='account'): ?>
61
+ <script type="text/javascript">
62
+ jQuery(function($){
63
+ var loadButton = document.getElementById('load-more');
64
+ var feed = new Instafeed({
65
+ get: 'user',
66
+ userId: "<?php echo $user_id; ?>",
67
+ accessToken: "<?php echo $access_token; ?>",
68
+ limit: 14,
69
+ template: '<a href="#"><img data-attr="{{id}}" src="{{image}}" alt="{{caption}}" data-username="{{link}}" /></a>',
70
+ after: function() {
71
+ if (!this.hasNext()) {
72
+ loadButton.setAttribute('disabled', 'disabled');
73
+ }
74
+ },
75
+ });
76
+ if(loadButton){
77
+ loadButton.addEventListener('click', function() {
78
+ feed.next();
79
+ });
80
+ }
81
+ feed.run();
82
+ });
83
+ </script>
84
+ <?php endif; ?>
85
+ <script type="text/javascript">
86
+ jQuery(document).on('click','#instafeed a img',function(){
87
+ jQuery(this).parent().addClass('selected').siblings().removeClass('selected');
88
+ jQuery('#post_media_id').val(jQuery(this).attr('data-attr'));
89
+ jQuery('#post_username').val(jQuery(this).attr('data-username'));
90
+ jQuery('#post_caption').val(jQuery(this).attr('alt'));
91
+ return false;
92
+ });
93
+ </script>
app/design/frontend/base/default/layout/sumankcdotcom_advinstagram.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Sumankcdotcom_AdvInstagram extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
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://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Sumankcdotcom
14
+ * @package Sumankcdotcom_AdvInstagram
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <default>
21
+ <reference name="head">
22
+ <action method="addJs"><script>advinstagram/instafeed.min.js</script></action>
23
+ </reference>
24
+ <reference name="root">
25
+ <action method="setTemplate">
26
+ <template>page/2columns-left.phtml</template>
27
+ </action>
28
+ </reference>
29
+ </default>
30
+ <sumankcdotcom_advinstagram_post_index translate="label" module="sumankcdotcom_advinstagram">
31
+ <label>Posts list</label>
32
+ <reference name="content">
33
+ <block type="sumankcdotcom_advinstagram/post_list" name="post_list" template="sumankcdotcom_advinstagram/post/list.phtml" />
34
+ </reference>
35
+ </sumankcdotcom_advinstagram_post_index>
36
+ </layout>
app/design/frontend/base/default/template/sumankcdotcom_advinstagram/post/list.phtml ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sumankcdotcom_AdvInstagram extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Sumankcdotcom
13
+ * @package Sumankcdotcom_AdvInstagram
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Post list template
19
+ *
20
+ * @category Sumankcdotcom
21
+ * @package Sumankcdotcom_AdvInstagram
22
+ * @author Suman kc [SUMANKC.COM]
23
+ */
24
+ ?>
25
+ <style type="text/css">
26
+ #instafeed{overflow:hidden;clear: both};
27
+ </style>
28
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
29
+ <?php
30
+ $post_type = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/post_type');
31
+ $user_id = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/user_id');
32
+ $access_token = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/access_token');
33
+ $filter_post = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/filter_post');
34
+ $limit = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/limit');
35
+ $link_posts = Mage::getStoreConfig('sumankcdotcom_advinstagram/post_features/link_posts');
36
+ $caption = Mage::getStoreConfig('sumankcdotcom_advinstagram/post_features/caption');
37
+ $likes_count = Mage::getStoreConfig('sumankcdotcom_advinstagram/post_features/likes_count');
38
+ $comment_count = Mage::getStoreConfig('sumankcdotcom_advinstagram/post_features/comment_count');
39
+
40
+ $tagname = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/tag_name');
41
+ $client_id = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/client_id');
42
+ $resolution = Mage::getStoreConfig('sumankcdotcom_advinstagram/post_features/resolution');
43
+ $filter_posts = Mage::getStoreConfig('sumankcdotcom_advinstagram/post/filter_posts');
44
+ ?>
45
+ <?php if(!$filter_posts): ?>
46
+ <div id="instafeed"></div>
47
+ <script type="text/javascript">
48
+ var templating = caption = likes = comment = '';
49
+ <?php if($link_posts){?>
50
+ templating = '<a target="_blank" href="{{link}}"><img src="{{image}}" /></a>';
51
+ <?php }else{?>
52
+ templating = '<img src="{{image}}" />';
53
+ <?php } ?>
54
+ <?php if($caption){?> caption = '<span class="insta_caption">{{caption}}</span>'; <?php }?>
55
+ <?php if($likes_count){?> likes = '<span class="insta_likes">{{likes}} Likes </span>'; <?php }?>
56
+ <?php if($comment_count){?> comment = '<span class="insta_comment">{{comments}} Comments</span>'; <?php }?>
57
+ templating = '<div class="individual-post">'+templating + caption + likes + comment +'</div>';
58
+ var userFeed = new Instafeed({
59
+ get: 'user',
60
+ userId: "<?php echo $user_id; ?>",
61
+ accessToken: "<?php echo $access_token; ?>",
62
+ limit : "<?php echo $limit; ?>",
63
+ resolution : "<?php echo $resolution ?>",
64
+ template: templating
65
+ });
66
+ var feed = new Instafeed({
67
+ get: 'tagged',
68
+ tagName: "<?php echo $tagname; ?>",
69
+ clientId: "<?php echo $client_id; ?>",
70
+ limit : "<?php echo $limit; ?>",
71
+ resolution : "<?php echo $resolution ?>",
72
+ template: templating
73
+ });
74
+ <?php if($post_type=='account'){ ?> userFeed.run();<?php }elseif($post_type=='hashtag'){ ?>feed.run();<?php }?>
75
+ </script>
76
+
77
+ <?php else: ?>
78
+ <?php $_posts = $this->getPosts(); ?> <!--/ Fetches only the selected posts from backend -->
79
+ <?php if ($_posts->getSize() > 0) :?>
80
+ <div class="post-list-container">
81
+ <?php foreach ($_posts as $_post) : ?>
82
+ <?php
83
+ $media_id = $_post->getMediaId();
84
+ /* Call Instagram API */
85
+ $url = 'https://api.instagram.com/v1/media/'.$media_id.'?access_token='.$access_token;
86
+ $data = file_get_contents($url);
87
+ $response = json_decode($data);
88
+ $image = $response->data->images->$resolution->url;
89
+ $likes = $response->data->likes->count;
90
+ $link = $response->data->link;
91
+ $insta_caption = htmlspecialchars($response->data->caption->text);
92
+ $username = $response->data->caption->from->username;
93
+ $comments = $response->data->comments->count;
94
+
95
+ echo '<div class="individual-post">';
96
+ if($link_posts){ echo '<a href="" target="_blank"><img src="'.$image.'"/></a>'; }else{ echo '<img src="'.$image.'"/>'; }
97
+ if($caption){
98
+ echo '<span class="insta_caption">'.$insta_caption.'</span>';
99
+ }if($likes_count){
100
+ echo '<span class="insta_likes"> '.$likes.' Likes </span>';
101
+ }if($comment_count){
102
+ echo '<span class="insta_comment"> '.$comments.' Comments</span>';
103
+ }
104
+ echo '</div>';
105
+ ?>
106
+ <?php endforeach;?>
107
+ </div>
108
+ <?php else : ?>
109
+ <?php echo Mage::helper('sumankcdotcom_advinstagram')->__('There are no posts at this moment');?>
110
+ <?php endif;?>
111
+
112
+ <?php endif; ?>
app/etc/modules/Sumankcdotcom_AdvInstagram.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Sumankcdotcom_AdvInstagram extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
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://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Sumankcdotcom
14
+ * @package Sumankcdotcom_AdvInstagram
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Sumankcdotcom_AdvInstagram>
22
+ <active>true</active>
23
+ <codePool>local</codePool>
24
+ <depends>
25
+ <Mage_Core />
26
+ </depends>
27
+ </Sumankcdotcom_AdvInstagram>
28
+ </modules>
29
+ </config>
js/advinstagram/instafeed.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ // Generated by CoffeeScript 1.9.3
2
+ (function(){var e;e=function(){function e(e,t){var n,r;this.options={target:"instafeed",get:"popular",resolution:"thumbnail",sortBy:"none",links:!0,mock:!1,useHttp:!1};if(typeof e=="object")for(n in e)r=e[n],this.options[n]=r;this.context=t!=null?t:this,this.unique=this._genKey()}return e.prototype.hasNext=function(){return typeof this.context.nextUrl=="string"&&this.context.nextUrl.length>0},e.prototype.next=function(){return this.hasNext()?this.run(this.context.nextUrl):!1},e.prototype.run=function(t){var n,r,i;if(typeof this.options.clientId!="string"&&typeof this.options.accessToken!="string")throw new Error("Missing clientId or accessToken.");if(typeof this.options.accessToken!="string"&&typeof this.options.clientId!="string")throw new Error("Missing clientId or accessToken.");return this.options.before!=null&&typeof this.options.before=="function"&&this.options.before.call(this),typeof document!="undefined"&&document!==null&&(i=document.createElement("script"),i.id="instafeed-fetcher",i.src=t||this._buildUrl(),n=document.getElementsByTagName("head"),n[0].appendChild(i),r="instafeedCache"+this.unique,window[r]=new e(this.options,this),window[r].unique=this.unique),!0},e.prototype.parse=function(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D;if(typeof e!="object"){if(this.options.error!=null&&typeof this.options.error=="function")return this.options.error.call(this,"Invalid JSON data"),!1;throw new Error("Invalid JSON response")}if(e.meta.code!==200){if(this.options.error!=null&&typeof this.options.error=="function")return this.options.error.call(this,e.meta.error_message),!1;throw new Error("Error from Instagram: "+e.meta.error_message)}if(e.data.length===0){if(this.options.error!=null&&typeof this.options.error=="function")return this.options.error.call(this,"No images were returned from Instagram"),!1;throw new Error("No images were returned from Instagram")}this.options.success!=null&&typeof this.options.success=="function"&&this.options.success.call(this,e),this.context.nextUrl="",e.pagination!=null&&(this.context.nextUrl=e.pagination.next_url);if(this.options.sortBy!=="none"){this.options.sortBy==="random"?M=["","random"]:M=this.options.sortBy.split("-"),O=M[0]==="least"?!0:!1;switch(M[1]){case"random":e.data.sort(function(){return.5-Math.random()});break;case"recent":e.data=this._sortBy(e.data,"created_time",O);break;case"liked":e.data=this._sortBy(e.data,"likes.count",O);break;case"commented":e.data=this._sortBy(e.data,"comments.count",O);break;default:throw new Error("Invalid option for sortBy: '"+this.options.sortBy+"'.")}}if(typeof document!="undefined"&&document!==null&&this.options.mock===!1){m=e.data,A=parseInt(this.options.limit,10),this.options.limit!=null&&m.length>A&&(m=m.slice(0,A)),u=document.createDocumentFragment(),this.options.filter!=null&&typeof this.options.filter=="function"&&(m=this._filter(m,this.options.filter));if(this.options.template!=null&&typeof this.options.template=="string"){f="",d="",w="",D=document.createElement("div");for(c=0,N=m.length;c<N;c++){h=m[c],p=h.images[this.options.resolution];if(typeof p!="object")throw o="No image found for resolution: "+this.options.resolution+".",new Error(o);E=p.width,y=p.height,b="square",E>y&&(b="landscape"),E<y&&(b="portrait"),v=p.url,l=window.location.protocol.indexOf("http")>=0,l&&!this.options.useHttp&&(v=v.replace(/https?:\/\//,"//")),d=this._makeTemplate(this.options.template,{model:h,id:h.id,link:h.link,type:h.type,image:v,width:E,height:y,orientation:b,caption:this._getObjectProperty(h,"caption.text"),likes:h.likes.count,comments:h.comments.count,location:this._getObjectProperty(h,"location.name")}),f+=d}D.innerHTML=f,i=[],r=0,n=D.childNodes.length;while(r<n)i.push(D.childNodes[r]),r+=1;for(x=0,C=i.length;x<C;x++)L=i[x],u.appendChild(L)}else for(T=0,k=m.length;T<k;T++){h=m[T],g=document.createElement("img"),p=h.images[this.options.resolution];if(typeof p!="object")throw o="No image found for resolution: "+this.options.resolution+".",new Error(o);v=p.url,l=window.location.protocol.indexOf("http")>=0,l&&!this.options.useHttp&&(v=v.replace(/https?:\/\//,"//")),g.src=v,this.options.links===!0?(t=document.createElement("a"),t.href=h.link,t.appendChild(g),u.appendChild(t)):u.appendChild(g)}_=this.options.target,typeof _=="string"&&(_=document.getElementById(_));if(_==null)throw o='No element with id="'+this.options.target+'" on page.',new Error(o);_.appendChild(u),a=document.getElementsByTagName("head")[0],a.removeChild(document.getElementById("instafeed-fetcher")),S="instafeedCache"+this.unique,window[S]=void 0;try{delete window[S]}catch(P){s=P}}return this.options.after!=null&&typeof this.options.after=="function"&&this.options.after.call(this),!0},e.prototype._buildUrl=function(){var e,t,n;e="https://api.instagram.com/v1";switch(this.options.get){case"popular":t="media/popular";break;case"tagged":if(!this.options.tagName)throw new Error("No tag name specified. Use the 'tagName' option.");t="tags/"+this.options.tagName+"/media/recent";break;case"location":if(!this.options.locationId)throw new Error("No location specified. Use the 'locationId' option.");t="locations/"+this.options.locationId+"/media/recent";break;case"user":if(!this.options.userId)throw new Error("No user specified. Use the 'userId' option.");t="users/"+this.options.userId+"/media/recent";break;default:throw new Error("Invalid option for get: '"+this.options.get+"'.")}return n=e+"/"+t,this.options.accessToken!=null?n+="?access_token="+this.options.accessToken:n+="?client_id="+this.options.clientId,this.options.limit!=null&&(n+="&count="+this.options.limit),n+="&callback=instafeedCache"+this.unique+".parse",n},e.prototype._genKey=function(){var e;return e=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},""+e()+e()+e()+e()},e.prototype._makeTemplate=function(e,t){var n,r,i,s,o;r=/(?:\{{2})([\w\[\]\.]+)(?:\}{2})/,n=e;while(r.test(n))s=n.match(r)[1],o=(i=this._getObjectProperty(t,s))!=null?i:"",n=n.replace(r,function(){return""+o});return n},e.prototype._getObjectProperty=function(e,t){var n,r;t=t.replace(/\[(\w+)\]/g,".$1"),r=t.split(".");while(r.length){n=r.shift();if(!(e!=null&&n in e))return null;e=e[n]}return e},e.prototype._sortBy=function(e,t,n){var r;return r=function(e,r){var i,s;return i=this._getObjectProperty(e,t),s=this._getObjectProperty(r,t),n?i>s?1:-1:i<s?1:-1},e.sort(r.bind(this)),e},e.prototype._filter=function(e,t){var n,r,i,s,o;n=[],r=function(e){if(t(e))return n.push(e)};for(i=0,o=e.length;i<o;i++)s=e[i],r(s);return n},e}(),function(e,t){return typeof define=="function"&&define.amd?define([],t):typeof module=="object"&&module.exports?module.exports=t():e.Instafeed=t()}(this,function(){return e})}).call(this);
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Sumankcdotcom_AdvInstagram</name>
4
+ <version>1.0.0</version>
5
+ <stability>devel</stability>
6
+ <license uri="http://opensource.org/licenses/mit-license.php">MIT License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Advance instagram module to fetch posts from instagram accounts or hastagged globally</summary>
10
+ <description>Instagram advance module to fetch posts from instagram accounts or via posts based on hastagged globally.</description>
11
+ <notes>Initial release</notes>
12
+ <authors><author><name>Suman K.C</name><user>sumankc</user><email>sumankc55@gmail.com</email></author></authors>
13
+ <date>2016-03-28</date>
14
+ <time>10:53:49</time>
15
+ <contents><target name="magelocal"><dir name="Sumankcdotcom"><dir name="AdvInstagram"><dir name="Block"><dir name="Adminhtml"><dir name="Post"><dir name="Edit"><file name="Form.php" hash="14f00e87ff91020ead6987e93a1a8331"/><dir name="Tab"><file name="Form.php" hash="ebc838eff1b405854594c8fe0b6cc4a3"/><file name="Stores.php" hash="588c3d796148797c9a23161536706572"/></dir><file name="Tabs.php" hash="133dc7d3a71881cd7fbc626e0f5bef98"/></dir><file name="Edit.php" hash="c7faa1a677cbb74a37c8e000b0adeeca"/><file name="Grid.php" hash="175e306027d2f54f122a011eddc3263b"/></dir><file name="Post.php" hash="f6f65304dd92a4cc11a29b742ac3309f"/></dir><dir name="Post"><file name="List.php" hash="4b5095a0be4acc1e7e10d67145fd2b24"/></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="AdvInstagram.php" hash="4ccf5de8199c53e1a390f518b0f1a6b5"/></dir></dir><dir name="Helper"><file name="Data.php" hash="8e3c7be530b7e0c7eb7f80752c43db88"/><file name="Post.php" hash="d5c0118b44570c03c756de08b8afce9e"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="Search"><file name="Post.php" hash="e264e4922e9308a5a3837d72e9f060e4"/></dir></dir><file name="Options.php" hash="8908fbb49e9f6d67d655552b0eedb67a"/><file name="Post.php" hash="640a7204f6c2dd320920105a2d6e351c"/><file name="Resolutions.php" hash="edaf7f5ddba3e9bc673a1a9125b70b12"/><dir name="Resource"><dir name="Post"><file name="Collection.php" hash="8a48eb927733417fd8d7b8c9ae5a6619"/></dir><file name="Post.php" hash="1bc83f1b237c0c293f20f5b034b0d21f"/><file name="Setup.php" hash="2291e19b49d85633c55390ba01e9e7b2"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Advinstagram"><file name="PostController.php" hash="6f2758f41a9bd12827fea2a0240ad6e7"/></dir></dir><file name="PostController.php" hash="0c04684d3663226a73091b7f763522c3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3905e1edf82e2c8105ee92eacf81d974"/><file name="config.xml" hash="5255f133a013735b37440a8dad8b432f"/><file name="system.xml" hash="90e5c4eb2e27dc14e022d3f3527ece44"/></dir><dir name="sql"><dir name="sumankcdotcom_advinstagram_setup"><file name="install-1.0.0.php" hash="ca6a54521ba8eff42e8a4541b30208ba"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sumankcdotcom_AdvInstagram.xml" hash="a9c3a04507c824fc604418a8a47bccc6"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sumankcdotcom_advinstagram.xml" hash="b5698d9117207d05bd29dc649904b75f"/></dir><dir name="template"><dir name="advinstagram"><file name="select.phtml" hash="57b186f9a63cf339f9bf666f8d4d074a"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sumankcdotcom_advinstagram.xml" hash="482f416c068c4a8040b742bb9ba37bc6"/></dir><dir name="template"><dir name="sumankcdotcom_advinstagram"><dir name="post"><file name="list.phtml" hash="eba7a1b15c4ba67cc5a02abe601b47d3"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="advinstagram"><file name="instafeed.min.js" hash="1b9d5439b41e462220f9e6937df15b60"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>