Samdoit_Mageportfolio - Version 1.0.0

Version Notes

Stable Version tested the compatibility with magento 1.7.2

Download this release

Release Info

Developer Samdoit
Extension Samdoit_Mageportfolio
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (21) hide show
  1. app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio.php +12 -0
  2. app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Edit.php +45 -0
  3. app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Edit/Form.php +19 -0
  4. app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Edit/Tab/Form.php +58 -0
  5. app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Edit/Tabs.php +24 -0
  6. app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Grid.php +116 -0
  7. app/code/community/Samdoit/Mageportfolio/Block/Mageportfolio.php +18 -0
  8. app/code/community/Samdoit/Mageportfolio/Helper/Data.php +6 -0
  9. app/code/community/Samdoit/Mageportfolio/Model/Mageportfolio.php +21 -0
  10. app/code/community/Samdoit/Mageportfolio/Model/Mysql4/Mageportfolio.php +10 -0
  11. app/code/community/Samdoit/Mageportfolio/Model/Mysql4/Mageportfolio/Collection.php +10 -0
  12. app/code/community/Samdoit/Mageportfolio/Model/Status.php +15 -0
  13. app/code/community/Samdoit/Mageportfolio/controllers/Adminhtml/MageportfolioController.php +179 -0
  14. app/code/community/Samdoit/Mageportfolio/controllers/IndexController.php +9 -0
  15. app/code/community/Samdoit/Mageportfolio/etc/config.xml +118 -0
  16. app/code/community/Samdoit/Mageportfolio/sql/mageportfolio_setup/mysql4-install-1.0.0.php +23 -0
  17. app/design/adminhtml/default/default/layout/mageportfolio.xml +8 -0
  18. app/design/frontend/default/default/layout/mageportfolio.xml +12 -0
  19. app/design/frontend/default/default/template/mageportfolio/mageportfolio.phtml +18 -0
  20. app/etc/modules/Samdoit_Mageportfolio.xml +9 -0
  21. package.xml +18 -0
app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Samdoit_Mageportfolio_Block_Adminhtml_Mageportfolio extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_mageportfolio';
7
+ $this->_blockGroup = 'mageportfolio';
8
+ $this->_headerText = Mage::helper('mageportfolio')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('mageportfolio')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Block_Adminhtml_Mageportfolio_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'mageportfolio';
11
+ $this->_controller = 'adminhtml_mageportfolio';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('mageportfolio')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('mageportfolio')->__('Delete Item'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('mageportfolio_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'mageportfolio_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'mageportfolio_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('mageportfolio_data') && Mage::registry('mageportfolio_data')->getId() ) {
40
+ return Mage::helper('mageportfolio')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('mageportfolio_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('mageportfolio')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Block_Adminhtml_Mageportfolio_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Edit/Tab/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Block_Adminhtml_Mageportfolio_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('mageportfolio_form', array('legend'=>Mage::helper('mageportfolio')->__('Item information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('mageportfolio')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('filename', 'file', array(
19
+ 'label' => Mage::helper('mageportfolio')->__('File'),
20
+ 'required' => false,
21
+ 'name' => 'filename',
22
+ ));
23
+
24
+ $fieldset->addField('status', 'select', array(
25
+ 'label' => Mage::helper('mageportfolio')->__('Status'),
26
+ 'name' => 'status',
27
+ 'values' => array(
28
+ array(
29
+ 'value' => 1,
30
+ 'label' => Mage::helper('mageportfolio')->__('Enabled'),
31
+ ),
32
+
33
+ array(
34
+ 'value' => 2,
35
+ 'label' => Mage::helper('mageportfolio')->__('Disabled'),
36
+ ),
37
+ ),
38
+ ));
39
+
40
+ $fieldset->addField('content', 'editor', array(
41
+ 'name' => 'content',
42
+ 'label' => Mage::helper('mageportfolio')->__('Content'),
43
+ 'title' => Mage::helper('mageportfolio')->__('Content'),
44
+ 'style' => 'width:700px; height:500px;',
45
+ 'wysiwyg' => false,
46
+ 'required' => true,
47
+ ));
48
+
49
+ if ( Mage::getSingleton('adminhtml/session')->getMageportfolioData() )
50
+ {
51
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getMageportfolioData());
52
+ Mage::getSingleton('adminhtml/session')->setMageportfolioData(null);
53
+ } elseif ( Mage::registry('mageportfolio_data') ) {
54
+ $form->setValues(Mage::registry('mageportfolio_data')->getData());
55
+ }
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Block_Adminhtml_Mageportfolio_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('mageportfolio_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('mageportfolio')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('mageportfolio')->__('Item Information'),
18
+ 'title' => Mage::helper('mageportfolio')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('mageportfolio/adminhtml_mageportfolio_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/community/Samdoit/Mageportfolio/Block/Adminhtml/Mageportfolio/Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Block_Adminhtml_Mageportfolio_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('mageportfolioGrid');
9
+ $this->setDefaultSort('mageportfolio_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('mageportfolio/mageportfolio')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('mageportfolio_id', array(
24
+ 'header' => Mage::helper('mageportfolio')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'mageportfolio_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('mageportfolio')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('mageportfolio')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('mageportfolio')->__('Status'),
46
+ 'align' => 'left',
47
+ 'width' => '80px',
48
+ 'index' => 'status',
49
+ 'type' => 'options',
50
+ 'options' => array(
51
+ 1 => 'Enabled',
52
+ 2 => 'Disabled',
53
+ ),
54
+ ));
55
+
56
+ $this->addColumn('action',
57
+ array(
58
+ 'header' => Mage::helper('mageportfolio')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('mageportfolio')->__('Edit'),
65
+ 'url' => array('base'=> '*/*/edit'),
66
+ 'field' => 'id'
67
+ )
68
+ ),
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ 'index' => 'stores',
72
+ 'is_system' => true,
73
+ ));
74
+
75
+ $this->addExportType('*/*/exportCsv', Mage::helper('mageportfolio')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('mageportfolio')->__('XML'));
77
+
78
+ return parent::_prepareColumns();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('mageportfolio_id');
84
+ $this->getMassactionBlock()->setFormFieldName('mageportfolio');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('mageportfolio')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('mageportfolio')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('mageportfolio/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label'=> Mage::helper('mageportfolio')->__('Change status'),
97
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
98
+ 'additional' => array(
99
+ 'visibility' => array(
100
+ 'name' => 'status',
101
+ 'type' => 'select',
102
+ 'class' => 'required-entry',
103
+ 'label' => Mage::helper('mageportfolio')->__('Status'),
104
+ 'values' => $statuses
105
+ )
106
+ )
107
+ ));
108
+ return $this;
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
114
+ }
115
+
116
+ }
app/code/community/Samdoit/Mageportfolio/Block/Mageportfolio.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Samdoit_Mageportfolio_Block_Mageportfolio extends Mage_Core_Block_Template
3
+ {
4
+ protected $_pageCollection;
5
+ public function _prepareLayout()
6
+ {
7
+ return parent::_prepareLayout();
8
+ }
9
+
10
+ public function getMageportfolio()
11
+ {
12
+ $resource = Mage::getSingleton('core/resource');
13
+ $readConnection = $resource->getConnection('core_read');
14
+ $query = "SELECT *FROM mageportfolio WHERE status=1";
15
+ $pageCollection = $readConnection->fetchAll($query);
16
+ return $pageCollection;
17
+ }
18
+ }
app/code/community/Samdoit/Mageportfolio/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/Samdoit/Mageportfolio/Model/Mageportfolio.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Samdoit_Mageportfolio_Model_Mageportfolio extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('mageportfolio/mageportfolio');
8
+ }
9
+ /* public getDetail()
10
+ {
11
+ $resource = Mage::getSingleton('core/resource');
12
+ $readConnection = $resource->getConnection('core_read');
13
+ $query = "SELECT *FROM mageportfolio";
14
+ echo $query;
15
+ $wppageCollection = $readConnection->fetchAll($query);
16
+ foreach($wppageCollection as $key=>$value)
17
+ {
18
+ print_r($value);
19
+ }
20
+ }*/
21
+ }
app/code/community/Samdoit/Mageportfolio/Model/Mysql4/Mageportfolio.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Model_Mysql4_Mageportfolio extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the mageportfolio_id refers to the key field in your database table.
8
+ $this->_init('mageportfolio/mageportfolio', 'mageportfolio_id');
9
+ }
10
+ }
app/code/community/Samdoit/Mageportfolio/Model/Mysql4/Mageportfolio/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Model_Mysql4_Mageportfolio_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('mageportfolio/mageportfolio');
9
+ }
10
+ }
app/code/community/Samdoit/Mageportfolio/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('mageportfolio')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('mageportfolio')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/community/Samdoit/Mageportfolio/controllers/Adminhtml/MageportfolioController.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Samdoit_Mageportfolio_Adminhtml_MageportfolioController extends Mage_Adminhtml_Controller_action
4
+ {
5
+ protected function _initAction() {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('admin')
8
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
9
+
10
+ return $this;
11
+ }
12
+
13
+ public function indexAction() {
14
+ $this->_initAction()
15
+ ->renderLayout();
16
+ }
17
+
18
+ public function editAction() {
19
+ $id = $this->getRequest()->getParam('id');
20
+ $model = Mage::getModel('mageportfolio/mageportfolio')->load($id);
21
+
22
+ if ($model->getId() || $id == 0) {
23
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
24
+ if (!empty($data)) {
25
+ $model->setData($data);
26
+ }
27
+
28
+ Mage::register('mageportfolio_data', $model);
29
+
30
+ $this->loadLayout();
31
+ $this->_setActiveMenu('mageportfolio/items');
32
+
33
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
35
+
36
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
37
+
38
+ $this->_addContent($this->getLayout()->createBlock('mageportfolio/adminhtml_mageportfolio_edit'))
39
+ ->_addLeft($this->getLayout()->createBlock('mageportfolio/adminhtml_mageportfolio_edit_tabs'));
40
+
41
+ $this->renderLayout();
42
+ } else {
43
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mageportfolio')->__('Item does not exist'));
44
+ $this->_redirect('*/*/');
45
+ }
46
+ }
47
+
48
+ public function newAction() {
49
+ $this->_forward('edit');
50
+ }
51
+
52
+ public function saveAction() {
53
+ if ($data = $this->getRequest()->getPost()) {
54
+
55
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
56
+ try {
57
+ /* Starting upload */
58
+ $uploader = new Varien_File_Uploader('filename');
59
+
60
+ // Any extention would work
61
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
62
+ $uploader->setAllowRenameFiles(false);
63
+
64
+ // Set the file upload mode
65
+ // false -> get the file directly in the specified folder
66
+ // true -> get the file in the product like folders
67
+ // (file.jpg will go in something like /media/f/i/file.jpg)
68
+ $uploader->setFilesDispersion(false);
69
+
70
+ // We set media as the upload dir
71
+ $path = Mage::getBaseDir('media') . DS ;
72
+ $uploader->save($path, $_FILES['filename']['name'] );
73
+
74
+ } catch (Exception $e) {
75
+
76
+ }
77
+
78
+ //this way the name is saved in DB
79
+ $data['filename'] = $_FILES['filename']['name'];
80
+ }
81
+
82
+
83
+ $model = Mage::getModel('mageportfolio/mageportfolio');
84
+ $model->setData($data)
85
+ ->setId($this->getRequest()->getParam('id'));
86
+
87
+ try {
88
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
89
+ $model->setCreatedTime(now())
90
+ ->setUpdateTime(now());
91
+ } else {
92
+ $model->setUpdateTime(now());
93
+ }
94
+
95
+ $model->save();
96
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('mageportfolio')->__('Item was successfully saved'));
97
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
98
+
99
+ if ($this->getRequest()->getParam('back')) {
100
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
101
+ return;
102
+ }
103
+ $this->_redirect('*/*/');
104
+ return;
105
+ } catch (Exception $e) {
106
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
107
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
108
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
109
+ return;
110
+ }
111
+ }
112
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mageportfolio')->__('Unable to find item to save'));
113
+ $this->_redirect('*/*/');
114
+ }
115
+
116
+ public function deleteAction() {
117
+ if( $this->getRequest()->getParam('id') > 0 ) {
118
+ try {
119
+ $model = Mage::getModel('mageportfolio/mageportfolio');
120
+
121
+ $model->setId($this->getRequest()->getParam('id'))
122
+ ->delete();
123
+
124
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
125
+ $this->_redirect('*/*/');
126
+ } catch (Exception $e) {
127
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
128
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
129
+ }
130
+ }
131
+ $this->_redirect('*/*/');
132
+ }
133
+
134
+ public function massDeleteAction() {
135
+ $mageportfolioIds = $this->getRequest()->getParam('mageportfolio');
136
+ if(!is_array($mageportfolioIds)) {
137
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
138
+ } else {
139
+ try {
140
+ foreach ($mageportfolioIds as $mageportfolioId) {
141
+ $mageportfolio = Mage::getModel('mageportfolio/mageportfolio')->load($mageportfolioId);
142
+ $mageportfolio->delete();
143
+ }
144
+ Mage::getSingleton('adminhtml/session')->addSuccess(
145
+ Mage::helper('adminhtml')->__(
146
+ 'Total of %d record(s) were successfully deleted', count($mageportfolioIds)
147
+ )
148
+ );
149
+ } catch (Exception $e) {
150
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
151
+ }
152
+ }
153
+ $this->_redirect('*/*/index');
154
+ }
155
+
156
+ public function massStatusAction()
157
+ {
158
+ $mageportfolioIds = $this->getRequest()->getParam('mageportfolio');
159
+ if(!is_array($mageportfolioIds)) {
160
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
161
+ } else {
162
+ try {
163
+ foreach ($mageportfolioIds as $mageportfolioId) {
164
+ $mageportfolio = Mage::getSingleton('mageportfolio/mageportfolio')
165
+ ->load($mageportfolioId)
166
+ ->setStatus($this->getRequest()->getParam('status'))
167
+ ->setIsMassupdate(true)
168
+ ->save();
169
+ }
170
+ $this->_getSession()->addSuccess(
171
+ $this->__('Total of %d record(s) were successfully updated', count($mageportfolioIds))
172
+ );
173
+ } catch (Exception $e) {
174
+ $this->_getSession()->addError($e->getMessage());
175
+ }
176
+ }
177
+ $this->_redirect('*/*/index');
178
+ }
179
+ }
app/code/community/Samdoit/Mageportfolio/controllers/IndexController.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Samdoit_Mageportfolio_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+ }
app/code/community/Samdoit/Mageportfolio/etc/config.xml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Samdoit_Mageportfolio>
5
+ <version>1.0.0</version>
6
+ </Samdoit_Mageportfolio>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <mageportfolio>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Samdoit_Mageportfolio</module>
14
+ <frontName>portfolio</frontName>
15
+ </args>
16
+ </mageportfolio>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <mageportfolio>
21
+ <file>mageportfolio.xml</file>
22
+ </mageportfolio>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <mageportfolio>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Samdoit_Mageportfolio</module>
32
+ <frontName>mageportfolio</frontName>
33
+ </args>
34
+ </mageportfolio>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ <cms>
40
+ <children>
41
+ <items module="mageportfolio">
42
+ <title>Portfolio</title>
43
+ <sort_order>25</sort_order>
44
+ <action>mageportfolio/adminhtml_mageportfolio</action>
45
+ </items>
46
+ </children>
47
+ </cms>
48
+ </menu>
49
+ <acl>
50
+ <resources>
51
+ <all>
52
+ <title>Allow Everything</title>
53
+ </all>
54
+ <admin>
55
+ <children>
56
+ <Samdoit_Mageportfolio>
57
+ <title>Mageportfolio Module</title>
58
+ <sort_order>10</sort_order>
59
+ </Samdoit_Mageportfolio>
60
+ </children>
61
+ </admin>
62
+ </resources>
63
+ </acl>
64
+ <layout>
65
+ <updates>
66
+ <mageportfolio>
67
+ <file>mageportfolio.xml</file>
68
+ </mageportfolio>
69
+ </updates>
70
+ </layout>
71
+ </adminhtml>
72
+ <global>
73
+ <models>
74
+ <mageportfolio>
75
+ <class>Samdoit_Mageportfolio_Model</class>
76
+ <resourceModel>mageportfolio_mysql4</resourceModel>
77
+ </mageportfolio>
78
+ <mageportfolio_mysql4>
79
+ <class>Samdoit_Mageportfolio_Model_Mysql4</class>
80
+ <entities>
81
+ <mageportfolio>
82
+ <table>mageportfolio</table>
83
+ </mageportfolio>
84
+ </entities>
85
+ </mageportfolio_mysql4>
86
+ </models>
87
+ <resources>
88
+ <mageportfolio_setup>
89
+ <setup>
90
+ <module>Samdoit_Mageportfolio</module>
91
+ </setup>
92
+ <connection>
93
+ <use>core_setup</use>
94
+ </connection>
95
+ </mageportfolio_setup>
96
+ <mageportfolio_write>
97
+ <connection>
98
+ <use>core_write</use>
99
+ </connection>
100
+ </mageportfolio_write>
101
+ <mageportfolio_read>
102
+ <connection>
103
+ <use>core_read</use>
104
+ </connection>
105
+ </mageportfolio_read>
106
+ </resources>
107
+ <blocks>
108
+ <mageportfolio>
109
+ <class>Samdoit_Mageportfolio_Block</class>
110
+ </mageportfolio>
111
+ </blocks>
112
+ <helpers>
113
+ <mageportfolio>
114
+ <class>Samdoit_Mageportfolio_Helper</class>
115
+ </mageportfolio>
116
+ </helpers>
117
+ </global>
118
+ </config>
app/code/community/Samdoit/Mageportfolio/sql/mageportfolio_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('mageportfolio')};
10
+ CREATE TABLE {$this->getTable('mageportfolio')} (
11
+ `mageportfolio_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `filename` varchar(255) NOT NULL default '',
14
+ `content` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ PRIMARY KEY (`mageportfolio_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/mageportfolio.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <mageportfolio_adminhtml_mageportfolio_index>
4
+ <reference name="content">
5
+ <block type="mageportfolio/adminhtml_mageportfolio" name="mageportfolio" />
6
+ </reference>
7
+ </mageportfolio_adminhtml_mageportfolio_index>
8
+ </layout>
app/design/frontend/default/default/layout/mageportfolio.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+ <mageportfolio_index_index>
3
+ <reference name="root">
4
+ <action method="setTemplate">
5
+ <template>page/1column.phtml</template>
6
+ </action>
7
+ </reference>
8
+ <reference name="content">
9
+ <block type="mageportfolio/mageportfolio" name="mageportfolio" template="mageportfolio/mageportfolio.phtml" />
10
+ </reference>
11
+ </mageportfolio_index_index>
12
+ </layout>
app/design/frontend/default/default/template/mageportfolio/mageportfolio.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $pageDetail = $this->getMageportfolio();
3
+ ?>
4
+ <ul>
5
+ <?php foreach($pageDetail as $key=>$value) {?>
6
+ <li>
7
+ <div>
8
+ <div id="portfolio-header">
9
+ <h3><?php echo $value['title'];?></h3>
10
+ </div>
11
+ <div id="portfolio-content">
12
+ <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$value['filename'];?>" height="500" width="500" alt="<?php echo $value['title'];?>"><br/><br/>
13
+ <?php echo $value['content'];?>
14
+ </div>
15
+ </div>
16
+ </li>
17
+ <?php } ?>
18
+ </ul>
app/etc/modules/Samdoit_Mageportfolio.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Samdoit_Mageportfolio>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Samdoit_Mageportfolio>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Samdoit_Mageportfolio</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Portfolio easy to create your portfolio detail snapshot content of portfolio and easy to access by admin user</summary>
10
+ <description>Magento Portfolio to add your portfolio in magento admin you can view from your front end, you can view the portfolio by http://your-domain/portfolio</description>
11
+ <notes>Stable Version tested the compatibility with magento 1.7.2</notes>
12
+ <authors><author><name>Samdoit</name><user>samdoit</user><email>arulmanickams@samdoit.com</email></author></authors>
13
+ <date>2013-08-20</date>
14
+ <time>11:40:01</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Samdoit_Mageportfolio.xml" hash="dcb64db6ad3dae0c5159cfdf6bb6577d"/></dir></target><target name="magecommunity"><dir name="Samdoit"><dir name="Mageportfolio"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Mageportfolio"><dir name="Edit"><file name="Form.php" hash="cc698dcf823567d00e4fc8471a582e06"/><dir name="Tab"><file name="Form.php" hash="22534371cd7fac3c324fc89c53b86282"/></dir><file name="Tabs.php" hash="a06c18da85fd0193ba9cc4dd21b6c2a5"/></dir><file name="Edit.php" hash="567bbee4f4600fd829c3d7799eda5260"/><file name="Grid.php" hash="40dc87defc4117a2266b7ee5c99f1cf0"/></dir><file name="Mageportfolio.php" hash="c415927c72ae9e96cf4015648385d469"/></dir><file name="Mageportfolio.php" hash="6066bd107bb7594285f0d02ecc0ba45d"/></dir><dir name="Helper"><file name="Data.php" hash="6ce7a43b4ff0a8db4bcf3083acfcb73b"/></dir><dir name="Model"><file name="Mageportfolio.php" hash="761446fe4bdaad58405af79bac8e5e39"/><dir name="Mysql4"><dir name="Mageportfolio"><file name="Collection.php" hash="44f8c04d09679178a5493387cf2bc259"/></dir><file name="Mageportfolio.php" hash="657f9cf6e7c4d435169fd85934c68552"/></dir><file name="Status.php" hash="daf6330870b4c091b5be510b1d379493"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MageportfolioController.php" hash="e70d03debbbced4501144e09416625b2"/></dir><file name="IndexController.php" hash="fa482fc73dd8568ae615c237f06f0475"/></dir><dir name="etc"><file name="config.xml" hash="e1b1ce9e7dd98d9b68221ecc36fc505f"/></dir><dir name="sql"><dir name="mageportfolio_setup"><file name="mysql4-install-1.0.0.php" hash="37aa00fead24136e24f356e3c16f3513"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mageportfolio.xml" hash="91ced8de17332ecfdfe307c575ad0de4"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="mageportfolio"><file name="mageportfolio.phtml" hash="aafb21a30bdaccdd469016b80a4d8b83"/></dir></dir><dir name="layout"><file name="mageportfolio.xml" hash="ab2876109f8a2a0bf576da5bc7e0e852"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>