upload-file-tags - Version 0.1.0

Version Notes

test

Download this release

Release Info

Developer Vitaly
Extension upload-file-tags
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (29) hide show
  1. app/code/local/Freaks/Quotes/Block/Adminhtml/Edit.php +28 -0
  2. app/code/local/Freaks/Quotes/Block/Adminhtml/Edit/Form.php +57 -0
  3. app/code/local/Freaks/Quotes/Block/Adminhtml/Quotes.php +12 -0
  4. app/code/local/Freaks/Quotes/Block/Adminhtml/Quotes/Grid.php +110 -0
  5. app/code/local/Freaks/Quotes/Block/Content.php +20 -0
  6. app/code/local/Freaks/Quotes/Block/Quote/Content.php +13 -0
  7. app/code/local/Freaks/Quotes/Helper/Data.php +4 -0
  8. app/code/local/Freaks/Quotes/Model/Quote.php +74 -0
  9. app/code/local/Freaks/Quotes/Model/Resource/Quote.php +8 -0
  10. app/code/local/Freaks/Quotes/Model/Resource/Quote/Collection.php +8 -0
  11. app/code/local/Freaks/Quotes/controllers/Adminhtml/QuotesController.php +103 -0
  12. app/code/local/Freaks/Quotes/controllers/IndexController.php +27 -0
  13. app/code/local/Freaks/Quotes/etc/adminhtml.xml +22 -0
  14. app/code/local/Freaks/Quotes/etc/config.xml +92 -0
  15. app/code/local/Freaks/Quotes/sql/quotes_setup/mysql4-install-0.1.0.php +15 -0
  16. app/code/local/Magestore/Fgrid/Block/Fgrid.php +34 -0
  17. app/code/local/Magestore/Fgrid/Helper/Data.php +6 -0
  18. app/code/local/Magestore/Fgrid/Model/Fgrid.php +10 -0
  19. app/code/local/Magestore/Fgrid/Model/Mysql4/Fgrid.php +10 -0
  20. app/code/local/Magestore/Fgrid/Model/Mysql4/Fgrid/Collection.php +10 -0
  21. app/code/local/Magestore/Fgrid/Model/Status.php +15 -0
  22. app/code/local/Magestore/Fgrid/controllers/IndexController.php +47 -0
  23. app/code/local/Magestore/Fgrid/etc/config.xml +72 -0
  24. app/code/local/Magestore/Fgrid/sql/fgrid_setup/mysql4-install-0.1.0.php +23 -0
  25. app/code/local/Magestore/etc/config.xml +68 -0
  26. app/design/adminhtml/default/default/layout/fgrid.xml +8 -0
  27. app/design/adminhtml/default/default/layout/freaks/quotes.xml +18 -0
  28. app/etc/modules/Freaks_All.xml +9 -0
  29. package.xml +18 -0
app/code/local/Freaks/Quotes/Block/Adminhtml/Edit.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Block_Adminhtml_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_blockGroup = 'freaks_quotes';
7
+ $this->_mode = 'edit';
8
+ $this->_controller = 'adminhtml';
9
+
10
+ $quote_id = (int)$this->getRequest()->getParam($this->_objectId);
11
+ if(!$quote_id) {
12
+ // Mage::throwException($this->__('Quote with this id does not exists'));
13
+ }
14
+ $quote = Mage::getModel('freaks_quotes/quote')->load($quote_id);
15
+ Mage::register('current_quote', $quote);
16
+ $this->_removeButton('reset');
17
+ }
18
+
19
+ public function getHeaderText()
20
+ {
21
+ $quote = Mage::registry('current_quote');
22
+ if ($quote->getId()) {
23
+ return Mage::helper('freaks_quotes')->__("Edit File Tags '%s'", $this->escapeHtml($quote->getName()));
24
+ } else {
25
+ return Mage::helper('freaks_quotes')->__("Add new File");
26
+ }
27
+ }
28
+ }
app/code/local/Freaks/Quotes/Block/Adminhtml/Edit/Form.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Block_Adminhtml_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $quote = Mage::registry('current_quote');
7
+ $form = new Varien_Data_Form(array(
8
+ 'enctype'=> 'multipart/form-data'
9
+ ));
10
+ $fieldset = $form->addFieldset('edit_quote', array(
11
+ 'legend' => Mage::helper('freaks_quotes')->__('File Tags Details')
12
+ ));
13
+
14
+ if ($quote->getId()) {
15
+ $fieldset->addField('id', 'hidden', array(
16
+ 'name' => 'id',
17
+ 'required' => true
18
+ ));
19
+ }
20
+
21
+ $fieldset->addField('name', 'text', array(
22
+ 'name' => 'name',
23
+ 'title' => Mage::helper('freaks_quotes')->__('Tags'),
24
+ 'label' => Mage::helper('freaks_quotes')->__('Tags'),
25
+ 'maxlength' => '250',
26
+ 'note' => Mage::helper('cms')->__('Format tags (pdf;video;)'),
27
+ 'required' => true,
28
+ ));
29
+
30
+ $fieldset->addField('title', 'text', array(
31
+ 'name' => 'title',
32
+ 'title' => Mage::helper('freaks_quotes')->__('Title'),
33
+ 'label' => Mage::helper('freaks_quotes')->__('Title'),
34
+ 'maxlength' => '250',
35
+ 'note' => Mage::helper('cms')->__('Document title'),
36
+ 'required' => true,
37
+ ));
38
+
39
+ $fieldset->addField('image', 'file', array(
40
+ 'name' => 'image',
41
+ 'label' => Mage::helper('freaks_quotes')->__('File'),
42
+ 'note' => 'Max file size: '.ini_get('upload_max_filesize'),
43
+ ));
44
+
45
+ $form->setMethod('post');
46
+ $form->setUseContainer(true);
47
+ $form->setId('edit_form');
48
+ $form->setAction($this->getUrl('*/*/save'));
49
+
50
+ $data = $quote->getData();
51
+ $data['image'] = $quote->getImage();
52
+
53
+ $form->setValues($data);
54
+
55
+ $this->setForm($form);
56
+ }
57
+ }
app/code/local/Freaks/Quotes/Block/Adminhtml/Quotes.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Block_Adminhtml_Quotes extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_addButtonLabel = Mage::helper('freaks_quotes')->__('Add New File');
7
+
8
+ $this->_blockGroup = 'freaks_quotes';
9
+ $this->_controller = 'adminhtml_quotes';
10
+ $this->_headerText = Mage::helper('freaks_quotes')->__('Upload Files');
11
+ }
12
+ }
app/code/local/Freaks/Quotes/Block/Adminhtml/Quotes/Grid.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Block_Adminhtml_Quotes_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+
5
+ protected function _construct()
6
+ {
7
+ $this->setId('quotesGrid');
8
+ $this->_controller = 'adminhtml_quotes';
9
+ $this->setUseAjax(true);
10
+
11
+ $this->setDefaultSort('id');
12
+ $this->setDefaultDir('desc');
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel('freaks_quotes/quote')->getCollection();
18
+ $this->setCollection($collection);
19
+
20
+ return parent::_prepareCollection();
21
+ }
22
+
23
+ protected function _prepareColumns()
24
+ {
25
+ $this->addColumn('id', array(
26
+ 'header' => Mage::helper('freaks_quotes')->__('ID'),
27
+ 'align' => 'right',
28
+ 'width' => '20px',
29
+ 'filter_index' => 'id',
30
+ 'index' => 'id'
31
+ ));
32
+
33
+ $this->addColumn('name', array(
34
+ 'header' => Mage::helper('freaks_quotes')->__('Tags'),
35
+ 'align' => 'left',
36
+ 'filter_index' => 'name',
37
+ 'index' => 'name',
38
+ 'type' => 'text',
39
+ 'truncate' => 50,
40
+ 'escape' => true,
41
+ ));
42
+
43
+ $this->addColumn('title', array(
44
+ 'header' => Mage::helper('freaks_quotes')->__('Document Title'),
45
+ 'align' => 'left',
46
+ 'filter_index' => 'title',
47
+ 'index' => 'title',
48
+ 'type' => 'text',
49
+ 'truncate' => 50,
50
+ 'escape' => true,
51
+ ));
52
+
53
+ $this->addColumn('image', array(
54
+ 'header' => Mage::helper('freaks_quotes')->__('Filename'),
55
+ 'align' => 'left',
56
+ 'filter_index' => 'name',
57
+ 'index' => 'image',
58
+ 'type' => 'text',
59
+ 'truncate' => 50,
60
+ 'escape' => true,
61
+ ));
62
+
63
+ $this->addColumn('action', array(
64
+ 'header' => Mage::helper('freaks_quotes')->__('Action'),
65
+ 'width' => '50px',
66
+ 'type' => 'action',
67
+ 'getter' => 'getId',
68
+ 'actions' => array(
69
+ array(
70
+ 'caption' => Mage::helper('freaks_quotes')->__('Edit'),
71
+ 'url' => array(
72
+ 'base'=>'*/*/edit',
73
+ ),
74
+ 'field' => 'id'
75
+ )
76
+ ),
77
+ 'filter' => false,
78
+ 'sortable' => false,
79
+ 'index' => 'id',
80
+ ));
81
+
82
+ return parent::_prepareColumns();
83
+ }
84
+
85
+ public function getRowUrl($quotes)
86
+ {
87
+ return $this->getUrl('*/*/edit', array(
88
+ 'id' => $quotes->getId(),
89
+ ));
90
+ }
91
+
92
+ public function getGridUrl()
93
+ {
94
+ return $this->getUrl('*/*/grid', array('_current'=>true));
95
+ }
96
+
97
+ protected function _prepareMassaction()
98
+ {
99
+ $this->setMassactionIdField('quotesGrid_id');
100
+ $this->getMassactionBlock()->setFormFieldName('quotesGrid');
101
+ $this->getMassactionBlock()->addItem('delete', array(
102
+ 'label'=> Mage::helper('freaks_quotes')->__('Delete'),
103
+ 'url' => $this->getUrl('*/*/massDelete', array('' => '')), // public function massDeleteAction() in Mage_Adminhtml_Tax_RateController
104
+ 'confirm' => Mage::helper('freaks_quotes')->__('Are you sure?')
105
+ ));
106
+
107
+ return $this;
108
+ }
109
+
110
+ }
app/code/local/Freaks/Quotes/Block/Content.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Block_Content extends Mage_Core_Block_Template
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setTemplate('freaks/quotes/view.phtml');
7
+ }
8
+
9
+ public function getRowUrl(Freaks_Quotes_Model_Quote $quote)
10
+ {
11
+ return $this->getUrl('*/*/view', array(
12
+ 'id' => $quote->getId()
13
+ ));
14
+ }
15
+
16
+ public function getCollection()
17
+ {
18
+ return Mage::getModel('freaks_quotes/quote')->getCollection();
19
+ }
20
+ }
app/code/local/Freaks/Quotes/Block/Quote/Content.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Block_Quote_Content extends Mage_Core_Block_Template
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setTemplate('freaks/quotes/quote/view.phtml');
7
+ }
8
+
9
+ public function getQuote()
10
+ {
11
+ return Mage::getModel('freaks_quotes/quote')->load($this->getQuoteId());
12
+ }
13
+ }
app/code/local/Freaks/Quotes/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Freaks/Quotes/Model/Quote.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Model_Quote extends Mage_Core_Model_Abstract
3
+ {
4
+ protected $imagePath = 'upload_files';
5
+
6
+ protected function _construct()
7
+ {
8
+ $this->_init('freaks_quotes/quote');
9
+ }
10
+
11
+ protected function _beforeSave()
12
+ {
13
+ if ($this->getData('image/delete')) {
14
+ $this->unsImage();
15
+ }
16
+ try {
17
+ $uploader = new Varien_File_Uploader('image');
18
+ //$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
19
+ $uploader->setAllowRenameFiles(true);
20
+
21
+ $this->setImage($uploader);
22
+ } catch (Exception $e) {
23
+ // it means that we do not have files for uploading
24
+ }
25
+
26
+ return parent::_beforeSave();
27
+ }
28
+
29
+ public function getImagePath()
30
+ {
31
+ return Mage::getBaseDir('media') . DS . $this->imagePath . DS;
32
+ }
33
+
34
+ public function setImage($image)
35
+ {
36
+ if ($image instanceof Varien_File_Uploader) {
37
+ $image->save($this->getImagePath());
38
+ $image = $image->getUploadedFileName();
39
+ }
40
+ $this->setData('image', $image);
41
+ return $this;
42
+ }
43
+
44
+ public function getImage()
45
+ {
46
+ if ($image = $this->getData('image')) {
47
+ return Mage::getBaseUrl('media') . $this->imagePath . DS . $image;
48
+ } else {
49
+ return '';
50
+ }
51
+ }
52
+
53
+ protected function prepareImageForDelete()
54
+ {
55
+ $image = $this->getData('image');
56
+ return str_replace(Mage::getBaseUrl('media'), Mage::getBaseDir('media') . DS, $image['value']);
57
+ }
58
+
59
+ public function unsImage()
60
+ {
61
+ $image = $this->getData('image');
62
+ if (is_array($image)) {
63
+ $image = $this->prepareImageForDelete();
64
+ } else {
65
+ $image = $this->getImagePath() . $image;
66
+ }
67
+
68
+ if (file_exists($image)) {
69
+ unlink($image);
70
+ }
71
+ $this->setData('image', '');
72
+ return $this;
73
+ }
74
+ }
app/code/local/Freaks/Quotes/Model/Resource/Quote.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Model_Resource_Quote extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('freaks_quotes/quote', 'id');
7
+ }
8
+ }
app/code/local/Freaks/Quotes/Model/Resource/Quote/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Model_Resource_Quote_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('freaks_quotes/quote');
7
+ }
8
+ }
app/code/local/Freaks/Quotes/controllers/Adminhtml/QuotesController.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_Adminhtml_QuotesController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->_title($this->__('Upload Files'));
7
+
8
+ $this->loadLayout();
9
+ $this->_setActiveMenu('freaks_quotes');
10
+ $this->_addBreadcrumb(Mage::helper('freaks_quotes')->__('Upload Files'), Mage::helper('freaks_quotes')->__('Upload'));
11
+ $this->renderLayout();
12
+ }
13
+
14
+ public function newAction()
15
+ {
16
+ $this->_title($this->__('Add new file'));
17
+ $this->loadLayout();
18
+ $this->_setActiveMenu('freaks_quotes');
19
+ $this->_addBreadcrumb(Mage::helper('freaks_quotes')->__('Add new file'), Mage::helper('freaks_quotes')->__('Add new file'));
20
+ $this->renderLayout();
21
+ }
22
+
23
+ public function editAction()
24
+ {
25
+ $this->_title($this->__('Edit File Tags'));
26
+
27
+ $this->loadLayout();
28
+ $this->_setActiveMenu('freaks_quotes');
29
+ $this->_addBreadcrumb(Mage::helper('freaks_quotes')->__('Edit tags'), Mage::helper('freaks_quotes')->__('Edit tags'));
30
+ $this->renderLayout();
31
+ }
32
+
33
+ public function deleteAction()
34
+ {
35
+ $tipId = $this->getRequest()->getParam('id', false);
36
+
37
+ try {
38
+ Mage::getModel('freaks_quotes/quote')->setId($tipId)->delete();
39
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('freaks_quotes')->__('File successfully deleted'));
40
+
41
+ return $this->_redirect('*/*/');
42
+ } catch (Mage_Core_Exception $e){
43
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
44
+ } catch (Exception $e) {
45
+ Mage::logException($e);
46
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Somethings went wrong'));
47
+ }
48
+
49
+ $this->_redirectReferer();
50
+ }
51
+
52
+ public function saveAction()
53
+ {
54
+ $data = $this->getRequest()->getPost();
55
+ if (!empty($data)) {
56
+ try {
57
+ Mage::getModel('freaks_quotes/quote')->setData($data)
58
+ ->save();
59
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('freaks_quotes')->__('File successfully saved'));
60
+ } catch (Mage_Core_Exception $e) {
61
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
62
+ } catch (Exception $e) {
63
+ Mage::logException($e);
64
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Somethings went wrong'));
65
+ }
66
+ }
67
+ return $this->_redirect('*/*/');
68
+ }
69
+
70
+ public function gridAction()
71
+ {
72
+ $this->loadLayout();
73
+ $this->getResponse()->setBody(
74
+ $this->getLayout()->createBlock('freaks_quotes/adminhtml_quotes_grid')->toHtml()
75
+ );
76
+ }
77
+
78
+ public function massDeleteAction()
79
+ {
80
+ $taxIds = $this->getRequest()->getParam('quotesGrid'); // $this->getMassactionBlock()->setFormFieldName('tax_id'); from Mage_Adminhtml_Block_Tax_Rate_Grid
81
+ if(!is_array($taxIds))
82
+ {
83
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select file(es).'));
84
+ }
85
+ else
86
+ {
87
+ try
88
+ {
89
+ $rateModel = Mage::getModel('freaks_quotes/quote');
90
+ foreach ($taxIds as $taxId) {
91
+ $rateModel->load($taxId)->delete();
92
+ }
93
+ Mage::getSingleton('adminhtml/session')->addSuccess(
94
+ Mage::helper('tax')->__('Total of %d record(s) were deleted.', count($taxIds)));
95
+ }
96
+ catch (Exception $e) {
97
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
98
+ }
99
+ }
100
+
101
+ $this->_redirect('*/*/index');
102
+ }
103
+ }
app/code/local/Freaks/Quotes/controllers/IndexController.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freaks_Quotes_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout()
7
+ ->renderLayout();
8
+ }
9
+
10
+ public function viewAction()
11
+ {
12
+ $quote_id = (int)$this->getRequest()->getParam('id');
13
+ if (!$quote_id) {
14
+ $this->_forward('noRoute');
15
+ }
16
+ $this->loadLayout();
17
+ $this->getLayout()
18
+ ->getBlock('quote.item')
19
+ ->setQuoteId($quote_id);
20
+ try {
21
+ $this->renderLayout();
22
+ } catch (Exception $e) {
23
+ Mage::logException($e);
24
+ $this->_forward('noRoute');
25
+ }
26
+ }
27
+ }
app/code/local/Freaks/Quotes/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <freaks_quotes translate="title" module="freaks_quotes">
5
+ <title>Upload Files</title>
6
+ <sort_order>55</sort_order>
7
+ <action>adminhtml/quotes</action>
8
+ </freaks_quotes>
9
+ </menu>
10
+ <acl>
11
+ <resources>
12
+ <admin>
13
+ <children>
14
+ <freaks_quotes translate="title" module="freaks_quotes">
15
+ <title>Upload File</title>
16
+ <sort_order>0</sort_order>
17
+ </freaks_quotes>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/local/Freaks/Quotes/etc/config.xml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Freaks_Quotes>
5
+ <version>0.1.0</version>
6
+ </Freaks_Quotes>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <freaks_quotes>
11
+ <class>Freaks_Quotes_Block</class>
12
+ </freaks_quotes>
13
+ </blocks>
14
+ <helpers>
15
+ <freaks_quotes>
16
+ <class>Freaks_Quotes_Helper</class>
17
+ </freaks_quotes>
18
+ </helpers>
19
+ <models>
20
+ <freaks_quotes>
21
+ <class>Freaks_Quotes_Model</class>
22
+ <resourceModel>quotes_resource</resourceModel>
23
+ </freaks_quotes>
24
+ <quotes_resource>
25
+ <class>Freaks_Quotes_Model_Resource</class>
26
+ <entities>
27
+ <quote>
28
+ <table>freaks_quotes</table>
29
+ </quote>
30
+ </entities>
31
+ </quotes_resource>
32
+ </models>
33
+ <resources>
34
+ <quotes_setup>
35
+ <setup>
36
+ <module>Freaks_Quotes</module>
37
+ </setup>
38
+ <connection>
39
+ <use>core_setup</use>
40
+ </connection>
41
+ </quotes_setup>
42
+ <quotes_write>
43
+ <connection>
44
+ <use>core_write</use>
45
+ </connection>
46
+ </quotes_write>
47
+ <quotes_read>
48
+ <connection>
49
+ <use>core_read</use>
50
+ </connection>
51
+ </quotes_read>
52
+ </resources>
53
+ </global>
54
+ <frontend>
55
+ <routers>
56
+ <Freaks_Quotes>
57
+ <use>standard</use>
58
+ <args>
59
+ <module>Freaks_Quotes</module>
60
+ <frontName>quotes</frontName>
61
+ </args>
62
+ </Freaks_Quotes>
63
+ </routers>
64
+ <layout>
65
+ <updates>
66
+ <freaks_quotes>
67
+ <file>freaks/quotes.xml</file>
68
+ </freaks_quotes>
69
+ </updates>
70
+ </layout>
71
+ </frontend>
72
+ <adminhtml>
73
+ <layout>
74
+ <updates>
75
+ <freaks_quotes>
76
+ <file>freaks/quotes.xml</file>
77
+ </freaks_quotes>
78
+ </updates>
79
+ </layout>
80
+ </adminhtml>
81
+ <admin>
82
+ <routers>
83
+ <adminhtml>
84
+ <args>
85
+ <modules>
86
+ <freaks_quotes before="Mage_Adminhtml">Freaks_Quotes_Adminhtml</freaks_quotes>
87
+ </modules>
88
+ </args>
89
+ </adminhtml>
90
+ </routers>
91
+ </admin>
92
+ </config>
app/code/local/Freaks/Quotes/sql/quotes_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $installer->run("
6
+ CREATE TABLE `{$this->getTable('freaks_quotes/quote')}` (
7
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
8
+ `name` varchar(255) NOT NULL,
9
+ `title` varchar(255) NOT NULL,
10
+ `image` varchar(255) NOT NULL,
11
+ PRIMARY KEY (`id`)
12
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
13
+ ");
14
+
15
+ $installer->endSetup();
app/code/local/Magestore/Fgrid/Block/Fgrid.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Fgrid_Block_Fgrid extends Mage_Core_Block_Template
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $tags = $_GET['q'];
8
+ $collection = Mage::getModel('fgrid/fgrid')->getCollection()->addFieldToFilter('name', array('like' => '%'.$tags.'%'));
9
+ $this->setCollection($collection);
10
+ }
11
+
12
+ public function _prepareLayout()
13
+ {
14
+ parent::_prepareLayout();
15
+ $pager= $this->getLayout()->createBlock('page/html_pager', 'fgrid.pager')->setCollection($this->getCollection());
16
+ $this->setChild('pager', $pager);
17
+ return $this;
18
+ }
19
+
20
+ public function getFgrid()
21
+ {
22
+ if (!$this->hasData('fgrid')) {
23
+ $this->setData('fgrid', Mage::registry('fgrid'));
24
+ }
25
+ return $this->getData('fgrid');
26
+
27
+ }
28
+
29
+ public function getPagerHtml()
30
+ {
31
+ return $this->getChildHtml('pager');
32
+ }
33
+
34
+ }
app/code/local/Magestore/Fgrid/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Fgrid_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Magestore/Fgrid/Model/Fgrid.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Fgrid_Model_Fgrid extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('fgrid/fgrid');
9
+ }
10
+ }
app/code/local/Magestore/Fgrid/Model/Mysql4/Fgrid.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Fgrid_Model_Mysql4_Fgrid extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the fgrid_id refers to the key field in your database table.
8
+ $this->_init('fgrid/fgrid', 'fgrid_id');
9
+ }
10
+ }
app/code/local/Magestore/Fgrid/Model/Mysql4/Fgrid/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Fgrid_Model_Mysql4_Fgrid_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('fgrid/fgrid');
9
+ }
10
+ }
app/code/local/Magestore/Fgrid/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Fgrid_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('fgrid')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('fgrid')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Magestore/Fgrid/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Fgrid_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/fgrid?id=15
11
+ * or
12
+ * http://site.com/fgrid/id/15
13
+ */
14
+ /*
15
+ $fgrid_id = $this->getRequest()->getParam('id');
16
+
17
+ if($fgrid_id != null && $fgrid_id != '') {
18
+ $fgrid = Mage::getModel('fgrid/fgrid')->load($fgrid_id)->getData();
19
+ } else {
20
+ $fgrid = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($fgrid == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $fgridTable = $resource->getTableName('fgrid');
32
+
33
+ $select = $read->select()
34
+ ->from($fgridTable,array('fgrid_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $fgrid = $read->fetchRow($select);
39
+ }
40
+ Mage::register('fgrid', $fgrid);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Magestore/Fgrid/etc/config.xml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magestore_Fgrid>
5
+ <version>0.1.0</version>
6
+ </Magestore_Fgrid>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <fgrid>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Magestore_Fgrid</module>
14
+ <frontName>download-files</frontName>
15
+ </args>
16
+ </fgrid>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <fgrid>
21
+ <file>fgrid.xml</file>
22
+ </fgrid>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <models>
28
+ <fgrid>
29
+ <class>Magestore_Fgrid_Model</class>
30
+ <resourceModel>fgrid_mysql4</resourceModel>
31
+ </fgrid>
32
+ <fgrid_mysql4>
33
+ <class>Magestore_Fgrid_Model_Mysql4</class>
34
+ <entities>
35
+ <fgrid>
36
+ <table>freaks_quotes</table>
37
+ </fgrid>
38
+ </entities>
39
+ </fgrid_mysql4>
40
+ </models>
41
+ <resources>
42
+ <fgrid_setup>
43
+ <setup>
44
+ <module>Magestore_Fgrid</module>
45
+ </setup>
46
+ <connection>
47
+ <use>core_setup</use>
48
+ </connection>
49
+ </fgrid_setup>
50
+ <fgrid_write>
51
+ <connection>
52
+ <use>core_write</use>
53
+ </connection>
54
+ </fgrid_write>
55
+ <fgrid_read>
56
+ <connection>
57
+ <use>core_read</use>
58
+ </connection>
59
+ </fgrid_read>
60
+ </resources>
61
+ <blocks>
62
+ <fgrid>
63
+ <class>Magestore_Fgrid_Block</class>
64
+ </fgrid>
65
+ </blocks>
66
+ <helpers>
67
+ <fgrid>
68
+ <class>Magestore_Fgrid_Helper</class>
69
+ </fgrid>
70
+ </helpers>
71
+ </global>
72
+ </config>
app/code/local/Magestore/Fgrid/sql/fgrid_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('fgrid')};
10
+ CREATE TABLE {$this->getTable('fgrid')} (
11
+ `fgrid_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 (`fgrid_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+ $installer->endSetup();
app/code/local/Magestore/etc/config.xml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magestore_>
5
+ <version>0.1.0</version>
6
+ </Magestore_>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Magestore_</module>
14
+ <frontName></frontName>
15
+ </args>
16
+ </>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <menu>
21
+ < module="">
22
+ <title>Fgrid</title>
23
+ <sort_order>71</sort_order>
24
+ <children>
25
+ <items module="">
26
+ <title>Manage Items</title>
27
+ <sort_order>0</sort_order>
28
+ <action>/fgrid</action>
29
+ </items>
30
+ </children>
31
+ </>
32
+ </menu>
33
+ <acl>
34
+ <resources>
35
+ <all>
36
+ <title>Allow Everything</title>
37
+ </all>
38
+ <admin>
39
+ <children>
40
+ <Magestore_>
41
+ <title>Fgrid Module</title>
42
+ <sort_order>10</sort_order>
43
+ </Magestore_>
44
+ </children>
45
+ </admin>
46
+ </resources>
47
+ </acl>
48
+ <layout>
49
+ <updates>
50
+ <>
51
+ <file>.xml</file>
52
+ </>
53
+ </updates>
54
+ </layout>
55
+ </adminhtml>
56
+ <global>
57
+ <blocks>
58
+ <>
59
+ <class>Magestore__Block</class>
60
+ </>
61
+ </blocks>
62
+ <helpers>
63
+ <>
64
+ <class>Magestore__Helper</class>
65
+ </>
66
+ </helpers>
67
+ </global>
68
+ </config>
app/design/adminhtml/default/default/layout/fgrid.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <fgrid_adminhtml_fgrid_index>
4
+ <reference name="content">
5
+ <block type="fgrid/adminhtml_fgrid" name="fgrid" />
6
+ </reference>
7
+ </fgrid_adminhtml_fgrid_index>
8
+ </layout>
app/design/adminhtml/default/default/layout/freaks/quotes.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_quotes_index>
4
+ <reference name="content">
5
+ <block type="freaks_quotes/adminhtml_quotes" name="quotes.grid_container" />
6
+ </reference>
7
+ </adminhtml_quotes_index>
8
+
9
+ <adminhtml_quotes_new>
10
+ <update handle="adminhtml_quotes_edit"/>
11
+ </adminhtml_quotes_new>
12
+
13
+ <adminhtml_quotes_edit>
14
+ <reference name="content">
15
+ <block type="freaks_quotes/adminhtml_edit" name="quotes.edit" />
16
+ </reference>
17
+ </adminhtml_quotes_edit>
18
+ </layout>
app/etc/modules/Freaks_All.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Freaks_Quotes>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Freaks_Quotes>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>upload-file-tags</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>open source</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>test</summary>
10
+ <description>test</description>
11
+ <notes>test</notes>
12
+ <authors><author><name>Vitaly</name><user>Vitaly</user><email>v.morozov@interesnee.ru</email></author></authors>
13
+ <date>2014-06-19</date>
14
+ <time>08:54:38</time>
15
+ <contents><target name="magelocal"><dir name="Freaks"><dir><dir name="Quotes"><dir name="Block"><dir name="Adminhtml"><dir name="Edit"><file name="Form.php" hash="cc87c7842fa29e951e0aab9c4a3159fd"/></dir><file name="Edit.php" hash="7d6dd8f97368adc16d1e7d4d08778bd7"/><dir name="Quotes"><file name="Grid.php" hash="c8917404c387757ecfb45de73aee66e4"/></dir><file name="Quotes.php" hash="b83e8a10619c25828e42bf729b3ba417"/></dir><file name="Content.php" hash="629da41c84fa0c872475b08a73660efb"/><dir name="Quote"><file name="Content.php" hash="c4048e9054a7d15021d56f431ad6ea8c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="db40438ce5ff268f6fcab95de55fa3b2"/></dir><dir name="Model"><file name="Quote.php" hash="8f0e8a8782914ad3e3effaefa48ee988"/><dir name="Resource"><dir name="Quote"><file name="Collection.php" hash="b9603de0a76a4b6fbce0239393ba65bc"/></dir><file name="Quote.php" hash="9263ac9fc539b8be1a804315de79ff7b"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="QuotesController.php" hash="65143799b4ce9332eb06e02eb38ca6cf"/></dir><file name="IndexController.php" hash="0c2799665be433b46943628b9949e8b6"/></dir><dir name="etc"><file name="adminhtml.xml" hash="08a8f1faa12a4e62ebcb077d6512d838"/><file name="config.xml" hash="04b216ee364de10f715e3ee9e5f7c48c"/></dir><dir name="sql"><dir name="quotes_setup"><file name="mysql4-install-0.1.0.php" hash="7c3a76fcb789119054626e0f821103d4"/></dir></dir></dir></dir></dir><dir name="Magestore"><dir><dir name="Fgrid"><dir name="Block"><file name="Fgrid.php" hash="4912be1bc6af98feaea65f4b078d4ede"/></dir><dir name="Helper"><file name="Data.php" hash="f1606b88b5e07d1a4f2f3c3a45ebefff"/></dir><dir name="Model"><file name="Fgrid.php" hash="273d7832b7f3ade3a222ed6d57f28b0d"/><dir name="Mysql4"><dir name="Fgrid"><file name="Collection.php" hash="0aa4cf0d88a89de990298ddcb6d6e3f5"/></dir><file name="Fgrid.php" hash="18a75313218f2460168951519f9819cf"/></dir><file name="Status.php" hash="818d0af801f97d9001d3573a5ab02271"/></dir><dir name="controllers"><file name="IndexController.php" hash="fd55c4ab6062a3cc2892472c4477a28e"/></dir><dir name="etc"><file name="config.xml" hash="d8b610f42b835be9db986613defbcf16"/></dir><dir name="sql"><dir name="fgrid_setup"><file name="mysql4-install-0.1.0.php" hash="f0a9f96bcaa824875accf08537d0250f"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="61a71d0d1bdfe0997e50e8bea8d7c11d"/></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><file name="fgrid.xml" hash=""/><dir name="layout"><file name="fgrid.xml" hash=""/></dir></dir></dir></dir><dir name="modules"><file name="Magestore_Fgrid.xml" hash=""/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="freaks"><file name="quotes.xml" hash="b2e8e5bcf917e273d000038d68cd3244"/></dir><file name="fgrid.xml" hash="529c16d57bd2e9fc7bbf8f9674fb47ce"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Freaks_All.xml" hash="d94fcb7e6f8955c964839aeeb41a26b3"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>5.4.13</max></php></required></dependencies>
18
+ </package>