Piyush_Events - Version 1.7.0

Version Notes

Event Manager

Download this release

Release Info

Developer Piyush
Extension Piyush_Events
Version 1.7.0
Comparing to
See all releases


Version 1.7.0

Files changed (30) hide show
  1. app/code/community/Piyush/Events/Block/Adminhtml/Events.php +36 -0
  2. app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit.php +70 -0
  3. app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Form.php +29 -0
  4. app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Form/Element/Image.php +24 -0
  5. app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Tab/Content.php +129 -0
  6. app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Tab/Image.php +109 -0
  7. app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Tab/Main.php +125 -0
  8. app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Tabs.php +22 -0
  9. app/code/community/Piyush/Events/Block/Adminhtml/Events/Grid.php +125 -0
  10. app/code/community/Piyush/Events/Block/Item.php +50 -0
  11. app/code/community/Piyush/Events/Block/List.php +99 -0
  12. app/code/community/Piyush/Events/Helper/Admin.php +21 -0
  13. app/code/community/Piyush/Events/Helper/Data.php +89 -0
  14. app/code/community/Piyush/Events/Helper/Image.php +200 -0
  15. app/code/community/Piyush/Events/Model/Events.php +32 -0
  16. app/code/community/Piyush/Events/Model/Observer.php +27 -0
  17. app/code/community/Piyush/Events/Model/Resource/Events.php +18 -0
  18. app/code/community/Piyush/Events/Model/Resource/Events/Collection.php +31 -0
  19. app/code/community/Piyush/Events/controllers/Adminhtml/EventsController.php +272 -0
  20. app/code/community/Piyush/Events/controllers/IndexController.php +79 -0
  21. app/code/community/Piyush/Events/etc/adminhtml.xml +64 -0
  22. app/code/community/Piyush/Events/etc/config.xml +108 -0
  23. app/code/community/Piyush/Events/etc/system.xml +64 -0
  24. app/code/community/Piyush/Events/sql/piyush_events_setup/install-1.0.1.php +67 -0
  25. app/design/adminhtml/default/default/layout/piyush_events.xml +40 -0
  26. app/design/frontend/default/default/layout/piyush_events.xml +58 -0
  27. app/design/frontend/default/default/template/piyushevents/events/item.phtml +36 -0
  28. app/design/frontend/default/default/template/piyushevents/events/list.phtml +37 -0
  29. app/etc/modules/Piyush_Events.xml +16 -0
  30. package.xml +18 -0
app/code/community/Piyush/Events/Block/Adminhtml/Events.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Adminhtml_Events extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ /**
12
+ * Block constructor
13
+ */
14
+ public function __construct()
15
+ {
16
+ $this->_blockGroup = 'piyush_events';
17
+ $this->_controller = 'adminhtml_events';
18
+ $this->_headerText = Mage::helper('piyush_events')->__('Manage Events');
19
+
20
+ parent::__construct();
21
+
22
+ if (Mage::helper('piyush_events/admin')->isActionAllowed('save')) {
23
+ $this->_updateButton('add', 'label', Mage::helper('piyush_events')->__('Add New Event'));
24
+ } else {
25
+ $this->_removeButton('add');
26
+ }
27
+ $this->addButton(
28
+ 'events_flush_images_cache',
29
+ array(
30
+ 'label' => Mage::helper('piyush_events')->__('Flush Images Cache'),
31
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/flush') . '\')',
32
+ )
33
+ );
34
+
35
+ }
36
+ }
app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Adminhtml_Events_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ /**
12
+ * Initialize edit form container
13
+ *
14
+ */
15
+ public function __construct()
16
+ {
17
+ $this->_objectId = 'id';
18
+ $this->_blockGroup = 'piyush_events';
19
+ $this->_controller = 'adminhtml_events';
20
+
21
+ parent::__construct();
22
+
23
+ if (Mage::helper('piyush_events/admin')->isActionAllowed('save')) {
24
+ $this->_updateButton('save', 'label', Mage::helper('piyush_events')->__('Save Events Item'));
25
+ $this->_addButton('saveandcontinue', array(
26
+ 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
27
+ 'onclick' => 'saveAndContinueEdit()',
28
+ 'class' => 'save',
29
+ ), -100);
30
+ } else {
31
+ $this->_removeButton('save');
32
+ }
33
+
34
+ if (Mage::helper('piyush_events/admin')->isActionAllowed('delete')) {
35
+ $this->_updateButton('delete', 'label', Mage::helper('piyush_events')->__('Delete Events Item'));
36
+ } else {
37
+ $this->_removeButton('delete');
38
+ }
39
+
40
+ $this->_formScripts[] = "
41
+ function toggleEditor() {
42
+ if (tinyMCE.getInstanceById('page_content') == null) {
43
+ tinyMCE.execCommand('mceAddControl', false, 'page_content');
44
+ } else {
45
+ tinyMCE.execCommand('mceRemoveControl', false, 'page_content');
46
+ }
47
+ }
48
+
49
+ function saveAndContinueEdit(){
50
+ editForm.submit($('edit_form').action+'back/edit/');
51
+ }
52
+ ";
53
+ }
54
+
55
+ /**
56
+ * Retrieve text for header element depending on loaded page
57
+ *
58
+ * @return string
59
+ */
60
+ public function getHeaderText()
61
+ {
62
+ $model = Mage::helper('piyush_events')->getEventsItemInstance();
63
+ if ($model->getId()) {
64
+ return Mage::helper('piyush_events')->__("Edit Events Item '%s'",
65
+ $this->escapeHtml($model->getTitle()));
66
+ } else {
67
+ return Mage::helper('piyush_events')->__('New Events Item');
68
+ }
69
+ }
70
+ }
app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Form.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Adminhtml_Events_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ /**
12
+ * Prepare form action
13
+ *
14
+ * @return Piyush_Events_Block_Adminhtml_News_Edit_Form
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ $form = new Varien_Data_Form(array(
19
+ 'id' => 'edit_form',
20
+ 'action' => $this->getUrl('*/*/save'),
21
+ 'method' => 'post',
22
+ 'enctype' => 'multipart/form-data'
23
+ ));
24
+
25
+ $form->setUseContainer(true);
26
+ $this->setForm($form);
27
+ return parent::_prepareForm();
28
+ }
29
+ }
app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Form/Element/Image.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Adminhtml_Events_Edit_Form_Element_Image extends Varien_Data_Form_Element_Image
10
+ {
11
+ /**
12
+ * Get image preview url
13
+ *
14
+ * @return string
15
+ */
16
+ protected function _getUrl()
17
+ {
18
+ $url = false;
19
+ if ($this->getValue()) {
20
+ $url = Mage::helper('piyush_events/image')->getBaseUrl() . '/' . $this->getValue();
21
+ }
22
+ return $url;
23
+ }
24
+ }
app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Tab/Content.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Adminhtml_Events_Edit_Tab_Content extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface
10
+ {
11
+ /**
12
+ * Load WYSIWYG on demand and prepare layout
13
+ *
14
+ * @return Piyush_Events_Block_Adminhtml_Events_Edit_Tab_Content
15
+ */
16
+ protected function _prepareLayout()
17
+ {
18
+ parent::_prepareLayout();
19
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
20
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
21
+ }
22
+ return $this;
23
+ }
24
+
25
+ /**
26
+ * Prepares tab form
27
+ *
28
+ * @return Mage_Adminhtml_Block_Widget_Form
29
+ */
30
+ protected function _prepareForm()
31
+ {
32
+ $model = Mage::helper('piyush_events')->getEventsItemInstance();
33
+
34
+ /**
35
+ * Checking if user have permissions to save information
36
+ */
37
+ if (Mage::helper('piyush_events/admin')->isActionAllowed('save')) {
38
+ $isElementDisabled = false;
39
+ } else {
40
+ $isElementDisabled = true;
41
+ }
42
+
43
+ $form = new Varien_Data_Form();
44
+
45
+ $form->setHtmlIdPrefix('events_content_');
46
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array(
47
+ 'tab_id' => $this->getTabId()
48
+ ));
49
+ $fieldset = $form->addFieldset('eligibility_fieldset', array(
50
+ 'legend' => Mage::helper('piyush_events')->__('Events Eligibility'),
51
+ 'class' => 'fieldset-wide'
52
+ ));
53
+ $eligibilityField = $fieldset->addField('eligibility', 'editor', array(
54
+ 'name' => 'eligibility',
55
+ 'style' => 'height:6em;',
56
+ 'required' => true,
57
+ 'disabled' => $isElementDisabled,
58
+ 'config' => $wysiwygConfig
59
+ ));
60
+
61
+ $fieldset = $form->addFieldset('content_fieldset', array(
62
+ 'legend' => Mage::helper('piyush_events')->__('Events Details'),
63
+ 'class' => 'fieldset-wide'
64
+ ));
65
+
66
+ $contentField = $fieldset->addField('details', 'editor', array(
67
+ 'name' => 'details',
68
+ 'style' => 'height:16em;',
69
+ 'required' => true,
70
+ 'disabled' => $isElementDisabled,
71
+ 'config' => $wysiwygConfig
72
+ ));
73
+
74
+
75
+
76
+ // Setting custom renderer for content field to remove label column
77
+ $renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')
78
+ ->setTemplate('cms/page/edit/form/renderer/content.phtml');
79
+ $contentField->setRenderer($renderer);
80
+ $eligibilityField->setRenderer($renderer);
81
+
82
+ $form->setValues($model->getData());
83
+ $this->setForm($form);
84
+
85
+ Mage::dispatchEvent('adminhtml_events_edit_tab_content_prepare_form', array('form' => $form));
86
+
87
+ return parent::_prepareForm();
88
+ }
89
+
90
+ /**
91
+ * Prepare label for tab
92
+ *
93
+ * @return string
94
+ */
95
+ public function getTabLabel()
96
+ {
97
+ return Mage::helper('piyush_events')->__('Content');
98
+ }
99
+
100
+ /**
101
+ * Prepare title for tab
102
+ *
103
+ * @return string
104
+ */
105
+ public function getTabTitle()
106
+ {
107
+ return Mage::helper('piyush_events')->__('Content');
108
+ }
109
+
110
+ /**
111
+ * Returns status flag about this tab can be shown or not
112
+ *
113
+ * @return true
114
+ */
115
+ public function canShowTab()
116
+ {
117
+ return true;
118
+ }
119
+
120
+ /**
121
+ * Returns status flag about this tab hidden or not
122
+ *
123
+ * @return true
124
+ */
125
+ public function isHidden()
126
+ {
127
+ return false;
128
+ }
129
+ }
app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Tab/Image.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Adminhtml_Events_Edit_Tab_Image
10
+ extends Mage_Adminhtml_Block_Widget_Form
11
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
12
+ {
13
+ /**
14
+ * Prepare form elements
15
+ *
16
+ * @return Mage_Adminhtml_Block_Widget_Form
17
+ */
18
+ protected function _prepareForm()
19
+ {
20
+ /**
21
+ * Checking if user have permissions to save information
22
+ */
23
+ if (Mage::helper('piyush_events/admin')->isActionAllowed('save')) {
24
+ $isElementDisabled = false;
25
+ } else {
26
+ $isElementDisabled = true;
27
+ }
28
+
29
+ $form = new Varien_Data_Form();
30
+
31
+ $form->setHtmlIdPrefix('events_image_');
32
+
33
+ $model = Mage::helper('piyush_events')->getEventsItemInstance();
34
+
35
+
36
+ $fieldset = $form->addFieldset('image_fieldset', array(
37
+ 'legend' => Mage::helper('piyush_events')->__('Image Thumbnail'), 'class' => 'fieldset-wide'
38
+ ));
39
+
40
+ $this->_addElementTypes($fieldset);
41
+
42
+ $fieldset->addField('image', 'image', array(
43
+ 'name' => 'image',
44
+ 'label' => Mage::helper('piyush_events')->__('Image'),
45
+ 'title' => Mage::helper('piyush_events')->__('Image'),
46
+ 'required' => false,
47
+ 'disabled' => $isElementDisabled
48
+ ));
49
+
50
+ Mage::dispatchEvent('adminhtml_news_edit_tab_image_prepare_form', array('form' => $form));
51
+
52
+ $form->setValues($model->getData());
53
+ $this->setForm($form);
54
+
55
+ return parent::_prepareForm();
56
+ }
57
+
58
+ /**
59
+ * Prepare label for tab
60
+ *
61
+ * @return string
62
+ */
63
+ public function getTabLabel()
64
+ {
65
+ return Mage::helper('piyush_events')->__('Image Thumbnail');
66
+ }
67
+
68
+ /**
69
+ * Prepare title for tab
70
+ *
71
+ * @return string
72
+ */
73
+ public function getTabTitle()
74
+ {
75
+ return Mage::helper('piyush_events')->__('Image Thumbnail');
76
+ }
77
+
78
+ /**
79
+ * Returns status flag about this tab can be showen or not
80
+ *
81
+ * @return true
82
+ */
83
+ public function canShowTab()
84
+ {
85
+ return true;
86
+ }
87
+
88
+ /**
89
+ * Returns status flag about this tab hidden or not
90
+ *
91
+ * @return true
92
+ */
93
+ public function isHidden()
94
+ {
95
+ return false;
96
+ }
97
+
98
+ /**
99
+ * Retrieve predefined additional element types
100
+ *
101
+ * @return array
102
+ */
103
+ protected function _getAdditionalElementTypes()
104
+ {
105
+ return array(
106
+ 'image' => Mage::getConfig()->getBlockClassName('piyush_events/adminhtml_events_edit_form_element_image')
107
+ );
108
+ }
109
+ }
app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Tab/Main.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Valuelabs_Events_Block_Adminhtml_Events_Edit_Tab_Main
10
+ extends Mage_Adminhtml_Block_Widget_Form
11
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
12
+ {
13
+ /**
14
+ * Prepare form elements for tab
15
+ *
16
+ * @return Mage_Adminhtml_Block_Widget_Form
17
+ */
18
+ protected function _prepareForm()
19
+ {
20
+ $model = Mage::helper('valuelabs_events')->getEventsItemInstance();
21
+
22
+ /**
23
+ * Checking if user have permissions to save information
24
+ */
25
+ if (Mage::helper('valuelabs_events/admin')->isActionAllowed('save')) {
26
+ $isElementDisabled = false;
27
+ } else {
28
+ $isElementDisabled = true;
29
+ }
30
+
31
+ $form = new Varien_Data_Form();
32
+
33
+ $form->setHtmlIdPrefix('news_main_');
34
+
35
+ $fieldset = $form->addFieldset('base_fieldset', array(
36
+ 'legend' => Mage::helper('valuelabs_events')->__('Events Item Info')
37
+ ));
38
+
39
+ if ($model->getId()) {
40
+ $fieldset->addField('events_id', 'hidden', array(
41
+ 'name' => 'events_id',
42
+ ));
43
+ }
44
+
45
+ $fieldset->addField('title', 'text', array(
46
+ 'name' => 'title',
47
+ 'label' => Mage::helper('valuelabs_events')->__('Events Title'),
48
+ 'title' => Mage::helper('valuelabs_events')->__('Events Title'),
49
+ 'required' => true,
50
+ 'disabled' => $isElementDisabled
51
+ ));
52
+
53
+ $fieldset->addField('venue', 'text', array(
54
+ 'name' => 'venue',
55
+ 'label' => Mage::helper('valuelabs_events')->__('Venue'),
56
+ 'title' => Mage::helper('valuelabs_events')->__('Venue'),
57
+ 'required' => true,
58
+ 'disabled' => $isElementDisabled
59
+ ));
60
+
61
+ $fieldset->addField('entry_fee', 'text', array(
62
+ 'name' => 'entry_fee',
63
+ 'label' => Mage::helper('valuelabs_events')->__('Entry Fee'),
64
+ 'title' => Mage::helper('valuelabs_events')->__('Entry Fee'),
65
+ 'required' => true,
66
+ 'disabled' => $isElementDisabled
67
+ ));
68
+
69
+ $fieldset->addField('published_at', 'date', array(
70
+ 'name' => 'published_at',
71
+ 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
72
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
73
+ 'label' => Mage::helper('valuelabs_events')->__('Publishing Date'),
74
+ 'title' => Mage::helper('valuelabs_events')->__('Publishing Date'),
75
+ 'required' => true
76
+ ));
77
+
78
+ Mage::dispatchEvent('adminhtml_events_edit_tab_main_prepare_form', array('form' => $form));
79
+
80
+ $form->setValues($model->getData());
81
+ $this->setForm($form);
82
+
83
+ return parent::_prepareForm();
84
+ }
85
+
86
+ /**
87
+ * Prepare label for tab
88
+ *
89
+ * @return string
90
+ */
91
+ public function getTabLabel()
92
+ {
93
+ return Mage::helper('valuelabs_events')->__('Events Info');
94
+ }
95
+
96
+ /**
97
+ * Prepare title for tab
98
+ *
99
+ * @return string
100
+ */
101
+ public function getTabTitle()
102
+ {
103
+ return Mage::helper('valuelabs_events')->__('Events Info');
104
+ }
105
+
106
+ /**
107
+ * Returns status flag about this tab can be shown or not
108
+ *
109
+ * @return true
110
+ */
111
+ public function canShowTab()
112
+ {
113
+ return true;
114
+ }
115
+
116
+ /**
117
+ * Returns status flag about this tab hidden or not
118
+ *
119
+ * @return true
120
+ */
121
+ public function isHidden()
122
+ {
123
+ return false;
124
+ }
125
+ }
app/code/community/Piyush/Events/Block/Adminhtml/Events/Edit/Tabs.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Adminhtml_Events_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+ /**
12
+ * Initialize tabs and define tabs block settings
13
+ *
14
+ */
15
+ public function __construct()
16
+ {
17
+ parent::__construct();
18
+ $this->setId('page_tabs');
19
+ $this->setDestElementId('edit_form');
20
+ $this->setTitle(Mage::helper('piyush_events')->__('Event Item Info'));
21
+ }
22
+ }
app/code/community/Piyush/Events/Block/Adminhtml/Events/Grid.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Adminhtml_Events_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+ /**
12
+ * Init Grid default properties
13
+ *
14
+ */
15
+ public function __construct()
16
+ {
17
+ parent::__construct();
18
+ $this->setId('events_list_grid');
19
+ $this->setDefaultSort('created_at');
20
+ $this->setDefaultDir('DESC');
21
+ $this->setSaveParametersInSession(true);
22
+ $this->setUseAjax(true);
23
+ }
24
+
25
+ /**
26
+ * Prepare collection for Grid
27
+ *
28
+ * @return Piyush_Events_Block_Adminhtml_Grid
29
+ */
30
+ protected function _prepareCollection()
31
+ {
32
+ $collection = Mage::getModel('piyush_events/events')->getResourceCollection();
33
+ //echo "<pre>";var_dump($collection);echo "</pre>";
34
+
35
+ $this->setCollection($collection);
36
+ return parent::_prepareCollection();
37
+ }
38
+
39
+ /**
40
+ * Prepare Grid columns
41
+ *
42
+ * @return Mage_Adminhtml_Block_Catalog_Search_Grid
43
+ */
44
+ protected function _prepareColumns()
45
+ {
46
+ $this->addColumn('events_id', array(
47
+ 'header' => Mage::helper('piyush_events')->__('ID #'),
48
+ 'width' => '50px',
49
+ 'index' => 'events_id',
50
+ ));
51
+
52
+ $this->addColumn('title', array(
53
+ 'header' => Mage::helper('piyush_events')->__('Title'),
54
+ 'index' => 'title',
55
+ ));
56
+
57
+ /*$this->addColumn('details', array(
58
+ 'header' => Mage::helper('piyush_events')->__('Details'),
59
+ 'index' => 'details',
60
+ ));*/
61
+ $this->addColumn('entry_fee', array(
62
+ 'header' => Mage::helper('piyush_events')->__('Entry Fee'),
63
+ 'index' => 'entry_fee',
64
+ ));
65
+
66
+ $this->addColumn('venue', array(
67
+ 'header' => Mage::helper('piyush_events')->__('Venue'),
68
+ 'index' => 'venue',
69
+ ));
70
+
71
+ $this->addColumn('published_at', array(
72
+ 'header' => Mage::helper('piyush_events')->__('Published On'),
73
+ 'sortable' => true,
74
+ 'width' => '170px',
75
+ 'index' => 'published_at',
76
+ 'type' => 'date',
77
+ ));
78
+
79
+ $this->addColumn('created_at', array(
80
+ 'header' => Mage::helper('piyush_events')->__('Created'),
81
+ 'sortable' => true,
82
+ 'width' => '170px',
83
+ 'index' => 'created_at',
84
+ 'type' => 'datetime',
85
+ ));
86
+
87
+ $this->addColumn('action',
88
+ array(
89
+ 'header' => Mage::helper('piyush_events')->__('Action'),
90
+ 'width' => '100px',
91
+ 'type' => 'action',
92
+ 'getter' => 'getId',
93
+ 'actions' => array(array(
94
+ 'caption' => Mage::helper('piyush_events')->__('Edit'),
95
+ 'url' => array('base' => '*/*/edit'),
96
+ 'field' => 'id'
97
+ )),
98
+ 'filter' => false,
99
+ 'sortable' => false,
100
+ 'index' => 'news',
101
+ ));
102
+
103
+ return parent::_prepareColumns();
104
+ }
105
+
106
+ /**
107
+ * Return row URL for js event handlers
108
+ *
109
+ * @return string
110
+ */
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
114
+ }
115
+
116
+ /**
117
+ * Grid url getter
118
+ *
119
+ * @return string current grid url
120
+ */
121
+ public function getGridUrl()
122
+ {
123
+ return $this->getUrl('*/*/grid', array('_current' => true));
124
+ }
125
+ }
app/code/community/Piyush/Events/Block/Item.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Block_Item extends Mage_Core_Block_Template
10
+ {
11
+ /**
12
+ * Current news item instance
13
+ *
14
+ * @var Piyush_Events_Model_Events
15
+ */
16
+ protected $_item;
17
+
18
+ /**
19
+ * Return parameters for back url
20
+ *
21
+ * @param array $additionalParams
22
+ * @return array
23
+ */
24
+ protected function _getBackUrlQueryParams($additionalParams = array())
25
+ {
26
+ return array_merge(array('p' => $this->getPage()), $additionalParams);
27
+ }
28
+
29
+ /**
30
+ * Return URL to the news list page
31
+ *
32
+ * @return string
33
+ */
34
+ public function getBackUrl()
35
+ {
36
+ return $this->getUrl('*/', array('_query' => $this->_getBackUrlQueryParams()));
37
+ }
38
+
39
+ /**
40
+ * Return URL for resized Events Item image
41
+ *
42
+ * @param Piyush_Events_Model_Events $item
43
+ * @param integer $width
44
+ * @return string|false
45
+ */
46
+ public function getImageUrl($item, $width)
47
+ {
48
+ return Mage::helper('piyush_events/image')->resize($item, $width);
49
+ }
50
+ }
app/code/community/Piyush/Events/Block/List.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ <!--
4
+ * @category Event Manager Module
5
+ * @package Piyush_Events
6
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ * @link N/A
9
+ -->
10
+ */
11
+ class Piyush_Events_Block_List extends Mage_Core_Block_Template
12
+ {
13
+ /**
14
+ * Events collection
15
+ *
16
+ * @var Piyush_Events_Model_Resource_Events_Collection
17
+ */
18
+ protected $_eventsCollection = null;
19
+
20
+ /**
21
+ * Retrieve events collection
22
+ *
23
+ * @return Piyush_Events_Model_Resource_Events_Collection
24
+ */
25
+ protected function _getCollection()
26
+ {
27
+ return Mage::getResourceModel('piyush_events/events_collection');
28
+ }
29
+
30
+ /**
31
+ * Retrieve prepared events collection
32
+ *
33
+ * @return Piyush_Events_Model_Resource_Events_Collection
34
+ */
35
+ public function getCollection()
36
+ {
37
+ if (is_null($this->_eventsCollection)) {
38
+ $this->_eventsCollection = $this->_getCollection();
39
+ $this->_eventsCollection->prepareForList($this->getCurrentPage());
40
+ }
41
+
42
+ return $this->_eventsCollection;
43
+ }
44
+
45
+ /**
46
+ * Return URL to item's view page
47
+ *
48
+ * @param Piyush_Events_Model_Events $eventsItem
49
+ * @return string
50
+ */
51
+ public function getItemUrl($eventsItem)
52
+ {
53
+ return $this->getUrl('*/*/view', array('id' => $eventsItem->getId()));
54
+ }
55
+
56
+ /**
57
+ * Fetch the current page for the events list
58
+ *
59
+ * @return int
60
+ */
61
+ public function getCurrentPage()
62
+ {
63
+ return $this->getData('current_page') ? $this->getData('current_page') : 1;
64
+ }
65
+
66
+ /**
67
+ * Get a pager
68
+ *
69
+ * @return string|null
70
+ */
71
+ public function getPager()
72
+ {
73
+ $pager = $this->getChild('events_list_pager');
74
+ if ($pager) {
75
+ $eventsPerPage = Mage::helper('piyush_events')->getEventsPerPage();
76
+
77
+ $pager->setAvailableLimit(array($eventsPerPage => $eventsPerPage));
78
+ $pager->setTotalNum($this->getCollection()->getSize());
79
+ $pager->setCollection($this->getCollection());
80
+ $pager->setShowPerPage(true);
81
+
82
+ return $pager->toHtml();
83
+ }
84
+
85
+ return null;
86
+ }
87
+
88
+ /**
89
+ * Return URL for resized Events Item image
90
+ *
91
+ * @param Piyush_Events_Model_Events $item
92
+ * @param integer $width
93
+ * @return string|false
94
+ */
95
+ public function getImageUrl($item, $width)
96
+ {
97
+ return Mage::helper('piyush_events/image')->resize($item, $width);
98
+ }
99
+ }
app/code/community/Piyush/Events/Helper/Admin.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Helper_Admin extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * Check permission for passed action
13
+ *
14
+ * @param string $action
15
+ * @return bool
16
+ */
17
+ public function isActionAllowed($action)
18
+ {
19
+ return Mage::getSingleton('admin/session')->isAllowed('events/manage/' . $action);
20
+ }
21
+ }
app/code/community/Piyush/Events/Helper/Data.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Helper_Data extends Mage_Core_Helper_Data
10
+ {
11
+ /**
12
+ * Path to store config if front-end output is enabled
13
+ *
14
+ * @var string
15
+ */
16
+ const XML_PATH_ENABLED = 'events/view/enabled';
17
+
18
+ /**
19
+ * Path to store config where count of events posts per page is stored
20
+ *
21
+ * @var string
22
+ */
23
+ const XML_PATH_ITEMS_PER_PAGE = 'events/view/items_per_page';
24
+
25
+ /**
26
+ * Path to store config where count of days while events is still recently added is stored
27
+ *
28
+ * @var string
29
+ */
30
+ const XML_PATH_DAYS_DIFFERENCE = 'events/view/days_difference';
31
+
32
+ /**
33
+ * Events Item instance for lazy loading
34
+ *
35
+ * @var Piyush_Events_Model_Events
36
+ */
37
+ protected $_eventsItemInstance;
38
+
39
+ /**
40
+ * Checks whether events can be displayed in the frontend
41
+ *
42
+ * @param integer|string|Mage_Core_Model_Store $store
43
+ * @return boolean
44
+ */
45
+ public function isEnabled($store = null)
46
+ {
47
+ return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED, $store);
48
+ }
49
+
50
+ /**
51
+ * Return the number of items per page
52
+ *
53
+ * @param integer|string|Mage_Core_Model_Store $store
54
+ * @return int
55
+ */
56
+ public function getEventsPerPage($store = null)
57
+ {
58
+ return abs((int)Mage::getStoreConfig(self::XML_PATH_ITEMS_PER_PAGE, $store));
59
+ }
60
+
61
+ /**
62
+ * Return difference in days while events is recently added
63
+ *
64
+ * @param integer|string|Mage_Core_Model_Store $store
65
+ * @return int
66
+ */
67
+ public function getDaysDifference($store = null)
68
+ {
69
+ return abs((int)Mage::getStoreConfig(self::XML_PATH_DAYS_DIFFERENCE, $store));
70
+ }
71
+
72
+ /**
73
+ * Return current events item instance from the Registry
74
+ *
75
+ * @return Piyush_Events_Model_Events
76
+ */
77
+ public function getEventsItemInstance()
78
+ {
79
+ if (!$this->_eventsItemInstance) {
80
+ $this->_eventsItemInstance = Mage::registry('events_item');
81
+
82
+ if (!$this->_eventsItemInstance) {
83
+ Mage::throwException($this->__('Events item instance does not exist in Registry'));
84
+ }
85
+ }
86
+
87
+ return $this->_eventsItemInstance;
88
+ }
89
+ }
app/code/community/Piyush/Events/Helper/Image.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Helper_Image extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * Media path to extension imahes
13
+ *
14
+ * @var string
15
+ */
16
+ const MEDIA_PATH = 'events';
17
+
18
+ /**
19
+ * Maximum size for image in bytes
20
+ * Default value is 1M
21
+ *
22
+ * @var int
23
+ */
24
+ const MAX_FILE_SIZE = 1048576;
25
+
26
+ /**
27
+ * Manimum image height in pixels
28
+ *
29
+ * @var int
30
+ */
31
+ const MIN_HEIGHT = 50;
32
+
33
+ /**
34
+ * Maximum image height in pixels
35
+ *
36
+ * @var int
37
+ */
38
+ const MAX_HEIGHT = 800;
39
+
40
+ /**
41
+ * Manimum image width in pixels
42
+ *
43
+ * @var int
44
+ */
45
+ const MIN_WIDTH = 50;
46
+
47
+ /**
48
+ * Maximum image width in pixels
49
+ *
50
+ * @var int
51
+ */
52
+ const MAX_WIDTH = 800;
53
+
54
+ /**
55
+ * Array of image size limitation
56
+ *
57
+ * @var array
58
+ */
59
+ protected $_imageSize = array(
60
+ 'minheight' => self::MIN_HEIGHT,
61
+ 'minwidth' => self::MIN_WIDTH,
62
+ 'maxheight' => self::MAX_HEIGHT,
63
+ 'maxwidth' => self::MAX_WIDTH,
64
+ );
65
+
66
+ /**
67
+ * Array of allowed file extensions
68
+ *
69
+ * @var array
70
+ */
71
+ protected $_allowedExtensions = array('jpg', 'gif', 'png');
72
+
73
+ /**
74
+ * Return the base media directory for Events Item images
75
+ *
76
+ * @return string
77
+ */
78
+ public function getBaseDir()
79
+ {
80
+ return Mage::getBaseDir('media') . DS . self::MEDIA_PATH;
81
+ }
82
+
83
+ /**
84
+ * Return the Base URL for Events Item images
85
+ *
86
+ * @return string
87
+ */
88
+ public function getBaseUrl()
89
+ {
90
+ return Mage::getBaseUrl('media') . '/' . self::MEDIA_PATH;
91
+ }
92
+
93
+ /**
94
+ * Remove event item image by image filename
95
+ *
96
+ * @param string $imageFile
97
+ * @return bool
98
+ */
99
+ public function removeImage($imageFile)
100
+ {
101
+ $io = new Varien_Io_File();
102
+ $io->open(array('path' => $this->getBaseDir()));
103
+ if ($io->fileExists($imageFile)) {
104
+ return $io->rm($imageFile);
105
+ }
106
+ return false;
107
+ }
108
+
109
+ /**
110
+ * Upload image and return uploaded image file name or false
111
+ *
112
+ * @throws Mage_Core_Exception
113
+ * @param string $scope the request key for file
114
+ * @return bool|string
115
+ */
116
+ public function uploadImage($scope)
117
+ {
118
+ $adapter = new Zend_File_Transfer_Adapter_Http();
119
+ $adapter->addValidator('ImageSize', true, $this->_imageSize);
120
+ $adapter->addValidator('Size', true, self::MAX_FILE_SIZE);
121
+ if ($adapter->isUploaded($scope)) {
122
+ // validate image
123
+ if (!$adapter->isValid($scope)) {
124
+ Mage::throwException(Mage::helper('piyush_events')->__('Uploaded image is not valid'));
125
+ }
126
+ $upload = new Varien_File_Uploader($scope);
127
+ $upload->setAllowCreateFolders(true);
128
+ $upload->setAllowedExtensions($this->_allowedExtensions);
129
+ $upload->setAllowRenameFiles(true);
130
+ $upload->setFilesDispersion(false);
131
+ if ($upload->save($this->getBaseDir())) {
132
+ return $upload->getUploadedFileName();
133
+ }
134
+ }
135
+ return false;
136
+ }
137
+
138
+ /**
139
+ * Return URL for resized Events Item Image
140
+ *
141
+ * @param Piyush_Events_Model_Item $item
142
+ * @param integer $width
143
+ * @param integer $height
144
+ * @return bool|string
145
+ */
146
+ public function resize(Piyush_Events_Model_Events $item, $width, $height = null)
147
+ {
148
+ if (!$item->getImage()) {
149
+ return false;
150
+ }
151
+
152
+ if ($width < self::MIN_WIDTH || $width > self::MAX_WIDTH) {
153
+ return false;
154
+ }
155
+ $width = (int)$width;
156
+
157
+ if (!is_null($height)) {
158
+ if ($height < self::MIN_HEIGHT || $height > self::MAX_HEIGHT) {
159
+ return false;
160
+ }
161
+ $height = (int)$height;
162
+ }
163
+
164
+ $imageFile = $item->getImage();
165
+ $cacheDir = $this->getBaseDir() . DS . 'cache' . DS . $width;
166
+ $cacheUrl = $this->getBaseUrl() . '/' . 'cache' . '/' . $width . '/';
167
+
168
+ $io = new Varien_Io_File();
169
+ $io->checkAndCreateFolder($cacheDir);
170
+ $io->open(array('path' => $cacheDir));
171
+ if ($io->fileExists($imageFile)) {
172
+ return $cacheUrl . $imageFile;
173
+ }
174
+
175
+ try {
176
+ $image = new Varien_Image($this->getBaseDir() . DS . $imageFile);
177
+ $image->resize($width, $height);
178
+ $image->save($cacheDir . DS . $imageFile);
179
+ return $cacheUrl . $imageFile;
180
+ } catch (Exception $e) {
181
+ Mage::logException($e);
182
+ return false;
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Removes folder with cached images
188
+ *
189
+ * @return boolean
190
+ */
191
+ public function flushImagesCache()
192
+ {
193
+ $cacheDir = $this->getBaseDir() . DS . 'cache' . DS ;
194
+ $io = new Varien_Io_File();
195
+ if ($io->fileExists($cacheDir, false) ) {
196
+ return $io->rmdir($cacheDir, true);
197
+ }
198
+ return true;
199
+ }
200
+ }
app/code/community/Piyush/Events/Model/Events.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Model_Events extends Mage_Core_Model_Abstract
10
+ {
11
+ /**
12
+ * Define resource model
13
+ */
14
+ protected function _construct()
15
+ {
16
+ $this->_init('piyush_events/events');
17
+ }
18
+
19
+ /**
20
+ * If object is new adds creation date
21
+ *
22
+ * @return Piyush_Events_Model_Events
23
+ */
24
+ protected function _beforeSave()
25
+ {
26
+ parent::_beforeSave();
27
+ if ($this->isObjectNew()) {
28
+ $this->setData('created_at', Varien_Date::now());
29
+ }
30
+ return $this;
31
+ }
32
+ }
app/code/community/Piyush/Events/Model/Observer.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Model_Observer
10
+ {
11
+ /**
12
+ * Event before show event item on frontend
13
+ * If specified new post was added recently (term is defined in config) we'll see message about this on front-end.
14
+ *
15
+ * @param Varien_Event_Observer $observer
16
+ */
17
+ public function beforeEventsDisplayed(Varien_Event_Observer $observer)
18
+ {
19
+ $eventsItem = $observer->getEvent()->getEventsItem();
20
+ $currentDate = Mage::app()->getLocale()->date();
21
+ $eventsCreatedAt = Mage::app()->getLocale()->date(strtotime($eventsItem->getCreatedAt()));
22
+ $daysDifference = $currentDate->sub($eventsCreatedAt)->getTimestamp() / (60 * 60 * 24);
23
+ /*if ($daysDifference < Mage::helper('piyush_events')->getDaysDifference()) {
24
+ Mage::getSingleton('core/session')->addSuccess(Mage::helper('piyush_events')->__('Recently added'));
25
+ }*/
26
+ }
27
+ }
app/code/community/Piyush/Events/Model/Resource/Events.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Model_Resource_Events extends Mage_Core_Model_Resource_Db_Abstract
10
+ {
11
+ /**
12
+ * Initialize connection and define main table and primary key
13
+ */
14
+ protected function _construct()
15
+ {
16
+ $this->_init('piyush_events/events', 'events_id');
17
+ }
18
+ }
app/code/community/Piyush/Events/Model/Resource/Events/Collection.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Model_Resource_Events_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
10
+ {
11
+ /**
12
+ * Define collection model
13
+ */
14
+ protected function _construct()
15
+ {
16
+ $this->_init('piyush_events/events');
17
+ }
18
+
19
+ /**
20
+ * Prepare for displaying in list
21
+ *
22
+ * @param integer $page
23
+ * @return Piyush_Events_Model_Resource_Events_Collection
24
+ */
25
+ public function prepareForList($page)
26
+ {
27
+ $this->setPageSize(Mage::helper('piyush_events')->getEventsPerPage());
28
+ $this->setCurPage($page)->setOrder('published_at', Varien_Data_Collection::SORT_ORDER_DESC);
29
+ return $this;
30
+ }
31
+ }
app/code/community/Piyush/Events/controllers/Adminhtml/EventsController.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_Adminhtml_EventsController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ /**
12
+ * Init actions
13
+ *
14
+ * @return Piyush_Events_Adminhtml_EventsController
15
+ */
16
+ protected function _initAction()
17
+ {
18
+ // load layout, set active menu and breadcrumbs
19
+ $this->loadLayout()
20
+ ->_setActiveMenu('events/manage')
21
+ ->_addBreadcrumb(
22
+ Mage::helper('piyush_events')->__('Events'),
23
+ Mage::helper('piyush_events')->__('Events')
24
+ )
25
+ ->_addBreadcrumb(
26
+ Mage::helper('piyush_events')->__('Manage Events'),
27
+ Mage::helper('piyush_events')->__('Manage Events')
28
+ )
29
+ ;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Index action
35
+ */
36
+ public function indexAction()
37
+ {
38
+ $this->_title($this->__('Events'))
39
+ ->_title($this->__('Manage Events'));
40
+
41
+ $this->_initAction();
42
+ $this->renderLayout();
43
+ }
44
+
45
+ /**
46
+ * Create new Events item
47
+ */
48
+ public function newAction()
49
+ {
50
+ // the same form is used to create and edit
51
+ $this->_forward('edit');
52
+ }
53
+
54
+ /**
55
+ * Edit Events item
56
+ */
57
+ public function editAction()
58
+ {
59
+ $this->_title($this->__('Events'))
60
+ ->_title($this->__('Manage Events'));
61
+
62
+ // 1. instance events model
63
+ /* @var $model Piyush_Events_Model_Item */
64
+ $model = Mage::getModel('piyush_events/events');
65
+
66
+ // 2. if exists id, check it and load data
67
+ $eventsId = $this->getRequest()->getParam('id');
68
+ if ($eventsId) {
69
+ $model->load($eventsId);
70
+
71
+ if (!$model->getId()) {
72
+ $this->_getSession()->addError(
73
+ Mage::helper('piyush_events')->__('Events item does not exist.')
74
+ );
75
+ return $this->_redirect('*/*/');
76
+ }
77
+ // prepare title
78
+ $this->_title($model->getTitle());
79
+ $breadCrumb = Mage::helper('piyush_events')->__('Edit Item');
80
+ } else {
81
+ $this->_title(Mage::helper('piyush_events')->__('New Item'));
82
+ $breadCrumb = Mage::helper('piyush_events')->__('New Item');
83
+ }
84
+
85
+ // Init breadcrumbs
86
+ $this->_initAction()->_addBreadcrumb($breadCrumb, $breadCrumb);
87
+
88
+ // 3. Set entered data if was error when we do save
89
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
90
+ if (!empty($data)) {
91
+ $model->addData($data);
92
+ }
93
+
94
+ // 4. Register model to use later in blocks
95
+ Mage::register('events_item', $model);
96
+
97
+ // 5. render layout
98
+ $this->renderLayout();
99
+ }
100
+
101
+ /**
102
+ * Save action
103
+ */
104
+ public function saveAction()
105
+ {
106
+ $redirectPath = '*/*';
107
+ $redirectParams = array();
108
+
109
+ // check if data sent
110
+ $data = $this->getRequest()->getPost();
111
+ if ($data) {
112
+ $data = $this->_filterPostData($data);
113
+ // init model and set data
114
+ /* @var $model Piyush_Events_Model_Item */
115
+ $model = Mage::getModel('piyush_events/events');
116
+
117
+ // if events item exists, try to load it
118
+ $eventsId = $this->getRequest()->getParam('events_id');
119
+ if ($eventsId) {
120
+ $model->load($eventsId);
121
+ }
122
+ // save image data and remove from data array
123
+ if (isset($data['image'])) {
124
+ $imageData = $data['image'];
125
+ unset($data['image']);
126
+ } else {
127
+ $imageData = array();
128
+ }
129
+ $model->addData($data);
130
+
131
+ try {
132
+ $hasError = false;
133
+ /* @var $imageHelper Piyush_Events_Helper_Image */
134
+ $imageHelper = Mage::helper('piyush_events/image');
135
+ // remove image
136
+
137
+ if (isset($imageData['delete']) && $model->getImage()) {
138
+ $imageHelper->removeImage($model->getImage());
139
+ $model->setImage(null);
140
+ }
141
+
142
+ // upload new image
143
+ $imageFile = $imageHelper->uploadImage('image');
144
+ if ($imageFile) {
145
+ if ($model->getImage()) {
146
+ $imageHelper->removeImage($model->getImage());
147
+ }
148
+ $model->setImage($imageFile);
149
+ }
150
+ // save the data
151
+ $model->save();
152
+
153
+ // display success message
154
+ $this->_getSession()->addSuccess(
155
+ Mage::helper('piyush_events')->__('The events item has been saved.')
156
+ );
157
+
158
+ // check if 'Save and Continue'
159
+ if ($this->getRequest()->getParam('back')) {
160
+ $redirectPath = '*/*/edit';
161
+ $redirectParams = array('id' => $model->getId());
162
+ }
163
+ } catch (Mage_Core_Exception $e) {
164
+ $hasError = true;
165
+ $this->_getSession()->addError($e->getMessage());
166
+ } catch (Exception $e) {
167
+ $hasError = true;
168
+ $this->_getSession()->addException($e,
169
+ Mage::helper('piyush_events')->__('An error occurred while saving the events item.')
170
+ );
171
+ }
172
+
173
+ if ($hasError) {
174
+ $this->_getSession()->setFormData($data);
175
+ $redirectPath = '*/*/edit';
176
+ $redirectParams = array('id' => $this->getRequest()->getParam('id'));
177
+ }
178
+ }
179
+
180
+ $this->_redirect($redirectPath, $redirectParams);
181
+ }
182
+
183
+ /**
184
+ * Delete action
185
+ */
186
+ public function deleteAction()
187
+ {
188
+ // check if we know what should be deleted
189
+ $itemId = $this->getRequest()->getParam('id');
190
+ if ($itemId) {
191
+ try {
192
+ // init model and delete
193
+ /** @var $model Piyush_Events_Model_Item */
194
+ $model = Mage::getModel('piyush_events/events');
195
+ $model->load($itemId);
196
+ if (!$model->getId()) {
197
+ Mage::throwException(Mage::helper('piyush_events')->__('Unable to find a event item.'));
198
+ }
199
+ $model->delete();
200
+
201
+ // display success message
202
+ $this->_getSession()->addSuccess(
203
+ Mage::helper('piyush_events')->__('The event item has been deleted.')
204
+ );
205
+ } catch (Mage_Core_Exception $e) {
206
+ $this->_getSession()->addError($e->getMessage());
207
+ } catch (Exception $e) {
208
+ $this->_getSession()->addException($e,
209
+ Mage::helper('piyush_events')->__('An error occurred while deleting the event item.')
210
+ );
211
+ }
212
+ }
213
+
214
+ // go to grid
215
+ $this->_redirect('*/*/');
216
+ }
217
+
218
+ /**
219
+ * Check the permission to run it
220
+ *
221
+ * @return boolean
222
+ */
223
+ protected function _isAllowed()
224
+ {
225
+ switch ($this->getRequest()->getActionName()) {
226
+ case 'new':
227
+ case 'save':
228
+ return Mage::getSingleton('admin/session')->isAllowed('events/manage/save');
229
+ break;
230
+ case 'delete':
231
+ return Mage::getSingleton('admin/session')->isAllowed('events/manage/delete');
232
+ break;
233
+ default:
234
+ return Mage::getSingleton('admin/session')->isAllowed('events/manage');
235
+ break;
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Filtering posted data. Converting localized data if needed
241
+ *
242
+ * @param array
243
+ * @return array
244
+ */
245
+ protected function _filterPostData($data)
246
+ {
247
+ $data = $this->_filterDates($data, array('time_published'));
248
+ return $data;
249
+ }
250
+
251
+ /**
252
+ * Grid ajax action
253
+ */
254
+ public function gridAction()
255
+ {
256
+ $this->loadLayout();
257
+ $this->renderLayout();
258
+ }
259
+
260
+ /**
261
+ * Flush Events Posts Images Cache action
262
+ */
263
+ public function flushAction()
264
+ {
265
+ if (Mage::helper('piyush_events/image')->flushImagesCache()) {
266
+ $this->_getSession()->addSuccess('Cache successfully flushed');
267
+ } else {
268
+ $this->_getSession()->addError('There was error during flushing cache');
269
+ }
270
+ $this->_forward('index');
271
+ }
272
+ }
app/code/community/Piyush/Events/controllers/IndexController.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ class Piyush_Events_IndexController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Pre dispatch action that allows to redirect to no route page in case of disabled extension through admin panel
13
+ */
14
+ public function preDispatch()
15
+ {
16
+ parent::preDispatch();
17
+
18
+ if (!Mage::helper('piyush_events')->isEnabled()) {
19
+ $this->setFlag('', 'no-dispatch', true);
20
+ $this->_redirect('noRoute');
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Index action
26
+ */
27
+ public function indexAction()
28
+ {
29
+ $this->loadLayout();
30
+
31
+ $listBlock = $this->getLayout()->getBlock('events.list');
32
+
33
+ if ($listBlock) {
34
+ $currentPage = abs(intval($this->getRequest()->getParam('p')));
35
+ if ($currentPage < 1) {
36
+ $currentPage = 1;
37
+ }
38
+ $listBlock->setCurrentPage($currentPage);
39
+ }
40
+
41
+ $this->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * Events view action
46
+ */
47
+ public function viewAction()
48
+ {
49
+ $eventsId = $this->getRequest()->getParam('id');
50
+ if (!$eventsId) {
51
+ return $this->_forward('noRoute');
52
+ }
53
+
54
+ /** @var $model Piyush_Events_Model_Events */
55
+ $model = Mage::getModel('piyush_events/events');
56
+ $model->load($eventsId);
57
+
58
+ if (!$model->getId()) {
59
+ return $this->_forward('noRoute');
60
+ }
61
+
62
+ Mage::register('events_item', $model);
63
+
64
+ Mage::dispatchEvent('before_events_item_display', array('events_item' => $model));
65
+
66
+ $this->loadLayout();
67
+ $itemBlock = $this->getLayout()->getBlock('events.item');
68
+ if ($itemBlock) {
69
+ $listBlock = $this->getLayout()->getBlock('events.list');
70
+ if ($listBlock) {
71
+ $page = (int)$listBlock->getCurrentPage() ? (int)$listBlock->getCurrentPage() : 1;
72
+ } else {
73
+ $page = 1;
74
+ }
75
+ $itemBlock->setPage($page);
76
+ }
77
+ $this->renderLayout();
78
+ }
79
+ }
app/code/community/Piyush/Events/etc/adminhtml.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+ * @category Event Manager Module
5
+ * @package Piyush_Events
6
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ * @link N/A
9
+ */
10
+ -->
11
+ <config>
12
+ <menu>
13
+ <events translate="title" module="piyush_events">
14
+ <title>Events</title>
15
+ <sort_order>30</sort_order>
16
+ <children>
17
+ <manage translate="title" module="piyush_events">
18
+ <title>Manage Events</title>
19
+ <action>adminhtml/events</action>
20
+ <sort_order>35</sort_order>
21
+ </manage>
22
+ </children>
23
+ </events>
24
+ </menu>
25
+ <acl>
26
+ <resources>
27
+ <admin>
28
+ <children>
29
+ <events translate="title" module="piyush_events">
30
+ <title>Events</title>
31
+ <sort_order>30</sort_order>
32
+ <children>
33
+ <manage translate="title">
34
+ <title>Manage Events</title>
35
+ <sort_order>0</sort_order>
36
+ <children>
37
+ <save translate="title">
38
+ <title>Save Events</title>
39
+ <sort_order>0</sort_order>
40
+ </save>
41
+ <delete translate="title">
42
+ <title>Delete Events</title>
43
+ <sort_order>10</sort_order>
44
+ </delete>
45
+ </children>
46
+ </manage>
47
+ </children>
48
+ </events>
49
+ <system>
50
+ <children>
51
+ <config>
52
+ <children>
53
+ <events translate="title" module="piyush_events">
54
+ <title>Events Management</title>
55
+ </events>
56
+ </children>
57
+ </config>
58
+ </children>
59
+ </system>
60
+ </children>
61
+ </admin>
62
+ </resources>
63
+ </acl>
64
+ </config>
app/code/community/Piyush/Events/etc/config.xml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+ * @category Event Manager Module
5
+ * @package Piyush_Events
6
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ * @link N/A
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Piyush_Events>
14
+ <version>1.0.1</version>
15
+ </Piyush_Events>
16
+ </modules>
17
+ <global>
18
+ <models>
19
+ <piyush_events>
20
+ <class>Piyush_Events_Model</class>
21
+ <resourceModel>events_resource</resourceModel>
22
+ </piyush_events>
23
+ <events_resource>
24
+ <class>Piyush_Events_Model_Resource</class>
25
+ <entities>
26
+ <events>
27
+ <table>piyush_events</table>
28
+ </events>
29
+ </entities>
30
+ </events_resource>
31
+ </models>
32
+ <helpers>
33
+ <piyush_events>
34
+ <class>Piyush_Events_Helper</class>
35
+ </piyush_events>
36
+ </helpers>
37
+ <blocks>
38
+ <piyush_events>
39
+ <class>Piyush_Events_Block</class>
40
+ </piyush_events>
41
+ </blocks>
42
+ <resources>
43
+ <piyush_events_setup>
44
+ <setup>
45
+ <module>Piyush_Events</module>
46
+ <class>Mage_Core_Model_Resource_Setup</class>
47
+ </setup>
48
+ </piyush_events_setup>
49
+ </resources>
50
+ <events>
51
+ <before_events_item_display>
52
+ <observers>
53
+ <piyush_events>
54
+ <class>piyush_events/observer</class>
55
+ <method>beforeEventsDisplayed</method>
56
+ </piyush_events>
57
+ </observers>
58
+ </before_events_item_display>
59
+ </events>
60
+ </global>
61
+ <frontend>
62
+ <routers>
63
+ <piyush_events>
64
+ <use>standard</use>
65
+ <args>
66
+ <module>Piyush_Events</module>
67
+ <frontName>events</frontName>
68
+ </args>
69
+ </piyush_events>
70
+ </routers>
71
+ <layout>
72
+ <updates>
73
+ <piyush_events>
74
+ <file>piyush_events.xml</file>
75
+ </piyush_events>
76
+ </updates>
77
+ </layout>
78
+ </frontend>
79
+ <admin>
80
+ <routers>
81
+ <adminhtml>
82
+ <args>
83
+ <modules>
84
+ <Piyush_Events before="Mage_Adminhtml">Piyush_Events_Adminhtml</Piyush_Events>
85
+ </modules>
86
+ </args>
87
+ </adminhtml>
88
+ </routers>
89
+ </admin>
90
+ <adminhtml>
91
+ <layout>
92
+ <updates>
93
+ <piyush_events>
94
+ <file>piyush_events.xml</file>
95
+ </piyush_events>
96
+ </updates>
97
+ </layout>
98
+ </adminhtml>
99
+ <default>
100
+ <events>
101
+ <view>
102
+ <enabled>1</enabled>
103
+ <items_per_page>10</items_per_page>
104
+ <days_difference>3</days_difference>
105
+ </view>
106
+ </events>
107
+ </default>
108
+ </config>
app/code/community/Piyush/Events/etc/system.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+ * @category Event Manager Module
5
+ * @package Piyush_Events
6
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ * @link N/A
9
+ */
10
+ -->
11
+ <config>
12
+ <sections>
13
+ <events>
14
+ <class>separator-top</class>
15
+ <label>Events</label>
16
+ <tab>general</tab>
17
+ <frontend_type>text</frontend_type>
18
+ <sort_order>500</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+
23
+ <groups>
24
+ <view translate="label">
25
+ <label>Events View Settings</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>10</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <fields>
32
+ <enabled translate="label">
33
+ <label>Enable Events On Frontend</label>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>10</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ </enabled>
41
+ <items_per_page translate="label">
42
+ <label>Events Per Page</label>
43
+ <comment>Empty value is the same as default 20.</comment>
44
+ <sort_order>30</sort_order>
45
+ <depends><enabled>1</enabled></depends>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ </items_per_page>
50
+ <days_difference translate="label">
51
+ <label>Number of days since a event has been marked as recently added</label>
52
+ <comment>Empty value is the same as default 3.</comment>
53
+ <sort_order>50</sort_order>
54
+ <depends><enabled>1</enabled></depends>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </days_difference>
59
+ </fields>
60
+ </view>
61
+ </groups>
62
+ </events>
63
+ </sections>
64
+ </config>
app/code/community/Piyush/Events/sql/piyush_events_setup/install-1.0.1.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+
10
+ /**
11
+ * @var $installer Mage_Core_Model_Resource_Setup
12
+ */
13
+ $installer = $this;
14
+
15
+ /**
16
+ * Creating table piyush_events
17
+ */
18
+ $table = $installer->getConnection()
19
+ ->newTable($installer->getTable('piyush_events/events'))
20
+ ->addColumn('events_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
21
+ 'unsigned' => true,
22
+ 'identity' => true,
23
+ 'nullable' => false,
24
+ 'primary' => true,
25
+ ), 'Entity id')
26
+ ->addColumn('title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
27
+ 'nullable' => true,
28
+ ), 'Title')
29
+ ->addColumn('details', Varien_Db_Ddl_Table::TYPE_TEXT, '2M', array(
30
+ 'nullable' => true,
31
+ 'default' => null,
32
+ ), 'Details')
33
+ ->addColumn('venue', Varien_Db_Ddl_Table::TYPE_TEXT, 63, array(
34
+ 'nullable' => true,
35
+ 'default' => null,
36
+ ), 'Venue')
37
+ ->addColumn('eligibility', Varien_Db_Ddl_Table::TYPE_TEXT, '2M', array(
38
+ 'nullable' => true,
39
+ 'default' => null,
40
+ ), 'Eligibility')
41
+ ->addColumn('entry_fee', Varien_Db_Ddl_Table::TYPE_INTEGER, 100, array(
42
+ 'nullable' => true,
43
+ 'default' => null,
44
+ ), 'Entry Fee')
45
+ ->addColumn('image', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
46
+ 'nullable' => true,
47
+ 'default' => null,
48
+ ), 'Events image media path')
49
+ ->addColumn('published_at', Varien_Db_Ddl_Table::TYPE_DATE, null, array(
50
+ 'nullable' => true,
51
+ 'default' => null,
52
+ ), 'World publish date')
53
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
54
+ 'nullable' => true,
55
+ 'default' => null,
56
+ ), 'Creation Time')
57
+ ->addIndex($installer->getIdxName(
58
+ $installer->getTable('piyush_events/events'),
59
+ array('published_at'),
60
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
61
+ ),
62
+ array('published_at'),
63
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
64
+ )
65
+ ->setComment('Event item');
66
+
67
+ $installer->getConnection()->createTable($table);
app/design/adminhtml/default/default/layout/piyush_events.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * @category Event Manager Module
4
+ * @package Valuelabs_Events
5
+ * @author Piyush Kumar <piyush.kumar@valuelabs.net>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ -->
9
+ <layout>
10
+ <adminhtml_events_index>
11
+ <reference name="content">
12
+ <block type="piyush_events/adminhtml_events" name="events" />
13
+ </reference>
14
+ </adminhtml_events_index>
15
+
16
+ <adminhtml_events_grid>
17
+ <block type="piyush_events/adminhtml_events_grid" name="root"/>
18
+ </adminhtml_events_grid>
19
+
20
+ <adminhtml_events_new>
21
+ <update handle="adminhtml_events_edit" />
22
+ </adminhtml_events_new>
23
+
24
+ <adminhtml_events_edit>
25
+ <update handle="editor"/>
26
+ <reference name="content">
27
+ <block type="piyush_events/adminhtml_events_edit" name="events_edit" />
28
+ </reference>
29
+ <reference name="left">
30
+ <block type="piyush_events/adminhtml_events_edit_tabs" name="events_edit_tabs">
31
+ <block type="piyush_events/adminhtml_events_edit_tab_main" name="events_edit_tab_main" />
32
+ <block type="piyush_events/adminhtml_events_edit_tab_content" name="events_edit_tab_content" />
33
+ <block type="piyush_events/adminhtml_events_edit_tab_image" name="events_edit_tab_image" />
34
+ <action method="addTab"><name>main_section</name><block>events_edit_tab_main</block></action>
35
+ <action method="addTab"><name>content_section</name><block>events_edit_tab_content</block></action>
36
+ <action method="addTab"><name>image_section</name><block>events_edit_tab_image</block></action>
37
+ </block>
38
+ </reference>
39
+ </adminhtml_events_edit>
40
+ </layout>
app/design/frontend/default/default/layout/piyush_events.xml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+ * @category Event Manager Module
5
+ * @package Piyush_Events
6
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ * @link N/A
9
+ */
10
+ -->
11
+ <layout version="0.1.0">
12
+ <default>
13
+ <reference name="footer_links">
14
+ <action method="addLink" translate="label title" module="piyush_events">
15
+ <label>Events</label>
16
+ <url>events</url>
17
+ <title>Events</title>
18
+ <prepare>true</prepare>
19
+ </action>
20
+ </reference>
21
+ <reference name="top.links">
22
+ <action method="addLink" translate="label title" module="piyush_events">
23
+ <label>Events</label>
24
+ <url>events</url>
25
+ <title>Events</title>
26
+ <prepare>true</prepare>
27
+ </action>
28
+ </reference>
29
+ </default>
30
+ <piyush_events_index_index translate="label">
31
+ <label>Events Page</label>
32
+ <reference name="root">
33
+ <action method="setTemplate">
34
+ <template>page/2columns-right.phtml</template>
35
+ </action>
36
+ <action method="setHeaderTitle" translate="title" module="piyush_events">
37
+ <title>Site Events</title>
38
+ </action>
39
+ </reference>
40
+ <reference name="content">
41
+ <block type="piyush_events/list" name="events.list" template="piyushevents/events/list.phtml">
42
+ <block type="page/html_pager" name="events.list.pager" as="events_list_pager" />
43
+ </block>
44
+ </reference>
45
+ </piyush_events_index_index>
46
+
47
+ <piyush_events_index_view translate="label">
48
+ <label>Events Item Page</label>
49
+ <reference name="root">
50
+ <action method="setTemplate">
51
+ <template>page/2columns-right.phtml</template>
52
+ </action>
53
+ </reference>
54
+ <reference name="content">
55
+ <block type="piyush_events/item" name="events.item" template="piyushevents/events/item.phtml" />
56
+ </reference>
57
+ </piyush_events_index_view>
58
+ </layout>
app/design/frontend/default/default/template/piyushevents/events/item.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ ?>
10
+ <?php $_eventsItem = $this->helper('piyush_events')->getEventsItemInstance(); ?>
11
+ <div id="events_item_messages"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
12
+
13
+ <div class="page-title">
14
+ <h1><?php echo $this->escapeHtml($_eventsItem->getTitle()) ?></h1>
15
+
16
+ <div class="events_item_subtitle">
17
+ <?php echo $this->formatDate($_eventsItem->getTimePublished(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM) ?>
18
+ <?php echo "<br/>Venue Details: ". $this->escapeHtml($_eventsItem->getVenue())?>
19
+ <?php echo "<br/>Entry Fee: ".Mage::helper('core')->currency($_eventsItem->getEntryFee()); ?>
20
+ </div>
21
+
22
+ </div>
23
+
24
+ <div class="events_item_view">
25
+ <?php if ($imageUrl = $this->getImageUrl($_eventsItem, 400)): ?>
26
+ <p><img src="<?php echo $imageUrl ?>" alt="<?php echo $this->escapeHtml($_eventsItem->getTitle()) ?>" /></p>
27
+ <?php endif; ?>
28
+ <div class="events_item_content"><span style="font-size:14px;font-weight:bold">Event Details</span><br/><?php echo $_eventsItem->getDetails(); ?></div>
29
+ <div class="events_item_content"><span style="font-size:14px;font-weight:bold">Eligibility</span><br/><?php echo $_eventsItem->getEligibility(); ?></div>
30
+
31
+ <div class="pager">
32
+ <a href="<?php echo $this->getBackUrl() ?>">
33
+ <?php echo Mage::helper('piyush_events')->__('Return to list') ?>
34
+ </a>
35
+ </div>
36
+ </div>
app/design/frontend/default/default/template/piyushevents/events/list.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ */
9
+ ?>
10
+ <div id="events_list_messages"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
11
+ <div class="page-title">
12
+ <h1><?php echo Mage::helper('piyush_events')->__('Events Listing') ?></h1>
13
+ </div>
14
+
15
+ <div class="events_list_view">
16
+ <?php foreach ($this->getCollection() as $eventsItem): ?>
17
+ <div id="item_<?php echo $eventsItem->getId() ?>" class="page-title">
18
+ <h2>
19
+ <a href="<?php echo $this->getItemUrl($eventsItem) ?>">
20
+ <?php echo $this->escapeHtml($eventsItem->getTitle()) ?>
21
+ </a>
22
+ </h2>
23
+ <div class="events_item_subtitle">
24
+ <?php echo $this->formatDate($eventsItem->getTimePublished(), 'medium') ?>
25
+ <?php echo "<br/>Venue Details: ". $this->escapeHtml($eventsItem->getVenue())?>
26
+ <?php echo "<br/>Entry Fee: ".Mage::helper('core')->currency($eventsItem->getEntryFee()); ?>
27
+ </div>
28
+
29
+ <?php if ($imageUrl = $this->getImageUrl($eventsItem, 100)): ?>
30
+ <p><img src="<?php echo $imageUrl ?>" alt="<?php echo $this->escapeHtml($eventsItem->getTitle()); ?>" /></p>
31
+ <?php endif; ?>
32
+
33
+ </div>
34
+ <?php endforeach; ?>
35
+ </div>
36
+
37
+ <?php echo $this->getPager() ?>
app/etc/modules/Piyush_Events.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * @category Event Manager Module
4
+ * @package Piyush_Events
5
+ * @author Piyush Kumar <phpteamlead.mca@gmail.com,er.piyush.kumar@gmail.com>
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ * @link N/A
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Piyush_Events>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ </Piyush_Events>
15
+ </modules>
16
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Piyush_Events</name>
4
+ <version>1.7.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Event Manager</summary>
10
+ <description>Event Manager</description>
11
+ <notes>Event Manager</notes>
12
+ <authors><author><name>Piyush</name><user>Piyush</user><email>phpteamlead.mca@gmail.com</email></author></authors>
13
+ <date>2013-03-08</date>
14
+ <time>22:12:56</time>
15
+ <contents><target name="magecommunity"><dir name="Piyush"><dir name="Events"><dir name="Block"><dir name="Adminhtml"><dir name="Events"><dir name="Edit"><dir name="Form"><dir name="Element"><file name="Image.php" hash="966af99cc5769f2f401d1de921d0463f"/></dir></dir><file name="Form.php" hash="5f47c53f39b196b0b5498d65a81f3b2c"/><dir name="Tab"><file name="Content.php" hash="735f927c414ef1142b4c99c7b74048d8"/><file name="Image.php" hash="180fa9cefb9c4b7ffad7cd899882f41b"/><file name="Main.php" hash="66f29a1501b5c371c5e3459199fb8d63"/></dir><file name="Tabs.php" hash="9a45d9fc529903055cc7974e1f4f830a"/></dir><file name="Edit.php" hash="e664996f06249b2bd51f141dd7f93c56"/><file name="Grid.php" hash="e4982562c84614523de3b959ba287c5b"/></dir><file name="Events.php" hash="867ae54da8d57614a6b224ec66320ee3"/></dir><file name="Item.php" hash="1e30d49616b610b4c4126bd04fef9922"/><file name="List.php" hash="99a1c8caec3234dec2de9b76aeec7b44"/></dir><dir name="Helper"><file name="Admin.php" hash="57308cc47270203757cacf2e94960792"/><file name="Data.php" hash="b9e933853088370d73590938f14fed35"/><file name="Image.php" hash="d8604db97ce3f805064148ea5d928b1e"/></dir><dir name="Model"><file name="Events.php" hash="d91448f2018d2cd93a49f31a777862f1"/><file name="Observer.php" hash="7132c65f130bc7cea2bb81130f807b28"/><dir name="Resource"><dir name="Events"><file name="Collection.php" hash="4f17378a96e462b320b059c4edb8e475"/></dir><file name="Events.php" hash="5dc25d0eee990880f5554fe3216430dc"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="EventsController.php" hash="c8134dd3948e88b53abc0fdef9325f4e"/></dir><file name="IndexController.php" hash="de58090971805551323009562b78b12c"/></dir><dir name="etc"><file name="adminhtml.xml" hash="fe1bbf561cea34142a6e2351d60b32dc"/><file name="config.xml" hash="0fdce3296e24d25c73c36ffeae17a45b"/><file name="system.xml" hash="ff242e0ce92f60df74d62cfddfb37276"/></dir><dir name="sql"><dir name="piyush_events_setup"><file name="install-1.0.1.php" hash="50acb64ce2344737f006691f69081db9"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="piyush_events.xml" hash="02209595d585a023cdebaa53563a5153"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="piyush_events.xml" hash="d147adee2b0d86261df042c92b171838"/></dir><dir name="template"><dir name="piyushevents"><dir name="events"><file name="item.phtml" hash="99d34e3180ba7cc5b31109afd0193b32"/><file name="list.phtml" hash="27b3ea1a8d98b543d717181e97360313"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Piyush_Events.xml" hash="1300830cc50a3992aa4e2c7d176c74fa"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>5.5.5</max></php></required></dependencies>
18
+ </package>