MDWNewsAndTestimonialsExtension - Version 1.10

Version Notes

This extension adds new CMS content pages to Magento.
You can associate image, thumbnail and PDF file to every new content.

Download this release

Release Info

Developer Magento Core Team
Extension MDWNewsAndTestimonialsExtension
Version 1.10
Comparing to
See all releases


Version 1.10

Files changed (53) hide show
  1. app/code/community/RichardMason/Profile/Block/Adminhtml/Profile.php +25 -0
  2. app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit.php +92 -0
  3. app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit/Form.php +28 -0
  4. app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit/Tab/Main.php +219 -0
  5. app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit/Tab/Meta.php +119 -0
  6. app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit/Tabs.php +28 -0
  7. app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Grid.php +120 -0
  8. app/code/community/RichardMason/Profile/Block/Profile.php +69 -0
  9. app/code/community/RichardMason/Profile/Helper/Data.php +80 -0
  10. app/code/community/RichardMason/Profile/Model/Mysql4/Profile.php +179 -0
  11. app/code/community/RichardMason/Profile/Model/Mysql4/Profile/Collection.php +96 -0
  12. app/code/community/RichardMason/Profile/Model/Profile.php +184 -0
  13. app/code/community/RichardMason/Profile/Model/Status.php +22 -0
  14. app/code/community/RichardMason/Profile/controllers/Adminhtml/ProfileController.php +274 -0
  15. app/code/community/RichardMason/Profile/controllers/IndexController.php +12 -0
  16. app/code/community/RichardMason/Profile/controllers/NewsController.php +32 -0
  17. app/code/community/RichardMason/Profile/controllers/PressarticlesController.php +30 -0
  18. app/code/community/RichardMason/Profile/controllers/PressreleasesController.php +32 -0
  19. app/code/community/RichardMason/Profile/controllers/TestimonialsController.php +17 -0
  20. app/code/community/RichardMason/Profile/etc/config.xml +143 -0
  21. app/code/community/RichardMason/Profile/sql/profile_setup/mysql4-install-0.1.0.php +50 -0
  22. app/design/adminhtml/default/default/layout/profile.xml +71 -0
  23. app/design/frontend/default/default/layout/profile.xml +45 -0
  24. app/design/frontend/default/default/template/profile/news.phtml +36 -0
  25. app/design/frontend/default/default/template/profile/pressarticles.phtml +131 -0
  26. app/design/frontend/default/default/template/profile/pressreleases.phtml +37 -0
  27. app/design/frontend/default/default/template/profile/readnews.phtml +26 -0
  28. app/design/frontend/default/default/template/profile/readpressrelease.phtml +31 -0
  29. app/design/frontend/default/default/template/profile/testimonials.phtml +25 -0
  30. app/etc/modules/RichardMason_Profile.xml +9 -0
  31. media/profile_examples/a1.jpg +0 -0
  32. media/profile_examples/a2.jpg +0 -0
  33. media/profile_examples/a3.jpg +0 -0
  34. media/profile_examples/a4.jpg +0 -0
  35. media/profile_examples/a5.jpg +0 -0
  36. media/profile_examples/article1.jpg +0 -0
  37. media/profile_examples/article1pic.jpg +0 -0
  38. media/profile_examples/article2.jpg +0 -0
  39. media/profile_examples/article2pic.jpg +0 -0
  40. media/profile_examples/article3.jpg +0 -0
  41. media/profile_examples/article3pic.jpg +0 -0
  42. media/profile_examples/article4.jpg +0 -0
  43. media/profile_examples/article4pic.jpg +0 -0
  44. media/profile_examples/press1.pdf +0 -0
  45. media/profile_examples/press2.pdf +0 -0
  46. media/profile_examples/press3.pdf +0 -0
  47. media/profile_examples/resized_a1.jpg +0 -0
  48. media/profile_examples/resized_a2.jpg +0 -0
  49. media/profile_examples/resized_a3.jpg +0 -0
  50. media/profile_examples/resized_a4.jpg +0 -0
  51. media/profile_examples/resized_a5.jpg +0 -0
  52. package.xml +23 -0
  53. skin/frontend/default/default/js/modalbox/modalbox.js +515 -0
app/code/community/RichardMason/Profile/Block/Adminhtml/Profile.php ADDED
@@ -0,0 +1,25 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_Block_Adminhtml_Profile extends Mage_Adminhtml_Block_Widget_Grid_Container
11
+ {
12
+ public function __construct()
13
+ {
14
+ $this->_controller = 'adminhtml_profile';
15
+ $this->_blockGroup = 'profile';
16
+
17
+ $this->_headerText = Mage::helper('profile')->getText(Mage::registry('profile_category_id'), '_headerText');
18
+ parent::__construct();
19
+ parent::_addButton('add', array(
20
+ 'label' => Mage::helper('profile')->getText(Mage::registry('profile_category_id'), 'New'),
21
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/edit', array('category_id' => Mage::registry('profile_category_id'))).'\')',
22
+ 'class' => 'add',
23
+ ));
24
+ }
25
+ }
app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit.php ADDED
@@ -0,0 +1,92 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Block_Adminhtml_Profile_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
19
+ {
20
+ public function __construct()
21
+ {
22
+ $this->_objectId = 'profile_id';
23
+ $this->_blockGroup = 'profile';
24
+ $this->_controller = 'adminhtml_profile';
25
+
26
+ parent::__construct();
27
+
28
+ $url=Mage::registry('profile_profile')->getCategoryUrl(Mage::registry('profile_profile')->getData("category_id"));
29
+ parent::addButton('back', array(
30
+ 'label' => Mage::helper('adminhtml')->__('Back'),
31
+ 'onclick' => 'setLocation(\'' . $this->getUrl("*/*/".$url."/") . '\')',
32
+ 'class' => 'back',
33
+ ), -1);
34
+
35
+ if ($this->_isAllowedAction('save')) {
36
+ $this->_updateButton('save', 'label', Mage::helper('profile')->__('Save'));
37
+ $this->_addButton('saveandcontinue', array(
38
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
39
+ 'onclick' => 'saveAndContinueEdit()',
40
+ 'class' => 'save',
41
+ ), -100);
42
+ } else {
43
+ $this->_removeButton('save');
44
+ }
45
+
46
+ if ($this->_isAllowedAction('delete')) {
47
+ $this->_updateButton('delete', 'label', Mage::helper('profile')->__('Delete'));
48
+ } else {
49
+ $this->_removeButton('delete');
50
+ }
51
+
52
+ $this->_formScripts[] = "
53
+ function toggleEditor() {
54
+ if (tinyMCE.getInstanceById('page_content') == null) {
55
+ tinyMCE.execCommand('mceAddControl', false, 'content');
56
+ } else {
57
+ tinyMCE.execCommand('mceRemoveControl', false, 'content');
58
+ }
59
+ }
60
+
61
+ function saveAndContinueEdit(){
62
+ editForm.submit($('edit_form').action+'back/edit/');
63
+ }
64
+ ";
65
+ }
66
+
67
+ /**
68
+ * Retrieve text for header element depending on loaded page
69
+ *
70
+ * @return string
71
+ */
72
+ public function getHeaderText()
73
+ {
74
+ if (Mage::registry('profile_profile')->getId()) {
75
+ return Mage::helper('profile')->__("Edit '%s'", $this->htmlEscape(Mage::registry('profile_profile')->getData("content_heading")));
76
+ }
77
+ else {
78
+ return Mage::helper('profile')->getText(Mage::registry('profile_profile')->getData("category_id"), 'New');
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Check permission for passed action
84
+ *
85
+ * @param string $action
86
+ * @return bool
87
+ */
88
+ protected function _isAllowedAction($action)
89
+ {
90
+ return Mage::getSingleton('admin/session')->isAllowed('profile/' . $action);
91
+ }
92
+ }
app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit/Form.php ADDED
@@ -0,0 +1,28 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Block_Adminhtml_Profile_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+ protected function _prepareForm()
21
+ {
22
+ $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data'));
23
+ $form->setUseContainer(true);
24
+ $this->setForm($form);
25
+ return parent::_prepareForm();
26
+ }
27
+
28
+ }
app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit/Tab/Main.php ADDED
@@ -0,0 +1,219 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Block_Adminhtml_Profile_Edit_Tab_Main
19
+ extends Mage_Adminhtml_Block_Widget_Form
20
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
21
+ {
22
+
23
+ /**
24
+ * Load Wysiwyg on demand and Prepare layout
25
+ */
26
+ protected function _prepareLayout()
27
+ {
28
+ parent::_prepareLayout();
29
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
30
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
31
+ }
32
+ }
33
+
34
+ protected function _prepareForm()
35
+ {
36
+ /* @var $model Mage_Cms_Model_Page */
37
+ $model = Mage::registry('profile_profile');
38
+
39
+ /*
40
+ * Checking if user have permissions to save information
41
+ */
42
+ if ($this->_isAllowedAction('save')) {
43
+ $isElementDisabled = false;
44
+ } else {
45
+ $isElementDisabled = true;
46
+ }
47
+
48
+
49
+ $form = new Varien_Data_Form();
50
+
51
+ $form->setHtmlIdPrefix('profile_');
52
+
53
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('profile')->__('Content')));
54
+
55
+ //profile_id
56
+ if ($model->getProfileId()) {
57
+ $fieldset->addField('profile_id', 'hidden', array(
58
+ 'name' => 'profile_id',
59
+ ));
60
+ }
61
+ //category_id
62
+ $fieldset->addField('category_id', 'hidden', array(
63
+ 'name' => 'category_id',
64
+ ));
65
+ //head of content
66
+ $fieldset->addField('content_heading', 'text', array(
67
+ 'name' => 'content_heading',
68
+ 'label' => Mage::helper('profile')->getText($model->getData("category_id"),'content_heading'),
69
+ 'title' => Mage::helper('profile')->getText($model->getData("category_id"),'content_heading'),
70
+ 'disabled' => $isElementDisabled
71
+ ));
72
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
73
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
74
+ );
75
+ $fieldset->addField('creation_time', 'date', array(
76
+ 'name' => 'creation_time',
77
+ 'label' => Mage::helper('profile')->__('Date'),
78
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
79
+ 'format' => $dateFormatIso
80
+ ));
81
+
82
+ if($model->getData("category_id") != RichardMason_Profile_Model_Profile::CATEGORY_TESTIMONIALS) {
83
+ $fieldset->addField('thumbnail', 'image', array(
84
+ 'label' => Mage::helper('profile')->__('Thumbnail (Max. 90x90px)'),
85
+ 'required' => false,
86
+ 'name' => 'thumbnail',
87
+ ));
88
+
89
+ $fieldset->addField('thumbnail_position', 'select', array(
90
+ 'label' => Mage::helper('profile')->__('Thumbnail Position'),
91
+ 'title' => Mage::helper('profile')->__('Thumbnail Position'),
92
+ 'name' => 'thumbnail_position',
93
+ 'required' => true,
94
+ 'options' => $model->getAvailableThumbnailPositions()
95
+ ));
96
+ }
97
+
98
+ if($model->getData("category_id") == RichardMason_Profile_Model_Profile::CATEGORY_ARTICLES) {
99
+ $fieldset->addField('picture', 'image', array(
100
+ 'label' => Mage::helper('profile')->__('Picture'),
101
+ 'required' => false,
102
+ 'name' => 'picture',
103
+ ));
104
+ }
105
+
106
+ if($model->getData("category_id") == RichardMason_Profile_Model_Profile::CATEGORY_RELEASES) {
107
+ $fieldset->addField('file', 'image', array(
108
+ 'label' => Mage::helper('profile')->__('PDF File'),
109
+ 'required' => false,
110
+ 'name' => 'file',
111
+ ));
112
+ }
113
+
114
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(
115
+ array('tab_id' => $this->getTabId())
116
+ );
117
+ $contentField = $fieldset->addField('content', 'editor', array(
118
+ 'name' => 'content',
119
+ 'style' => 'height:20em; width:50em;',
120
+ 'required' => true,
121
+ 'disabled' => $isElementDisabled,
122
+ 'config' => $wysiwygConfig
123
+ ));
124
+ // Setting custom renderer for content field to remove label column
125
+ $renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')
126
+ ->setTemplate('cms/page/edit/form/renderer/content.phtml');
127
+ $contentField->setRenderer($renderer);
128
+
129
+ /**
130
+ * Check is single store mode
131
+ */
132
+ if (!Mage::app()->isSingleStoreMode()) {
133
+ $fieldset->addField('store_id', 'multiselect', array(
134
+ 'name' => 'stores[]',
135
+ 'label' => Mage::helper('cms')->__('Store View'),
136
+ 'title' => Mage::helper('cms')->__('Store View'),
137
+ 'required' => true,
138
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
139
+ 'disabled' => $isElementDisabled
140
+ ));
141
+ }
142
+ else {
143
+ $fieldset->addField('store_id', 'hidden', array(
144
+ 'name' => 'stores[]',
145
+ 'value' => Mage::app()->getStore(true)->getId()
146
+ ));
147
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
148
+ }
149
+
150
+ $fieldset->addField('is_active', 'select', array(
151
+ 'label' => Mage::helper('profile')->__('Status'),
152
+ 'title' => Mage::helper('profile')->__('Status'),
153
+ 'name' => 'is_active',
154
+ 'required' => true,
155
+ 'options' => $model->getAvailableStatuses(),
156
+ 'disabled' => $isElementDisabled,
157
+ ));
158
+ if (!$model->getId()) {
159
+ $model->setData('is_active', $isElementDisabled ? '0' : '1');
160
+ }
161
+
162
+ Mage::dispatchEvent('adminhtml_profile_edit_tab_main_prepare_form', array('form' => $form));
163
+ $form->setValues($model->getData());
164
+ $this->setForm($form);
165
+
166
+ return parent::_prepareForm();
167
+ }
168
+
169
+ /**
170
+ * Prepare label for tab
171
+ *
172
+ * @return string
173
+ */
174
+ public function getTabLabel()
175
+ {
176
+ return Mage::helper('profile')->__('Content');
177
+ }
178
+
179
+ /**
180
+ * Prepare title for tab
181
+ *
182
+ * @return string
183
+ */
184
+ public function getTabTitle()
185
+ {
186
+ return Mage::helper('profile')->__('Content');
187
+ }
188
+
189
+ /**
190
+ * Returns status flag about this tab can be shown or not
191
+ *
192
+ * @return true
193
+ */
194
+ public function canShowTab()
195
+ {
196
+ return true;
197
+ }
198
+
199
+ /**
200
+ * Returns status flag about this tab hidden or not
201
+ *
202
+ * @return true
203
+ */
204
+ public function isHidden()
205
+ {
206
+ return false;
207
+ }
208
+
209
+ /**
210
+ * Check permission for passed action
211
+ *
212
+ * @param string $action
213
+ * @return bool
214
+ */
215
+ protected function _isAllowedAction($action)
216
+ {
217
+ return Mage::getSingleton('admin/session')->isAllowed('profile/' . $action);
218
+ }
219
+ }
app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit/Tab/Meta.php ADDED
@@ -0,0 +1,119 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Block_Adminhtml_Profile_Edit_Tab_Meta
19
+ extends Mage_Adminhtml_Block_Widget_Form
20
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
21
+ {
22
+ public function __construct()
23
+ {
24
+ parent::__construct();
25
+ }
26
+
27
+ protected function _prepareForm()
28
+ {
29
+ /*
30
+ * Checking if user have permissions to save information
31
+ */
32
+ if ($this->_isAllowedAction('save')) {
33
+ $isElementDisabled = false;
34
+ } else {
35
+ $isElementDisabled = true;
36
+ }
37
+
38
+ $form = new Varien_Data_Form();
39
+
40
+ $form->setHtmlIdPrefix('page_');
41
+
42
+ $model = Mage::registry('profile_profile');
43
+
44
+ $fieldset = $form->addFieldset('meta_fieldset', array('legend' => Mage::helper('profile')->__('Meta Data'), 'class' => 'fieldset-wide'));
45
+
46
+ $fieldset->addField('meta_keywords', 'textarea', array(
47
+ 'name' => 'meta_keywords',
48
+ 'label' => Mage::helper('profile')->__('Keywords'),
49
+ 'title' => Mage::helper('profile')->__('Meta Keywords'),
50
+ 'disabled' => $isElementDisabled
51
+ ));
52
+
53
+ $fieldset->addField('meta_description', 'textarea', array(
54
+ 'name' => 'meta_description',
55
+ 'label' => Mage::helper('profile')->__('Description'),
56
+ 'title' => Mage::helper('profile')->__('Meta Description'),
57
+ 'disabled' => $isElementDisabled
58
+ ));
59
+
60
+ Mage::dispatchEvent('adminhtml_profile_edit_tab_meta_prepare_form', array('form' => $form));
61
+
62
+ $form->setValues($model->getData());
63
+
64
+ $this->setForm($form);
65
+
66
+ return parent::_prepareForm();
67
+ }
68
+
69
+ /**
70
+ * Prepare label for tab
71
+ *
72
+ * @return string
73
+ */
74
+ public function getTabLabel()
75
+ {
76
+ return Mage::helper('profile')->__('Meta Data');
77
+ }
78
+
79
+ /**
80
+ * Prepare title for tab
81
+ *
82
+ * @return string
83
+ */
84
+ public function getTabTitle()
85
+ {
86
+ return Mage::helper('profile')->__('Meta Data');
87
+ }
88
+
89
+ /**
90
+ * Returns status flag about this tab can be showen or not
91
+ *
92
+ * @return true
93
+ */
94
+ public function canShowTab()
95
+ {
96
+ return true;
97
+ }
98
+
99
+ /**
100
+ * Returns status flag about this tab hidden or not
101
+ *
102
+ * @return true
103
+ */
104
+ public function isHidden()
105
+ {
106
+ return false;
107
+ }
108
+
109
+ /**
110
+ * Check permission for passed action
111
+ *
112
+ * @param string $action
113
+ * @return bool
114
+ */
115
+ protected function _isAllowedAction($action)
116
+ {
117
+ return Mage::getSingleton('admin/session')->isAllowed('profile/' . $action);
118
+ }
119
+ }
app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Edit/Tabs.php ADDED
@@ -0,0 +1,28 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Block_Adminhtml_Profile_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
19
+ {
20
+ public function __construct()
21
+ {
22
+ parent::__construct();
23
+ $this->setId('profiles_tabs');
24
+ $this->setDestElementId('edit_form');
25
+ $this->setTitle(Mage::helper('profile')->__('Information'));
26
+ }
27
+
28
+ }
app/code/community/RichardMason/Profile/Block/Adminhtml/Profile/Grid.php ADDED
@@ -0,0 +1,120 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Block_Adminhtml_Profile_Grid extends Mage_Adminhtml_Block_Widget_Grid
19
+ {
20
+ public function __construct()
21
+ {
22
+ parent::__construct();
23
+ $this->setId('profileBlockGrid');
24
+ $this->setDefaultSort('profile_id');
25
+ $this->setDefaultDir('ASC');
26
+ }
27
+
28
+ protected function _prepareCollection()
29
+ {
30
+ $collection = Mage::getModel('profile/profile')->getCollection();
31
+ $collection->addFieldToFilter('category_id', Mage::registry('profile_category_id'));
32
+ /* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
33
+ $this->setCollection($collection);
34
+ return parent::_prepareCollection();
35
+ }
36
+
37
+ protected function _prepareColumns()
38
+ {
39
+ $baseUrl = $this->getUrl();
40
+
41
+ $this->addColumn('content_heading', array(
42
+ 'header' => Mage::helper('profile')->getText(Mage::registry('profile_category_id'),'content_heading'),
43
+ 'align' => 'left',
44
+ 'index' => 'content_heading'
45
+ ));
46
+
47
+ /*
48
+ if(Mage::registry('profile_category_id') != RichardMason_Profile_Model_Profile::CATEGORY_RELEASES) {
49
+ $this->addColumn('content', array(
50
+ 'header' => Mage::helper('profile')->getText(Mage::registry('profile_category_id'),'content'),
51
+ 'align' => 'left',
52
+ 'index' => 'content'
53
+ ));
54
+ }
55
+ */
56
+
57
+ if (!Mage::app()->isSingleStoreMode()) {
58
+ $this->addColumn('store_id', array(
59
+ 'header' => Mage::helper('profile')->__('Store View'),
60
+ 'index' => 'store_id',
61
+ 'type' => 'store',
62
+ 'store_all' => true,
63
+ 'store_view' => true,
64
+ 'sortable' => false,
65
+ 'filter_condition_callback'
66
+ => array($this, '_filterStoreCondition'),
67
+ ));
68
+ }
69
+
70
+ $this->addColumn('is_active', array(
71
+ 'header' => Mage::helper('profile')->__('Status'),
72
+ 'index' => 'is_active',
73
+ 'type' => 'options',
74
+ 'options' => array(
75
+ 0 => Mage::helper('profile')->__('Disabled'),
76
+ 1 => Mage::helper('profile')->__('Enabled')
77
+ ),
78
+ ));
79
+
80
+ $this->addColumn('creation_time', array(
81
+ 'header' => Mage::helper('profile')->__('Date Created'),
82
+ 'index' => 'creation_time',
83
+ 'type' => 'datetime',
84
+ ));
85
+
86
+ $this->addColumn('update_time', array(
87
+ 'header' => Mage::helper('profile')->__('Last Modified'),
88
+ 'index' => 'update_time',
89
+ 'type' => 'datetime',
90
+ ));
91
+
92
+ return parent::_prepareColumns();
93
+ }
94
+
95
+ protected function _afterLoadCollection()
96
+ {
97
+ $this->getCollection()->walk('afterLoad');
98
+ parent::_afterLoadCollection();
99
+ }
100
+
101
+ protected function _filterStoreCondition($collection, $column)
102
+ {
103
+ if (!$value = $column->getFilter()->getValue()) {
104
+ return;
105
+ }
106
+
107
+ $this->getCollection()->addStoreFilter($value);
108
+ }
109
+
110
+ /**
111
+ * Row click url
112
+ *
113
+ * @return string
114
+ */
115
+ public function getRowUrl($row)
116
+ {
117
+ return $this->getUrl('*/*/edit', array('profile_id' => $row->getId(), 'category_id' => Mage::registry('profile_category_id') ));
118
+ }
119
+
120
+ }
app/code/community/RichardMason/Profile/Block/Profile.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Block_Profile extends Mage_Core_Block_Template
19
+ {
20
+ public function _prepareLayout(){
21
+ return parent::_prepareLayout();
22
+ }
23
+
24
+ public function getNews(){
25
+ return $this->getProfiles(RichardMason_Profile_Model_Profile::CATEGORY_NEWS);
26
+ }
27
+
28
+ public function getTestimonials(){
29
+ return $this->getProfiles(RichardMason_Profile_Model_Profile::CATEGORY_TESTIMONIALS);
30
+ }
31
+
32
+ public function getPressarticles(){
33
+ return $this->getProfiles(RichardMason_Profile_Model_Profile::CATEGORY_ARTICLES);
34
+ }
35
+
36
+ public function getPressreleases(){
37
+ return $this->getProfiles(RichardMason_Profile_Model_Profile::CATEGORY_RELEASES);
38
+ }
39
+
40
+ /*
41
+ * Return a collection of profiles.
42
+ * @param category_id is the category of profile.
43
+ * @return Collection of Profile Model
44
+ */
45
+ public function getProfiles($category_id) {
46
+ $profiles = Mage::getModel('profile/profile')->getCollection()
47
+ ->addStoreFilter(Mage::app()->getStore()->getId());
48
+ $profiles->addFieldToFilter('category_id', $category_id);
49
+ $profiles->setOrder("creation_time", "DESC");
50
+ return $profiles;
51
+ }
52
+
53
+ /*
54
+ * Return a specific profile.
55
+ * @param GET or POST "id"
56
+ * @return Profile model class
57
+ */
58
+ public function getProfile(){
59
+ if($profile_id = $this->getRequest()->getParam('id')){
60
+ if($profile_id != null && $profile_id != ''){
61
+ $profile = Mage::getModel('profile/profile')->load($profile_id);
62
+ } else {
63
+ $profile = null;
64
+ }
65
+ $this->setData('profile', $profile);
66
+ }
67
+ return $this->getData('profile');
68
+ }
69
+ }
app/code/community/RichardMason/Profile/Helper/Data.php ADDED
@@ -0,0 +1,80 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+
13
+ public function getText($category_id, $text){
14
+ switch ($text) {
15
+ case "New":
16
+ switch ($category_id) {
17
+ case 0:
18
+ return $this->__('Add a News Article');
19
+ case 1:
20
+ return $this->__('Add a Testimonial');
21
+ case 2:
22
+ return $this->__('Add a Press Release');
23
+ case 3:
24
+ return $this->__('Add a Press Article');
25
+
26
+ }
27
+ break;
28
+ case "_headerText":
29
+ switch ($category_id) {
30
+ case 0:
31
+ return $this->__('News Manager');
32
+ case 1:
33
+ return $this->__('Testimonials Manager');
34
+ case 2:
35
+ return $this->__('Press Releases Manager');
36
+ case 3:
37
+ return $this->__('Press Articles Manager');
38
+
39
+ }
40
+ break;
41
+ case "content_heading":
42
+ switch ($category_id) {
43
+ case 0:
44
+ return $this->__('Heading');
45
+ case 1:
46
+ return $this->__('Name');
47
+ case 2:
48
+ return $this->__('Title');
49
+ case 3:
50
+ return $this->__('Title');
51
+
52
+ }
53
+ break;
54
+ case "content":
55
+ switch ($category_id) {
56
+ case 0:
57
+ return $this->__('Content');
58
+ case 1:
59
+ return $this->__('Quote');
60
+ case 2:
61
+ return $this->__('Quote');
62
+ case 3:
63
+ return $this->__('Quote');
64
+
65
+ }
66
+ break;
67
+ case "thumbnail":
68
+ switch ($category_id) {
69
+ case 0:
70
+ return $this->__('Thumbnail (Max. 90x90px)');
71
+ case 1:
72
+ case 2:
73
+ case 3:
74
+ return $this->__('Thumbnail (Max. 100x130px)');
75
+
76
+ }
77
+ break;
78
+ }
79
+ }
80
+ }
app/code/community/RichardMason/Profile/Model/Mysql4/Profile.php ADDED
@@ -0,0 +1,179 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Model_Mysql4_Profile extends Mage_Core_Model_Mysql4_Abstract
19
+ {
20
+
21
+ /**
22
+ * Store model
23
+ *
24
+ * @var null|Mage_Core_Model_Store
25
+ */
26
+ protected $_store = null;
27
+
28
+
29
+ public function _construct()
30
+ {
31
+ // Note that the profiles_id refers to the key field in your database table.
32
+ $this->_init('profile/profile', 'profile_id');
33
+ }
34
+
35
+ /**
36
+ * Process page data before saving
37
+ *
38
+ * @param Mage_Core_Model_Abstract $object
39
+ */
40
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
41
+ {
42
+
43
+ if (! $object->getId() && $object->getCreationTime() == "") {
44
+ $object->setCreationTime(Mage::getSingleton('core/date')->gmtDate());
45
+ }
46
+
47
+ $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
48
+ if ($date = $object->getData('creation_time')) {
49
+ $object->setData('creation_time', Mage::app()->getLocale()->date($date, $format, null, false)
50
+ ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
51
+ );
52
+ }
53
+ $object->setUpdateTime(Mage::getSingleton('core/date')->gmtDate());
54
+
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ *
60
+ * @param Mage_Core_Model_Abstract $object
61
+ */
62
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
63
+ {
64
+ $select = $this->_getReadAdapter()->select()
65
+ ->from($this->getTable('profile/profile_store'))
66
+ ->where('profile_id = ?', $object->getId());
67
+
68
+ if ($data = $this->_getReadAdapter()->fetchAll($select)) {
69
+ $storesArray = array();
70
+ foreach ($data as $row) {
71
+ $storesArray[] = $row['store_id'];
72
+ }
73
+ $object->setData('store_id', $storesArray);
74
+ }
75
+
76
+ return parent::_afterLoad($object);
77
+ }
78
+
79
+ /**
80
+ * Assign page to store views
81
+ *
82
+ * @param Mage_Core_Model_Abstract $object
83
+ */
84
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
85
+ {
86
+ $condition = $this->_getWriteAdapter()->quoteInto('profile_id = ?', $object->getId());
87
+ $this->_getWriteAdapter()->delete($this->getTable('profile/profile_store'), $condition);
88
+
89
+ foreach ((array)$object->getData('stores') as $store) {
90
+ $storeArray = array();
91
+ $storeArray['profile_id'] = $object->getId();
92
+ $storeArray['store_id'] = $store;
93
+ $this->_getWriteAdapter()->insert($this->getTable('profile/profile_store'), $storeArray);
94
+ }
95
+
96
+ return parent::_afterSave($object);
97
+ }
98
+
99
+ /**
100
+ * Retrieve select object for load object data
101
+ *
102
+ * @param string $field
103
+ * @param mixed $value
104
+ * @return Zend_Db_Select
105
+ */
106
+ protected function _getLoadSelect($field, $value, $object)
107
+ {
108
+ $select = parent::_getLoadSelect($field, $value, $object);
109
+
110
+ if ($object->getStoreId()) {
111
+ $select->join(
112
+ array('cps' => $this->getTable('profile/profile_store')),
113
+ $this->getMainTable().'.profile_id = `cps`.profile_id'
114
+ )
115
+ ->where('is_active=1 AND `cps`.store_id in (' . Mage_Core_Model_App::ADMIN_STORE_ID . ', ?) ', $object->getStoreId())
116
+ ->order('store_id DESC')
117
+ ->limit(1);
118
+ }
119
+ return $select;
120
+ }
121
+
122
+ /**
123
+ * Check if page identifier exist for specific store
124
+ * return page id if page exists
125
+ *
126
+ * @param string $identifier
127
+ * @param int $storeId
128
+ * @return int
129
+ */
130
+ public function checkIdentifier($profile_id, $storeId)
131
+ {
132
+ $select = $this->_getReadAdapter()->select()->from(array('main_table'=>$this->getMainTable()), 'profile_id')
133
+ ->join(
134
+ array('cps' => $this->getTable('profile/profile_store')),
135
+ 'main_table.profile_id = `cps`.profile_id'
136
+ )
137
+ ->where('main_table.profile_id=?', $profile_id)
138
+ ->where('main_table.is_active=1 AND `cps`.store_id in (' . Mage_Core_Model_App::ADMIN_STORE_ID . ', ?) ', $storeId)
139
+ ->order('store_id DESC');
140
+
141
+ return $this->_getReadAdapter()->fetchOne($select);
142
+ }
143
+
144
+ /**
145
+ * Get store ids to which specified item is assigned
146
+ *
147
+ * @param int $id
148
+ * @return array
149
+ */
150
+ public function lookupStoreIds($id)
151
+ {
152
+ return $this->_getReadAdapter()->fetchCol($this->_getReadAdapter()->select()
153
+ ->from($this->getTable('profile/profile_store'), 'store_id')
154
+ ->where("{$this->getIdFieldName()} = ?", $id)
155
+ );
156
+ }
157
+
158
+ /**
159
+ * Set store model
160
+ *
161
+ * @param Mage_Core_Model_Store $store
162
+ * @return Mage_Cms_Model_Mysql4_Page
163
+ */
164
+ public function setStore($store)
165
+ {
166
+ $this->_store = $store;
167
+ return $this;
168
+ }
169
+
170
+ /**
171
+ * Retrieve store model
172
+ *
173
+ * @return Mage_Core_Model_Store
174
+ */
175
+ public function getStore()
176
+ {
177
+ return Mage::app()->getStore($this->_store);
178
+ }
179
+ }
app/code/community/RichardMason/Profile/Model/Mysql4/Profile/Collection.php ADDED
@@ -0,0 +1,96 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Model_Mysql4_Profile_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
19
+ {
20
+
21
+ protected $_previewFlag;
22
+
23
+ public function _construct()
24
+ {
25
+ parent::_construct();
26
+ $this->_init('profile/profile');
27
+
28
+ $this->_map['fields']['profile_id'] = 'main_table.profile_id';
29
+ }
30
+
31
+ public function setFirstStoreFlag($flag = false)
32
+ {
33
+ $this->_previewFlag = $flag;
34
+ return $this;
35
+ }
36
+
37
+ protected function _afterLoad()
38
+ {
39
+ if ($this->_previewFlag) {
40
+ $items = $this->getColumnValues('profile_id');
41
+ if (count($items)) {
42
+ $select = $this->getConnection()->select()
43
+ ->from($this->getTable('profile/profile_store'))
44
+ ->where($this->getTable('profile/profile_store').'.profile_id IN (?)', $items);
45
+ if ($result = $this->getConnection()->fetchPairs($select)) {
46
+ foreach ($this as $item) {
47
+ if (!isset($result[$item->getData('profile_id')])) {
48
+ continue;
49
+ }
50
+ if ($result[$item->getData('profile_id')] == 0) {
51
+ $stores = Mage::app()->getStores(false, true);
52
+ $storeId = current($stores)->getId();
53
+ $storeCode = key($stores);
54
+ } else {
55
+ $storeId = $result[$item->getData('profile_id')];
56
+ $storeCode = Mage::app()->getStore($storeId)->getCode();
57
+ }
58
+ $item->setData('_first_store_id', $storeId);
59
+ $item->setData('store_code', $storeCode);
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ parent::_afterLoad();
66
+ }
67
+
68
+
69
+ /**
70
+ * Add Filter by store
71
+ *
72
+ * @param int|Mage_Core_Model_Store $store
73
+ * @return Mage_Cms_Model_Mysql4_Page_Collection
74
+ */
75
+ public function addStoreFilter($store, $withAdmin = true)
76
+ {
77
+ if (!$this->getFlag('store_filter_added')) {
78
+ if ($store instanceof Mage_Core_Model_Store) {
79
+ $store = array($store->getId());
80
+ }
81
+
82
+ $this->getSelect()->join(
83
+ array('store_table' => $this->getTable('profile/profile_store')),
84
+ 'main_table.profile_id = store_table.profile_id',
85
+ array()
86
+ )
87
+ ->where('store_table.store_id in (?)', ($withAdmin ? array(0, $store) : $store))
88
+ ->group('main_table.profile_id');
89
+
90
+ $this->setFlag('store_filter_added', true);
91
+ }
92
+
93
+ return $this;
94
+ }
95
+
96
+ }
app/code/community/RichardMason/Profile/Model/Profile.php ADDED
@@ -0,0 +1,184 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_Model_Profile extends Mage_Core_Model_Abstract
11
+ {
12
+ /**
13
+ * Profile's Statuses
14
+ */
15
+ const STATUS_ENABLED = 1;
16
+ const STATUS_DISABLED = 0;
17
+
18
+ /**
19
+ * Thumbnail's positions
20
+ */
21
+ const THUMBNAIL_LEFT = 0;
22
+ const THUMBNAIL_RIGHT = 1;
23
+
24
+ /**
25
+ * Profile's Categories
26
+ */
27
+ const CATEGORY_NEWS = 0;
28
+ const CATEGORY_TESTIMONIALS = 1;
29
+ const CATEGORY_RELEASES = 2;
30
+ const CATEGORY_ARTICLES = 3;
31
+
32
+ public function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->_init('profile/profile');
36
+ }
37
+
38
+
39
+ /**
40
+ * Prepare profile thumbnail positions.
41
+ *
42
+ * @return array
43
+ */
44
+ public function getAvailableThumbnailPositions()
45
+ {
46
+ $statuses = new Varien_Object(array(
47
+ self::THUMBNAIL_LEFT => Mage::helper('profile')->__('Left'),
48
+ self::THUMBNAIL_RIGHT => Mage::helper('profile')->__('Right'),
49
+ ));
50
+
51
+ Mage::dispatchEvent('profile_get_available_statuses', array('statuses' => $statuses));
52
+
53
+ return $statuses->getData();
54
+ }
55
+
56
+
57
+ /**
58
+ * Prepare profile's statuses.
59
+ * Available event cms_page_get_available_statuses to customize statuses.
60
+ *
61
+ * @return array
62
+ */
63
+ public function getAvailableStatuses()
64
+ {
65
+ $statuses = new Varien_Object(array(
66
+ self::STATUS_ENABLED => Mage::helper('profile')->__('Enabled'),
67
+ self::STATUS_DISABLED => Mage::helper('profile')->__('Disabled'),
68
+ ));
69
+
70
+ Mage::dispatchEvent('profile_get_available_statuses', array('statuses' => $statuses));
71
+
72
+ return $statuses->getData();
73
+ }
74
+
75
+ /**
76
+ * Get the align position of the Thumnail picture
77
+ */
78
+ public function getThumbnailAlign()
79
+ {
80
+ switch($this->getData("thumbnail_position")){
81
+ case self::THUMBNAIL_LEFT:
82
+ return "left";
83
+ case self::THUMBNAIL_RIGHT:
84
+ return "right";
85
+ }
86
+ return "";
87
+ }
88
+
89
+ /**
90
+ * Return the URL of the Thumbnail new image resized to the params.
91
+ *
92
+ * @param $with With of the resized image
93
+ * @param $height Height of the resized image (Default: null)
94
+ * @return the Url of the new resized image.
95
+ */
96
+ public function getThumbnailResize($with, $height = null) {
97
+ // actual path of image
98
+ $imageUrl = Mage::getBaseDir('media').DS.$this->getData("thumbnail");
99
+
100
+ // path of the resized image to be saved
101
+ // here, the resized image is saved in media/resized folder
102
+ $imageResized = Mage::getBaseDir('media').DS."resized_".$this->getData("thumbnail");
103
+
104
+ // resize image only if the image file exists and the resized image file doesn't exist
105
+ // the image is resized proportionally with the width/height 135px
106
+ if (!file_exists($imageResized)&&file_exists($imageUrl)) {
107
+ $imageObj = new Varien_Image($imageUrl);
108
+ $imageObj->constrainOnly(TRUE);
109
+ $imageObj->keepAspectRatio(TRUE);
110
+ $imageObj->keepFrame(FALSE);
111
+ $imageObj->resize($with, $height);
112
+ $imageObj->save($imageResized);
113
+ }
114
+ return (Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . "media/" . "resized_".$this->getData("thumbnail"));
115
+ }
116
+
117
+ /**
118
+ * Return the Url key for the category
119
+ *
120
+ * @param category_id
121
+ * @return string
122
+ */
123
+ public function getCategoryUrl($category_id)
124
+ {
125
+ $url="";
126
+
127
+ switch((int)$category_id){
128
+ case self::CATEGORY_NEWS:
129
+ $url = "news";
130
+ break;
131
+ case self::CATEGORY_TESTIMONIALS:
132
+ $url = "testimonials";
133
+ break;
134
+ case self::CATEGORY_RELEASES:
135
+ $url = "pressreleases";
136
+ break;
137
+ case self::CATEGORY_ARTICLES:
138
+ $url = "pressarticles";
139
+ break;
140
+ }
141
+
142
+ return($url);
143
+ }
144
+
145
+ /**
146
+ * Check if page identifier exist for specific store
147
+ * return page id if page exists
148
+ *
149
+ * @param int $profile_id
150
+ * @param int $storeId
151
+ * @return int
152
+ */
153
+ public function checkIdentifier($profile_id, $storeId)
154
+ {
155
+ return $this->_getResource()->checkIdentifier($profile_id, $storeId);
156
+ }
157
+
158
+
159
+ private function html_cut_text($text,$limit)
160
+ {
161
+ $max_code=8; // max for special code like &permil; &aacute; ...
162
+
163
+ if(($limit<>0)&&(strlen($text)>$limit))
164
+ {
165
+ $pos=strpos(substr($text,0,$limit+$max_code),';'); //find ;
166
+ if($pos) // cut when pass ;
167
+ $text=substr($text,0,$pos+1);
168
+ else //cut at limit
169
+ $text=substr($text,0,$limit);
170
+ return($text."...");
171
+ }
172
+ else
173
+ return($text); // return
174
+ }
175
+
176
+ public function getContent($limit = 0)
177
+ {
178
+ if($limit)
179
+ return $this->html_cut_text($this->getData("content"), $limit);
180
+ else
181
+ return ($this->getData("content"));
182
+
183
+ }
184
+ }
app/code/community/RichardMason/Profile/Model/Status.php ADDED
@@ -0,0 +1,22 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_Model_Status extends Varien_Object
11
+ {
12
+ const STATUS_ENABLED = 1;
13
+ const STATUS_DISABLED = 2;
14
+
15
+ static public function getOptionArray()
16
+ {
17
+ return array(
18
+ self::STATUS_ENABLED => Mage::helper('profile')->__('Enabled'),
19
+ self::STATUS_DISABLED => Mage::helper('profile')->__('Disabled')
20
+ );
21
+ }
22
+ }
app/code/community/RichardMason/Profile/controllers/Adminhtml/ProfileController.php ADDED
@@ -0,0 +1,274 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * Part of the code of this file was obtained from:
8
+ * -category Mage
9
+ * -package Mage_Adminhtml
10
+ * -copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
11
+ * -license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
12
+ *
13
+ * @category RichardMason
14
+ * @package RichardMason_Profile
15
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class RichardMason_Profile_Adminhtml_ProfileController extends Mage_Adminhtml_Controller_action
19
+ {
20
+
21
+ protected function _initAction() {
22
+ $this->loadLayout()
23
+ ->_setActiveMenu('profile/items')
24
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Profiles Manager'), Mage::helper('adminhtml')->__('Profile Manager'));
25
+
26
+ return $this;
27
+ }
28
+
29
+ /*
30
+ * News Index
31
+ */
32
+ public function newsAction(){
33
+ Mage::register('profile_category_id', RichardMason_Profile_Model_Profile::CATEGORY_NEWS);
34
+ $this->_initAction()
35
+ ->renderLayout();
36
+ }
37
+ /*
38
+ * Testimonials Index
39
+ */
40
+ public function testimonialsAction(){
41
+ Mage::register('profile_category_id', RichardMason_Profile_Model_Profile::CATEGORY_TESTIMONIALS);
42
+ $this->_initAction()
43
+ ->renderLayout();
44
+ }
45
+ /*
46
+ * Press Releases Index
47
+ */
48
+ public function pressreleasesAction(){
49
+ Mage::register('profile_category_id', RichardMason_Profile_Model_Profile::CATEGORY_RELEASES);
50
+ $this->_initAction()
51
+ ->renderLayout();
52
+ }
53
+ /*
54
+ * Press Articles Index
55
+ */
56
+ public function pressarticlesAction(){
57
+ Mage::register('profile_category_id', RichardMason_Profile_Model_Profile::CATEGORY_ARTICLES);
58
+ $this->_initAction()
59
+ ->renderLayout();
60
+ }
61
+
62
+ /**
63
+ * Edit CMS page
64
+ */
65
+ public function editAction()
66
+ {
67
+ // 1. Get ID and create model
68
+ $id = $this->getRequest()->getParam('profile_id');
69
+ $model = Mage::getModel('profile/profile');
70
+
71
+ // 2. Initial checking
72
+ if ($id) {
73
+ $model->load($id);
74
+ if (! $model->getId()) {
75
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('profile')->__('This profile no longer exists'));
76
+ $this->_redirect('*/*/');
77
+ return;
78
+ }
79
+ }
80
+
81
+ // 3. Set entered data if was error when we do save
82
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
83
+ if (! empty($data)) {
84
+ $model->setData($data);
85
+ }
86
+ if($this->getRequest()->getParam('category_id'))
87
+ $model->setData("category_id", $this->getRequest()->getParam('category_id'));
88
+
89
+ // 4. Register model to use later in blocks
90
+ Mage::register('profile_profile', $model);
91
+
92
+ // 5. Build edit form
93
+ $this->_initAction()
94
+ ->_addBreadcrumb(Mage::helper('profile')->__('CMS'), Mage::helper('profile')->__('CMS'))
95
+ ->_addContent($this->getLayout()->createBlock('profile/adminhtml_profile_edit'))
96
+ ->_addLeft($this->getLayout()->createBlock('profile/adminhtml_profile_edit_tabs'));
97
+
98
+ $this->renderLayout();
99
+ }
100
+
101
+ /**
102
+ * Save action
103
+ */
104
+ public function saveAction()
105
+ {
106
+ // check if data sent
107
+ if ($data = $this->getRequest()->getPost()) {
108
+ //thumbnail file
109
+ if(isset($_FILES['thumbnail']['name']) && $_FILES['thumbnail']['name'] != '') {
110
+ try {
111
+ /* Starting upload */
112
+ $uploader = new Varien_File_Uploader('thumbnail');
113
+ // Any extention would work
114
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
115
+ $uploader->setAllowRenameFiles(false);
116
+ $uploader->setFilesDispersion(false);
117
+ // We set media as the upload dir
118
+ $path = Mage::getBaseDir('media') . DS ;
119
+ $uploader->save($path, $_FILES['thumbnail']['name'] );
120
+ } catch (Exception $e) {
121
+ $this->_getSession()->addException($e, Mage::helper('profile')->__('Error uploading image. Please try again later.'));
122
+ }
123
+ $data['thumbnail'] = $_FILES['thumbnail']['name'];
124
+ }
125
+ else
126
+ {
127
+ if(isset($data['thumbnail']['delete']) && $data['thumbnail']['delete'] == 1)
128
+ $data["thumbnail"]="";
129
+ else
130
+ unset($data["thumbnail"]);
131
+ }
132
+ //file pdf,...
133
+ if(isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') {
134
+ try {
135
+ $uploader = new Varien_File_Uploader('file');
136
+ // Any extention would work
137
+ $uploader->setAllowedExtensions(array('pdf'));
138
+ $uploader->setAllowRenameFiles(false);
139
+ $uploader->setFilesDispersion(false);
140
+ // We set media as the upload dir
141
+ $path = Mage::getBaseDir('media') . DS ;
142
+ $uploader->save($path, $_FILES['file']['name'] );
143
+ } catch (Exception $e) {
144
+ $this->_getSession()->addException($e, Mage::helper('profile')->__('Error uploading file. Please try again later.'));
145
+ }
146
+ $data['file'] = $_FILES['file']['name'];
147
+ }
148
+ else
149
+ {
150
+ if(isset($data['file']['delete']) && $data['file']['delete'] == 1)
151
+ $data["file"]="";
152
+ else
153
+ unset($data["file"]);
154
+ }
155
+ //picture file
156
+ if(isset($_FILES['picture']['name']) && $_FILES['picture']['name'] != '') {
157
+ try {
158
+ /* Starting upload */
159
+ $uploader = new Varien_File_Uploader('picture');
160
+ // Any extention would work
161
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
162
+ $uploader->setAllowRenameFiles(false);
163
+ $uploader->setFilesDispersion(false);
164
+ // We set media as the upload dir
165
+ $path = Mage::getBaseDir('media') . DS ;
166
+ $uploader->save($path, $_FILES['picture']['name'] );
167
+ } catch (Exception $e) {
168
+ $this->_getSession()->addException($e, Mage::helper('profile')->__('Error uploading image. Please try again later.'));
169
+ }
170
+ $data['picture'] = $_FILES['picture']['name'];
171
+ }
172
+ else
173
+ {
174
+ if(isset($data['picture']['delete']) && $data['picture']['delete'] == 1)
175
+ $data["picture"]="";
176
+ else
177
+ unset($data["picture"]);
178
+ }
179
+
180
+ //init model and set data
181
+ $model = Mage::getModel('profile/profile');
182
+
183
+ if ($id = $this->getRequest()->getParam('profile_id')) {
184
+ $model->load($id);
185
+ }
186
+ $model->setData($data);
187
+
188
+ $url = $model->getCategoryUrl($model->getData("category_id"));
189
+
190
+ Mage::dispatchEvent('profile_prepare_save', array('profile' => $model, 'request' => $this->getRequest()));
191
+
192
+ // try to save it
193
+ try {
194
+ // save the data
195
+ $model->save();
196
+
197
+ // display success message
198
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('profile')->__('Profile was successfully saved'));
199
+ // clear previously saved data from session
200
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
201
+ // check if 'Save and Continue'
202
+ if ($this->getRequest()->getParam('back')) {
203
+ $this->_redirect('*/*/edit', array('profile_id' => $model->getId()));
204
+ return;
205
+ }
206
+ // go to grid
207
+ $this->_redirect('*/*/'.$url);
208
+ return;
209
+
210
+ } catch (Mage_Core_Exception $e) {
211
+ $this->_getSession()->addError($e->getMessage());
212
+ }
213
+ catch (Exception $e) {
214
+ $this->_getSession()->addException($e, Mage::helper('profile')->__('Error while saving. Please try again later.'.$e));
215
+ }
216
+
217
+ $this->_getSession()->setFormData($data);
218
+ $this->_redirect('*/*/edit', array('profile_id' => $this->getRequest()->getParam('profile_id')));
219
+ return;
220
+ }
221
+ $this->_redirect('*/*/'.$url);
222
+ }
223
+
224
+ /**
225
+ * Delete action
226
+ */
227
+ public function deleteAction()
228
+ {
229
+ // check if we know what should be deleted
230
+ if ($id = $this->getRequest()->getParam('profile_id')) {
231
+ $title = "";
232
+ try {
233
+ // init model and delete
234
+ $model = Mage::getModel('profile/profile');
235
+ $model->load($id);
236
+ $title = $model->getTitle();
237
+ $model->delete();
238
+ // display success message
239
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('profile')->__('Profile was successfully deleted'));
240
+ // go to grid
241
+ Mage::dispatchEvent('adminhtml_cmspage_on_delete', array('title' => $title, 'status' => 'success'));
242
+ // go to grid
243
+ $url = $model->getCategoryUrl($model->getData("category_id"));
244
+ $this->_redirect('*/*/'.$url);
245
+ return;
246
+
247
+ } catch (Exception $e) {
248
+ Mage::dispatchEvent('adminhtml_profile_on_delete', array('title' => $title, 'status' => 'fail'));
249
+ // display error message
250
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
251
+ // go back to edit form
252
+ $this->_redirect('*/*/edit', array('profile_id' => $id));
253
+ return;
254
+ }
255
+ }
256
+ // display error message
257
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('profile')->__('Unable to find a profile to delete'));
258
+ // go to grid
259
+ $this->_redirect('*/*/');
260
+ }
261
+
262
+ /**
263
+ * Filtering posted data. Converting localized data if needed
264
+ *
265
+ * @param array
266
+ * @return array
267
+ */
268
+ protected function _filterPostData($data)
269
+ {
270
+ $data = $this->_filterDates($data, array('creation_time'));
271
+ return $data;
272
+ }
273
+
274
+ }
app/code/community/RichardMason/Profile/controllers/IndexController.php ADDED
@@ -0,0 +1,12 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_IndexController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ }
app/code/community/RichardMason/Profile/controllers/NewsController.php ADDED
@@ -0,0 +1,32 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_NewsController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ public function indexAction()
13
+ {
14
+ $this->loadLayout();
15
+ $this->renderLayout();
16
+ }
17
+
18
+ public function readAction()
19
+ {
20
+ $this->loadLayout();
21
+ $block=Mage::getBlockSingleton('profile/profile');
22
+ //load profile
23
+ $profile = $block->getProfile();
24
+ if($profile) {
25
+ $this->getLayout()->getBlock('head')->setTitle($profile->getData("content_heading"))
26
+ ->setDescription($profile->getData("meta_description"))
27
+ ->setKeywords($profile->getData("meta_keywords"));
28
+ }
29
+ $this->renderLayout();
30
+ }
31
+
32
+ }
app/code/community/RichardMason/Profile/controllers/PressarticlesController.php ADDED
@@ -0,0 +1,30 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_PressarticlesController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ public function indexAction()
13
+ {
14
+ $this->loadLayout();
15
+ $this->renderLayout();
16
+ }
17
+
18
+ public function readAction()
19
+ {
20
+ $block=Mage::getBlockSingleton('profile/profile');
21
+ $profile = $block->getProfile();
22
+ if($profile->getData("picture")){
23
+ echo "&nbsp;";
24
+ echo "<img src=\"". Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . "media/" . $profile->getData("picture"). "\" width='950px' />";
25
+ echo "&nbsp;";
26
+ }
27
+
28
+ }
29
+
30
+ }
app/code/community/RichardMason/Profile/controllers/PressreleasesController.php ADDED
@@ -0,0 +1,32 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_PressreleasesController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ public function indexAction()
13
+ {
14
+ $this->loadLayout();
15
+ $this->renderLayout();
16
+ }
17
+
18
+ public function readAction()
19
+ {
20
+ $this->loadLayout();
21
+ $block=Mage::getBlockSingleton('profile/profile');
22
+ //load profile
23
+ $profile = $block->getProfile();
24
+ if($profile) {
25
+ $this->getLayout()->getBlock('head')->setTitle($profile->getData("content_heading"))
26
+ ->setDescription($profile->getData("meta_description"))
27
+ ->setKeywords($profile->getData("meta_keywords"));
28
+ }
29
+ $this->renderLayout();
30
+ }
31
+
32
+ }
app/code/community/RichardMason/Profile/controllers/TestimonialsController.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ /**
3
+ * Mason Web Development
4
+ *
5
+ * @category RichardMason
6
+ * @package RichardMason_Profile
7
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class RichardMason_Profile_TestimonialsController extends Mage_Core_Controller_Front_Action {
11
+
12
+ public function indexAction()
13
+ {
14
+ $this->loadLayout();
15
+ $this->renderLayout();
16
+ }
17
+ }
app/code/community/RichardMason/Profile/etc/config.xml ADDED
@@ -0,0 +1,143 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <RichardMason_Profile>
5
+ <version>1.10</version>
6
+ </RichardMason_Profile>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <profile>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>RichardMason_Profile</module>
14
+ <frontName>profile</frontName>
15
+ </args>
16
+ </profile>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <profile>
21
+ <file>profile.xml</file>
22
+ </profile>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <profile>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>RichardMason_Profile</module>
32
+ <frontName>profile</frontName>
33
+ </args>
34
+ </profile>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ <cms>
40
+ <children>
41
+ <news module="profile">
42
+ <title>News</title>
43
+ <sort_order>60</sort_order>
44
+ <action>profile/adminhtml_profile/news</action>
45
+ </news>
46
+ </children>
47
+ <children>
48
+ <testimonials module="profile">
49
+ <title>Testimonials</title>
50
+ <sort_order>61</sort_order>
51
+ <action>profile/adminhtml_profile/testimonials</action>
52
+ </testimonials>
53
+ </children>
54
+ <children>
55
+ <pressreleases module="profile">
56
+ <title>Press Releases</title>
57
+ <sort_order>62</sort_order>
58
+ <action>profile/adminhtml_profile/pressreleases</action>
59
+ </pressreleases>
60
+ </children>
61
+ <children>
62
+ <pressarticles module="profile">
63
+ <title>Press Articles</title>
64
+ <sort_order>63</sort_order>
65
+ <action>profile/adminhtml_profile/pressarticles</action>
66
+ </pressarticles>
67
+ </children>
68
+ </cms>
69
+ </menu>
70
+ <layout>
71
+ <updates>
72
+ <profile>
73
+ <file>profile.xml</file>
74
+ </profile>
75
+ </updates>
76
+ </layout>
77
+ <acl>
78
+ <resources>
79
+ <all>
80
+ <title>Allow Everything</title>
81
+ </all>
82
+ <admin>
83
+ <children>
84
+ <RichardMason_Profile>
85
+ <title>Profile Module</title>
86
+ <sort_order>10</sort_order>
87
+ </RichardMason_Profile>
88
+ </children>
89
+ </admin>
90
+ </resources>
91
+ </acl>
92
+
93
+ </adminhtml>
94
+ <global>
95
+ <models>
96
+ <profile>
97
+ <class>RichardMason_Profile_Model</class>
98
+ <resourceModel>profile_mysql4</resourceModel>
99
+ </profile>
100
+ <profile_mysql4>
101
+ <class>RichardMason_Profile_Model_Mysql4</class>
102
+ <entities>
103
+ <profile>
104
+ <table>profile</table>
105
+ </profile>
106
+ <profile_store>
107
+ <table>profile_store</table>
108
+ </profile_store>
109
+ </entities>
110
+ </profile_mysql4>
111
+ </models>
112
+ <resources>
113
+ <profile_setup>
114
+ <setup>
115
+ <module>RichardMason_Profile</module>
116
+ </setup>
117
+ <connection>
118
+ <use>core_setup</use>
119
+ </connection>
120
+ </profile_setup>
121
+ <profile_write>
122
+ <connection>
123
+ <use>core_write</use>
124
+ </connection>
125
+ </profile_write>
126
+ <profile_read>
127
+ <connection>
128
+ <use>core_read</use>
129
+ </connection>
130
+ </profile_read>
131
+ </resources>
132
+ <blocks>
133
+ <profile>
134
+ <class>RichardMason_Profile_Block</class>
135
+ </profile>
136
+ </blocks>
137
+ <helpers>
138
+ <profile>
139
+ <class>RichardMason_Profile_Helper</class>
140
+ </profile>
141
+ </helpers>
142
+ </global>
143
+ </config>
app/code/community/RichardMason/Profile/sql/profile_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,50 @@
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+ DROP TABLE IF EXISTS {$this->getTable('profile')};
9
+ CREATE TABLE {$this->getTable('profile')} (
10
+ `profile_id` smallint(6) NOT NULL AUTO_INCREMENT,
11
+ `category_id` int(11) NOT NULL,
12
+ `thumbnail` varchar(255) NOT NULL,
13
+ `thumbnail_position` int(11) NOT NULL,
14
+ `picture` varchar(255) NOT NULL,
15
+ `file` varchar(255) NOT NULL,
16
+ `content_heading` varchar(255) NOT NULL DEFAULT '',
17
+ `content` mediumtext,
18
+ `meta_keywords` text NOT NULL,
19
+ `meta_description` text NOT NULL,
20
+ `creation_time` datetime DEFAULT NULL,
21
+ `update_time` datetime DEFAULT NULL,
22
+ `is_active` tinyint(1) NOT NULL DEFAULT '1',
23
+ PRIMARY KEY (`profile_id`),
24
+ KEY `identifier` (`content_heading`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26
+
27
+ DROP TABLE IF EXISTS `{$this->getTable('profile/profile_store')}`;
28
+ CREATE TABLE `{$this->getTable('profile/profile_store')}` (
29
+ `profile_id` smallint(6) NOT NULL,
30
+ `store_id` smallint(5) unsigned NOT NULL,
31
+ PRIMARY KEY (`profile_id`,`store_id`),
32
+ CONSTRAINT `FK_CMS_PROFILE_STORE_PAGE` FOREIGN KEY (`profile_id`) REFERENCES `{$this->getTable('profile')}` (`profile_id`) ON UPDATE CASCADE ON DELETE CASCADE,
33
+ CONSTRAINT `FK_CMS_PROFILE_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
34
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='CMS Profiles to Stores';
35
+
36
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(1, 0, 'profile_examples/a5.jpg', 0, '', '', 'Example number 1', '<p><strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </strong>Vestibulum et neque neque. Vestibulum id aliquet dolor. Etiam porta nulla ac odio pharetra venenatis euismod risus pulvinar. Donec tempor molestie faucibus. Aenean tempus, mi sed scelerisque tincidunt, nunc dui tristique dui, auctor auctor eros ipsum nec augue. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec consectetur erat quis nisi feugiat sit amet tempus mi aliquam. Nam mattis tortor eu lectus laoreet eu dignissim turpis rhoncus. Proin eu mi neque, et hendrerit tellus. Ut sed tortor nisi, id sodales lacus. Nulla ac elit tortor. Nulla eleifend turpis ac dui venenatis convallis. Etiam quis augue justo. Nunc eget tortor magna.</p>', 'keywords, keywords,...', 'this is a new', '2010-05-24 00:00:00', '2010-05-25 11:16:10', 1);
37
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(2, 0, 'profile_examples/a4.jpg', 0, '', '', 'Example number 2', '<p><strong>Donec vitae consequat nibh. </strong>Morbi blandit convallis rhoncus. Sed vel sapien urna, in rhoncus eros. In quis viverra urna. Donec bibendum nunc eget dolor scelerisque aliquam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse potenti. Proin dictum urna rutrum sapien pellentesque semper. Etiam vulputate odio et orci imperdiet eu sollicitudin neque sodales. Nunc quis quam tortor. Quisque viverra massa in tellus malesuada sed bibendum massa sollicitudin. Donec cursus purus aliquet nibh ultricies hendrerit. Suspendisse potenti. Vivamus egestas dictum arcu, vitae fringilla tortor egestas ac.</p>', '', '', '2010-05-25 00:00:00', '2010-05-25 11:15:47', 1);
38
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(3, 0, 'profile_examples/a3.jpg', 1, '', '', 'Example number 3', '<p><strong>Phasellus feugiat euismod orci at adipiscing.</strong> Proin bibendum velit cursus mauris dapibus elementum. Mauris ultrices nisl felis. Sed lacinia tempor varius. Fusce venenatis rhoncus sem, et imperdiet lectus adipiscing sit amet. Pellentesque ut vulputate nisl. Sed ac mauris nunc, quis dignissim augue. Quisque et tincidunt augue. Vivamus in nisl id nulla pretium bibendum. Sed pharetra ullamcorper aliquam. Sed nec est diam, vel laoreet mauris.</p>', '', '', '2010-05-26 00:00:00', '2010-05-25 11:15:15', 1);
39
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(4, 1, '', 0, '', '', 'Mr. Natoque et Magnis', '<p><em>'The service was brilliant! Ut luctus rhoncus mauris eu pharetra. Fusce dapibus aliquam nisl, non lacinia ligula pretium sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.'</em></p>\r\n<p><strong>Mr. Natoque et Magnis</strong></p>', '', '', '2010-05-25 00:00:00', '2010-05-25 11:23:40', 1);
40
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(5, 1, '', 0, '', '', 'Mss. Nulla Amet', '<p><em>'Good quality of the products. Quisque fringilla diam quis lacus venenatis varius. Fusce imperdiet fringilla justo eu malesuada. Sed id nisl vulputate risus scelerisque suscipit. Nulla sit amet lorem non felis interdum venenatis. Fusce sollicitudin lorem ac erat varius sed mollis magna scelerisque.'</em></p>\r\n<p><strong>Mss. Nulla Amet</strong></p>', '', '', '2010-05-25 00:00:00', '2010-05-25 11:23:56', 1);
41
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(6, 2, '', 0, '', 'profile_examples/press1.pdf', 'How can I capture credit card information without a payment gateway?', '<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>If you do not have a payment gateway, but still want to accept Credit Cards for processing offline you can capture the credit card information using the Saved Credit Card payment method.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>To set this up go to&nbsp;<strong>System</strong>&nbsp;-&gt;&nbsp;<strong>Configuration</strong>&nbsp;and select&nbsp;<strong>Payment Methods</strong>&nbsp;from the left navigation. Once there you will see Saved CC as one of the available methods.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'><img style='padding: 0px; margin: 0px; border: 0px initial initial;' src='http://www.magentocommerce.com/images/uploads/admin_payment_savedcc.jpg' alt='image' /></p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>To enable this option you will want to set the Enabled dropdown to Yes.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>You can change the Title of the method to whatever you like in the Title field.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>Below this you can set the preferences of this payment method just as you do with all other payment methods. This includes the status of new orders placed with this method, the sort order as it will appear in the front-end in relation to the other methods, whether your customers must enter a card verification number, and the country and order amount filters for your customer to be able to use this method.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>When you are finished, select the Save Config button and you will be able to accept credit cards without integrating with a payment gateway.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>Orders placed using this method will appear in the admin with the card number, name on card and expiration date displayed to the store owner. You can then take this information and use it to charge your customers using your preferred method.&nbsp;</p>', '', '', '2010-02-09 00:00:00', '2010-05-25 11:36:50', 1);
42
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(7, 2, '', 0, '', 'profile_examples/press2.pdf', 'How Do I Accept Checks and Money Orders as Payment? ', '<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>To accept checks and money orders as payment for orders go to&nbsp;<strong style='padding: 0px; margin: 0px;'>System</strong>&nbsp;-&gt;&nbsp;<strong style='padding: 0px; margin: 0px;'>Configuration</strong>. Select Payment Methods from the left navigation. The current release of Magento supports offline payment using checks and money orders. Future releases will support the acceptance of electronic checks on the site.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'><img style='padding: 0px; margin: 0px; border: 0px initial initial;' src='http://www.magentocommerce.com/images/uploads/admin_payment_checks_thumb.jpg' alt='image' /></p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>To display this method to customers in the checkout process you must select Yes from the enabled dropdown.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>You are able to edit the title of the payment method by entering the text in the title field. The text entered here is what is displayed on the payment information page and on all order correspondence with the customer, including order confirmation emails, invoices, and the order history in the customer&rsquo;s account. If you only want to accept Money Orders and not Checks, for example, you can rename the method to Money Orders.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>You can then select the status you want orders placed using Checks and Money Orders. Any orders placed using the Checks / Money Orders payment method will be displayed in the admin panel with this status.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>Enter the name and address of your company so that your customers know where the send the checks and to whom the checks will be payable. This information will appear in the checkout process for your customers to see.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>As with all payment methods, you can add country and order amount filters to determine which customers will be able to use this payment method. You will also be able to move the positioning of the Checks / Money Orders method around on the payment page by changing the sort order. The lowest number will be displayed in the highest position on the page.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>Below this payment method is the Purchase Orders option. This is also an offline method, but it is different from Checks and Money Orders. This is intended to be used when you and the customer have established a credit system, where they are given a Purchase Order number to enter during the checkout process and you can cross-reference this number with a payment option that you have or will arrange with the customer.&nbsp;</p>', '', '', '2010-05-25 00:00:00', '2010-05-25 11:33:08', 1);
43
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(8, 2, '', 0, '', 'profile_examples/press3.pdf', 'What are Tax Rules and How Do I Use Them?', '<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>Tax Rules are defined as a combination of a Customer Tax Class and a Product Tax Class with a Tax Rate (see&nbsp;<a style='color: #0068b7; text-decoration: none; padding: 0px; margin: 0px;' title='What are tax classes? (product and customer)' href='http://www.magentocommerce.com/knowledge-base/entry/what-are-tax-classes-product-and-customer'>What are tax classes? (product and customer)</a>). Each customer will be assigned a class and each product is assigned a tax class. Each region is assigned a set of up to five tax rates. Based on the class of the customer and the class of the products in the shopping cart, and the region (this can be the shipping address, billing address, or shipping origin) the system will calculate out the appropriate tax.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>To create a Tax Rule go to&nbsp;<strong>Sales</strong>&nbsp;-&gt;&nbsp;<strong>Tax</strong>&nbsp;-&gt;&nbsp;<strong>Manage Tax Rules</strong>. Once there you will see a grid list of the Tax Rules you have created. To create a Tax Rule you will also have to create Tax Rates, along with the Tax Classes. See&nbsp;<a style='color: #0068b7; text-decoration: none; padding: 0px; margin: 0px;' title='How do I define tax rates?' href='http://www.magentocommerce.com/knowledge-base/entry/how-do-i-define-tax-rates-per-product-tax-rules/'>How do I define tax rates?</a>&nbsp;for more on setting Tax Rates.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>Once you have created your Tax Classes and Tax Rates you can create rules. In this case we are going to create four rules. We have two different customer types, Retail customers and Wholesale Customers, and two different types of products, taxable and downloadable.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>In this example we are a store in California and we have created a tax rate of 8.25%. (NOTE: This is for example purposes only. Consult your state laws for tax rates). We have also left a rate as being 0%.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>The first Tax Rule we create is for Retail Customers buying taxable goods.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'><img style='padding: 0px; margin: 0px; border: 0px initial initial;' src='http://www.magentocommerce.com/images/uploads/admin_tax_rule1.jpg' alt='image' width='455' height='210' /></p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>We select the Customer and Product class from the dropdowns and then select the Rate we want to use for this combination. In this case we want to use the first rate, 8.25%.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>Select Save Rule and Retail customers with a shipping address in California will be charged a rate of 8.25% on all items marked as being Taxable Goods. That is set, but let&rsquo;s say we have downloadable items we don&rsquo;t want charge tax on. We create a new rule with the combination of the Retail Customer Tax Class and the Downloadable Items Product Tax Class and select the rate we want to charge.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>In this case the rate is the second we created, 0.0%, so customers will not be charged tax on these items.</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>Now that we have our retail customers set up with tax rates we need to set up the two rules for Wholesale Customers. We select the Wholesale Customer from the tax class, select Taxable Items and Rate 2. Then we do the same for Downloadable Items and we have our four tax rates created:</p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'><img style='padding: 0px; margin: 0px; border: 0px initial initial;' src='http://www.magentocommerce.com/images/uploads/admin_taxrule2.jpg' alt='image' width='598' height='203' /></p>\r\n<p style='margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;'>If you need to charge tax on shipping, you can do so by creating a Tax Rule for shipping. This means that you should create a Product Tax Class that will be applied to shipping. Navigate to&nbsp;<strong>System -&gt; Configuration</strong>, and click the Sales tab. In the Tax Calculation section, you can select which product tax class will be applied to the shipping, if you choose to tax shipping. You can also determine whether tax will apply before or after discounts, and how the region of the Tax Rate will be determined (billing address, shipping destination, or shipping origin).</p>', '', '', '2010-03-17 00:00:00', '2010-05-25 11:37:07', 1);
44
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(9, 3, 'profile_examples/article1pic.jpg', 0, 'profile_examples/article1.jpg', '', 'cnet Wireless', '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ut dolor sit amet nisl elementum rhoncus et at lorem. Pellentesque quis felis quis eros fermentum interdum. Curabitur nibh lacus, varius quis fermentum sit amet, pretium ut enim. Proin euismod enim a ligula tristique volutpat.</p>', '', '', '2010-05-25 00:00:00', '2010-05-25 11:54:31', 1);
45
+ INSERT INTO `{$this->getTable('profile/profile_store')}` VALUES(10, 3, 'profile_examples/article2pic.jpg', 0, 'profile_examples/article2.jpg', '', 'cnet Security', '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ut dolor sit amet nisl elementum rhoncus et at lorem. Pellentesque quis felis quis eros fermentum interdum. Curabitur nibh lacus, varius quis fermentum sit amet, pretium ut enim.