Version Notes
Fixed Minor bugs
Download this release
Release Info
Developer | Magento Core Team |
Extension | Saurabh_Test |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/Saurabh/Test/Block/Adminhtml/Test.php +12 -0
- app/code/local/Saurabh/Test/Block/Adminhtml/Test/Edit.php +21 -0
- app/code/local/Saurabh/Test/Block/Adminhtml/Test/Edit/Form.php +16 -0
- app/code/local/Saurabh/Test/Block/Adminhtml/Test/Edit/Tab/Form.php +47 -0
- app/code/local/Saurabh/Test/Block/Adminhtml/Test/Edit/Tabs.php +20 -0
- app/code/local/Saurabh/Test/Block/Adminhtml/Test/Grid.php +114 -0
- app/code/local/Saurabh/Test/Block/Test.php +13 -0
- app/code/local/Saurabh/Test/Helper/Data.php +4 -0
- app/code/local/Saurabh/Test/Model/Mysql4/Test.php +15 -0
- app/code/local/Saurabh/Test/Model/Mysql4/Test/Collection.php +9 -0
- app/code/local/Saurabh/Test/Model/Test.php +13 -0
- app/code/local/Saurabh/Test/controllers/Adminhtml/TestController.php +118 -0
- app/code/local/Saurabh/Test/controllers/IndexController.php +34 -0
- app/code/local/Saurabh/Test/etc/config.xml +120 -0
- app/code/local/Saurabh/Test/sql/test_setup/mysql4-install-0.1.0.php +18 -0
- app/design/adminhtml/default/default/layout/test.xml +8 -0
- app/design/frontend/default/default/layout/test.xml +11 -0
- app/design/frontend/default/default/template/test/test.phtml +11 -0
- app/etc/modules/Saurabh_Test.xml +35 -0
- package.xml +18 -0
app/code/local/Saurabh/Test/Block/Adminhtml/Test.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Block_Adminhtml_Test extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_test';
|
7 |
+
$this->_blockGroup = 'test';
|
8 |
+
$this->_headerText = Mage::helper('test')->__('Test Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('test')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Saurabh/Test/Block/Adminhtml/Test/Edit.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Block_Adminhtml_Test_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->_objectId = 'id';
|
8 |
+
$this->_blockGroup = 'test';
|
9 |
+
$this->_controller = 'adminhtml_test';
|
10 |
+
$this->_updateButton('save', 'label', Mage::helper('test')->__('Save Item'));
|
11 |
+
$this->_updateButton('delete', 'label', Mage::helper('test')->__('Delete Item'));
|
12 |
+
}
|
13 |
+
public function getHeaderText()
|
14 |
+
{
|
15 |
+
if( Mage::registry('test_data') && Mage::registry('test_data')->getId() ) {
|
16 |
+
return Mage::helper('test')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('test_data')->getTitle()));
|
17 |
+
} else {
|
18 |
+
return Mage::helper('test')->__('Add Item');
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
app/code/local/Saurabh/Test/Block/Adminhtml/Test/Edit/Form.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Block_Adminhtml_Test_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form(array(
|
7 |
+
'id' => 'edit_form',
|
8 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
9 |
+
'method' => 'post',
|
10 |
+
)
|
11 |
+
);
|
12 |
+
$form->setUseContainer(true);
|
13 |
+
$this->setForm($form);
|
14 |
+
return parent::_prepareForm();
|
15 |
+
}
|
16 |
+
}
|
app/code/local/Saurabh/Test/Block/Adminhtml/Test/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Block_Adminhtml_Test_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
$fieldset = $form->addFieldset('test_form', array('legend'=>Mage::helper('test')->__('Item information')));
|
9 |
+
$fieldset->addField('title', 'text', array(
|
10 |
+
'label' => Mage::helper('test')->__('Title'),
|
11 |
+
'class' => 'required-entry',
|
12 |
+
'required' => true,
|
13 |
+
'name' => 'title',
|
14 |
+
));
|
15 |
+
|
16 |
+
$fieldset->addField('status', 'select', array(
|
17 |
+
'label' => Mage::helper('test')->__('Status'),
|
18 |
+
'name' => 'status',
|
19 |
+
'values' => array(
|
20 |
+
array(
|
21 |
+
'value' => 1,
|
22 |
+
'label' => Mage::helper('test')->__('Active'),
|
23 |
+
),
|
24 |
+
array(
|
25 |
+
'value' => 0,
|
26 |
+
'label' => Mage::helper('test')->__('Inactive'),
|
27 |
+
),
|
28 |
+
),
|
29 |
+
));
|
30 |
+
$fieldset->addField('content', 'editor', array(
|
31 |
+
'name' => 'content',
|
32 |
+
'label' => Mage::helper('test')->__('Content'),
|
33 |
+
'title' => Mage::helper('test')->__('Content'),
|
34 |
+
'style' => 'width:98%; height:400px;',
|
35 |
+
'wysiwyg' => false,
|
36 |
+
'required' => true,
|
37 |
+
));
|
38 |
+
if ( Mage::getSingleton('adminhtml/session')->getTestData() )
|
39 |
+
{
|
40 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getTestData());
|
41 |
+
Mage::getSingleton('adminhtml/session')->setTestData(null);
|
42 |
+
} elseif ( Mage::registry('test_data') ) {
|
43 |
+
$form->setValues(Mage::registry('test_data')->getData());
|
44 |
+
}
|
45 |
+
return parent::_prepareForm();
|
46 |
+
}
|
47 |
+
}
|
app/code/local/Saurabh/Test/Block/Adminhtml/Test/Edit/Tabs.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Block_Adminhtml_Test_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('test_tabs');
|
8 |
+
$this->setDestElementId('edit_form');
|
9 |
+
$this->setTitle(Mage::helper('test')->__('News Information'));
|
10 |
+
}
|
11 |
+
protected function _beforeToHtml()
|
12 |
+
{
|
13 |
+
$this->addTab('form_section', array(
|
14 |
+
'label' => Mage::helper('test')->__('Item Information'),
|
15 |
+
'title' => Mage::helper('test')->__('Item Information'),
|
16 |
+
'content' => $this->getLayout()->createBlock('test/adminhtml_test_edit_tab_form')->toHtml(),
|
17 |
+
));
|
18 |
+
return parent::_beforeToHtml();
|
19 |
+
}
|
20 |
+
}
|
app/code/local/Saurabh/Test/Block/Adminhtml/Test/Grid.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Saurabh_Test_Block_Adminhtml_Test_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('testGrid');
|
9 |
+
$this->setDefaultSort('test_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('test/test')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('test_id', array(
|
24 |
+
'header' => Mage::helper('test')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '10px',
|
27 |
+
'index' => 'test_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('name', array(
|
31 |
+
'header' => Mage::helper('test')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'title',
|
34 |
+
'width' => '50px',
|
35 |
+
));
|
36 |
+
|
37 |
+
$this->addColumn('content', array(
|
38 |
+
'header' => Mage::helper('test')->__('Description'),
|
39 |
+
'width' => '150px',
|
40 |
+
'index' => 'content',
|
41 |
+
));
|
42 |
+
$this->addColumn('created_time', array(
|
43 |
+
'header' => Mage::helper('test')->__('Creation Time'),
|
44 |
+
'align' => 'left',
|
45 |
+
'width' => '120px',
|
46 |
+
'type' => 'date',
|
47 |
+
'default' => '--',
|
48 |
+
'index' => 'created_time',
|
49 |
+
));
|
50 |
+
$this->addColumn('update_time', array(
|
51 |
+
'header' => Mage::helper('test')->__('Update Time'),
|
52 |
+
'align' => 'left',
|
53 |
+
'width' => '120px',
|
54 |
+
'type' => 'date',
|
55 |
+
'default' => '--',
|
56 |
+
'index' => 'update_time',
|
57 |
+
));
|
58 |
+
$this->addColumn('status', array(
|
59 |
+
'header' => Mage::helper('test')->__('Status'),
|
60 |
+
'align' => 'left',
|
61 |
+
'width' => '80px',
|
62 |
+
'index' => 'status',
|
63 |
+
'type' => 'options',
|
64 |
+
'options' => array(
|
65 |
+
1 => 'Active',
|
66 |
+
0 => 'Inactive',
|
67 |
+
),
|
68 |
+
));
|
69 |
+
return parent::_prepareColumns();
|
70 |
+
}
|
71 |
+
public function getRowUrl($row)
|
72 |
+
{
|
73 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
74 |
+
}
|
75 |
+
|
76 |
+
protected function _prepareMassaction()
|
77 |
+
{
|
78 |
+
$this->setMassactionIdField('test_id');
|
79 |
+
$this->getMassactionBlock()->setFormFieldName('test');
|
80 |
+
|
81 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
82 |
+
'label' => Mage::helper('test')->__('Delete'),
|
83 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
84 |
+
'confirm' => Mage::helper('test')->__('Are you sure?')
|
85 |
+
));
|
86 |
+
|
87 |
+
$statuses = Mage::getSingleton('test/test')->getOptionArray();
|
88 |
+
|
89 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
90 |
+
$this->getMassactionBlock()->addItem('status', array(
|
91 |
+
'label'=> Mage::helper('test')->__('Change status'),
|
92 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
93 |
+
'additional' => array(
|
94 |
+
'visibility' => array(
|
95 |
+
'name' => 'status',
|
96 |
+
'type' => 'select',
|
97 |
+
'class' => 'required-entry',
|
98 |
+
'label' => Mage::helper('test')->__('Status'),
|
99 |
+
'values' => array(
|
100 |
+
array(
|
101 |
+
'value' => 1,
|
102 |
+
'label' => Mage::helper('test')->__('Active'),
|
103 |
+
),
|
104 |
+
array(
|
105 |
+
'value' => 0,
|
106 |
+
'label' => Mage::helper('test')->__('Inactive'),
|
107 |
+
),
|
108 |
+
),
|
109 |
+
)
|
110 |
+
)
|
111 |
+
));
|
112 |
+
return $this;
|
113 |
+
}
|
114 |
+
}
|
app/code/local/Saurabh/Test/Block/Test.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Block_Test extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function getContent()
|
5 |
+
{
|
6 |
+
return "Hello World!";
|
7 |
+
}
|
8 |
+
public function getDetail()
|
9 |
+
{
|
10 |
+
$model = Mage::getModel('test/test')->getCollection();
|
11 |
+
return $model;
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Saurabh/Test/Helper/Data.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
app/code/local/Saurabh/Test/Model/Mysql4/Test.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Model_Mysql4_Test extends Mage_Core_Model_Mysql4_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('test/test', 'test_id'); // here test_id is the primary of the table test. And test/test, is the magento table name as mentioned in the //config.xml file.
|
7 |
+
}
|
8 |
+
public function loadByField($field,$value){
|
9 |
+
$table = $this->getMainTable();
|
10 |
+
$where = $this->_getReadAdapter()->quoteInto("$field = ?", $value);
|
11 |
+
$select = $this->_getReadAdapter()->select()->from($table,array('test_id'))->where($where);
|
12 |
+
$id = $this->_getReadAdapter()->fetchOne($select);
|
13 |
+
return $id;
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Saurabh/Test/Model/Mysql4/Test/Collection.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Model_Mysql4_Test_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
//parent::__construct();
|
7 |
+
$this->_init('test/test');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Saurabh/Test/Model/Test.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Model_Test extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('test/test'); // this is location of the resource file.
|
8 |
+
}
|
9 |
+
public function loadByField($field,$value){
|
10 |
+
$id = $this->getResource()->loadByField($field,$value);
|
11 |
+
$this->load($id);
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Saurabh/Test/controllers/Adminhtml/TestController.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Saurabh_Test_Adminhtml_TestController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
protected function _initAction()
|
5 |
+
{
|
6 |
+
$this->loadLayout()
|
7 |
+
->_setActiveMenu('test/items')
|
8 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
9 |
+
return $this;
|
10 |
+
}
|
11 |
+
public function indexAction() {
|
12 |
+
$this->_initAction();
|
13 |
+
//$this->_addContent($this->getLayout()->createBlock('test/adminhtml_test'));
|
14 |
+
$this->renderLayout();
|
15 |
+
}
|
16 |
+
public function editAction()
|
17 |
+
{
|
18 |
+
$testId = $this->getRequest()->getParam('id');
|
19 |
+
$testModel = Mage::getModel('test/test')->load($testId);
|
20 |
+
if ($testModel->getId() || $testId == 0) {
|
21 |
+
Mage::register('test_data', $testModel);
|
22 |
+
$this->loadLayout();
|
23 |
+
$this->_setActiveMenu('test/items');
|
24 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
25 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
26 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
27 |
+
$this->_addContent($this->getLayout()->createBlock('test/adminhtml_test_edit'))
|
28 |
+
->_addLeft($this->getLayout()->createBlock('test/adminhtml_test_edit_tabs'));
|
29 |
+
$this->renderLayout();
|
30 |
+
} else {
|
31 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('test')->__('Item does not exist'));
|
32 |
+
$this->_redirect('*/*/');
|
33 |
+
}
|
34 |
+
}
|
35 |
+
public function newAction()
|
36 |
+
{
|
37 |
+
$this->_redirect('*/*/edit');
|
38 |
+
}
|
39 |
+
public function saveAction()
|
40 |
+
{
|
41 |
+
if ( $this->getRequest()->getPost() ) {
|
42 |
+
try {
|
43 |
+
$postData = $this->getRequest()->getPost();
|
44 |
+
$testModel = Mage::getModel('test/test');
|
45 |
+
$testModel->setId($this->getRequest()->getParam('id'))
|
46 |
+
->setTitle($postData['title'])
|
47 |
+
->setContent($postData['content'])
|
48 |
+
->setStatus($postData['status'])
|
49 |
+
->save();
|
50 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
|
51 |
+
Mage::getSingleton('adminhtml/session')->settestData(false);
|
52 |
+
$this->_redirect('*/*/');
|
53 |
+
return;
|
54 |
+
} catch (Exception $e) {
|
55 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
56 |
+
Mage::getSingleton('adminhtml/session')->settestData($this->getRequest()->getPost());
|
57 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
$this->_redirect('*/*/');
|
62 |
+
}
|
63 |
+
public function deleteAction()
|
64 |
+
{
|
65 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
66 |
+
try {
|
67 |
+
$testModel = Mage::getModel('test/test');
|
68 |
+
$testModel->setId($this->getRequest()->getParam('id'))
|
69 |
+
->delete();
|
70 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
71 |
+
$this->_redirect('*/*/');
|
72 |
+
} catch (Exception $e) {
|
73 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
74 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
75 |
+
}
|
76 |
+
}
|
77 |
+
$this->_redirect('*/*/');
|
78 |
+
}
|
79 |
+
/**
|
80 |
+
|
81 |
+
* Product grid for AJAX request.
|
82 |
+
|
83 |
+
* Sort and filter result for example.
|
84 |
+
|
85 |
+
*/
|
86 |
+
public function gridAction()
|
87 |
+
{
|
88 |
+
$this->loadLayout();
|
89 |
+
$this->getResponse()->setBody(
|
90 |
+
$this->getLayout()->createBlock('importedit/adminhtml_test_grid')->toHtml()
|
91 |
+
);
|
92 |
+
}
|
93 |
+
public function massStatusAction()
|
94 |
+
{
|
95 |
+
$ids = $this->getRequest()->getParam('test');
|
96 |
+
foreach($ids as $id)
|
97 |
+
{
|
98 |
+
$model = Mage::getModel('test/test');
|
99 |
+
$model->setId($id)
|
100 |
+
->setStatus($this->getRequest()->getParam('status'))
|
101 |
+
->save();
|
102 |
+
}
|
103 |
+
$this->_redirect('*/*/');
|
104 |
+
|
105 |
+
}
|
106 |
+
public function massDeleteAction()
|
107 |
+
{
|
108 |
+
$ids = $this->getRequest()->getParam('test');
|
109 |
+
foreach($ids as $id)
|
110 |
+
{
|
111 |
+
$model = Mage::getModel('test/test');
|
112 |
+
$model->setId($id)
|
113 |
+
->delete();
|
114 |
+
}
|
115 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
116 |
+
$this->_redirect('*/*/');
|
117 |
+
}
|
118 |
+
}
|
app/code/local/Saurabh/Test/controllers/IndexController.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<?php
|
3 |
+
class Saurabh_Test_IndexController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->renderLayout();
|
9 |
+
}
|
10 |
+
public function createNewPostAction()
|
11 |
+
{
|
12 |
+
$blogpost = Mage::getModel('test/test');
|
13 |
+
$blogpost->setTitle('Code Post!');
|
14 |
+
$blogpost->setPost('This post was created from code!');
|
15 |
+
$blogpost->save();
|
16 |
+
echo 'post created';
|
17 |
+
}
|
18 |
+
public function editFirstPostAction()
|
19 |
+
{
|
20 |
+
$blogpost = Mage::getModel('test/test');
|
21 |
+
$blogpost->load(5);
|
22 |
+
$blogpost->setTitle("The First post!");
|
23 |
+
$blogpost->save();
|
24 |
+
echo 'post edited';
|
25 |
+
}
|
26 |
+
public function deleteFirstPostAction()
|
27 |
+
{
|
28 |
+
$blogpost = Mage::getModel('test/test');
|
29 |
+
$blogpost->load(5);
|
30 |
+
$blogpost->delete();
|
31 |
+
echo 'post removed';
|
32 |
+
}
|
33 |
+
}
|
34 |
+
?>
|
app/code/local/Saurabh/Test/etc/config.xml
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Saurabh_Test>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Saurabh_Test>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<test>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Saurabh_Test</module>
|
14 |
+
<frontName>test</frontName>
|
15 |
+
</args>
|
16 |
+
</test>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<test>
|
21 |
+
<file>test.xml</file>
|
22 |
+
</test>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<global>
|
27 |
+
<blocks>
|
28 |
+
<test>
|
29 |
+
<class>Saurabh_Test_Block</class>
|
30 |
+
</test>
|
31 |
+
</blocks>
|
32 |
+
<helpers>
|
33 |
+
<test>
|
34 |
+
<class>Saurabh_Test_Helper</class>
|
35 |
+
</test>
|
36 |
+
</helpers>
|
37 |
+
<models>
|
38 |
+
<test>
|
39 |
+
<class>Saurabh_Test_Model</class> <!-- Location of all model class files -->
|
40 |
+
<resourceModel>test_mysql4</resourceModel> <!-- Location of resource model -->
|
41 |
+
</test>
|
42 |
+
<test_mysql4>
|
43 |
+
<class>Saurabh_Test_Model_Mysql4</class>
|
44 |
+
<entities>
|
45 |
+
<test>
|
46 |
+
<table>test</table> <!-- Actual table name in sql -->
|
47 |
+
</test>
|
48 |
+
</entities>
|
49 |
+
</test_mysql4>
|
50 |
+
</models>
|
51 |
+
<resources> <!-- These are resource setting giving access to module, read/write permission on database -->
|
52 |
+
<test_setup>
|
53 |
+
<setup>
|
54 |
+
<module>Saurabh_Test</module>
|
55 |
+
</setup>
|
56 |
+
<connection>
|
57 |
+
<use>core_setup</use>
|
58 |
+
</connection>
|
59 |
+
</test_setup>
|
60 |
+
<test_write>
|
61 |
+
<connection>
|
62 |
+
<use>core_write</use>
|
63 |
+
</connection>
|
64 |
+
</test_write>
|
65 |
+
<test_read>
|
66 |
+
<connection>
|
67 |
+
<use>core_read</use>
|
68 |
+
</connection>
|
69 |
+
</test_read>
|
70 |
+
</resources>
|
71 |
+
</global>
|
72 |
+
<admin>
|
73 |
+
<routers>
|
74 |
+
<test>
|
75 |
+
<use>admin</use>
|
76 |
+
<args>
|
77 |
+
<test>Saurabh_Test</test>
|
78 |
+
<frontName>test</frontName>
|
79 |
+
</args>
|
80 |
+
</test>
|
81 |
+
</routers>
|
82 |
+
</admin>
|
83 |
+
<adminhtml>
|
84 |
+
<menu>
|
85 |
+
<test module="test">
|
86 |
+
<title>test</title>
|
87 |
+
<sort_order>71</sort_order>
|
88 |
+
<children>
|
89 |
+
<items module="test">
|
90 |
+
<title>Manage Items</title>
|
91 |
+
<sort_order>0</sort_order>
|
92 |
+
<action>test/adminhtml_test</action>
|
93 |
+
</items>
|
94 |
+
</children>
|
95 |
+
</test>
|
96 |
+
</menu>
|
97 |
+
<acl>
|
98 |
+
<resources>
|
99 |
+
<all>
|
100 |
+
<title>Allow Everything</title>
|
101 |
+
</all>
|
102 |
+
<admin>
|
103 |
+
<children>
|
104 |
+
<test>
|
105 |
+
<title>Test Module</title>
|
106 |
+
<sort_order>200</sort_order>
|
107 |
+
</test>
|
108 |
+
</children>
|
109 |
+
</admin>
|
110 |
+
</resources>
|
111 |
+
</acl>
|
112 |
+
<layout>
|
113 |
+
<updates>
|
114 |
+
<test>
|
115 |
+
<file>test.xml</file>
|
116 |
+
</test>
|
117 |
+
</updates>
|
118 |
+
</layout>
|
119 |
+
</adminhtml>
|
120 |
+
</config>
|
app/code/local/Saurabh/Test/sql/test_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this; //Getting Installer Class Object In A Variable
|
3 |
+
$installer->startSetup();
|
4 |
+
$installer->run("
|
5 |
+
-- DROP TABLE IF EXISTS {$this->getTable('test')};
|
6 |
+
CREATE TABLE {$this->getTable('test')} (
|
7 |
+
`test_id` int(11) unsigned NOT NULL auto_increment,
|
8 |
+
`title` varchar(255) NOT NULL default '',
|
9 |
+
`filename` varchar(255) NOT NULL default '',
|
10 |
+
`content` text NOT NULL default '',
|
11 |
+
`status` smallint(6) NOT NULL default '0',
|
12 |
+
`created_time` datetime NULL,
|
13 |
+
`update_time` datetime NULL,
|
14 |
+
PRIMARY KEY (`test_id`)
|
15 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
16 |
+
");
|
17 |
+
$installer->endSetup();
|
18 |
+
?>
|
app/design/adminhtml/default/default/layout/test.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<test_adminhtml_test_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="test/adminhtml_test" name="test" />
|
6 |
+
</reference>
|
7 |
+
</test_adminhtml_test_index>
|
8 |
+
</layout>
|
app/design/frontend/default/default/layout/test.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<test_index_index>
|
4 |
+
<reference name="root">
|
5 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
6 |
+
</reference>
|
7 |
+
<reference name="content">
|
8 |
+
<block type="test/test" name="test" template="test/test.phtml" />
|
9 |
+
</reference>
|
10 |
+
</test_index_index>
|
11 |
+
</layout>
|
app/design/frontend/default/default/template/test/test.phtml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php echo $this->getContent()."<br/>"; ?>
|
2 |
+
<?php $detail = $this->getDetail();
|
3 |
+
foreach($detail as $a)
|
4 |
+
{
|
5 |
+
echo $a->getTestId();
|
6 |
+
}?>
|
7 |
+
<?php
|
8 |
+
echo "<br/>";
|
9 |
+
$model = Mage::getModel('test/test');
|
10 |
+
$model->loadbyfield('title','Saurabh');
|
11 |
+
echo $model->getTestId();?>
|
app/etc/modules/Saurabh_Test.xml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Find
|
23 |
+
* @package Find_Feed
|
24 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
<config>
|
29 |
+
<modules>
|
30 |
+
<Saurabh_Test>
|
31 |
+
<active>true</active>
|
32 |
+
<codePool>local</codePool>
|
33 |
+
</Saurabh_Test>
|
34 |
+
</modules>
|
35 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Saurabh_Test</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This is a testing module</summary>
|
10 |
+
<description>This is a testing module</description>
|
11 |
+
<notes>Fixed Minor bugs</notes>
|
12 |
+
<authors><author><name>Saurabh Sutariya</name><user>auto-converted</user><email>saurabh.sutariya664@gmail.com</email></author></authors>
|
13 |
+
<date>2012-01-13</date>
|
14 |
+
<time>18:39:21</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Saurabh"><dir name="Test"><dir name="Block"><dir name="Adminhtml"><dir name="Test"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="7fae3ef8df93dac843b32a4e23200542"/></dir><file name="Form.php" hash="9e7c77ebc6fa167bb22db664968bd9b5"/><file name="Tabs.php" hash="556d7b73a6cb95115d8f753a0190ad73"/></dir><file name="Edit.php" hash="005aded34f8b06a1bbae9136a61681bc"/><file name="Grid.php" hash="5d5eb321ed1968311a334f141ccc58b1"/></dir><file name="Test.php" hash="9308ef3a85376346bfce8b90136b0888"/></dir><file name="Test.php" hash="825303803f84a8fd8e8801f129e97013"/></dir><dir name="Helper"><file name="Data.php" hash="a7dae32764c56945bfee58b81bb3d279"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Test"><file name="Collection.php" hash="ad03a6359aa77d2f56b2e2c2fd42d31a"/></dir><file name="Test.php" hash="d250755ec49b6465ae9a1c49dce87449"/></dir><file name="Test.php" hash="1d753919bc992fb560e86fdf46a43963"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="TestController.php" hash="30add281b36dec518271581d593b19f4"/></dir><file name="IndexController.php" hash="171fc3ca1f4086181f48ad5657d459b3"/></dir><dir name="etc"><file name="config.xml" hash="ec8a1b15c882e0b4e4c83f2b308e5789"/></dir><dir name="sql"><dir name="test_setup"><file name="mysql4-install-0.1.0.php" hash="9a86ab8e8d7ed58c755b17a2731c3ce1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Saurabh_Test.xml" hash="9dbbacb303c37370139c7992220b5d88"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="test.xml" hash="ff98d1c3f7be0062d991bdcb05d7c197"/></dir><dir name="template"><dir name="test"><file name="test.phtml" hash="488d206c23e8755805c8f8cf49d50c38"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="test.xml" hash="9b166ab91bc26cb71959433cc0983642"/></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|