Quickview - Version 0.1.0

Version Notes

It is the stable version without any bug.

Download this release

Release Info

Developer Magento Core Team
Extension Quickview
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (21) hide show
  1. app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook.php +12 -0
  2. app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Edit.php +45 -0
  3. app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Edit/Form.php +19 -0
  4. app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Edit/Tab/Form.php +58 -0
  5. app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Edit/Tabs.php +24 -0
  6. app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Grid.php +116 -0
  7. app/code/local/Webspeaks/Productbook/Block/Productbook.php +17 -0
  8. app/code/local/Webspeaks/Productbook/Helper/Data.php +6 -0
  9. app/code/local/Webspeaks/Productbook/Model/Mysql4/Productbook.php +10 -0
  10. app/code/local/Webspeaks/Productbook/Model/Mysql4/Productbook/Collection.php +10 -0
  11. app/code/local/Webspeaks/Productbook/Model/Productbook.php +10 -0
  12. app/code/local/Webspeaks/Productbook/Model/Status.php +15 -0
  13. app/code/local/Webspeaks/Productbook/controllers/Adminhtml/ProductbookController.php +214 -0
  14. app/code/local/Webspeaks/Productbook/controllers/IndexController.php +63 -0
  15. app/code/local/Webspeaks/Productbook/etc/config.xml +120 -0
  16. app/code/local/Webspeaks/Productbook/sql/productbook_setup/mysql4-install-0.1.0.php +23 -0
  17. app/design/frontend/default/default/layout/productbook.xml +10 -0
  18. app/design/frontend/default/default/template/catalog/product/list.phtml +281 -0
  19. app/design/frontend/default/default/template/productbook/productbook.phtml +265 -0
  20. app/etc/modules/Webspeaks_Productbook.xml +9 -0
  21. package.xml +18 -0
app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Webspeaks_Productbook_Block_Adminhtml_Productbook extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_productbook';
7
+ $this->_blockGroup = 'productbook';
8
+ $this->_headerText = Mage::helper('productbook')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('productbook')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Block_Adminhtml_Productbook_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 = 'productbook';
11
+ $this->_controller = 'adminhtml_productbook';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('productbook')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('productbook')->__('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('productbook_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'productbook_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'productbook_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('productbook_data') && Mage::registry('productbook_data')->getId() ) {
40
+ return Mage::helper('productbook')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('productbook_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('productbook')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Block_Adminhtml_Productbook_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/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Edit/Tab/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Block_Adminhtml_Productbook_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('productbook_form', array('legend'=>Mage::helper('productbook')->__('Item information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('productbook')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('filename', 'file', array(
19
+ 'label' => Mage::helper('productbook')->__('File'),
20
+ 'required' => false,
21
+ 'name' => 'filename',
22
+ ));
23
+
24
+ $fieldset->addField('status', 'select', array(
25
+ 'label' => Mage::helper('productbook')->__('Status'),
26
+ 'name' => 'status',
27
+ 'values' => array(
28
+ array(
29
+ 'value' => 1,
30
+ 'label' => Mage::helper('productbook')->__('Enabled'),
31
+ ),
32
+
33
+ array(
34
+ 'value' => 2,
35
+ 'label' => Mage::helper('productbook')->__('Disabled'),
36
+ ),
37
+ ),
38
+ ));
39
+
40
+ $fieldset->addField('content', 'editor', array(
41
+ 'name' => 'content',
42
+ 'label' => Mage::helper('productbook')->__('Content'),
43
+ 'title' => Mage::helper('productbook')->__('Content'),
44
+ 'style' => 'width:700px; height:500px;',
45
+ 'wysiwyg' => false,
46
+ 'required' => true,
47
+ ));
48
+
49
+ if ( Mage::getSingleton('adminhtml/session')->getProductbookData() )
50
+ {
51
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getProductbookData());
52
+ Mage::getSingleton('adminhtml/session')->setProductbookData(null);
53
+ } elseif ( Mage::registry('productbook_data') ) {
54
+ $form->setValues(Mage::registry('productbook_data')->getData());
55
+ }
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Block_Adminhtml_Productbook_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('productbook_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('productbook')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('productbook')->__('Item Information'),
18
+ 'title' => Mage::helper('productbook')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('productbook/adminhtml_productbook_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Webspeaks/Productbook/Block/Adminhtml/Productbook/Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Block_Adminhtml_Productbook_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('productbookGrid');
9
+ $this->setDefaultSort('productbook_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('productbook/productbook')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('productbook_id', array(
24
+ 'header' => Mage::helper('productbook')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'productbook_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('productbook')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('productbook')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('productbook')->__('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('productbook')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('productbook')->__('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('productbook')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('productbook')->__('XML'));
77
+
78
+ return parent::_prepareColumns();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('productbook_id');
84
+ $this->getMassactionBlock()->setFormFieldName('productbook');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('productbook')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('productbook')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('productbook/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label'=> Mage::helper('productbook')->__('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('productbook')->__('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/local/Webspeaks/Productbook/Block/Productbook.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Webspeaks_Productbook_Block_Productbook extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getProductbook()
10
+ {
11
+ if (!$this->hasData('productbook')) {
12
+ $this->setData('productbook', Mage::registry('productbook'));
13
+ }
14
+ return $this->getData('productbook');
15
+
16
+ }
17
+ }
app/code/local/Webspeaks/Productbook/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Webspeaks/Productbook/Model/Mysql4/Productbook.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Model_Mysql4_Productbook extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productbook_id refers to the key field in your database table.
8
+ $this->_init('productbook/productbook', 'productbook_id');
9
+ }
10
+ }
app/code/local/Webspeaks/Productbook/Model/Mysql4/Productbook/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Model_Mysql4_Productbook_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productbook/productbook');
9
+ }
10
+ }
app/code/local/Webspeaks/Productbook/Model/Productbook.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Model_Productbook extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productbook/productbook');
9
+ }
10
+ }
app/code/local/Webspeaks/Productbook/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_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('productbook')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('productbook')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Webspeaks/Productbook/controllers/Adminhtml/ProductbookController.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webspeaks_Productbook_Adminhtml_ProductbookController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('productbook/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('productbook/productbook')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('productbook_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('productbook/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('productbook/adminhtml_productbook_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('productbook/adminhtml_productbook_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productbook')->__('Item does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function newAction() {
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ public function saveAction() {
54
+ if ($data = $this->getRequest()->getPost()) {
55
+
56
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
57
+ try {
58
+ /* Starting upload */
59
+ $uploader = new Varien_File_Uploader('filename');
60
+
61
+ // Any extention would work
62
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
63
+ $uploader->setAllowRenameFiles(false);
64
+
65
+ // Set the file upload mode
66
+ // false -> get the file directly in the specified folder
67
+ // true -> get the file in the product like folders
68
+ // (file.jpg will go in something like /media/f/i/file.jpg)
69
+ $uploader->setFilesDispersion(false);
70
+
71
+ // We set media as the upload dir
72
+ $path = Mage::getBaseDir('media') . DS ;
73
+ $uploader->save($path, $_FILES['filename']['name'] );
74
+
75
+ } catch (Exception $e) {
76
+
77
+ }
78
+
79
+ //this way the name is saved in DB
80
+ $data['filename'] = $_FILES['filename']['name'];
81
+ }
82
+
83
+
84
+ $model = Mage::getModel('productbook/productbook');
85
+ $model->setData($data)
86
+ ->setId($this->getRequest()->getParam('id'));
87
+
88
+ try {
89
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
90
+ $model->setCreatedTime(now())
91
+ ->setUpdateTime(now());
92
+ } else {
93
+ $model->setUpdateTime(now());
94
+ }
95
+
96
+ $model->save();
97
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productbook')->__('Item was successfully saved'));
98
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
99
+
100
+ if ($this->getRequest()->getParam('back')) {
101
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
102
+ return;
103
+ }
104
+ $this->_redirect('*/*/');
105
+ return;
106
+ } catch (Exception $e) {
107
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
108
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
109
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
110
+ return;
111
+ }
112
+ }
113
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productbook')->__('Unable to find item to save'));
114
+ $this->_redirect('*/*/');
115
+ }
116
+
117
+ public function deleteAction() {
118
+ if( $this->getRequest()->getParam('id') > 0 ) {
119
+ try {
120
+ $model = Mage::getModel('productbook/productbook');
121
+
122
+ $model->setId($this->getRequest()->getParam('id'))
123
+ ->delete();
124
+
125
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
126
+ $this->_redirect('*/*/');
127
+ } catch (Exception $e) {
128
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
129
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
130
+ }
131
+ }
132
+ $this->_redirect('*/*/');
133
+ }
134
+
135
+ public function massDeleteAction() {
136
+ $productbookIds = $this->getRequest()->getParam('productbook');
137
+ if(!is_array($productbookIds)) {
138
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
139
+ } else {
140
+ try {
141
+ foreach ($productbookIds as $productbookId) {
142
+ $productbook = Mage::getModel('productbook/productbook')->load($productbookId);
143
+ $productbook->delete();
144
+ }
145
+ Mage::getSingleton('adminhtml/session')->addSuccess(
146
+ Mage::helper('adminhtml')->__(
147
+ 'Total of %d record(s) were successfully deleted', count($productbookIds)
148
+ )
149
+ );
150
+ } catch (Exception $e) {
151
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
152
+ }
153
+ }
154
+ $this->_redirect('*/*/index');
155
+ }
156
+
157
+ public function massStatusAction()
158
+ {
159
+ $productbookIds = $this->getRequest()->getParam('productbook');
160
+ if(!is_array($productbookIds)) {
161
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
162
+ } else {
163
+ try {
164
+ foreach ($productbookIds as $productbookId) {
165
+ $productbook = Mage::getSingleton('productbook/productbook')
166
+ ->load($productbookId)
167
+ ->setStatus($this->getRequest()->getParam('status'))
168
+ ->setIsMassupdate(true)
169
+ ->save();
170
+ }
171
+ $this->_getSession()->addSuccess(
172
+ $this->__('Total of %d record(s) were successfully updated', count($productbookIds))
173
+ );
174
+ } catch (Exception $e) {
175
+ $this->_getSession()->addError($e->getMessage());
176
+ }
177
+ }
178
+ $this->_redirect('*/*/index');
179
+ }
180
+
181
+ public function exportCsvAction()
182
+ {
183
+ $fileName = 'productbook.csv';
184
+ $content = $this->getLayout()->createBlock('productbook/adminhtml_productbook_grid')
185
+ ->getCsv();
186
+
187
+ $this->_sendUploadResponse($fileName, $content);
188
+ }
189
+
190
+ public function exportXmlAction()
191
+ {
192
+ $fileName = 'productbook.xml';
193
+ $content = $this->getLayout()->createBlock('productbook/adminhtml_productbook_grid')
194
+ ->getXml();
195
+
196
+ $this->_sendUploadResponse($fileName, $content);
197
+ }
198
+
199
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
200
+ {
201
+ $response = $this->getResponse();
202
+ $response->setHeader('HTTP/1.1 200 OK','');
203
+ $response->setHeader('Pragma', 'public', true);
204
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
205
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
206
+ $response->setHeader('Last-Modified', date('r'));
207
+ $response->setHeader('Accept-Ranges', 'bytes');
208
+ $response->setHeader('Content-Length', strlen($content));
209
+ $response->setHeader('Content-type', $contentType);
210
+ $response->setBody($content);
211
+ $response->sendResponse();
212
+ die;
213
+ }
214
+ }
app/code/local/Webspeaks/Productbook/controllers/IndexController.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Webspeaks_Productbook_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/productbook?id=15
11
+ * or
12
+ * http://site.com/productbook/id/15
13
+ */
14
+ /*
15
+ $productbook_id = $this->getRequest()->getParam('id');
16
+
17
+ if($productbook_id != null && $productbook_id != '') {
18
+ $productbook = Mage::getModel('productbook/productbook')->load($productbook_id)->getData();
19
+ } else {
20
+ $productbook = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($productbook == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $productbookTable = $resource->getTableName('productbook');
32
+
33
+ $select = $read->select()
34
+ ->from($productbookTable,array('productbook_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $productbook = $read->fetchRow($select);
39
+ }
40
+ Mage::register('productbook', $productbook);
41
+ */
42
+
43
+ echo $this->getLayout()->createBlock('productbook/productbook')->setTemplate('productbook/productbook.phtml')->toHtml();
44
+
45
+ // $this->loadLayout();
46
+ // $this->renderLayout();
47
+ }
48
+
49
+ public function cartinfoAction()
50
+ {
51
+ if(Mage::getSingleton('customer/session')->isLoggedIn())
52
+ {
53
+ $quote = Mage::getModel('checkout/session')->getQuote();
54
+ $total = $quote->getGrandTotal();
55
+ // print_r(get_class_methods(Mage::helper('checkout/cart')->getCart()));
56
+ echo 'Items in cart: <b>'. Mage::helper('checkout/cart')->getCart()->getSummaryQty().'</b>&nbsp;&nbsp;&nbsp;&nbsp;<br />Cart total: <b>'.Mage::helper('checkout')->formatPrice($total).'</b>';
57
+ }
58
+ else
59
+ {
60
+ echo "Please login to view cart details.";
61
+ }
62
+ }
63
+ }
app/code/local/Webspeaks/Productbook/etc/config.xml ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Webspeaks_Productbook>
5
+ <version>0.1.0</version>
6
+ </Webspeaks_Productbook>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <productbook>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Webspeaks_Productbook</module>
14
+ <frontName>productbook</frontName>
15
+ </args>
16
+ </productbook>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <productbook>
21
+ <file>productbook.xml</file>
22
+ </productbook>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <productbook>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Webspeaks_Productbook</module>
32
+ <frontName>productbook</frontName>
33
+ </args>
34
+ </productbook>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ <productbook module="productbook">
40
+ <title>Productbook</title>
41
+ <sort_order>71</sort_order>
42
+ <children>
43
+ <items module="productbook">
44
+ <title>Manage Items</title>
45
+ <sort_order>0</sort_order>
46
+ <action>productbook/adminhtml_productbook</action>
47
+ </items>
48
+ </children>
49
+ </productbook>
50
+ </menu>
51
+ <acl>
52
+ <resources>
53
+ <all>
54
+ <title>Allow Everything</title>
55
+ </all>
56
+ <admin>
57
+ <children>
58
+ <Webspeaks_Productbook>
59
+ <title>Productbook Module</title>
60
+ <sort_order>10</sort_order>
61
+ </Webspeaks_Productbook>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+ <layout>
67
+ <updates>
68
+ <productbook>
69
+ <file>productbook.xml</file>
70
+ </productbook>
71
+ </updates>
72
+ </layout>
73
+ </adminhtml>
74
+ <global>
75
+ <models>
76
+ <productbook>
77
+ <class>Webspeaks_Productbook_Model</class>
78
+ <resourceModel>productbook_mysql4</resourceModel>
79
+ </productbook>
80
+ <productbook_mysql4>
81
+ <class>Webspeaks_Productbook_Model_Mysql4</class>
82
+ <entities>
83
+ <productbook>
84
+ <table>productbook</table>
85
+ </productbook>
86
+ </entities>
87
+ </productbook_mysql4>
88
+ </models>
89
+ <resources>
90
+ <productbook_setup>
91
+ <setup>
92
+ <module>Webspeaks_Productbook</module>
93
+ </setup>
94
+ <connection>
95
+ <use>core_setup</use>
96
+ </connection>
97
+ </productbook_setup>
98
+ <productbook_write>
99
+ <connection>
100
+ <use>core_write</use>
101
+ </connection>
102
+ </productbook_write>
103
+ <productbook_read>
104
+ <connection>
105
+ <use>core_read</use>
106
+ </connection>
107
+ </productbook_read>
108
+ </resources>
109
+ <blocks>
110
+ <productbook>
111
+ <class>Webspeaks_Productbook_Block</class>
112
+ </productbook>
113
+ </blocks>
114
+ <helpers>
115
+ <productbook>
116
+ <class>Webspeaks_Productbook_Helper</class>
117
+ </productbook>
118
+ </helpers>
119
+ </global>
120
+ </config>
app/code/local/Webspeaks/Productbook/sql/productbook_setup/mysql4-install-0.1.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('productbook')};
10
+ CREATE TABLE {$this->getTable('productbook')} (
11
+ `productbook_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 (`productbook_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+ $installer->endSetup();
app/design/frontend/default/default/layout/productbook.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ </default>
5
+ <catalogsearch_result_index translate="label">
6
+ <reference name="content">
7
+ <!-- <block type="productbook/productbook" name="productbook" template="productbook/productbook.phtml" />-->
8
+ </reference>
9
+ </catalogsearch_result_index>
10
+ </layout>
app/design/frontend/default/default/template/catalog/product/list.phtml ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Product list template
30
+ *
31
+ * @see Mage_Catalog_Block_Product_List
32
+ */
33
+ ?>
34
+ <?php
35
+ $_productCollection=$this->getLoadedProductCollection();
36
+ $_helper = $this->helper('catalog/output');
37
+ ?>
38
+ <?php if(!$_productCollection->count()): ?>
39
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
40
+ <?php else: ?>
41
+ <div class="category-products">
42
+ <?php echo $this->getToolbarHtml() ?>
43
+ <?php // List mode ?>
44
+ <?php if($this->getMode()!='grid'): ?>
45
+ <?php $_iterator = 0; ?>
46
+ <ol class="products-list" id="products-list">
47
+ <?php foreach ($_productCollection as $_product): ?>
48
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
49
+ <?php // Product Image ?>
50
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
51
+ <?php // Product description ?>
52
+ <div class="product-shop">
53
+ <div class="f-fix">
54
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
55
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
56
+ <?php if($_product->getRatingSummary()): ?>
57
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
58
+ <?php endif; ?>
59
+ <?php echo $this->getPriceHtml($_product, true) ?>
60
+ <?php if($_product->isSaleable()): ?>
61
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
62
+ <?php else: ?>
63
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
64
+ <?php endif; ?>
65
+ <div class="desc std">
66
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
67
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
68
+ </div>
69
+ <ul class="add-to-links">
70
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
71
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
72
+ <?php endif; ?>
73
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
74
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
75
+ <?php endif; ?>
76
+ <li>
77
+ <!-- #dialog is the id of a DIV defined in the code below -->
78
+ <a href="#dialog" name="modal" id="<?php echo $_product->getId() ?>">Quickshop</a>
79
+
80
+ </li>
81
+ </ul>
82
+ </div>
83
+ </div>
84
+ </li>
85
+ <?php endforeach; ?>
86
+ </ol>
87
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
88
+
89
+ <?php else: ?>
90
+
91
+ <?php // Grid Mode ?>
92
+
93
+ <?php $_collectionSize = $_productCollection->count() ?>
94
+ <?php $_columnCount = $this->getColumnCount(); ?>
95
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
96
+ <?php if ($i++%$_columnCount==0): ?>
97
+ <ul class="products-grid">
98
+ <?php endif ?>
99
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
100
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
101
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
102
+ <?php if($_product->getRatingSummary()): ?>
103
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
104
+ <?php endif; ?>
105
+ <?php echo $this->getPriceHtml($_product, true) ?>
106
+ <div class="actions">
107
+ <?php if($_product->isSaleable()): ?>
108
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
109
+ <?php else: ?>
110
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
111
+ <?php endif; ?>
112
+ <ul class="add-to-links">
113
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
114
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
115
+ <?php endif; ?>
116
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
117
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
118
+ <?php endif; ?>
119
+
120
+ <li>
121
+ <!-- #dialog is the id of a DIV defined in the code below -->
122
+ <a href="#dialog" name="modal" id="<?php echo $_product->getId() ?>">Quickshop</a>
123
+
124
+ </li>
125
+ </ul>
126
+ </div>
127
+ </li>
128
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
129
+ </ul>
130
+ <?php endif ?>
131
+ <?php endforeach ?>
132
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
133
+ <?php endif; ?>
134
+
135
+ <div class="toolbar-bottom">
136
+ <?php echo $this->getToolbarHtml() ?>
137
+ </div>
138
+ </div>
139
+ <?php endif; ?>
140
+
141
+ <div id="boxes">
142
+
143
+ <!-- Do not remove div#mask, because you'll need it to fill the whole screen -->
144
+ <div id="mask"></div>
145
+
146
+ <!-- #customize your modal window here -->
147
+
148
+
149
+ <div id="dialog" class="window">
150
+ <div id="product_data">
151
+ </div>
152
+ </div>
153
+
154
+
155
+
156
+ </div>
157
+
158
+ <style>
159
+ #dialog{margin:3px;}
160
+ /* Z-index of #mask must lower than #boxes .window */
161
+ #mask {
162
+ z-index:9000;
163
+ background-color:#000;
164
+ display:none;
165
+ }
166
+
167
+ #boxes .window {
168
+ position:absolute;
169
+ width:0px;
170
+ height:0px;
171
+ display:none;
172
+ z-index:9999;
173
+ padding:5px;
174
+ }
175
+
176
+
177
+ /* Customize your modal window here, you can add background image too */
178
+ #boxes #dialog {
179
+ border:5px solid #D2B9D3;
180
+ background-color:#EBDDE2;
181
+ width:550px;
182
+ height:400px;
183
+ overflow-x: hidden;
184
+ overflow-y: auto;
185
+ }
186
+ </style>
187
+
188
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" language="javascript"></script>
189
+
190
+ <script>
191
+
192
+ $(document).ready(function() {
193
+
194
+ //select all the a tag with name equal to modal
195
+ $('a[name=modal]').click(function(e) {
196
+ //Cancel the link behavior
197
+ e.preventDefault();
198
+
199
+ /************************************************************************************************************/
200
+ var baseUrl = '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); ?>';
201
+ var productId = $(this).attr('id');
202
+
203
+ $('#product_data').html('<div style="text-align:center; color:#fff; font-size:14px; font-weight:bold;">Loading Product Information...</div>');
204
+ $.ajax({
205
+ type: "POST",
206
+ url: baseUrl+"productbook",
207
+ data: "id="+productId,
208
+ success: function(msg){
209
+ $('#product_data').empty().append(msg);
210
+ getCartInfo();
211
+ }
212
+ });
213
+
214
+ function getCartInfo()
215
+ {
216
+ <?php
217
+ if(Mage::getSingleton('customer/session')->isLoggedIn())
218
+ {
219
+ ?>
220
+ $('#cartInfo').empty().html('Updating cart info...');
221
+ cartHtml = 'Items in cart: <b><?php echo Mage::getSingleton('checkout/cart')->getQuote()->getItemsSummaryQty() ?></b>&nbsp;&nbsp;&nbsp;&nbsp;<br />Cart total: <b><?php echo $this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()) ?></b>';
222
+ <?php
223
+ }
224
+ else
225
+ {
226
+ ?>
227
+ cartHtml = 'Please login to view cart details.';
228
+ <?php
229
+ }
230
+ ?>
231
+ $('#cartInfo').empty().html(cartHtml);
232
+ }
233
+ /************************************************************************************************************/
234
+
235
+
236
+
237
+
238
+ //Get the A tag
239
+ var id = $(this).attr('href');
240
+
241
+ //Get the screen height and width
242
+ var maskHeight = 0;//$(document).height();
243
+ var maskWidth = 0;//$(window).width();
244
+
245
+ //Set height and width to mask to fill up the whole screen
246
+ $('#mask').css({'width':maskWidth,'height':maskHeight, 'top':0});
247
+
248
+ //transition effect
249
+ // $('#mask').fadeIn('fast');
250
+ // $('#mask').fadeTo("slow",1.0);
251
+
252
+ //Get the window height and width
253
+ var winH = $(window).height();
254
+ var winW = $(window).width();
255
+
256
+ //Set the popup window to center
257
+ $(id).css('top', winH/2-$(id).height()/2);
258
+ $(id).css('left', winW/2-$(id).width()/2);
259
+
260
+ //transition effect
261
+ $(id).fadeIn('fast');
262
+
263
+ });
264
+
265
+ //if close button is clicked
266
+ $('.window .close').click(function (e) {
267
+ //Cancel the link behavior
268
+ e.preventDefault();
269
+ $('#product_data').empty();
270
+ $('#mask, .window').hide();
271
+ });
272
+
273
+ //if mask is clicked
274
+ $('#mask').click(function () {
275
+ $(this).hide();
276
+ $('.window').hide();
277
+ });
278
+
279
+ });
280
+
281
+ </script>
app/design/frontend/default/default/template/productbook/productbook.phtml ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+ .hd{background-color:#D2B9D3; padding:3px; color:#FFFFFF; font-size:14px; font-weight:bold;}
3
+ .close{text-decoration:none; color:#FFFFFF; font-weight:none; font-size:10px; vertical-align:middle;}
4
+ td.share a{border:0; text-decoration:none;}
5
+ td.share a img{border:0; text-decoration:none; padding:3px; height:30px; width:30px;}
6
+ </style>
7
+
8
+ <?php
9
+ $productid = Mage::app()->getRequest()->getParam('id');
10
+ if(isset($productid) && $productid!='')
11
+ {
12
+ // echo "Product-".$productid.'<br>';
13
+ }
14
+ else
15
+ {
16
+ $productid = 1;
17
+ }
18
+
19
+ $model = Mage::getModel('catalog/product'); //getting product model
20
+
21
+ $_product = $model->load($productid); //getting product object for particular product id
22
+
23
+ // var_dump(get_class_methods(Mage::helper('checkout/cart')->getQuote()));
24
+ // echo "<br>----".Mage::helper('checkout/cart')->getSummaryCount();
25
+ // $quote = Mage::getModel('checkout/session')->getQuote();
26
+ // echo "<br>----".$total = $quote->getGrandTotal();
27
+ // echo "<br>----". $this->helper('checkout')->formatPrice(Mage::helper('checkout/cart')->getQuote()->getTotals());
28
+ // var_dump(get_class($this));exit
29
+
30
+ // echo $_product->getShortDescription(); //product�s short description
31
+ // echo $_product->getDescription(); // product�s long description
32
+ // echo $_product->getName(); //product name
33
+ // echo $_product->getPrice(); //product�s regular Price
34
+ // echo $_product->getSpecialPrice(); //product�s special Price
35
+ // echo $_product->getProductUrl(); //product url
36
+ // echo $_product->getImageUrl(); //product�s image url
37
+ // echo $_product->getSmallImageUrl(); //product�s small image url
38
+ // echo $_product->getThumbnailUrl(); //product�s thumbnail image url
39
+
40
+ ?>
41
+
42
+ <html>
43
+ <body>
44
+
45
+ <table cellpadding="0" cellspacing="0" width="100%">
46
+ <tr>
47
+ <td style="text-align:left;" class="hd">
48
+ Product Overview
49
+ </td>
50
+ <td style="text-align:right;" class="hd">
51
+ <a href="#" class="close">Close</a>
52
+ </td>
53
+ </tr>
54
+ <tr>
55
+ <td colspan="2">
56
+ <table cellpadding="0" cellspacing="0" width="100%" style="text-align:left; vertical-align:top;">
57
+ <tr>
58
+ <td style="vertical-align:top;">
59
+ <div class="product-img-box" style="margin:5px; width=265px; vertical-align:top;" >
60
+ <p class="product-image" style="vertical-align:top;">
61
+ <img title="<?php echo $_product->getName() ?>" alt="<?php echo $_product->getName() ?>" src="<?php echo $_product->getImageUrl() ?>"></p>
62
+ </div>
63
+ </td>
64
+ <td style="text-align:left;">
65
+ <div class="product-shop">
66
+ <div class="product-name">
67
+ <h1><?php echo $_product->getName() ?></h1>
68
+ </div>
69
+
70
+ <?php
71
+ if($_product->isSaleable()){
72
+ if($_product->stock_item->is_in_stock == 1){
73
+ echo '<p class="availability in-stock"><span>'.$this->__('Availability: In stock.').'</span></p>';
74
+ }else{
75
+ echo '<p class="availability in-stock"><span>'.$this->__('Availability: Temporarily out of stock.').'</span></p>';
76
+ }
77
+ }
78
+ ?>
79
+
80
+ <div class="price-box">
81
+ <span class="regular-price">
82
+ <span class="price"><?php echo $this->helper('checkout')->formatPrice($_product->getPrice()); ?></span>
83
+ </span>
84
+ </div>
85
+
86
+ <?php
87
+ if($_product->isSaleable())
88
+ {
89
+ ?>
90
+ <div class="add-to-cart">
91
+ <label for="qty">Qty:</label>
92
+ <input type="text" class="input-text qty" title="Qty" value="1" maxlength="12" id="qty_<?php echo $productid ?>" name="qty">
93
+ <button class="button btn-cart" id="<?php echo $_product->getId() ?>" title="Add to Cart" type="button"><span><span>Add to Cart</span></span></button>
94
+ <span style="padding:3px;" id="addingCart_<?php echo $productid ?>"></span>
95
+ </div>
96
+ <?php
97
+ }
98
+ ?>
99
+ </div>
100
+ <div class="short-description" style="margin-top:15px;">
101
+ <h2 class="hd">Quick Overview</h2>
102
+ <div class="std"><?php echo $_product->getShortDescription() ?></div>
103
+ </div>
104
+
105
+ <div style="margin-top:15px;">
106
+ <h2 class="hd">Current Cart Status</h2>
107
+ <div id="cartInfo"></div>
108
+ </div>
109
+
110
+ </td>
111
+ </tr>
112
+ </table>
113
+ </td>
114
+ </tr>
115
+ <tr>
116
+ <td colspan="2" class="hd">
117
+ Share This Product
118
+ </td>
119
+ </tr>
120
+ <tr>
121
+ <td class="share" style="width:100%;">
122
+ <a href="http://www.facebook.com/sharer.php?u=<?php echo $_product->getProductUrl() ?>&title=<?php echo urlencode($_product->getName()) ?>" target="_blank">
123
+ <img border="0" src="http://3.bp.blogspot.com/_vLeiVavkV_M/SnleIlLdGwI/AAAAAAAABd8/RfHnWIGGMEY/s200/facebook.png" alt="Post item information on Facebook" title="Post item information on Facebook" />
124
+ </a>
125
+
126
+ <a href="http://twitter.com/home?status=Currently buying <?php echo $_product->getProductUrl() ?>" title="Click to send this product to Twitter!" target="_blank">
127
+ <img border="0" src="http://www.cbc.ca/news/yourvoice/assets/images/yourvoice-twitter.png" alt="Add To Twiiter" title="Add To Twiiter">
128
+ </a>
129
+
130
+ <a title="Add To Del.icio.us" target="_blank" href="http://del.icio.us/post?url=<?php echo $_product->getProductUrl() ?>&amp;title=<?php echo urlencode($_product->getName()) ?>">
131
+ <img border="0" src="http://2.bp.blogspot.com/_vLeiVavkV_M/Snld35mPSDI/AAAAAAAABds/ccrOpOmP9Zk/s200/delicious.png" alt="Add To Del.icio.us" title="Add To Del.icio.us">
132
+ </a>
133
+
134
+ <a title="Stumble This" target="_blank" href="http://www.stumbleupon.com/refer.php?url=<?php echo $_product->getProductUrl() ?>&amp;title=<?php echo urlencode($_product->getName()) ?>">
135
+ <img border="0" src="http://2.bp.blogspot.com/_vLeiVavkV_M/SnleiulEMVI/AAAAAAAABeU/kO09nNTlQeo/s200/stumbleupon.png" alt="Stumble This" title="Stumble This">
136
+ </a>
137
+
138
+ <a title="Digg This" target="_blank" href="http://digg.com/submit?phase=2&amp;url=<?php echo $_product->getProductUrl() ?>&amp;title=<?php echo urlencode($_product->getName()) ?>">
139
+ <img border="0" src="http://3.bp.blogspot.com/_vLeiVavkV_M/Snld_x-wXoI/AAAAAAAABd0/cTsGU_Y-zQ8/s200/digg.png" alt="Digg This" title="Digg This">
140
+ </a>
141
+
142
+ <a title="Add To Reddit" target="_blank" href="http://reddit.com/submit?url=<?php echo $_product->getProductUrl() ?>&amp;title=<?php echo urlencode($_product->getName()) ?>">
143
+ <img border="0" src="http://3.bp.blogspot.com/_vLeiVavkV_M/SnleX1tMMtI/AAAAAAAABeM/gQSYdrmSc3k/s200/reddit.png" alt="Add To Reddit" title="Add To Reddit">
144
+ </a>
145
+
146
+ <a title="Add To Yahoo" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=<?php echo $_product->getProductUrl() ?>&amp;title=<?php echo urlencode($_product->getName()) ?>">
147
+ <img border="0" src="http://1.bp.blogspot.com/_vLeiVavkV_M/SnlexsGX2QI/AAAAAAAABes/ai6zvzZKCgw/s200/yahoo.png" alt="Add To Yahoo" title="Add To Yahoo">
148
+ </a>
149
+
150
+ </td>
151
+ </tr>
152
+ </table>
153
+ </body>
154
+ </html>
155
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" language="javascript"></script>
156
+
157
+ <script>
158
+
159
+ $(document).ready(function() {
160
+
161
+ var baseUrl = '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); ?>';
162
+ $('.button').click(function(){
163
+ var pid = $(this).attr('id');
164
+ var qty = $('#qty_'+pid).val();
165
+
166
+ $('#addingCart_'+pid).html('Adding to cart...');
167
+ $.ajax({
168
+ type: "POST",
169
+ url: baseUrl+"checkout/cart/add",
170
+ data: 'product='+pid+'&qty='+qty,
171
+ success: function(msg){
172
+ $('#addingCart_'+pid).html('Added to cart.');
173
+ cartInfo();
174
+ }
175
+ });
176
+ });
177
+
178
+ function cartInfo()
179
+ {
180
+ $('#cartInfo').empty().html('Updating cart info...');
181
+ $.ajax({
182
+ type: "POST",
183
+ url: baseUrl+"productbook/index/cartinfo",
184
+ // data: 'product='+pid+'&qty='+qty,
185
+ success: function(msg){
186
+ $('#cartInfo').empty().html(msg);
187
+ }
188
+ });
189
+ }
190
+
191
+ //if close button is clicked
192
+ $('.window .close').click(function (e) {
193
+ //Cancel the link behavior
194
+ e.preventDefault();
195
+ $('#product_data').empty();
196
+ $('#mask, .window').hide();
197
+ });
198
+
199
+ });
200
+
201
+ </script>
202
+ <?php
203
+
204
+ /*
205
+ This shows how to load specific fields from a record in the database.
206
+ 1) Note the load(15), this corresponds to saying "select * from table where table_id = 15"
207
+ 2) You can then just use the get(fieldname) to pull specific data from the table.
208
+ 3) If you have a field named news_id, then it becomes getNewsId, etc.
209
+ */
210
+ /*
211
+ $news = Mage::getModel('productbook/productbook')->load(15);
212
+ echo $news->getNewsId();
213
+ echo $news->getTitle();
214
+ echo $news->getContent();
215
+ echo $news->getStatus();
216
+ */
217
+
218
+ /*
219
+ This shows an alternate way of loading datas from a record using the database the "Magento Way" (using blocks and controller).
220
+ Uncomment blocks in /app/code/local/Namespace/Module/controllers/IndexController.php if you want to use it.
221
+
222
+ */
223
+ /*
224
+ $object = $this->getProductbook();
225
+ echo 'id: '.$object['test_id'].'<br/>';
226
+ echo 'title: '.$object['title'].'<br/>';
227
+ echo 'content: '.$object['content'].'<br/>';
228
+ echo 'status: '.$object['status'].'<br/>';
229
+ */
230
+
231
+
232
+ /*
233
+ This shows how to load multiple rows in a collection and save a change to them.
234
+ 1) The setPageSize function will load only 5 records per page and you can set the current Page with the setCurPage function.
235
+ 2) The $collection->walk('save') allows you to save everything in the collection after all changes have been made.
236
+ */
237
+ /*
238
+ $i = 0;
239
+
240
+ $collection = Mage::getModel('productbook/productbook')->getCollection();
241
+ $collection->setPageSize(5);
242
+ $collection->setCurPage(2);
243
+ $size = $collection->getSize();
244
+ $cnt = count($collection);
245
+ foreach ($collection as $item) {
246
+ $i = $i+1;
247
+ $item->setTitle($i);
248
+ echo $item->getTitle();
249
+ }
250
+
251
+ $collection->walk('save');
252
+ */
253
+
254
+ /*
255
+ This shows how to load a single record and save a change.
256
+ 1) Note the setTitle, this corresponds to the table field name, title, and then you pass it the text to change.
257
+ 2) Call the save() function only on a single record.
258
+ */
259
+ /*
260
+ $object = Mage::getModel('productbook/productbook')->load(1);
261
+ $object->setTitle('This is a changed title');
262
+ $object->save();
263
+ */
264
+
265
+ ?>
app/etc/modules/Webspeaks_Productbook.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Webspeaks_Productbook>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Webspeaks_Productbook>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Quickview</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>Extension to view product information and adding products to cart through AJAX. It also allows you to share your product information on various social networking sites.</summary>
10
+ <description>Extension to view product information and adding products to cart through AJAX. It also allows you to share your product information on various social networking sites.</description>
11
+ <notes>It is the stable version without any bug.</notes>
12
+ <authors><author><name>Arvind Bhardwaj</name><user>auto-converted</user><email>bhardwajsonheight@gmail.com</email></author></authors>
13
+ <date>2011-01-17</date>
14
+ <time>12:18:45</time>
15
+ <contents><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="productbook.xml" hash="c07f913531a3ee9213bad1f210026a85"/></dir><dir name="template"><dir name="catalog"><dir name="product"><file name="list.phtml" hash="01771c72f5760bfa50d63846be290f5a"/></dir></dir><dir name="productbook"><file name="productbook.phtml" hash="e3c3c1640647b02c3539d701831e41a2"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webspeaks_Productbook.xml" hash="24796a06a0b6f0e1bda107617ba14a45"/></dir></target><target name="magelocal"><dir name="Webspeaks"><dir name="Productbook"><dir name="Block"><file name="Productbook.php" hash="d618ee1b7bde8e2e860eab17b6d3b64f"/><dir name="Adminhtml"><file name="Productbook.php" hash="bedee405ca0b088ee22026cf3ea0d190"/><dir name="Productbook"><file name="Edit.php" hash="5375ad3376e7a5a24eb932d8df03a720"/><file name="Grid.php" hash="be0e836e7acb7252d6b1d8a57d63bf77"/><dir name="Edit"><file name="Form.php" hash="609834ffa7231b704410bf5d4e310d83"/><file name="Tabs.php" hash="12bbef5287b2182fead9625953c5211d"/><dir name="Tab"><file name="Form.php" hash="08af7c328edc992f7b59ae855c27345e"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="75af5685e1d0e013968e09d147d44c42"/><dir name="Adminhtml"><file name="ProductbookController.php" hash="b0e0482e1fbdba7954fc7ef038d2be5d"/></dir></dir><dir name="etc"><file name="config.xml" hash="6f50e318b68eb7b7073b82e53e8afc21"/></dir><dir name="Helper"><file name="Data.php" hash="88f044abc77bc0e13d5f39bb0db24ead"/></dir><dir name="Model"><file name="Productbook.php" hash="0b888b0de6972fbb5f55a18ff5f9f300"/><file name="Status.php" hash="d4b913d34568c0061df6d41f19819de4"/><dir name="Mysql4"><file name="Productbook.php" hash="6e6cc48bc401632b6cf27a5caf7b1e52"/><dir name="Productbook"><file name="Collection.php" hash="32786643d09f26883d5b8d050c4a70d7"/></dir></dir></dir><dir name="sql"><dir name="productbook_setup"><file name="mysql4-install-0.1.0.php" hash="8bfbbbeb124642bb8154f3b9cbec4903"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>