Virtina_Attachments - Version 0.0.1

Version Notes

The Catalog Attachments is an extension for magento to upload product related files (Product manuals, guides, images or videos etc...) through admin panel and display the files in the product view page. There is a configuration section in the admin side to configure the module. The extension is responsive and will support in all common browsers and in different resolutions.

Download this release

Release Info

Developer Virtina
Extension Virtina_Attachments
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (74) hide show
  1. app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment.php +20 -0
  2. app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit.php +48 -0
  3. app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit/Form.php +34 -0
  4. app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit/Tab/Form.php +79 -0
  5. app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit/Tab/Product.php +194 -0
  6. app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit/Tabs.php +52 -0
  7. app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Grid.php +140 -0
  8. app/code/community/Virtina/Attachments/Block/Adminhtml/Catalog/Column/Renderer/Relation.php +43 -0
  9. app/code/community/Virtina/Attachments/Block/Adminhtml/Catalog/Product/Edit/Tab/Attachment.php +177 -0
  10. app/code/community/Virtina/Attachments/Block/Adminhtml/Helper/File.php +94 -0
  11. app/code/community/Virtina/Attachments/Block/Attachment.php +27 -0
  12. app/code/community/Virtina/Attachments/Block/Attachment/List.php +39 -0
  13. app/code/community/Virtina/Attachments/Helper/Attachment.php +36 -0
  14. app/code/community/Virtina/Attachments/Helper/Data.php +41 -0
  15. app/code/community/Virtina/Attachments/Helper/Product.php +39 -0
  16. app/code/community/Virtina/Attachments/Model/Adminhtml/Observer.php +67 -0
  17. app/code/community/Virtina/Attachments/Model/Attachment.php +49 -0
  18. app/code/community/Virtina/Attachments/Model/Attachmentproduct.php +46 -0
  19. app/code/community/Virtina/Attachments/Model/Mysql4/Attachment.php +16 -0
  20. app/code/community/Virtina/Attachments/Model/Mysql4/Attachment/Collection.php +42 -0
  21. app/code/community/Virtina/Attachments/Model/Mysql4/Attachmentproduct.php +16 -0
  22. app/code/community/Virtina/Attachments/Model/Mysql4/Attachmentproduct/Collection.php +16 -0
  23. app/code/community/Virtina/Attachments/Model/System/Config/Source/Truefalse.php +19 -0
  24. app/code/community/Virtina/Attachments/controllers/Adminhtml/Attachments/Attachment/Catalog/ProductController.php +38 -0
  25. app/code/community/Virtina/Attachments/controllers/Adminhtml/Attachments/AttachmentController.php +388 -0
  26. app/code/community/Virtina/Attachments/etc/adminhtml.xml +52 -0
  27. app/code/community/Virtina/Attachments/etc/config.xml +151 -0
  28. app/code/community/Virtina/Attachments/etc/system.xml +92 -0
  29. app/code/community/Virtina/Attachments/sql/attachments_setup/mysql4-install-0.0.1.php +38 -0
  30. app/code/community/Virtina/Attachments/sql/vattachments_setup/mysql4-install-0.0.1.php +38 -0
  31. app/design/adminhtml/default/default/layout/catalog-attachments.xml +100 -0
  32. app/design/frontend/base/default/layout/catalog-attachments.xml +24 -0
  33. app/design/frontend/base/default/template/catalog-attachment/catalog-attachment.phtml +114 -0
  34. app/etc/modules/Virtina_Attachments.xml +20 -0
  35. app/locale/en_US/Virtina_Attachments.csv +55 -0
  36. media/catalog-attachment/icons/3gp.png +0 -0
  37. media/catalog-attachment/icons/avi.png +0 -0
  38. media/catalog-attachment/icons/bmp.png +0 -0
  39. media/catalog-attachment/icons/css.png +0 -0
  40. media/catalog-attachment/icons/csv.png +0 -0
  41. media/catalog-attachment/icons/default.png +0 -0
  42. media/catalog-attachment/icons/doc.png +0 -0
  43. media/catalog-attachment/icons/docx.png +0 -0
  44. media/catalog-attachment/icons/flv.png +0 -0
  45. media/catalog-attachment/icons/gif.png +0 -0
  46. media/catalog-attachment/icons/htm.png +0 -0
  47. media/catalog-attachment/icons/html.png +0 -0
  48. media/catalog-attachment/icons/jpeg.png +0 -0
  49. media/catalog-attachment/icons/jpg.png +0 -0
  50. media/catalog-attachment/icons/mov.png +0 -0
  51. media/catalog-attachment/icons/mp3.png +0 -0
  52. media/catalog-attachment/icons/mp4.png +0 -0
  53. media/catalog-attachment/icons/odf.png +0 -0
  54. media/catalog-attachment/icons/odt.png +0 -0
  55. media/catalog-attachment/icons/pdf.png +0 -0
  56. media/catalog-attachment/icons/plain.png +0 -0
  57. media/catalog-attachment/icons/png.png +0 -0
  58. media/catalog-attachment/icons/ppt.png +0 -0
  59. media/catalog-attachment/icons/pptx.png +0 -0
  60. media/catalog-attachment/icons/psd.png +0 -0
  61. media/catalog-attachment/icons/rar.png +0 -0
  62. media/catalog-attachment/icons/rtf.png +0 -0
  63. media/catalog-attachment/icons/sql.png +0 -0
  64. media/catalog-attachment/icons/swf.png +0 -0
  65. media/catalog-attachment/icons/tiff.png +0 -0
  66. media/catalog-attachment/icons/txt.png +0 -0
  67. media/catalog-attachment/icons/wav.png +0 -0
  68. media/catalog-attachment/icons/wmv.png +0 -0
  69. media/catalog-attachment/icons/xls.png +0 -0
  70. media/catalog-attachment/icons/xlsx.png +0 -0
  71. media/catalog-attachment/icons/xml.png +0 -0
  72. media/catalog-attachment/icons/zip.png +0 -0
  73. package.xml +18 -0
  74. skin/frontend/base/default/css/catalog-attachments/catalog-attachment.css +32 -0
app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment admin block
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Attachment extends Mage_Adminhtml_Block_Widget_Grid_Container {
10
+
11
+ # Constructor
12
+ public function __construct() {
13
+ $this->_controller = 'adminhtml_attachment';
14
+ $this->_blockGroup = 'attachments';
15
+ parent::__construct();
16
+ $this->_headerText = Mage::helper('attachments')->__('Manage Attachments');
17
+ $this->_updateButton('add', 'label', Mage::helper('attachments')->__('Add Attachment'));
18
+ }
19
+
20
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment admin edit form
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Attachment_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
10
+
11
+ # Constructor
12
+ public function __construct() {
13
+ parent::__construct();
14
+ $this->_blockGroup = 'attachments';
15
+ $this->_controller = 'adminhtml_attachment';
16
+
17
+ $this->_updateButton('save', 'label', Mage::helper('attachments')->__('Save') );
18
+ $this->_updateButton('delete', 'label', Mage::helper('attachments')->__('Delete Attachment') );
19
+ $this->_addButton('saveandcontinue',
20
+ array(
21
+ 'label' => Mage::helper('attachments')->__('Save And Continue Edit'),
22
+ 'onclick' => 'saveAndContinueEdit()',
23
+ 'class' => 'save',
24
+ ),
25
+ -200
26
+ );
27
+
28
+ $this->_formScripts[] = "
29
+ function saveAndContinueEdit() {
30
+ editForm.submit($('edit_form').action+'back/edit/');
31
+ }
32
+ ";
33
+ }
34
+
35
+ # Get the edit form header
36
+ public function getHeaderText() {
37
+
38
+ if (Mage::registry('current_attachment') && Mage::registry('current_attachment')->getId()) {
39
+
40
+ return Mage::helper('attachments')->__("Edit Attachment '%s'", $this->escapeHtml(Mage::registry('current_attachment')->getTitle()));
41
+
42
+ } else {
43
+ return Mage::helper('attachments')->__('Add Attachment');
44
+ }
45
+
46
+ }
47
+
48
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit/Form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment edit form
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Attachment_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
10
+
11
+ # Prepare form
12
+ protected function _prepareForm() {
13
+
14
+ $form = new Varien_Data_Form(
15
+ array(
16
+ 'id' => 'edit_form',
17
+ 'action' => $this->getUrl(
18
+ '*/*/save',
19
+ array(
20
+ 'id' => $this->getRequest()->getParam('id')
21
+ )
22
+ ),
23
+ 'method' => 'post',
24
+ 'enctype' => 'multipart/form-data'
25
+ )
26
+ );
27
+
28
+ $form->setUseContainer(true);
29
+ $this->setForm($form);
30
+ return parent::_prepareForm();
31
+
32
+ }
33
+
34
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit/Tab/Form.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment edit form tab
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
10
+
11
+ # Prepare the form
12
+ protected function _prepareForm() {
13
+
14
+ $form = new Varien_Data_Form();
15
+ $form->setHtmlIdPrefix('attachment_');
16
+ $form->setFieldNameSuffix('attachment');
17
+ $this->setForm($form);
18
+
19
+ $fieldset = $form->addFieldset('attachment_form', array('legend' => Mage::helper('attachments')->__('Attachment Info')));
20
+ $fieldset->addType('file', Mage::getConfig()->getBlockClassName('attachments/adminhtml_helper_file'));
21
+ $fieldset->addField('title', 'text',
22
+ array(
23
+ 'label' => Mage::helper('attachments')->__('Title'),
24
+ 'name' => 'title',
25
+ 'required' => true,
26
+ 'class' => 'required-entry',
27
+ )
28
+ );
29
+
30
+ $fieldset->addField(
31
+ 'uploaded_file', 'file',
32
+ array(
33
+ 'label' => Mage::helper('attachments')->__('Uploaded file'),
34
+ 'name' => 'uploaded_file',
35
+ 'required' => $this->getRequest()->getParam('id') ? false:true,
36
+ 'class' => $this->getRequest()->getParam('id') ? '':'required-entry',
37
+ )
38
+ );
39
+
40
+ $fieldset->addField(
41
+ 'status',
42
+ 'select',
43
+ array(
44
+ 'label' => Mage::helper('attachments')->__('Status'),
45
+ 'name' => 'status',
46
+ 'values' => array(
47
+ array(
48
+ 'value' => 1,
49
+ 'label' => Mage::helper('attachments')->__('Enabled'),
50
+ ),
51
+ array(
52
+ 'value' => 0,
53
+ 'label' => Mage::helper('attachments')->__('Disabled'),
54
+ ),
55
+ ),
56
+ )
57
+ );
58
+
59
+ $formValues = Mage::registry('current_attachment')->getDefaultValues();
60
+
61
+ if (!is_array($formValues)) {
62
+ $formValues = array();
63
+ }
64
+
65
+ if (Mage::getSingleton('adminhtml/session')->getAttachmentData()) {
66
+ $formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAttachmentData());
67
+ Mage::getSingleton('adminhtml/session')->setAttachmentData(null);
68
+ }elseif (Mage::registry('current_attachment')) {
69
+ $formValues = array_merge($formValues, Mage::registry('current_attachment')->getData());
70
+ }
71
+
72
+ $form->setValues($formValues);
73
+
74
+ return parent::_prepareForm();
75
+
76
+ }
77
+
78
+
79
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit/Tab/Product.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment - product relation edit block
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid {
10
+
11
+ # Constructors
12
+ public function __construct() {
13
+ parent::__construct();
14
+ $this->setId('product_grid');
15
+ $this->setDefaultSort('entity_id');
16
+ $this->setDefaultDir('desc');
17
+ $this->setUseAjax(true);
18
+
19
+ if ($this->getAttachment()->getId()) {
20
+ $this->setDefaultFilter(array('in_products'=>1));
21
+ }
22
+ }
23
+
24
+ # Prepare the product collection
25
+ protected function _prepareCollection() {
26
+ $admnStore = Mage_Core_Model_App::ADMIN_STORE_ID;
27
+
28
+ $collection = Mage::getResourceModel('catalog/product_collection');
29
+ $collection->addAttributeToSelect('price');
30
+ $collection->joinAttribute('product_name', 'catalog_product/name', 'entity_id', null, 'left', $admnStore);
31
+
32
+ if ($this->getAttachment()->getId()) {
33
+ $constraint = '{{table}}.attachment_id='.$this->getAttachment()->getId();
34
+ }else{
35
+ $constraint = '{{table}}.attachment_id=0';
36
+ }
37
+
38
+ $collection->joinField('position', 'attachments/attachmentproduct', 'position', 'product_id=entity_id', $constraint, 'left');
39
+ $this->setCollection($collection);
40
+ parent::_prepareCollection();
41
+ return $this;
42
+ }
43
+
44
+ # Prepare mass action grid
45
+ protected function _prepareMassaction() {
46
+ return $this;
47
+ }
48
+
49
+ # Prepare the grid columns
50
+ protected function _prepareColumns() {
51
+
52
+ $this->addColumn('in_products',
53
+ array(
54
+ 'header_css_class' => 'a-center',
55
+ 'type' => 'checkbox',
56
+ 'name' => 'in_products',
57
+ 'values'=> $this->_getSelectedProducts(),
58
+ 'align' => 'center',
59
+ 'index' => 'entity_id'
60
+ )
61
+ );
62
+
63
+ $this->addColumn('entity_id',
64
+ array(
65
+ 'header' => Mage::helper('catalog')->__('ID'),
66
+ 'width' => 50,
67
+ 'align' => 'left',
68
+ 'index' => 'entity_id',
69
+ )
70
+ );
71
+
72
+ $this->addColumn('product_name',
73
+ array(
74
+ 'header' => Mage::helper('catalog')->__('Name'),
75
+ 'align' => 'left',
76
+ 'index' => 'product_name',
77
+ 'renderer' => 'attachments/adminhtml_catalog_column_renderer_relation',
78
+ 'params' => array('id' => 'getId'),
79
+ 'base_link' => 'adminhtml/catalog_product/edit',
80
+ )
81
+ );
82
+
83
+ $this->addColumn('sku',
84
+ array(
85
+ 'header' => Mage::helper('catalog')->__('SKU'),
86
+ 'align' => 'left',
87
+ 'index' => 'sku',
88
+ )
89
+ );
90
+
91
+ $this->addColumn('price',
92
+ array(
93
+ 'header' => Mage::helper('catalog')->__('Price'),
94
+ 'type' => 'currency',
95
+ 'width' => '1',
96
+ 'currency_code' => (string)Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
97
+ 'index' => 'price'
98
+ )
99
+ );
100
+
101
+ $this->addColumn('position',
102
+ array(
103
+ 'header' => Mage::helper('catalog')->__('Position'),
104
+ 'name' => 'position',
105
+ 'width' => 60,
106
+ 'type' => 'number',
107
+ 'validate_class' => 'validate-number',
108
+ 'index' => 'position',
109
+ 'editable' => true,
110
+ )
111
+ );
112
+
113
+ }
114
+
115
+ # Retrieve selected products
116
+ protected function _getSelectedProducts() {
117
+ $products = $this->getAttachmentProducts();
118
+
119
+ if (!is_array($products)) {
120
+ $products = array_keys($this->getSelectedProducts());
121
+ }
122
+
123
+ return $products;
124
+
125
+ }
126
+
127
+ # Retrieve selected products
128
+ public function getSelectedProducts() {
129
+
130
+ $products = array();
131
+ /* $selected = Mage::registry('current_attachment')->getSelectedProducts();
132
+
133
+ if (!is_array($selected)) {
134
+ $selected = array();
135
+ }
136
+ */
137
+ $attachmentId = $this->getRequest()->getParam('id');
138
+ if(!isset($attachmentId)) {
139
+ $attachmentId = 0;
140
+ }
141
+
142
+ $collection = Mage::getModel('attachments/attachmentproduct')->getCollection();
143
+ $collection->addFieldToFilter('attachment_id', $attachmentId);
144
+
145
+ foreach ($collection as $product) {
146
+ $products[$product->getProductId()] = array('position' => $product->getPosition());
147
+ }
148
+
149
+ return $products;
150
+
151
+ }
152
+
153
+ # Get row URL
154
+ public function getRowUrl($item) {
155
+ return '#';
156
+ }
157
+
158
+ # Get grid URL
159
+ public function getGridUrl() {
160
+ return $this->getUrl('*/*/productsGrid', array('id' => $this->getAttachment()->getId()));
161
+ }
162
+
163
+ # Get the current attachment
164
+ public function getAttachment() {
165
+ return Mage::registry('current_attachment');
166
+ }
167
+
168
+ # Add filter
169
+ protected function _addColumnFilterToCollection($column) {
170
+
171
+ # Set custom filter, in product flag
172
+ if ($column->getId() == 'in_products') {
173
+ $productIds = $this->_getSelectedProducts();
174
+ if (empty($productIds)) {
175
+ $productIds = 0;
176
+ }
177
+
178
+ if ($column->getFilter()->getValue()) {
179
+ $this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds));
180
+ }else{
181
+ if ($productIds) {
182
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds));
183
+ }
184
+ }
185
+
186
+ }else{
187
+ parent::_addColumnFilterToCollection($column);
188
+ }
189
+
190
+ return $this;
191
+
192
+ }
193
+
194
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Edit/Tabs.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment admin edit tabs
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Attachment_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
10
+
11
+ # Constructors
12
+ public function __construct() {
13
+ parent::__construct();
14
+ $this->setId('attachment_tabs');
15
+ $this->setDestElementId('edit_form');
16
+ $this->setTitle(Mage::helper('attachments')->__('Attachment Details'));
17
+ }
18
+
19
+ # Before render HTML
20
+ protected function _beforeToHtml() {
21
+
22
+ $this->addTab(
23
+ 'form_attachment',
24
+ array(
25
+ 'label' => Mage::helper('attachments')->__('Attachment Info'),
26
+ 'title' => Mage::helper('attachments')->__('Attachment Info'),
27
+ 'content' => $this->getLayout()->createBlock('attachments/adminhtml_attachment_edit_tab_form'
28
+ )
29
+ ->toHtml(),
30
+ )
31
+ );
32
+
33
+ $this->addTab(
34
+ 'products',
35
+ array(
36
+ 'label' => Mage::helper('attachments')->__('Associated Products'),
37
+ 'url' => $this->getUrl('*/*/products', array('_current' => true)),
38
+ 'class' => 'ajax'
39
+ )
40
+ );
41
+
42
+ return parent::_beforeToHtml();
43
+
44
+ }
45
+
46
+ # Retrieve attachment
47
+ public function getAttachment() {
48
+ return Mage::registry('current_attachment');
49
+ }
50
+
51
+
52
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Attachment/Grid.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment admin grid block
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Attachment_Grid extends Mage_Adminhtml_Block_Widget_Grid {
10
+
11
+ # Constructor
12
+ public function __construct(){
13
+ parent::__construct();
14
+ $this->setId('attachmentGrid');
15
+ $this->setDefaultSort('entity_id');
16
+ $this->setDefaultDir('ASC');
17
+ $this->setSaveParametersInSession(true);
18
+ $this->setUseAjax(true);
19
+ }
20
+
21
+ # Prepare collection
22
+ protected function _prepareCollection(){
23
+ $collection = Mage::getModel('attachments/attachment')->getCollection();
24
+
25
+ $this->setCollection($collection);
26
+ return parent::_prepareCollection();
27
+ }
28
+
29
+ # Prepare grid collection
30
+ protected function _prepareColumns() {
31
+
32
+ $this->addColumn(
33
+ 'entity_id',
34
+ array(
35
+ 'header' => Mage::helper('attachments')->__('ID'),
36
+ 'index' => 'entity_id',
37
+ 'type' => 'number'
38
+ )
39
+ );
40
+
41
+ $this->addColumn(
42
+ 'title',
43
+ array(
44
+ 'header' => Mage::helper('attachments')->__('Title'),
45
+ 'align' => 'left',
46
+ 'index' => 'title',
47
+ )
48
+ );
49
+
50
+ $this->addColumn(
51
+ 'status',
52
+ array(
53
+ 'header' => Mage::helper('attachments')->__('Status'),
54
+ 'index' => 'status',
55
+ 'type' => 'options',
56
+ 'options' => array(
57
+ '1' => Mage::helper('attachments')->__('Enabled'),
58
+ '0' => Mage::helper('attachments')->__('Disabled'),
59
+ )
60
+ )
61
+ );
62
+
63
+ $this->addColumn(
64
+ 'action',
65
+ array(
66
+ 'header' => Mage::helper('attachments')->__('Action'),
67
+ 'width' => '100',
68
+ 'type' => 'action',
69
+ 'getter' => 'getId',
70
+ 'actions' => array(
71
+ array(
72
+ 'caption' => Mage::helper('attachments')->__('Edit'),
73
+ 'url' => array('base'=> '*/*/edit'),
74
+ 'field' => 'id'
75
+ )
76
+ ),
77
+ 'filter' => false,
78
+ 'is_system' => true,
79
+ 'sortable' => false,
80
+ )
81
+ );
82
+
83
+ return parent::_prepareColumns();
84
+
85
+ }
86
+
87
+ # Prepare mass action
88
+ protected function _prepareMassaction() {
89
+ $this->setMassactionIdField('entity_id');
90
+ $this->getMassactionBlock()->setFormFieldName('attachment');
91
+ $this->getMassactionBlock()->addItem(
92
+ 'delete',
93
+ array(
94
+ 'label'=> Mage::helper('attachments')->__('Delete Attachment'),
95
+ 'url' => $this->getUrl('*/*/massDelete'),
96
+ 'confirm' => Mage::helper('attachments')->__('Do you want to delete the attachment(s)?')
97
+ )
98
+ );
99
+
100
+ $this->getMassactionBlock()->addItem(
101
+ 'status',
102
+ array(
103
+ 'label' => Mage::helper('attachments')->__('Change Status'),
104
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
105
+ 'additional' => array(
106
+ 'status' => array(
107
+ 'name' => 'status',
108
+ 'type' => 'select',
109
+ 'class' => 'required-entry',
110
+ 'label' => Mage::helper('attachments')->__('Status'),
111
+ 'values' => array(
112
+ '1' => Mage::helper('attachments')->__('Enabled'),
113
+ '0' => Mage::helper('attachments')->__('Disabled'),
114
+ )
115
+ )
116
+ )
117
+ )
118
+ );
119
+
120
+ return $this;
121
+ }
122
+
123
+ # After collection load
124
+ protected function _afterLoadCollection() {
125
+ $this->getCollection()->walk('afterLoad');
126
+ parent::_afterLoadCollection();
127
+ }
128
+
129
+ # Get the grid URL
130
+ public function getGridUrl() {
131
+ return $this->getUrl('*/*/grid', array('_current'=>true));
132
+ }
133
+
134
+ # Get the row URL
135
+ public function getRowUrl($row) {
136
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
137
+ }
138
+
139
+
140
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Catalog/Column/Renderer/Relation.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * related entities column renderer
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_catalog_Column_Renderer_Relation extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text {
10
+
11
+ # Render the column
12
+ public function render(Varien_Object $row) {
13
+
14
+ $base = $this->getColumn()->getBaseLink();
15
+
16
+ if (!$base) {
17
+ return parent::render($row);
18
+ }
19
+
20
+ $paramsData = $this->getColumn()->getData('params');
21
+ $params = array();
22
+
23
+ if (is_array($paramsData)) {
24
+ foreach ($paramsData as $name=>$getter) {
25
+ if (is_callable(array($row, $getter))) {
26
+ $params[$name] = call_user_func(array($row, $getter));
27
+ }
28
+ }
29
+ }
30
+
31
+ $staticParamsData = $this->getColumn()->getData('static');
32
+
33
+ if (is_array($staticParamsData)) {
34
+ foreach ($staticParamsData as $key=>$value) {
35
+ $params[$key] = $value;
36
+ }
37
+ }
38
+
39
+ return '<a href="'.$this->getUrl($base, $params).'" target="_blank">'.$this->_getValue($row).'</a>';
40
+
41
+ }
42
+
43
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Catalog/Product/Edit/Tab/Attachment.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment tab on product edit form
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Catalog_Product_Edit_Tab_Attachment extends Mage_Adminhtml_Block_Widget_Grid {
10
+
11
+ # Constructor
12
+ public function __construct() {
13
+
14
+ parent::__construct();
15
+ $this->setId('attachment_grid');
16
+ $this->setDefaultSort('entity_id');
17
+ $this->setDefaultDir('desc');
18
+ $this->setUseAjax(true);
19
+
20
+ if ($this->getProduct()->getId()) {
21
+ $this->setDefaultFilter(array('in_attachments'=>1));
22
+ }
23
+
24
+ }
25
+
26
+ # Prepare the attachment collection
27
+ protected function _prepareCollection() {
28
+
29
+ $collection = Mage::getResourceModel('attachments/attachment_collection');
30
+
31
+ if($this->getProduct()->getId()) {
32
+ $constraint = 'related.product_id='.$this->getProduct()->getId();
33
+ }else{
34
+ $constraint = 'related.product_id=0';
35
+ }
36
+
37
+ $collection->getSelect()->joinLeft(
38
+ array('related' => $collection->getTable('attachments/attachmentproduct')),
39
+ 'related.attachment_id=main_table.entity_id AND '.$constraint,
40
+ array('position')
41
+ );
42
+
43
+ $this->setCollection($collection);
44
+ parent::_prepareCollection();
45
+ return $this;
46
+
47
+ }
48
+
49
+ # Prepare mass action grid
50
+ protected function _prepareMassaction() {
51
+ return $this;
52
+ }
53
+
54
+ # Prepare the grid columns
55
+ protected function _prepareColumns() {
56
+
57
+ $this->addColumn('in_attachments',
58
+ array(
59
+ 'header_css_class' => 'a-center',
60
+ 'type' => 'checkbox',
61
+ 'name' => 'in_attachments',
62
+ 'values'=> $this->_getSelectedAttachments(),
63
+ 'align' => 'center',
64
+ 'index' => 'entity_id'
65
+ )
66
+ );
67
+
68
+ $this->addColumn('entity_id',
69
+ array(
70
+ 'header' => Mage::helper('catalog')->__('ID'),
71
+ 'width' => '1',
72
+ 'align' => 'left',
73
+ 'index' => 'entity_id',
74
+ )
75
+ );
76
+
77
+ $this->addColumn('title',
78
+ array(
79
+ 'header' => Mage::helper('attachments')->__('Title'),
80
+ 'align' => 'left',
81
+ 'index' => 'title',
82
+ 'renderer' => 'attachments/adminhtml_catalog_column_renderer_relation',
83
+ 'params' => array(
84
+ 'id' => 'getId'
85
+ ),
86
+ 'base_link' => 'adminhtml/attachments_attachment/edit',
87
+ )
88
+ );
89
+
90
+ $this->addColumn('position',
91
+ array(
92
+ 'header' => Mage::helper('attachments')->__('Position'),
93
+ 'name' => 'position',
94
+ 'width' => 55,
95
+ 'type' => 'number',
96
+ 'validate_class' => 'validate-number',
97
+ 'index' => 'position',
98
+ 'editable' => true,
99
+ )
100
+ );
101
+
102
+ return parent::_prepareColumns();
103
+ }
104
+
105
+ # Retrieve selected attachments
106
+ protected function _getSelectedAttachments() {
107
+ $attachments = $this->getProductAttachments();
108
+
109
+ if (!is_array($attachments)) {
110
+ $attachments = array_keys($this->getSelectedAttachments());
111
+ }
112
+
113
+ return $attachments;
114
+ }
115
+
116
+ # Retrieve selected attachments
117
+ public function getSelectedAttachments() {
118
+ $attachments = array();
119
+
120
+ # used helper here in order not to override the product model
121
+ $selected = Mage::helper('attachments/product')->getSelectedAttachments(Mage::registry('current_product'));
122
+
123
+ if (!is_array($selected)) {
124
+ $selected = array();
125
+ }
126
+
127
+ foreach ($selected as $attachment) {
128
+ $attachments[$attachment->getId()] = array('position' => $attachment->getPosition());
129
+ }
130
+
131
+ return $attachments;
132
+ }
133
+
134
+ # Add filter
135
+ protected function _addColumnFilterToCollection($column) {
136
+ if ($column->getId() == 'in_attachments') {
137
+ $attachmentIds = $this->_getSelectedAttachments();
138
+
139
+ if (empty($attachmentIds)) {
140
+ $attachmentIds = 0;
141
+ }
142
+
143
+ if ($column->getFilter()->getValue()) {
144
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$attachmentIds));
145
+ }else {
146
+
147
+ if ($attachmentIds) {
148
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$attachmentIds));
149
+ }
150
+
151
+ }
152
+
153
+ }else {
154
+ parent::_addColumnFilterToCollection($column);
155
+ }
156
+
157
+ return $this;
158
+
159
+ }
160
+
161
+ # Get the current product
162
+ public function getProduct() {
163
+ return Mage::registry('current_product');
164
+ }
165
+
166
+ # Get row URL
167
+ public function getRowUrl($item) {
168
+ return '#';
169
+ }
170
+
171
+ # Get grid URL
172
+ public function getGridUrl() {
173
+ return $this->getUrl('*/*/attachmentsGrid', array('id'=>$this->getProduct()->getId()));
174
+ }
175
+
176
+
177
+ }
app/code/community/Virtina/Attachments/Block/Adminhtml/Helper/File.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment file field renderer helper
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Adminhtml_Helper_File extends Varien_Data_Form_Element_Abstract {
10
+
11
+ # Constructor
12
+ public function __construct($data) {
13
+ parent::__construct($data);
14
+ $this->setType('file');
15
+ }
16
+
17
+ # Get element HTML
18
+ public function getElementHtml() {
19
+
20
+ $html = '';
21
+ $this->addClass('input-file');
22
+ $html .= parent::getElementHtml();
23
+
24
+ if ($this->getValue()) {
25
+ $att_file_arr = array();
26
+ $att_file_arr = explode("/",$this->getValue());
27
+ $att_file = $att_file_arr[count($att_file_arr)-1];
28
+
29
+ $url = $this->_getUrl();
30
+ if (!preg_match("/^http\:\/\/|https\:\/\//", $url)) {
31
+ $url = Mage::helper('attachments/attachment')->getFileBaseUrl() . $url;
32
+ }
33
+
34
+ $attmodel = Mage::getModel('attachments/attachment');
35
+
36
+ $ext = $attmodel->getFileExtension($this->getValue(), 1);
37
+ $mediaIcon_path = Mage::getBaseDir('media').'/attachment/icons/' . $ext . '.png';
38
+
39
+ if (file_exists($mediaIcon_path)) {
40
+ $mediaIcon = Mage::getBaseUrl('media') . '/attachment/icons/' . $ext . '.png';
41
+ } else {
42
+ $mediaIcon = Mage::getBaseUrl('media') . '/attachment/icons/plain.png';
43
+ }
44
+
45
+ $helper = Mage::helper('attachments/attachment');
46
+ $attachmentPath = Mage::helper('attachments/attachment')->getFileBaseDir().$this->getValue();
47
+ $_fileSize = $helper->getFileSize($attachmentPath);
48
+
49
+ $html .= '<br /><br /><span class="attach-img"><img src="' . $mediaIcon . '" style="margin-right: 5px;" width="25" /></span>';
50
+ $html .= '<a href="'.$url.'" target="_blank">'.$att_file.'</a>';
51
+ $html .= ' ('.$_fileSize.')';
52
+
53
+ }
54
+
55
+ //$html .= $this->_getDeleteCheckbox();
56
+ return $html;
57
+ }
58
+
59
+ # Get the delete checkbox HTML
60
+ protected function _getDeleteCheckbox() {
61
+ $html = '';
62
+
63
+ if ($this->getValue()) {
64
+ $label = Mage::helper('attachments')->__(' Delete File');
65
+ $html .= '<span class="delete-image">';
66
+ $html .= '<input type="checkbox" name="'.
67
+ parent::getName().'[delete]" value="1" class="checkbox" id="'.
68
+ $this->getHtmlId().'_delete"'.($this->getDisabled() ? ' disabled="disabled"': '').'/>';
69
+ $html .= '<label for="'.$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' class="disabled"' : '').'>';
70
+ $html .= $label.'</label>';
71
+ $html .= $this->_getHiddenInput();
72
+ $html .= '</span>';
73
+ }
74
+
75
+ return $html;
76
+ }
77
+
78
+ # Get the name
79
+ public function getName() {
80
+ return $this->getData('name');
81
+ }
82
+
83
+ # Get the hidden input
84
+ protected function _getHiddenInput() {
85
+ return '<input type="hidden" name="'.parent::getName().'[value]" value="'.$this->getValue().'" />';
86
+ }
87
+
88
+ # Get the file URL
89
+ protected function _getUrl() {
90
+ return $this->getValue();
91
+ }
92
+
93
+
94
+ }
app/code/community/Virtina/Attachments/Block/Attachment.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment list on product page block
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Attachment extends Mage_Catalog_Block_Product_Abstract {
10
+
11
+ # Get the list of attachments
12
+ public function getAttachmentCollection() {
13
+
14
+ if (!$this->hasData('attachment_collection')) {
15
+ $product = Mage::registry('product');
16
+ $collection = Mage::getResourceSingleton('attachments/attachment_collection')
17
+ ->addFieldToFilter('status', 1)
18
+ ->addProductFilter($product);
19
+ $collection->getSelect()->order('related_product.position', 'ASC');
20
+ $this->setData('attachment_collection', $collection);
21
+ }
22
+
23
+ return $this->getData('attachment_collection');
24
+
25
+ }
26
+
27
+ }
app/code/community/Virtina/Attachments/Block/Attachment/List.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment list block
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Block_Attachment_List extends Mage_Core_Block_Template {
10
+
11
+ # Constructor
12
+ public function __construct() {
13
+ parent::__construct();
14
+ $attachments = Mage::getResourceModel('virtina_attachments/attachment_collection')
15
+ ->addFieldToFilter('status', 1);
16
+ $attachments->setOrder('title', 'asc');
17
+ $this->setAttachments($attachments);
18
+ }
19
+
20
+ # Prepare the layout
21
+ protected function _prepareLayout() {
22
+ parent::_prepareLayout();
23
+ $pager = $this->getLayout()->createBlock(
24
+ 'page/html_pager',
25
+ 'virtina_attachments.attachment.html.pager'
26
+ )
27
+ ->setCollection($this->getAttachments());
28
+ $this->setChild('pager', $pager);
29
+ $this->getAttachments()->load();
30
+ return $this;
31
+ }
32
+
33
+ # Get the pager HTML
34
+ public function getPagerHtml() {
35
+ return $this->getChildHtml('pager');
36
+ }
37
+
38
+
39
+ }
app/code/community/Virtina/Attachments/Helper/Attachment.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment helper
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Helper_Attachment extends Mage_Core_Helper_Abstract {
10
+
11
+ # Get file size
12
+ public function getFileSize($file) {
13
+
14
+ $size = filesize($file);
15
+ $sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
16
+
17
+ if ($size == 0) {
18
+ return('n/a');
19
+ }else {
20
+ return (round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]);
21
+ }
22
+
23
+ }
24
+
25
+ # Get base files directory
26
+ public function getFileBaseDir() {
27
+ return Mage::getBaseDir('media').DS.'attachment'.DS.'file';
28
+ }
29
+
30
+ # Get base file URL
31
+ public function getFileBaseUrl() {
32
+ return Mage::getBaseUrl('media').'attachment'.'/'.'file';
33
+ }
34
+
35
+
36
+ }
app/code/community/Virtina/Attachments/Helper/Data.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachments default helper
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Helper_Data extends Mage_Core_Helper_Abstract{
10
+
11
+ # Convert array to options
12
+ public function convertOptions($options) {
13
+
14
+ $converted = array();
15
+
16
+ foreach ($options as $option) {
17
+
18
+ if (isset($option['value']) && !is_array($option['value']) &&
19
+ isset($option['label']) && !is_array($option['label'])) {
20
+ $converted[$option['value']] = $option['label'];
21
+ }
22
+
23
+ }
24
+
25
+ return $converted;
26
+
27
+ }
28
+
29
+ public function getAttachHeadFromConfig() {
30
+ $attachhead = Mage::getStoreConfig('virtina_attachments/attachment/attachhead');
31
+ //$attachhead = ($attachhead == '')? $this->__('Catalog Attachments'): $attachhead;
32
+ return $attachhead;
33
+ }
34
+
35
+ public function getTabTitleFromConfig() {
36
+ $tabheading = Mage::getStoreConfig('virtina_attachments/attachment/tabheading');
37
+ $tabheading = ($tabheading == '')? $this->__('Attachments'): $tabheading;
38
+ return $tabheading;
39
+ }
40
+
41
+ }
app/code/community/Virtina/Attachments/Helper/Product.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product helper
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Helper_Product extends Virtina_Attachments_Helper_Data {
10
+
11
+ # Get the selected attachments for a catalog
12
+ public function getSelectedAttachments(Mage_Catalog_Model_Product $product) {
13
+
14
+ if (!$product->hasSelectedAttachments()) {
15
+ $attachments = array();
16
+
17
+ foreach ($this->getSelectedAttachmentsCollection($product) as $attachment) {
18
+ $attachments[] = $attachment;
19
+ }
20
+
21
+ $product->setSelectedAttachments($attachments);
22
+
23
+ }
24
+
25
+ return $product->getData('selected_attachments');
26
+
27
+ }
28
+
29
+ # Get attachment collection for a catalog
30
+ public function getSelectedAttachmentsCollection(Mage_Catalog_Model_Product $product) {
31
+
32
+ $collection = Mage::getResourceSingleton('attachments/attachment_collection')
33
+ ->addProductFilter($product);
34
+
35
+ return $collection;
36
+
37
+ }
38
+
39
+ }
app/code/community/Virtina/Attachments/Model/Adminhtml/Observer.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Adminhtml observer
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Model_Adminhtml_Observer {
10
+
11
+ # Check if tab can be added
12
+ protected function _canAddTab($product) {
13
+ if ($product->getId()) {
14
+ return true;
15
+ }
16
+
17
+ if (!$product->getAttributeSetId()) {
18
+ return false;
19
+ }
20
+
21
+ $request = Mage::app()->getRequest();
22
+ if ($request->getParam('type') == 'configurable') {
23
+ if ($request->getParam('attributes')) {
24
+ return true;
25
+ }
26
+ }
27
+
28
+ return false;
29
+ }
30
+
31
+ # Save attachment - product relation
32
+ public function saveProductAttachmentInfo($observer) {
33
+ $post = Mage::app()->getRequest()->getPost('attachments', -1);
34
+
35
+ if ($post != '-1') {
36
+ $post = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post);
37
+ $product = Mage::registry('product');
38
+
39
+ $attachmentProduct = Mage::getModel('attachments/attachmentproduct')->saveProductRelation($product, $post);
40
+
41
+ }
42
+
43
+ return $this;
44
+ }
45
+
46
+ # Add the attachment tab to products
47
+ public function addProductAttachmentBlock($observer) {
48
+ $block = $observer->getEvent()->getBlock();
49
+ $product = Mage::registry('product');
50
+
51
+ if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)) {
52
+ $block->addTab('attachments',
53
+ array(
54
+ 'label' => Mage::helper('attachments')->__('Catalog Attachments'),
55
+ 'url' => Mage::helper('adminhtml')->getUrl(
56
+ 'adminhtml/attachments_attachment_catalog_product/attachments',
57
+ array('_current' => true)
58
+ ),
59
+ 'class' => 'ajax',
60
+ )
61
+ );
62
+ }
63
+
64
+ return $this;
65
+ }
66
+
67
+ }
app/code/community/Virtina/Attachments/Model/Attachment.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment model
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Model_Attachment extends Mage_Core_Model_Abstract {
10
+
11
+ public function _construct(){
12
+ parent::_construct();
13
+ $this->_init('attachments/attachment');
14
+ }
15
+
16
+ # Get attachment path
17
+ public function getAttachmentPath(){
18
+ return Mage::helper('attachments/attachment')->getFileBaseDir() . $this->getData('uploaded_file');
19
+ }
20
+
21
+ # Get attachment extension
22
+ public function getFileExtension($filename, $pos = 0) {
23
+ return strtolower(substr($filename, strrpos($filename, '.') + $pos));
24
+ }
25
+
26
+ # Get attachment icon
27
+ public function getIcon() {
28
+ $attachmentPath = $this->getData('uploaded_file');
29
+ $ext = $this->getFileExtension($attachmentPath, 1);
30
+
31
+ $mediaIcon_path = Mage::getBaseDir('media').'/attachment/icons/' . $ext . '.png';
32
+
33
+ if (file_exists($mediaIcon_path)) {
34
+ $mediaIcon = Mage::getBaseUrl('media') . '/attachment/icons/' . $ext . '.png';
35
+ } else {
36
+ $mediaIcon = Mage::getBaseUrl('media') . '/attachment/icons/plain.png';
37
+ }
38
+
39
+ $html = '<span class="attach-img"><img src="' . $mediaIcon . '" alt="View/Download File" style="margin-right: 5px;" width="40px"/></span>';
40
+ return $html;
41
+ }
42
+
43
+ # Get attachment URL
44
+ public function getAttachmentUrl() {
45
+ return Mage::helper('attachments/attachment')->getFileBaseUrl() . $this->getUploadedFile();
46
+ }
47
+
48
+
49
+ }
app/code/community/Virtina/Attachments/Model/Attachmentproduct.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment model
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Model_Attachmentproduct extends Mage_Core_Model_Abstract {
10
+
11
+
12
+ public function _construct(){
13
+ parent::_construct();
14
+ $this->_init('attachments/attachmentproduct');
15
+ }
16
+
17
+ # Save product attachment relations
18
+ public function saveProductRelation($product, $data) {
19
+
20
+ if (!is_array($data)) {
21
+ $data = array();
22
+ }
23
+
24
+ # Delete existing product attachment relation
25
+ $apmodel = Mage::getModel('attachments/attachmentproduct')->getCollection();
26
+ $apmodel->addFieldToFilter('product_id', $product->getId());
27
+ $apmodel->walk('delete');
28
+
29
+ # Save product attachment relation
30
+ foreach ($data as $attachmentId => $info) {
31
+
32
+ $info['position'] = ($info['position'])?$info['position']:0;
33
+
34
+ $model = Mage::getModel('attachments/attachmentproduct');
35
+ $model->setAttachmentId($attachmentId);
36
+ $model->setProductId($product->getId());
37
+ $model->setPosition($info['position']);
38
+ $model->save();
39
+ }
40
+
41
+ return $this;
42
+
43
+ }
44
+
45
+
46
+ }
app/code/community/Virtina/Attachments/Model/Mysql4/Attachment.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment model
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Model_Mysql4_Attachment extends Mage_Core_Model_Mysql4_Abstract {
10
+
11
+ public function _construct(){
12
+ $this->_init('attachments/attachment', 'entity_id');
13
+ }
14
+
15
+
16
+ }
app/code/community/Virtina/Attachments/Model/Mysql4/Attachment/Collection.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment product model
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Model_Mysql4_Attachment_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
10
+
11
+ protected $_joinedFields = array();
12
+
13
+ public function _construct() {
14
+ parent::_construct();
15
+ $this->_init('attachments/attachment');
16
+ }
17
+
18
+
19
+ # Add the product filter to collection
20
+ public function addProductFilter($product) {
21
+
22
+ if ($product instanceof Mage_Catalog_Model_Product) {
23
+ $product = $product->getId();
24
+ }
25
+
26
+ if (!isset($this->_joinedFields['product'])) {
27
+ $this->getSelect()->join(
28
+ array('related_product' => $this->getTable('attachments/attachmentproduct')),
29
+ 'related_product.attachment_id = main_table.entity_id',
30
+ array('position')
31
+ );
32
+
33
+ $this->getSelect()->where('related_product.product_id = ?', $product);
34
+ $this->_joinedFields['product'] = true;
35
+
36
+ }
37
+
38
+ return $this;
39
+
40
+ }
41
+
42
+ }
app/code/community/Virtina/Attachments/Model/Mysql4/Attachmentproduct.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment model
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Model_Mysql4_Attachmentproduct extends Mage_Core_Model_Mysql4_Abstract {
10
+
11
+ public function _construct(){
12
+ $this->_init('attachments/attachmentproduct', 'ap_id');
13
+ }
14
+
15
+
16
+ }
app/code/community/Virtina/Attachments/Model/Mysql4/Attachmentproduct/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment product model
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Model_Mysql4_Attachmentproduct_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
10
+
11
+ public function _construct(){
12
+ parent::_construct();
13
+ $this->_init('attachments/attachmentproduct');
14
+ }
15
+
16
+ }
app/code/community/Virtina/Attachments/Model/System/Config/Source/Truefalse.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Virtina
4
+ * @package Virtina_Attachments
5
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+
9
+ class Virtina_Attachments_Model_System_Config_Source_Truefalse{
10
+
11
+ public function toOptionArray(){
12
+ return array(
13
+
14
+ array('value' => 'true', 'label'=>Mage::helper('adminhtml')->__('Yes')),
15
+ array('value' => 'false', 'label'=>Mage::helper('adminhtml')->__('No')),
16
+ );
17
+ }
18
+
19
+ }
app/code/community/Virtina/Attachments/controllers/Adminhtml/Attachments/Attachment/Catalog/ProductController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment - product controller
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ require_once ("Mage/Adminhtml/controllers/Catalog/ProductController.php");
10
+
11
+ class Virtina_Attachments_Adminhtml_Attachments_Attachment_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController {
12
+
13
+ # Constructor
14
+ protected function _construct() {
15
+ # Define module dependent translate
16
+ $this->setUsedModuleName('Virtina_Attachments');
17
+ }
18
+
19
+ # Attachments grid in the catalog page
20
+ public function attachmentsGridAction() {
21
+ $this->_initProduct();
22
+ $this->loadLayout();
23
+ $this->getLayout()->getBlock('product.edit.tab.attachment')
24
+ ->setProductAttachments($this->getRequest()->getPost('product_attachments', null));
25
+ $this->renderLayout();
26
+ }
27
+
28
+ # Attachments in the catalog page
29
+ public function attachmentsAction() {
30
+ $this->_initProduct();
31
+ $this->loadLayout();
32
+ $this->getLayout()->getBlock('product.edit.tab.attachment')
33
+ ->setProductAttachments($this->getRequest()->getPost('product_attachments', null));
34
+ $this->renderLayout();
35
+ }
36
+
37
+
38
+ }
app/code/community/Virtina/Attachments/controllers/Adminhtml/Attachments/AttachmentController.php ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment admin controller
4
+ *
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Attachments_Adminhtml_Attachments_AttachmentController extends Mage_Adminhtml_Controller_Action {
10
+
11
+ # Init attachment
12
+ protected function _initAttachment(){
13
+
14
+ $attachmentId = (int) $this->getRequest()->getParam('id');
15
+ $attachment = Mage::getModel('attachments/attachment');
16
+
17
+ if ($attachmentId) {
18
+ $attachment->load($attachmentId);
19
+ }
20
+
21
+ Mage::register('current_attachment', $attachment);
22
+
23
+ return $attachment;
24
+
25
+ }
26
+
27
+ # Index action
28
+ public function indexAction(){
29
+ $this->loadLayout();
30
+ $this->_title(Mage::helper('attachments')->__('Catalog Attachments'));
31
+ $this->renderLayout();
32
+ }
33
+
34
+ # Grid action
35
+ public function gridAction() {
36
+ $this->loadLayout()->renderLayout();
37
+ }
38
+
39
+ # New action
40
+ public function newAction() {
41
+ $this->_forward('edit');
42
+ }
43
+
44
+ # Edit action
45
+ public function editAction() {
46
+ $attachmentId = $this->getRequest()->getParam('id');
47
+ $attachment = $this->_initAttachment();
48
+
49
+ if ($attachmentId && !$attachment->getId()) {
50
+
51
+ $this->_getSession()->addError(
52
+ Mage::helper('attachments')->__('This attachment no longer exists!!!')
53
+ );
54
+
55
+ $this->_redirect('*/*/');
56
+ return;
57
+ }
58
+
59
+ $data = Mage::getSingleton('adminhtml/session')->getAttachmentData(true);
60
+
61
+ if (!empty($data)) {
62
+ $attachment->setData($data);
63
+ }
64
+
65
+ Mage::register('attachment_data', $attachment);
66
+
67
+ $this->loadLayout();
68
+ $this->_title(Mage::helper('attachments')->__('Virtina'))
69
+ ->_title(Mage::helper('attachments')->__('Attachments'));
70
+
71
+ if ($attachment->getId()) {
72
+ $this->_title($attachment->getTitle());
73
+ }else {
74
+ $this->_title(Mage::helper('attachments')->__('Add attachment'));
75
+ }
76
+
77
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
78
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
79
+ }
80
+
81
+ $this->renderLayout();
82
+
83
+ }
84
+
85
+ # Save action
86
+ public function saveAction() {
87
+
88
+ if ($data = $this->getRequest()->getPost('attachment')) {
89
+ $allowedFormats = array();
90
+ $allowedFormats = strtolower(Mage::getStoreConfig('virtina_attachments/attachment/attachallowed'));
91
+ $allowedFormats = explode(",",$allowedFormats);
92
+
93
+ try {
94
+ $attachment = $this->_initAttachment();
95
+ $attachment->addData($data);
96
+
97
+ if($_FILES['uploaded_file']['name']){
98
+ $allowedFileSize = $_FILES['uploaded_file']['size'];
99
+
100
+ # Check if allowed file type
101
+ $att_file_arr = array();
102
+ $att_file_arr = explode(".",$_FILES['uploaded_file']['name']);
103
+ $att_file = strtolower($att_file_arr[count($att_file_arr)-1]);
104
+
105
+ if(!in_array($att_file, $allowedFormats)){
106
+
107
+ #throw new Exception('Such a file type is allowed to upload!!!');
108
+
109
+ if (isset($data['uploaded_file']['value'])) {
110
+ $data['uploaded_file'] = $data['uploaded_file']['value'];
111
+ }
112
+
113
+ Mage::getSingleton('adminhtml/session')->addError(
114
+ Mage::helper('attachments')->__('Such a file type is allowed to upload!!!')
115
+ );
116
+ Mage::getSingleton('adminhtml/session')->setAttachmentData($data);
117
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
118
+
119
+ return;
120
+ }
121
+
122
+ $uploadedFileName = $this->_uploadAndGetName(
123
+ 'uploaded_file',
124
+ Mage::helper('attachments/attachment')->getFileBaseDir(),
125
+ $data
126
+ );
127
+
128
+ $attachment->setData('uploaded_file', $uploadedFileName);
129
+ }
130
+
131
+ $attachment->save();
132
+
133
+ $attachmentId = $attachment->getId();
134
+ $products = $this->getRequest()->getPost('products', -1);
135
+
136
+ if ($products != -1) {
137
+ # Delete existing
138
+ $apmodel = Mage::getModel('attachments/attachmentproduct')->getCollection();
139
+ $apmodel->addFieldToFilter('attachment_id', $attachmentId);
140
+ $apmodel->walk('delete');
141
+
142
+ $productIds = Mage::helper('adminhtml/js')->decodeGridSerializedInput($products);
143
+ foreach($productIds as $key =>$productId){
144
+ $model = Mage::getModel('attachments/attachmentproduct');
145
+ $model->setAttachmentId($attachmentId);
146
+ $model->setProductId($key);
147
+ $model->save();
148
+ }
149
+ }
150
+
151
+ Mage::getSingleton('adminhtml/session')->addSuccess(
152
+ Mage::helper('attachments')->__('Attachment is successfully saved')
153
+ );
154
+
155
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
156
+ if ($this->getRequest()->getParam('back')) {
157
+ $this->_redirect('*/*/edit', array('id' => $attachment->getId()));
158
+ return;
159
+ }
160
+
161
+ $this->_redirect('*/*/');
162
+ return;
163
+
164
+ } catch (Mage_Core_Exception $e) {
165
+
166
+ if (isset($data['uploaded_file']['value'])) {
167
+ $data['uploaded_file'] = $data['uploaded_file']['value'];
168
+ }
169
+
170
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
171
+ Mage::getSingleton('adminhtml/session')->setAttachmentData($data);
172
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
173
+
174
+ return;
175
+
176
+ } catch (Exception $e) {
177
+
178
+ // Mage::logException($e);
179
+
180
+ if (isset($data['uploaded_file']['value'])) {
181
+ $data['uploaded_file'] = $data['uploaded_file']['value'];
182
+ }
183
+
184
+ Mage::getSingleton('adminhtml/session')->addError(
185
+ Mage::helper('attachments')->__('There is a problem saving the attachment!!!')
186
+ );
187
+
188
+ Mage::getSingleton('adminhtml/session')->setAttachmentData($data);
189
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
190
+
191
+ return;
192
+
193
+ }
194
+ }
195
+
196
+ Mage::getSingleton('adminhtml/session')->addError(
197
+ Mage::helper('attachments')->__('Unable to find attachment to save!!!')
198
+ );
199
+
200
+ $this->_redirect('*/*/');
201
+ }
202
+
203
+ # Delete action
204
+ public function deleteAction() {
205
+
206
+ if ( $this->getRequest()->getParam('id') > 0) {
207
+
208
+ try {
209
+ $attachment = Mage::getModel('attachments/attachment');
210
+ $attachment->setId($this->getRequest()->getParam('id'))->delete();
211
+ Mage::getSingleton('adminhtml/session')->addSuccess(
212
+ Mage::helper('attachments')->__('Attachment is successfully deleted.')
213
+ );
214
+
215
+ $this->_redirect('*/*/');
216
+ return;
217
+
218
+ } catch (Mage_Core_Exception $e) {
219
+
220
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
221
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
222
+
223
+ } catch (Exception $e) {
224
+
225
+ Mage::getSingleton('adminhtml/session')->addError(
226
+ Mage::helper('attachments')->__('There is an error deleting attachment!!!')
227
+ );
228
+
229
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
230
+ Mage::logException($e);
231
+
232
+ return;
233
+
234
+ }
235
+
236
+ }
237
+
238
+ Mage::getSingleton('adminhtml/session')->addError(
239
+ Mage::helper('attachments')->__('Could not find attachment to delete!!!')
240
+ );
241
+
242
+ $this->_redirect('*/*/');
243
+ }
244
+
245
+ # Mass delete action
246
+ public function massDeleteAction() {
247
+
248
+ $attachmentIds = $this->getRequest()->getParam('attachment');
249
+
250
+ if (!is_array($attachmentIds)) {
251
+
252
+ Mage::getSingleton('adminhtml/session')->addError(
253
+ Mage::helper('attachments')->__('Please select attachment(s) to delete!!!')
254
+ );
255
+
256
+ }else {
257
+
258
+ try {
259
+ foreach ($attachmentIds as $attachmentId) {
260
+ $attachment = Mage::getModel('attachments/attachment');
261
+ $attachment->setId($attachmentId)->delete();
262
+ }
263
+
264
+ Mage::getSingleton('adminhtml/session')->addSuccess(
265
+ Mage::helper('attachments')->__('Total of %d attachments are successfully deleted.', count($attachmentIds))
266
+ );
267
+
268
+ } catch (Mage_Core_Exception $e) {
269
+
270
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
271
+
272
+ } catch (Exception $e) {
273
+
274
+ Mage::getSingleton('adminhtml/session')->addError(
275
+ Mage::helper('attachments')->__('There is an error deleting attachment(s)!!!')
276
+ );
277
+
278
+ Mage::logException($e);
279
+
280
+ }
281
+
282
+ }
283
+
284
+ $this->_redirect('*/*/index');
285
+
286
+ }
287
+
288
+ # Mass status change action
289
+ public function massStatusAction() {
290
+
291
+ $attachmentIds = $this->getRequest()->getParam('attachment');
292
+
293
+ if (!is_array($attachmentIds)) {
294
+
295
+ Mage::getSingleton('adminhtml/session')->addError(
296
+ Mage::helper('attachments')->__('Please select attachment(s)!!!')
297
+ );
298
+
299
+ }else {
300
+
301
+ try {
302
+
303
+ foreach ($attachmentIds as $attachmentId) {
304
+
305
+ $attachment = Mage::getSingleton('attachments/attachment')->load($attachmentId)
306
+ ->setStatus($this->getRequest()->getParam('status'))
307
+ ->setIsMassupdate(true)
308
+ ->save();
309
+ }
310
+
311
+ $this->_getSession()->addSuccess(
312
+ $this->__('Total of %d attachments are successfully updated.', count($attachmentIds))
313
+ );
314
+
315
+ } catch (Mage_Core_Exception $e) {
316
+
317
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
318
+
319
+ } catch (Exception $e) {
320
+
321
+ Mage::getSingleton('adminhtml/session')->addError(
322
+ Mage::helper('attachments')->__('There is an error updating attachment(s)!!!')
323
+ );
324
+
325
+ Mage::logException($e);
326
+
327
+ }
328
+ }
329
+
330
+ $this->_redirect('*/*/index');
331
+ }
332
+
333
+ # Get grid of products action
334
+ public function productsAction() {
335
+ $this->_initAttachment();
336
+ $this->loadLayout();
337
+ $this->getLayout()->getBlock('attachment.edit.tab.product')
338
+ ->setAttachmentProducts($this->getRequest()->getPost('attachment_products', null));
339
+ $this->renderLayout();
340
+ }
341
+
342
+ # Get grid of products action
343
+ public function productsgridAction() {
344
+ $this->_initAttachment();
345
+ $this->loadLayout();
346
+ $this->getLayout()->getBlock('attachment.edit.tab.product')
347
+ ->setAttachmentProducts($this->getRequest()->getPost('attachment_products', null));
348
+ $this->renderLayout();
349
+ }
350
+
351
+ # Upload file and get the name
352
+ protected function _uploadAndGetName($input, $destinationFolder, $data) {
353
+
354
+ try {
355
+
356
+ if (isset($data[$input]['delete'])) {
357
+ return '';
358
+ }else {
359
+ $uploader = new Varien_File_Uploader($input);
360
+ $uploader->setAllowRenameFiles(true);
361
+ $uploader->setFilesDispersion(true);
362
+ $uploader->setAllowCreateFolders(true);
363
+ $result = $uploader->save($destinationFolder);
364
+ return $result['file'];
365
+ }
366
+
367
+ } catch (Exception $e) {
368
+
369
+ if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
370
+ throw $e;
371
+ }else {
372
+ if (isset($data[$input]['value'])) {
373
+ return $data[$input]['value'];
374
+ }
375
+ }
376
+
377
+ }
378
+
379
+ return '';
380
+
381
+ }
382
+
383
+ protected function _isAllowed(){
384
+ return true;
385
+ }
386
+
387
+
388
+ }
app/code/community/Virtina/Attachments/etc/adminhtml.xml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <menu>
12
+ <catalog translate="title" module="attachments">
13
+ <title>Catalog</title>
14
+ <sort_order>30</sort_order>
15
+ <children>
16
+ <attachment translate="title" module="attachments">
17
+ <title>Catalog Attachments</title>
18
+ <action>adminhtml/attachments_attachment</action>
19
+ <sort_order>0</sort_order>
20
+ </attachment>
21
+ </children>
22
+ </catalog>
23
+ </menu>
24
+ <acl>
25
+ <resources>
26
+ <admin>
27
+ <children>
28
+ <system>
29
+ <children>
30
+ <config>
31
+ <children>
32
+ <virtina_attachments translate="title" module="attachments">
33
+ <title>Catalog Attachment Settings</title>
34
+ </virtina_attachments>
35
+ </children>
36
+ </config>
37
+ </children>
38
+ </system>
39
+ <catalog translate="title" module="attachments">
40
+ <title>Catalog</title>
41
+ <children>
42
+ <attachment translate="title" module="attachments">
43
+ <title>Catalog Attachments</title>
44
+ <sort_order>30</sort_order>
45
+ </attachment>
46
+ </children>
47
+ </catalog>
48
+ </children>
49
+ </admin>
50
+ </resources>
51
+ </acl>
52
+ </config>
app/code/community/Virtina/Attachments/etc/config.xml ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Virtina_Attachments>
13
+ <version>0.0.1</version>
14
+ </Virtina_Attachments>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <attachments>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Virtina_Attachments</module>
22
+ <frontName>attachments</frontName>
23
+ </args>
24
+ </attachments>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <attachments>
29
+ <file>catalog-attachments.xml</file>
30
+ </attachments>
31
+ </updates>
32
+ </layout>
33
+ <translate>
34
+ <modules>
35
+ <Virtina_Attachments>
36
+ <files>
37
+ <default>Virtina_Attachments.csv</default>
38
+ </files>
39
+ </Virtina_Attachments>
40
+ </modules>
41
+ </translate>
42
+ </frontend>
43
+ <global>
44
+ <blocks>
45
+ <attachments>
46
+ <class>Virtina_Attachments_Block</class>
47
+ </attachments>
48
+ </blocks>
49
+ <helpers>
50
+ <attachments>
51
+ <class>Virtina_Attachments_Helper</class>
52
+ </attachments>
53
+ </helpers>
54
+ <models>
55
+ <attachments>
56
+ <class>Virtina_Attachments_Model</class>
57
+ <resourceModel>attachments_mysql4</resourceModel>
58
+ </attachments>
59
+ <attachments_mysql4>
60
+ <class>Virtina_Attachments_Model_Mysql4</class>
61
+ <entities>
62
+ <attachment>
63
+ <table>virtina_attachment</table>
64
+ </attachment>
65
+ <attachmentproduct>
66
+ <table>virtina_attachment_product</table>
67
+ </attachmentproduct>
68
+ </entities>
69
+ </attachments_mysql4>
70
+ </models>
71
+ <resources>
72
+ <vattachments_setup>
73
+ <setup>
74
+ <module>Virtina_Attachments</module>
75
+ </setup>
76
+ <connection>
77
+ <use>core_setup</use>
78
+ </connection>
79
+ </vattachments_setup>
80
+ <attachments_write>
81
+ <connection>
82
+ <use>core_write</use>
83
+ </connection>
84
+ </attachments_write>
85
+ <attachments_read>
86
+ <connection>
87
+ <use>core_read</use>
88
+ </connection>
89
+ </attachments_read>
90
+ </resources>
91
+ </global>
92
+ <admin>
93
+ <routers>
94
+ <adminhtml>
95
+ <args>
96
+ <modules>
97
+ <Virtina_Attachments before="Mage_Adminhtml">Virtina_Attachments_Adminhtml</Virtina_Attachments>
98
+ </modules>
99
+ </args>
100
+ </adminhtml>
101
+ </routers>
102
+ </admin>
103
+ <adminhtml>
104
+ <layout>
105
+ <updates>
106
+ <attachments>
107
+ <file>catalog-attachments.xml</file>
108
+ </attachments>
109
+ </updates>
110
+ </layout>
111
+ <translate>
112
+ <modules>
113
+ <Virtina_Attachments>
114
+ <files>
115
+ <default>Virtina_Attachments.csv</default>
116
+ </files>
117
+ </Virtina_Attachments>
118
+ </modules>
119
+ </translate>
120
+ <events>
121
+ <catalog_product_save_after>
122
+ <observers>
123
+ <attachments_attachment_product>
124
+ <type>singleton</type>
125
+ <class>attachments/adminhtml_observer</class>
126
+ <method>saveProductAttachmentInfo</method>
127
+ </attachments_attachment_product>
128
+ </observers>
129
+ </catalog_product_save_after>
130
+ <core_block_abstract_prepare_layout_after>
131
+ <observers>
132
+ <attachments_attachment_product>
133
+ <type>singleton</type>
134
+ <class>attachments/adminhtml_observer</class>
135
+ <method>addProductAttachmentBlock</method>
136
+ </attachments_attachment_product>
137
+ </observers>
138
+ </core_block_abstract_prepare_layout_after>
139
+ </events>
140
+ </adminhtml>
141
+ <default>
142
+ <virtina_attachments>
143
+ <attachment>
144
+ <attachallowed>jpg,png,bmp,csv,zip,mp3,mp4,zip,pdf,doc,docx,xls,xlx,txt</attachallowed>
145
+ </attachment>
146
+ <attachment>
147
+ <tabheading>ATTACHEMENTS</tabheading>
148
+ </attachment>
149
+ </virtina_attachments>
150
+ </default>
151
+ </config>
app/code/community/Virtina/Attachments/etc/system.xml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <tabs>
12
+ <virtina_extensions translate="label" module="attachments">
13
+ <label>Virtina Extentions</label>
14
+ <sort_order>100</sort_order>
15
+ </virtina_extensions>
16
+ </tabs>
17
+ <sections>
18
+ <virtina_attachments>
19
+ <class>separator-top</class>
20
+ <label>Catalog Attachments</label>
21
+ <tab>virtina_extensions</tab>
22
+ <sort_order>90</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <groups>
27
+ <attachment translate="label" module="attachments">
28
+ <label>Catalog Attachment Settings</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>0</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <comment><![CDATA[We can <em>configure</em> the <strong>Catalog Attachment Extension</strong> here.]]></comment>
35
+ <fields>
36
+ <enable translate="label">
37
+ <label>Enable Catalog attachment</label>
38
+ <comment>Enable / Disable the extension</comment>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>10</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </enable>
46
+ <tabheading translate="label">
47
+ <label>Attachment TAB heading</label>
48
+ <depends><enable>1</enable></depends>
49
+ <comment>Default: Attachments</comment>
50
+ <frontend_type>text</frontend_type>
51
+ <validate>required-entry</validate>
52
+ <sort_order>30</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </tabheading>
57
+ <attachhead translate="label">
58
+ <label>Attachments heading</label>
59
+ <depends><enable>1</enable></depends>
60
+ <frontend_type>text</frontend_type>
61
+ <sort_order>40</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </attachhead>
66
+ <filetypestatus translate="label">
67
+ <label>Enable display file type image</label>
68
+ <depends><enable>1</enable></depends>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>adminhtml/system_config_source_yesno</source_model>
71
+ <sort_order>50</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ </filetypestatus>
76
+ <attachallowed translate="label">
77
+ <label>Allowed file types</label>
78
+ <depends><enable>1</enable></depends>
79
+ <comment>Enter allowed file extensions seperated by comma. Eg:- jpg,png,bmp,csv,zip,mp3,mp4,zip,pdf,doc,docx,xls,xlx,txt</comment>
80
+ <frontend_type>textarea</frontend_type>
81
+ <validate>required-entry</validate>
82
+ <sort_order>20</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </attachallowed>
87
+ </fields>
88
+ </attachment>
89
+ </groups>
90
+ </virtina_attachments>
91
+ </sections>
92
+ </config>
app/code/community/Virtina/Attachments/sql/attachments_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachments module install script
4
+ *
5
+ * Virtina
6
+ * @package Virtina_Attachments
7
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ $installer = $this;
12
+ $installer->startSetup();
13
+
14
+ $installer->run("
15
+ -- DROP TABLE IF EXISTS {$this->getTable('virtina_attachment')};
16
+ CREATE TABLE IF NOT EXISTS {$this->getTable('virtina_attachment')} (
17
+ `entity_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Attachment ID',
18
+ `title` varchar(255) NOT NULL COMMENT 'Title',
19
+ `uploaded_file` varchar(255) DEFAULT NULL COMMENT 'Uploaded Attachment',
20
+ `status` smallint(6) DEFAULT NULL COMMENT 'Enabled',
21
+ `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated On',
22
+ `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created On',
23
+ PRIMARY KEY (`entity_id`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Attachment Table' AUTO_INCREMENT=1 ;");
25
+
26
+ $installer->run("
27
+ -- DROP TABLE IF EXISTS {$this->getTable('virtina_attachment_product')};
28
+ CREATE TABLE IF NOT EXISTS {$this->getTable('virtina_attachment_product')} (
29
+ `ap_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Attachment Product ID',
30
+ `attachment_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Attachment ID',
31
+ `product_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Product ID',
32
+ `position` int(11) NOT NULL DEFAULT '0' COMMENT 'Position',
33
+ PRIMARY KEY (`ap_id`),
34
+ UNIQUE KEY `UNQ_VIRTINA_ATTACHMENT_PRD_ATTACHMENT_ID_PRD_ID` (`attachment_id`,`product_id`),
35
+ KEY `IDX_VIRTINA_ATTACHMENT_PRODUCT_PRODUCT_ID` (`product_id`)
36
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Product Attachment Table' AUTO_INCREMENT=1 ;");
37
+
38
+ $installer->endSetup();
app/code/community/Virtina/Attachments/sql/vattachments_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachments module install script
4
+ *
5
+ * Virtina
6
+ * @package Virtina_Attachments
7
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ $installer = $this;
12
+ $installer->startSetup();
13
+
14
+ $installer->run("
15
+ -- DROP TABLE IF EXISTS {$this->getTable('virtina_attachment')};
16
+ CREATE TABLE IF NOT EXISTS {$this->getTable('virtina_attachment')} (
17
+ `entity_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Attachment ID',
18
+ `title` varchar(255) NOT NULL COMMENT 'Title',
19
+ `uploaded_file` varchar(255) DEFAULT NULL COMMENT 'Uploaded Attachment',
20
+ `status` smallint(6) DEFAULT NULL COMMENT 'Enabled',
21
+ `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated On',
22
+ `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created On',
23
+ PRIMARY KEY (`entity_id`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Attachment Table' AUTO_INCREMENT=1 ;");
25
+
26
+ $installer->run("
27
+ -- DROP TABLE IF EXISTS {$this->getTable('virtina_attachment_product')};
28
+ CREATE TABLE IF NOT EXISTS {$this->getTable('virtina_attachment_product')} (
29
+ `ap_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Attachment Product ID',
30
+ `attachment_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Attachment ID',
31
+ `product_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Product ID',
32
+ `position` int(11) NOT NULL DEFAULT '0' COMMENT 'Position',
33
+ PRIMARY KEY (`ap_id`),
34
+ UNIQUE KEY `UNQ_VIRTINA_ATTACHMENT_PRD_ATTACHMENT_ID_PRD_ID` (`attachment_id`,`product_id`),
35
+ KEY `IDX_VIRTINA_ATTACHMENT_PRODUCT_PRODUCT_ID` (`product_id`)
36
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Product Attachment Table' AUTO_INCREMENT=1 ;");
37
+
38
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/catalog-attachments.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <layout>
11
+
12
+ <!-- Attachment index action -->
13
+ <adminhtml_attachments_attachment_index>
14
+ <reference name="menu">
15
+ <action method="setActive">
16
+ <menupath>attachments/attachment</menupath>
17
+ </action>
18
+ </reference>
19
+ <reference name="content">
20
+ <block type="attachments/adminhtml_attachment" name="attachment" />
21
+ </reference>
22
+ </adminhtml_attachments_attachment_index>
23
+
24
+ <!-- Attachment grid action -->
25
+ <adminhtml_attachments_attachment_grid>
26
+ <block type="core/text_list" name="root" output="toHtml">
27
+ <block type="attachments/adminhtml_attachment_grid" name="attachment_grid"/>
28
+ </block>
29
+ </adminhtml_attachments_attachment_grid>
30
+
31
+ <!-- Attachment add/edit action -->
32
+ <adminhtml_attachments_attachment_edit>
33
+ <update handle="editor"/>
34
+ <reference name="menu">
35
+ <action method="setActive">
36
+ <menupath>attachments/attachment</menupath>
37
+ </action>
38
+ </reference>
39
+ <reference name="content">
40
+ <block type="attachments/adminhtml_attachment_edit" name="attachment_edit"></block>
41
+ </reference>
42
+ <reference name="left">
43
+ <block type="attachments/adminhtml_attachment_edit_tabs" name="attachment_tabs"></block>
44
+ </reference>
45
+ </adminhtml_attachments_attachment_edit>
46
+
47
+ <!-- Attachment attachment products -->
48
+ <adminhtml_attachments_attachment_products>
49
+ <block type="core/text_list" name="root" output="toHtml">
50
+ <block type="attachments/adminhtml_attachment_edit_tab_product" name="attachment.edit.tab.product"/>
51
+ <block type="adminhtml/widget_grid_serializer" name="product_grid_serializer">
52
+ <reference name="product_grid_serializer">
53
+ <action method="initSerializerBlock">
54
+ <grid_block_name>attachment.edit.tab.product</grid_block_name>
55
+ <data_callback>getSelectedProducts</data_callback>
56
+ <hidden_input_name>products</hidden_input_name>
57
+ <reload_param_name>attachment_products</reload_param_name>
58
+ </action>
59
+ <action method="addColumnInputName">
60
+ <input_name>position</input_name>
61
+ </action>
62
+ </reference>
63
+ </block>
64
+ </block>
65
+ </adminhtml_attachments_attachment_products>
66
+
67
+ <!-- Attachment attachment products grid -->
68
+ <adminhtml_attachments_attachment_productsgrid>
69
+ <block type="core/text_list" name="root" output="toHtml">
70
+ <block type="attachments/adminhtml_attachment_edit_tab_product" name="attachment.edit.tab.product"/>
71
+ </block>
72
+ </adminhtml_attachments_attachment_productsgrid>
73
+
74
+ <!-- Attachment product attachments -->
75
+ <adminhtml_attachments_attachment_catalog_product_attachments>
76
+ <block type="core/text_list" name="root" output="toHtml">
77
+ <block type="attachments/adminhtml_catalog_product_edit_tab_attachment" name="product.edit.tab.attachment"/>
78
+ <block type="adminhtml/widget_grid_serializer" name="attachment_grid_serializer">
79
+ <reference name="attachment_grid_serializer">
80
+ <action method="initSerializerBlock">
81
+ <grid_block_name>product.edit.tab.attachment</grid_block_name>
82
+ <data_callback>getSelectedAttachments</data_callback>
83
+ <hidden_input_name>attachments</hidden_input_name>
84
+ <reload_param_name>product_attachments</reload_param_name>
85
+ </action>
86
+ <action method="addColumnInputName">
87
+ <input_name>position</input_name>
88
+ </action>
89
+ </reference>
90
+ </block>
91
+ </block>
92
+ </adminhtml_attachments_attachment_catalog_product_attachments>
93
+
94
+ <!-- Attachment product attachments grid -->
95
+ <adminhtml_attachments_attachment_catalog_product_attachmentsgrid>
96
+ <block type="core/text_list" name="root" output="toHtml">
97
+ <block type="attachments/adminhtml_catalog_product_edit_tab_attachment" name="product.edit.tab.attachment"/>
98
+ </block>
99
+ </adminhtml_attachments_attachment_catalog_product_attachmentsgrid>
100
+ </layout>
app/design/frontend/base/default/layout/catalog-attachments.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <layout>
11
+ <catalog_product_view>
12
+ <reference name="head">
13
+ <action method="addCss" ><stylesheet>css/catalog-attachments/catalog-attachment.css</stylesheet></action>
14
+ </reference>
15
+ <reference name="product.info">
16
+ <block type="attachments/attachment" name="attachment_tab" as="attachment_tab" template="catalog-attachment/catalog-attachment.phtml">
17
+ <action method="addToParentGroup" ifconfig="virtina_attachments/attachment/enable"><group>detailed_info</group></action>
18
+ <action method="setTitle" translate="value" ifconfig="virtina_attachments/attachment/enable">
19
+ <value helper="attachments/data/getTabTitleFromConfig" />
20
+ </action>
21
+ </block>
22
+ </reference>
23
+ </catalog_product_view>
24
+ </layout>
app/design/frontend/base/default/template/catalog-attachment/catalog-attachment.phtml ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attachment list template on product page
4
+ * Virtina
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ $attachments = $this->getAttachmentCollection();
11
+ $helper = Mage::helper('attachments/attachment');
12
+
13
+ if ($attachments && $attachments->count() > 0) :?>
14
+ <script type="text/javascript">
15
+
16
+ // Limit attachment title length
17
+ function attachTitleResponsive(){
18
+ var width = document.viewport.getWidth();
19
+ var height = document.viewport.getHeight();
20
+ var dims = document.viewport.getDimensions();
21
+ var width = dims.width;
22
+ var attachIdstr = document.getElementById('atids').value;
23
+
24
+ if(attachIdstr){
25
+ var attachIdArray = attachIdstr.split(",");
26
+
27
+ for (i = 0; i < parseInt(attachIdArray.length); i++) {
28
+ var atid = 'attach-title-'+attachIdArray[i];
29
+ var atidFull = 'attach-title-full-'+attachIdArray[i];
30
+
31
+ var attachSpanObj = document.getElementById(atid);
32
+ var attachObj = document.getElementById(atidFull);
33
+
34
+ var attachTitle = "";
35
+ attachTitle = attachObj.value;
36
+ attachTitle = attachTitle.replace(/^\s+|\s+$/gm,'');
37
+
38
+ var attachSpanText = attachTitle;
39
+
40
+ if((width>='100')&&(width<'360')){
41
+ if(attachTitle.length >= 25){
42
+ attachSpanText = attachTitle.substring(0, 25)+'..';
43
+ }
44
+
45
+ } else if((width>='360')&&(width<'480')){
46
+ if(attachTitle.length >= 30){
47
+ attachSpanText = attachTitle.substring(0, 30)+'..';
48
+ }
49
+ } else if((width>='480')&&(width<'640')){
50
+ if(attachTitle.length >= 40){
51
+ attachSpanText = attachTitle.substring(0, 40)+'..';
52
+ }
53
+ } else if((width>='640')&&(width<'768')){
54
+ if(attachTitle.length >= 50){
55
+ attachSpanText = attachTitle.substring(0, 50)+'..';
56
+ }
57
+ }
58
+
59
+ if (attachSpanObj.innerText) {
60
+ attachSpanObj.innerText = attachSpanText;
61
+ } else if (attachSpanObj.textContent) {
62
+ attachSpanObj.textContent = attachSpanText;
63
+ }
64
+
65
+ }
66
+ }
67
+
68
+ }
69
+
70
+ // Executing Function Upon Page Load
71
+ Event.observe(window, "dom:loaded", attachTitleResponsive, true);
72
+
73
+ // Executing Function Upon Browser Resize
74
+ Event.observe(window, "resize", attachTitleResponsive, true);
75
+
76
+ </script>
77
+ <div class="attach-tab">
78
+ <?php
79
+ if(Mage::helper('attachments/data')->getAttachHeadFromConfig()){
80
+ ?>
81
+ <h1><?php echo Mage::helper('attachments/data')->getAttachHeadFromConfig(); ?></h1>
82
+ <?php
83
+ }
84
+ ?>
85
+ </div>
86
+ <div class="box-collateral box-attachments box-up-sell">
87
+ <?php $atids = ""; ?>
88
+ <ul class="attachment-outer">
89
+ <?php foreach ($attachments as $_attachment) : ?>
90
+ <?php $_fileSize = $helper->getFileSize($_attachment->getAttachmentPath()); ?>
91
+ <li><a href="<?php echo $_attachment->getAttachmentUrl(); ?>" title="<?php echo $_attachment->getTitle()?>" target="_blank">
92
+ <?php
93
+ if(Mage::getStoreConfig('virtina_attachments/attachment/filetypestatus')){
94
+ echo $_attachment->getIcon();
95
+ }
96
+ ?>
97
+ <span id="attach-title-<?php echo $_attachment->getId()?>"><?php
98
+ $attachTitle = $_attachment->getTitle();
99
+ echo $attachTitle;
100
+ $atids .= $_attachment->getId().",";
101
+ ?></span>
102
+ <?php echo $this->__(' (Size: ' .$_fileSize . ')'); ?>
103
+ </a>
104
+ <input type="hidden" id="attach-title-full-<?php echo $_attachment->getId()?>" name="attach-title-full-<?php echo $_attachment->getId()?>" value="<?php echo $attachTitle; ?>" />
105
+ </li>
106
+
107
+ <?php endforeach; ?>
108
+ </ul>
109
+ <?php $atids = substr($atids, 0, -1); ?>
110
+ <input type="hidden" id="atids" name="atids" value="<?php echo $atids; ?>" />
111
+ </div>
112
+ <?php else:?>
113
+ <div class="box-collateral box-attachments box-up-sell"><?php echo $this->__('No attachments found!!!')?></div>
114
+ <?php endif; ?>
app/etc/modules/Virtina_Attachments.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Attachments
6
+ * @copyright Copyright (coffee) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Virtina_Attachments>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ <depends>
16
+ <Mage_Catalog />
17
+ </depends>
18
+ </Virtina_Attachments>
19
+ </modules>
20
+ </config>
app/locale/en_US/Virtina_Attachments.csv ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,
2
+ Action,Action
3
+ Home,Home
4
+ Id,Id
5
+ No,No
6
+ None,None
7
+ Please select attachments to delete.,Please select attachments to delete.
8
+ Please select attachments.,Please select attachments.
9
+ Position,Position
10
+ Reset,Reset
11
+ Save And Continue Edit,Save And Continue Edit
12
+ Save Attachment,Save Attachment
13
+ Status,Status
14
+ Store views,Store views
15
+ The attachments has been deleted.,The attachments has been deleted.
16
+ There was a problem saving the attachment.,There was a problem saving the attachment.
17
+ There was an error deleting attachment.,There was an error deleting attachment.
18
+ There was an error deleting attachments.,There was an error deleting attachments.
19
+ There was an error updating attachments.,There was an error updating attachments.
20
+ This attachment no longer exists.,This attachment no longer exists.
21
+ Title,Title
22
+ Total of %d attachments were successfully deleted.,Total of %d attachments were successfully deleted.
23
+ Total of %d attachments were successfully updated.,Total of %d attachments were successfully updated.
24
+ Total of %d record(s) have been deleted.,Total of %d record(s) have been deleted.
25
+ Total of %d record(s) have been updated.,Total of %d record(s) have been updated.
26
+ Unable to find attachment to save.,Unable to find attachment to save.
27
+ Updated at,Updated at
28
+ Uploaded file,Uploaded file
29
+ Use Breadcrumbs,Use Breadcrumbs
30
+ WYSIWYG Editor,WYSIWYG Editor
31
+ XML,XML
32
+ Yes,Yes
33
+ Add Attachment,Add Attachment
34
+ An error occurred while updating the attachments.,An error occurred while updating the attachments.
35
+ Are you sure?,Are you sure?
36
+ Associated products,Associated products
37
+ Attachment was saved,Attachment was saved
38
+ Attachment was successfully deleted.,Attachment was successfully deleted.
39
+ Attachment was successfully saved,Attachment was successfully saved
40
+ Attachment,Attachment
41
+ Attachments,Attachments
42
+ CSV,CSV
43
+ Change status,Change status
44
+ Could not find attachment to delete.,Could not find attachment to delete.
45
+ Created at,Created at
46
+ Delete Attachment,Delete Attachment
47
+ Delete File,Delete File
48
+ Delete,Delete
49
+ Disabled,Disabled
50
+ Edit Attachment '%s',Edit Attachment '%s'
51
+ Edit,Edit
52
+ Enabled,Enabled
53
+ Error saving attachment,Error saving attachment
54
+ Excel,Excel
55
+ Catalog Attachments,Catalog Attachments
media/catalog-attachment/icons/3gp.png ADDED
Binary file
media/catalog-attachment/icons/avi.png ADDED
Binary file
media/catalog-attachment/icons/bmp.png ADDED
Binary file
media/catalog-attachment/icons/css.png ADDED
Binary file
media/catalog-attachment/icons/csv.png ADDED
Binary file
media/catalog-attachment/icons/default.png ADDED
Binary file
media/catalog-attachment/icons/doc.png ADDED
Binary file
media/catalog-attachment/icons/docx.png ADDED
Binary file
media/catalog-attachment/icons/flv.png ADDED
Binary file
media/catalog-attachment/icons/gif.png ADDED
Binary file
media/catalog-attachment/icons/htm.png ADDED
Binary file
media/catalog-attachment/icons/html.png ADDED
Binary file
media/catalog-attachment/icons/jpeg.png ADDED
Binary file
media/catalog-attachment/icons/jpg.png ADDED
Binary file
media/catalog-attachment/icons/mov.png ADDED
Binary file
media/catalog-attachment/icons/mp3.png ADDED
Binary file
media/catalog-attachment/icons/mp4.png ADDED
Binary file
media/catalog-attachment/icons/odf.png ADDED
Binary file
media/catalog-attachment/icons/odt.png ADDED
Binary file
media/catalog-attachment/icons/pdf.png ADDED
Binary file
media/catalog-attachment/icons/plain.png ADDED
Binary file
media/catalog-attachment/icons/png.png ADDED
Binary file
media/catalog-attachment/icons/ppt.png ADDED
Binary file
media/catalog-attachment/icons/pptx.png ADDED
Binary file
media/catalog-attachment/icons/psd.png ADDED
Binary file
media/catalog-attachment/icons/rar.png ADDED
Binary file
media/catalog-attachment/icons/rtf.png ADDED
Binary file
media/catalog-attachment/icons/sql.png ADDED
Binary file
media/catalog-attachment/icons/swf.png ADDED
Binary file
media/catalog-attachment/icons/tiff.png ADDED
Binary file
media/catalog-attachment/icons/txt.png ADDED
Binary file
media/catalog-attachment/icons/wav.png ADDED
Binary file
media/catalog-attachment/icons/wmv.png ADDED
Binary file
media/catalog-attachment/icons/xls.png ADDED
Binary file
media/catalog-attachment/icons/xlsx.png ADDED
Binary file
media/catalog-attachment/icons/xml.png ADDED
Binary file
media/catalog-attachment/icons/zip.png ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Virtina_Attachments</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Catalog Attachments extension is a simple tool to upload product related files through admin panel and display the files in the product view page. There is a configuration section in the admin side to configure the module.</summary>
10
+ <description>The Catalog Attachments is an extension for magento to upload product related files (Product manuals, guides, images or videos etc...) through admin panel and display the files in the product view page. There is a configuration section in the admin side to configure the module. The extension is responsive and will support in all common browsers and in different resolutions.</description>
11
+ <notes>The Catalog Attachments is an extension for magento to upload product related files (Product manuals, guides, images or videos etc...) through admin panel and display the files in the product view page. There is a configuration section in the admin side to configure the module. The extension is responsive and will support in all common browsers and in different resolutions.</notes>
12
+ <authors><author><name>Virtina</name><user>Virtina</user><email>gigijk@virtina.com</email></author></authors>
13
+ <date>2016-08-29</date>
14
+ <time>05:18:07</time>
15
+ <contents><target name="magecommunity"><dir name="Virtina"><dir name="Attachments"><dir name="Block"><dir name="Adminhtml"><dir name="Attachment"><dir name="Edit"><file name="Form.php" hash="7e333cfdab3fd3f2b7a2cb3b9d2c7a6e"/><dir name="Tab"><file name="Form.php" hash="f0c1f691f5eab86ffbf04763995d79f2"/><file name="Product.php" hash="aa866c668e68cc869fcfbee9290da399"/></dir><file name="Tabs.php" hash="8694ea78f83971ccbe2bca40f40e28a8"/></dir><file name="Edit.php" hash="3547f51487be7924a65974ac5da5c4dd"/><file name="Grid.php" hash="352c53d057b020ff58af02706b73ad43"/></dir><file name="Attachment.php" hash="8bd5c483e554cd9b20fa4b65d5900771"/><dir name="Catalog"><dir name="Column"><dir name="Renderer"><file name="Relation.php" hash="88f173be151c9edc6e4f38a5a7c7a846"/></dir></dir><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Attachment.php" hash="6479e102052d319b0c11f1da6c44d4a3"/></dir></dir></dir></dir><dir name="Helper"><file name="File.php" hash="27c79585e6360f6310bdc5f453381764"/></dir></dir><dir name="Attachment"><file name="List.php" hash="1d1fbc3d5dd04c4caa1b8a9ac42b36e3"/></dir><file name="Attachment.php" hash="1ad2e49320c45e9057b235eb92a0e0c1"/></dir><dir name="Helper"><file name="Attachment.php" hash="fae1ee53d6a0cb93d545574b004ca115"/><file name="Data.php" hash="b89534b486f81e2d283421acae7c6493"/><file name="Product.php" hash="dd7cbae877ed45350b419c5f1e53d631"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="2a077ca1c55fa62554697576012a5a0a"/></dir><file name="Attachment.php" hash="da8d185d5ec3f5b5450827853c96b445"/><file name="Attachmentproduct.php" hash="c1a269331fcae9c713fd7726e54d15a6"/><dir name="Mysql4"><dir name="Attachment"><file name="Collection.php" hash="63b12bbafbe9c5a1536f91372b446275"/></dir><file name="Attachment.php" hash="2bf7266b5322c6930452ec502a430d81"/><dir name="Attachmentproduct"><file name="Collection.php" hash="ed9c823980b153a9737ceef55221932b"/></dir><file name="Attachmentproduct.php" hash="409d9e6b7ff6cae097c83f31b641259e"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Truefalse.php" hash="02318f071ac5a138ef1610034b4564a8"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Attachments"><dir name="Attachment"><dir name="Catalog"><file name="ProductController.php" hash="39e2946a599a7e23e3740edbd416d43c"/></dir></dir><file name="AttachmentController.php" hash="babbaa5a9eebd79a326368d6731d6f6c"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="4a64090e9ed955821dc297d8e9764894"/><file name="config.xml" hash="908d67586dc3c4205e9e4241ee8af577"/><file name="system.xml" hash="502fd5ad15e2b4440903188ed1b24777"/></dir><dir name="sql"><dir name="attachments_setup"><file name="mysql4-install-0.0.1.php" hash="dec08607a270994b59ef634db94525dd"/></dir><dir name="vattachments_setup"><file name="mysql4-install-0.0.1.php" hash="dec08607a270994b59ef634db94525dd"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Virtina_Attachments.xml" hash="922d8fad9dd7072c8dceda79fe6461d2"/></dir></target><target name="magemedia"><dir name="catalog-attachment"><dir name="icons"><file name="3gp.png" hash="778ac12f7ed04f844a2c3bb908480764"/><file name="avi.png" hash="f66d43a112b36ed2cb53a9244f183982"/><file name="bmp.png" hash="5737ec5a1580f157a40fa2aee7a560cc"/><file name="css.png" hash="c6fedef5a900b2f6cb639a94aa91ee43"/><file name="csv.png" hash="3edf5e9b96d67b634a06427a80e55083"/><file name="default.png" hash="c362d1f34ea703c0fc073eb71da3190c"/><file name="doc.png" hash="1f922840d303fc238fb10d56520552e9"/><file name="docx.png" hash="5c83569f6564b8b48717a33da128c373"/><file name="flv.png" hash="bcad25e29f6bd285bc38e6d7efad4135"/><file name="gif.png" hash="595395848d6ab4d3edc9a6f613837b73"/><file name="htm.png" hash="94a4c254e9839ed523c823bc8044bbe2"/><file name="html.png" hash="e590722778e4298e6c44e981240a9c4c"/><file name="jpeg.png" hash="1b96229c4ac0b49f3a1539eca788e237"/><file name="jpg.png" hash="c6c4d18b7f9045dc2779948fa0b3a8d7"/><file name="mov.png" hash="c566822427197af5993fb017f9024515"/><file name="mp3.png" hash="e589e9573e622261d9ef688c3f96d64f"/><file name="mp4.png" hash="5af5ea9147330a8ec0a3c60f345672f4"/><file name="odf.png" hash="3516e9c591e7ab5cc657d3714d92ac60"/><file name="odt.png" hash="27d3f92692ecb30538da020872645e95"/><file name="pdf.png" hash="6c287aaf653a768fb3f6c603c48161b5"/><file name="plain.png" hash="2dffb4d43bfe35f219856b2ce8d79b09"/><file name="png.png" hash="2a0cc067f7e3efa8e083b4ff16aaecda"/><file name="ppt.png" hash="b73bc9033c7ed16921ac2ce457ea38eb"/><file name="pptx.png" hash="d24652ba9d994f7fadf930ee8449a043"/><file name="psd.png" hash="7066d72783e88f3bc1711a513dedac4a"/><file name="rar.png" hash="8e4f6c820b241932c03dd0a1490009ed"/><file name="rtf.png" hash="6f5edb44d2ceea0599a3caf7fb0839a1"/><file name="sql.png" hash="b91fa82222820b3227a443a4f933f212"/><file name="swf.png" hash="443decb7fd937d27856704e92015656d"/><file name="tiff.png" hash="e8d7f677d5dc1b60b3935fb262efa4dc"/><file name="txt.png" hash="7e601f44efba8e8159041a46f79830a1"/><file name="wav.png" hash="b37d9fe3fe54415b051aa50610acf659"/><file name="wmv.png" hash="675b5d36c2370eac8784f229dbd1f9b9"/><file name="xls.png" hash="baa879b507a8788045d613246755b85a"/><file name="xlsx.png" hash="1060387404d16194006806dc08e25ab4"/><file name="xml.png" hash="fa01de142c6ccb97b36fc50cda296412"/><file name="zip.png" hash="79032c01b9e4c3402d2c3607725005d7"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Virtina_Attachments.csv" hash="02737d0a1b7914b9f96f5500a77d00cb"/></dir></target><target name="mageskin"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="catalog-attachments"><file name="catalog-attachment.css" hash="bb3cdaaba8496831d11b4f9c74a1e044"/></dir></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="catalog-attachments.xml" hash="77dff9cc6756460024db0940fb229920"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="catalog-attachments.xml" hash="e2576fbf04319511b8f5bddb5889d43d"/></dir><dir name="template"><dir name="catalog-attachment"><file name="catalog-attachment.phtml" hash="721060098cc0fe55278241ab2cf2d5b0"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/catalog-attachments/catalog-attachment.css ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Virtina
3
+ * @package Virtina_Attachments
4
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.virtina.com)
5
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
6
+ */
7
+ .attach-img > img {
8
+ margin-right:5px;
9
+ }
10
+ .attach-img {
11
+ float: left;
12
+ }
13
+ .box-collateral.box-attachments.box-up-sell li {
14
+ height: 40px;
15
+ }
16
+ .attach-tab{
17
+ padding: 10px 0 5px 0;
18
+ }
19
+ .attach-tab h1 {
20
+ font-size: 20px;
21
+ font-weight: 500;
22
+ }
23
+ .attachment-outer{
24
+ margin-top:0;
25
+ }
26
+ .tab-content .attachment-outer{
27
+ margin-top:-20px !important;
28
+ }
29
+ .attachment-outer > li {
30
+ line-height: 20px;
31
+ margin-bottom: 10px !important;
32
+ }