Version Notes
Version number: 1.1.0
Stability: Stable
Compatibility: 1.5, 1.6, 1.6.1, 1.6.2.0, 1.7, 1.8, 1.9
Download this release
Release Info
Developer | Sergey Repin |
Extension | Web4pro_Attachments |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment.php +36 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit.php +76 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit/Form.php +46 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit/Tab/Form.php +94 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit/Tab/Product.php +263 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit/Tabs.php +76 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Grid.php +193 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Helper/File.php +115 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Widget/Chooser.php +177 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Catalog/Product/Edit/Tab/Attachment.php +241 -0
- app/code/community/Web4pro/Attachments/Block/Adminhtml/Helper/Column/Renderer/Relation.php +50 -0
- app/code/community/Web4pro/Attachments/Block/Attachment/List.php +66 -0
- app/code/community/Web4pro/Attachments/Block/Attachment/Widget/Link.php +21 -0
- app/code/community/Web4pro/Attachments/Block/Attachment/Widget/View.php +45 -0
- app/code/community/Web4pro/Attachments/Block/Catalog/Product/List/Attachment.php +41 -0
- app/code/community/Web4pro/Attachments/Controller/Adminhtml/Attachments.php +54 -0
- app/code/community/Web4pro/Attachments/Helper/Attachment.php +75 -0
- app/code/community/Web4pro/Attachments/Helper/Data.php +39 -0
- app/code/community/Web4pro/Attachments/Helper/Product.php +55 -0
- app/code/community/Web4pro/Attachments/Model/Adminhtml/Observer.php +90 -0
- app/code/community/Web4pro/Attachments/Model/Adminhtml/Search/Attachment.php +54 -0
- app/code/community/Web4pro/Attachments/Model/Attachment.php +200 -0
- app/code/community/Web4pro/Attachments/Model/Attachment/Product.php +62 -0
- app/code/community/Web4pro/Attachments/Model/Resource/Attachment.php +31 -0
- app/code/community/Web4pro/Attachments/Model/Resource/Attachment/Collection.php +103 -0
- app/code/community/Web4pro/Attachments/Model/Resource/Attachment/Product.php +90 -0
- app/code/community/Web4pro/Attachments/Model/Resource/Attachment/Product/Collection.php +66 -0
- app/code/community/Web4pro/Attachments/Model/Resource/Setup.php +20 -0
- app/code/community/Web4pro/Attachments/controllers/Adminhtml/Attachments/Attachment/Catalog/ProductController.php +64 -0
- app/code/community/Web4pro/Attachments/controllers/Adminhtml/Attachments/Attachment/WidgetController.php +39 -0
- app/code/community/Web4pro/Attachments/controllers/Adminhtml/Attachments/AttachmentController.php +370 -0
- app/code/community/Web4pro/Attachments/controllers/AttachmentController.php +20 -0
- app/code/community/Web4pro/Attachments/etc/adminhtml.xml +55 -0
- app/code/community/Web4pro/Attachments/etc/config.xml +145 -0
- app/code/community/Web4pro/Attachments/etc/system.xml +53 -0
- app/code/community/Web4pro/Attachments/etc/widget.xml +58 -0
- app/code/community/Web4pro/Attachments/sql/web4pro_attachments_setup/install-1.0.0.php +158 -0
- app/design/adminhtml/default/default/layout/web4pro_attachments.xml +92 -0
- app/design/frontend/base/default/layout/web4pro_attachments.xml +23 -0
- app/design/frontend/base/default/template/web4pro_attachments/attachment/widget/link.phtml +29 -0
- app/design/frontend/base/default/template/web4pro_attachments/attachment/widget/view.phtml +30 -0
- app/design/frontend/base/default/template/web4pro_attachments/catalog/product/list/attachment.phtml +37 -0
- app/etc/modules/Web4pro_Attachments.xml +23 -0
- app/locale/en_US/Web4pro_Attachments.csv +54 -0
- media/attachment/icons/avi.png +0 -0
- media/attachment/icons/bmp.png +0 -0
- media/attachment/icons/css.png +0 -0
- media/attachment/icons/csv.png +0 -0
- media/attachment/icons/doc.png +0 -0
- media/attachment/icons/docx.png +0 -0
- media/attachment/icons/flv.png +0 -0
- media/attachment/icons/gif.png +0 -0
- media/attachment/icons/htm.png +0 -0
- media/attachment/icons/html.png +0 -0
- media/attachment/icons/jpeg.png +0 -0
- media/attachment/icons/jpg.png +0 -0
- media/attachment/icons/mov.png +0 -0
- media/attachment/icons/mp3.png +0 -0
- media/attachment/icons/pdf.png +0 -0
- media/attachment/icons/plain.png +0 -0
- media/attachment/icons/png.png +0 -0
- media/attachment/icons/ppt.png +0 -0
- media/attachment/icons/rtf.png +0 -0
- media/attachment/icons/swf.png +0 -0
- media/attachment/icons/txt.png +0 -0
- media/attachment/icons/wav.png +0 -0
- media/attachment/icons/wmv.png +0 -0
- media/attachment/icons/xls.png +0 -0
- media/attachment/icons/xlsx.png +0 -0
- media/attachment/icons/xml.png +0 -0
- media/attachment/icons/zip.png +0 -0
- package.xml +21 -0
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment admin block
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment extends Mage_Adminhtml_Block_Widget_Grid_Container
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* constructor
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @return void
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
public function __construct()
|
28 |
+
{
|
29 |
+
$this->_controller = 'adminhtml_attachment';
|
30 |
+
$this->_blockGroup = 'web4pro_attachments';
|
31 |
+
parent::__construct();
|
32 |
+
$this->_headerText = Mage::helper('web4pro_attachments')->__('Attachment');
|
33 |
+
$this->_updateButton('add', 'label', Mage::helper('web4pro_attachments')->__('Add Attachment'));
|
34 |
+
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment admin edit form
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* constructor
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @return void
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
public function __construct()
|
28 |
+
{
|
29 |
+
parent::__construct();
|
30 |
+
$this->_blockGroup = 'web4pro_attachments';
|
31 |
+
$this->_controller = 'adminhtml_attachment';
|
32 |
+
$this->_updateButton(
|
33 |
+
'save',
|
34 |
+
'label',
|
35 |
+
Mage::helper('web4pro_attachments')->__('Save Attachment')
|
36 |
+
);
|
37 |
+
$this->_updateButton(
|
38 |
+
'delete',
|
39 |
+
'label',
|
40 |
+
Mage::helper('web4pro_attachments')->__('Delete Attachment')
|
41 |
+
);
|
42 |
+
$this->_addButton(
|
43 |
+
'saveandcontinue',
|
44 |
+
array(
|
45 |
+
'label' => Mage::helper('web4pro_attachments')->__('Save And Continue Edit'),
|
46 |
+
'onclick' => 'saveAndContinueEdit()',
|
47 |
+
'class' => 'save',
|
48 |
+
),
|
49 |
+
-100
|
50 |
+
);
|
51 |
+
$this->_formScripts[] = "
|
52 |
+
function saveAndContinueEdit() {
|
53 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
54 |
+
}
|
55 |
+
";
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* get the edit form header
|
60 |
+
*
|
61 |
+
* @access public
|
62 |
+
* @return string
|
63 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
64 |
+
*/
|
65 |
+
public function getHeaderText()
|
66 |
+
{
|
67 |
+
if (Mage::registry('current_attachment') && Mage::registry('current_attachment')->getId()) {
|
68 |
+
return Mage::helper('web4pro_attachments')->__(
|
69 |
+
"Edit Attachment '%s'",
|
70 |
+
$this->escapeHtml(Mage::registry('current_attachment')->getTitle())
|
71 |
+
);
|
72 |
+
} else {
|
73 |
+
return Mage::helper('web4pro_attachments')->__('Add Attachment');
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit/Form.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment edit form
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* prepare form
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Form
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
protected function _prepareForm()
|
28 |
+
{
|
29 |
+
$form = new Varien_Data_Form(
|
30 |
+
array(
|
31 |
+
'id' => 'edit_form',
|
32 |
+
'action' => $this->getUrl(
|
33 |
+
'*/*/save',
|
34 |
+
array(
|
35 |
+
'id' => $this->getRequest()->getParam('id')
|
36 |
+
)
|
37 |
+
),
|
38 |
+
'method' => 'post',
|
39 |
+
'enctype' => 'multipart/form-data'
|
40 |
+
)
|
41 |
+
);
|
42 |
+
$form->setUseContainer(true);
|
43 |
+
$this->setForm($form);
|
44 |
+
return parent::_prepareForm();
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment edit form tab
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* prepare the form
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Form
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
protected function _prepareForm()
|
28 |
+
{
|
29 |
+
$form = new Varien_Data_Form();
|
30 |
+
$form->setHtmlIdPrefix('attachment_');
|
31 |
+
$form->setFieldNameSuffix('attachment');
|
32 |
+
$this->setForm($form);
|
33 |
+
$fieldset = $form->addFieldset(
|
34 |
+
'attachment_form',
|
35 |
+
array('legend' => Mage::helper('web4pro_attachments')->__('Attachment'))
|
36 |
+
);
|
37 |
+
$fieldset->addType(
|
38 |
+
'file',
|
39 |
+
Mage::getConfig()->getBlockClassName('web4pro_attachments/adminhtml_attachment_helper_file')
|
40 |
+
);
|
41 |
+
|
42 |
+
$fieldset->addField(
|
43 |
+
'title',
|
44 |
+
'text',
|
45 |
+
array(
|
46 |
+
'label' => Mage::helper('web4pro_attachments')->__('Title'),
|
47 |
+
'name' => 'title',
|
48 |
+
'required' => true,
|
49 |
+
'class' => 'required-entry',
|
50 |
+
|
51 |
+
)
|
52 |
+
);
|
53 |
+
|
54 |
+
$fieldset->addField(
|
55 |
+
'uploaded_file',
|
56 |
+
'file',
|
57 |
+
array(
|
58 |
+
'label' => Mage::helper('web4pro_attachments')->__('Uploaded file'),
|
59 |
+
'name' => 'uploaded_file',
|
60 |
+
|
61 |
+
)
|
62 |
+
);
|
63 |
+
$fieldset->addField(
|
64 |
+
'status',
|
65 |
+
'select',
|
66 |
+
array(
|
67 |
+
'label' => Mage::helper('web4pro_attachments')->__('Status'),
|
68 |
+
'name' => 'status',
|
69 |
+
'values' => array(
|
70 |
+
array(
|
71 |
+
'value' => 1,
|
72 |
+
'label' => Mage::helper('web4pro_attachments')->__('Enabled'),
|
73 |
+
),
|
74 |
+
array(
|
75 |
+
'value' => 0,
|
76 |
+
'label' => Mage::helper('web4pro_attachments')->__('Disabled'),
|
77 |
+
),
|
78 |
+
),
|
79 |
+
)
|
80 |
+
);
|
81 |
+
$formValues = Mage::registry('current_attachment')->getDefaultValues();
|
82 |
+
if (!is_array($formValues)) {
|
83 |
+
$formValues = array();
|
84 |
+
}
|
85 |
+
if (Mage::getSingleton('adminhtml/session')->getAttachmentData()) {
|
86 |
+
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAttachmentData());
|
87 |
+
Mage::getSingleton('adminhtml/session')->setAttachmentData(null);
|
88 |
+
} elseif (Mage::registry('current_attachment')) {
|
89 |
+
$formValues = array_merge($formValues, Mage::registry('current_attachment')->getData());
|
90 |
+
}
|
91 |
+
$form->setValues($formValues);
|
92 |
+
return parent::_prepareForm();
|
93 |
+
}
|
94 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit/Tab/Product.php
ADDED
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment - product relation edit block
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Set grid params
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
25 |
+
*/
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
parent::__construct();
|
29 |
+
$this->setId('product_grid');
|
30 |
+
$this->setDefaultSort('entity_id');
|
31 |
+
$this->setDefaultDir('desc');
|
32 |
+
$this->setUseAjax(true);
|
33 |
+
if ($this->getAttachment()->getId()) {
|
34 |
+
$this->setDefaultFilter(array('in_products'=>1));
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* prepare the product collection
|
40 |
+
*
|
41 |
+
* @access protected
|
42 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Product
|
43 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
44 |
+
*/
|
45 |
+
protected function _prepareCollection()
|
46 |
+
{
|
47 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
48 |
+
$collection->addAttributeToSelect('price');
|
49 |
+
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
|
50 |
+
$collection->joinAttribute('product_name', 'catalog_product/name', 'entity_id', null, 'left', $adminStore);
|
51 |
+
if ($this->getAttachment()->getId()) {
|
52 |
+
$constraint = '{{table}}.attachment_id='.$this->getAttachment()->getId();
|
53 |
+
} else {
|
54 |
+
$constraint = '{{table}}.attachment_id=0';
|
55 |
+
}
|
56 |
+
$collection->joinField(
|
57 |
+
'position',
|
58 |
+
'web4pro_attachments/attachment_product',
|
59 |
+
'position',
|
60 |
+
'product_id=entity_id',
|
61 |
+
$constraint,
|
62 |
+
'left'
|
63 |
+
);
|
64 |
+
$this->setCollection($collection);
|
65 |
+
parent::_prepareCollection();
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* prepare mass action grid
|
71 |
+
*
|
72 |
+
* @access protected
|
73 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Product
|
74 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
75 |
+
*/
|
76 |
+
protected function _prepareMassaction()
|
77 |
+
{
|
78 |
+
return $this;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* prepare the grid columns
|
83 |
+
*
|
84 |
+
* @access protected
|
85 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Product
|
86 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
87 |
+
*/
|
88 |
+
protected function _prepareColumns()
|
89 |
+
{
|
90 |
+
$this->addColumn(
|
91 |
+
'in_products',
|
92 |
+
array(
|
93 |
+
'header_css_class' => 'a-center',
|
94 |
+
'type' => 'checkbox',
|
95 |
+
'name' => 'in_products',
|
96 |
+
'values'=> $this->_getSelectedProducts(),
|
97 |
+
'align' => 'center',
|
98 |
+
'index' => 'entity_id'
|
99 |
+
)
|
100 |
+
);
|
101 |
+
$this->addColumn(
|
102 |
+
'entity_id',
|
103 |
+
array(
|
104 |
+
'header' => Mage::helper('catalog')->__('ID'),
|
105 |
+
'width' => '1',
|
106 |
+
'align' => 'left',
|
107 |
+
'index' => 'entity_id',
|
108 |
+
)
|
109 |
+
);
|
110 |
+
$this->addColumn(
|
111 |
+
'product_name',
|
112 |
+
array(
|
113 |
+
'header' => Mage::helper('catalog')->__('Name'),
|
114 |
+
'align' => 'left',
|
115 |
+
'index' => 'product_name',
|
116 |
+
'renderer' => 'web4pro_attachments/adminhtml_helper_column_renderer_relation',
|
117 |
+
'params' => array(
|
118 |
+
'id' => 'getId'
|
119 |
+
),
|
120 |
+
'base_link' => 'adminhtml/catalog_product/edit',
|
121 |
+
)
|
122 |
+
);
|
123 |
+
$this->addColumn(
|
124 |
+
'sku',
|
125 |
+
array(
|
126 |
+
'header' => Mage::helper('catalog')->__('SKU'),
|
127 |
+
'align' => 'left',
|
128 |
+
'index' => 'sku',
|
129 |
+
)
|
130 |
+
);
|
131 |
+
$this->addColumn(
|
132 |
+
'price',
|
133 |
+
array(
|
134 |
+
'header' => Mage::helper('catalog')->__('Price'),
|
135 |
+
'type' => 'currency',
|
136 |
+
'width' => '1',
|
137 |
+
'currency_code' => (string)Mage::getStoreConfig(
|
138 |
+
Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE
|
139 |
+
),
|
140 |
+
'index' => 'price'
|
141 |
+
)
|
142 |
+
);
|
143 |
+
$this->addColumn(
|
144 |
+
'position',
|
145 |
+
array(
|
146 |
+
'header' => Mage::helper('catalog')->__('Position'),
|
147 |
+
'name' => 'position',
|
148 |
+
'width' => 60,
|
149 |
+
'type' => 'number',
|
150 |
+
'validate_class' => 'validate-number',
|
151 |
+
'index' => 'position',
|
152 |
+
'editable' => true,
|
153 |
+
)
|
154 |
+
);
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Retrieve selected products
|
159 |
+
*
|
160 |
+
* @access protected
|
161 |
+
* @return array
|
162 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
163 |
+
*/
|
164 |
+
protected function _getSelectedProducts()
|
165 |
+
{
|
166 |
+
$products = $this->getAttachmentProducts();
|
167 |
+
if (!is_array($products)) {
|
168 |
+
$products = array_keys($this->getSelectedProducts());
|
169 |
+
}
|
170 |
+
return $products;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Retrieve selected products
|
175 |
+
*
|
176 |
+
* @access protected
|
177 |
+
* @return array
|
178 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
179 |
+
*/
|
180 |
+
public function getSelectedProducts()
|
181 |
+
{
|
182 |
+
$products = array();
|
183 |
+
$selected = Mage::registry('current_attachment')->getSelectedProducts();
|
184 |
+
if (!is_array($selected)) {
|
185 |
+
$selected = array();
|
186 |
+
}
|
187 |
+
foreach ($selected as $product) {
|
188 |
+
$products[$product->getId()] = array('position' => $product->getPosition());
|
189 |
+
}
|
190 |
+
return $products;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* get row url
|
195 |
+
*
|
196 |
+
* @access public
|
197 |
+
* @param Web4pro_Attachments_Model_Product
|
198 |
+
* @return string
|
199 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
200 |
+
*/
|
201 |
+
public function getRowUrl($item)
|
202 |
+
{
|
203 |
+
return '#';
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* get grid url
|
208 |
+
*
|
209 |
+
* @access public
|
210 |
+
* @return string
|
211 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
212 |
+
*/
|
213 |
+
public function getGridUrl()
|
214 |
+
{
|
215 |
+
return $this->getUrl(
|
216 |
+
'*/*/productsGrid',
|
217 |
+
array(
|
218 |
+
'id' => $this->getAttachment()->getId()
|
219 |
+
)
|
220 |
+
);
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* get the current attachment
|
225 |
+
*
|
226 |
+
* @access public
|
227 |
+
* @return Web4pro_Attachments_Model_Attachment
|
228 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
229 |
+
*/
|
230 |
+
public function getAttachment()
|
231 |
+
{
|
232 |
+
return Mage::registry('current_attachment');
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Add filter
|
237 |
+
*
|
238 |
+
* @access protected
|
239 |
+
* @param object $column
|
240 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tab_Product
|
241 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
242 |
+
*/
|
243 |
+
protected function _addColumnFilterToCollection($column)
|
244 |
+
{
|
245 |
+
// Set custom filter for in product flag
|
246 |
+
if ($column->getId() == 'in_products') {
|
247 |
+
$productIds = $this->_getSelectedProducts();
|
248 |
+
if (empty($productIds)) {
|
249 |
+
$productIds = 0;
|
250 |
+
}
|
251 |
+
if ($column->getFilter()->getValue()) {
|
252 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds));
|
253 |
+
} else {
|
254 |
+
if ($productIds) {
|
255 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds));
|
256 |
+
}
|
257 |
+
}
|
258 |
+
} else {
|
259 |
+
parent::_addColumnFilterToCollection($column);
|
260 |
+
}
|
261 |
+
return $this;
|
262 |
+
}
|
263 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Edit/Tabs.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment admin edit tabs
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Initialize Tabs
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
25 |
+
*/
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
parent::__construct();
|
29 |
+
$this->setId('attachment_tabs');
|
30 |
+
$this->setDestElementId('edit_form');
|
31 |
+
$this->setTitle(Mage::helper('web4pro_attachments')->__('Attachment'));
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* before render html
|
36 |
+
*
|
37 |
+
* @access protected
|
38 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Edit_Tabs
|
39 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
40 |
+
*/
|
41 |
+
protected function _beforeToHtml()
|
42 |
+
{
|
43 |
+
$this->addTab(
|
44 |
+
'form_attachment',
|
45 |
+
array(
|
46 |
+
'label' => Mage::helper('web4pro_attachments')->__('Attachment'),
|
47 |
+
'title' => Mage::helper('web4pro_attachments')->__('Attachment'),
|
48 |
+
'content' => $this->getLayout()->createBlock(
|
49 |
+
'web4pro_attachments/adminhtml_attachment_edit_tab_form'
|
50 |
+
)
|
51 |
+
->toHtml(),
|
52 |
+
)
|
53 |
+
);
|
54 |
+
$this->addTab(
|
55 |
+
'products',
|
56 |
+
array(
|
57 |
+
'label' => Mage::helper('web4pro_attachments')->__('Associated products'),
|
58 |
+
'url' => $this->getUrl('*/*/products', array('_current' => true)),
|
59 |
+
'class' => 'ajax'
|
60 |
+
)
|
61 |
+
);
|
62 |
+
return parent::_beforeToHtml();
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Retrieve attachment entity
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @return Web4pro_Attachments_Model_Attachment
|
70 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
71 |
+
*/
|
72 |
+
public function getAttachment()
|
73 |
+
{
|
74 |
+
return Mage::registry('current_attachment');
|
75 |
+
}
|
76 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Grid.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment admin grid block
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* constructor
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
25 |
+
*/
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
parent::__construct();
|
29 |
+
$this->setId('attachmentGrid');
|
30 |
+
$this->setDefaultSort('entity_id');
|
31 |
+
$this->setDefaultDir('ASC');
|
32 |
+
$this->setSaveParametersInSession(true);
|
33 |
+
$this->setUseAjax(true);
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* prepare collection
|
38 |
+
*
|
39 |
+
* @access protected
|
40 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Grid
|
41 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
42 |
+
*/
|
43 |
+
protected function _prepareCollection()
|
44 |
+
{
|
45 |
+
$collection = Mage::getModel('web4pro_attachments/attachment')
|
46 |
+
->getCollection();
|
47 |
+
|
48 |
+
$this->setCollection($collection);
|
49 |
+
return parent::_prepareCollection();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* prepare grid collection
|
54 |
+
*
|
55 |
+
* @access protected
|
56 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Grid
|
57 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
58 |
+
*/
|
59 |
+
protected function _prepareColumns()
|
60 |
+
{
|
61 |
+
$this->addColumn(
|
62 |
+
'entity_id',
|
63 |
+
array(
|
64 |
+
'header' => Mage::helper('web4pro_attachments')->__('Id'),
|
65 |
+
'index' => 'entity_id',
|
66 |
+
'type' => 'number'
|
67 |
+
)
|
68 |
+
);
|
69 |
+
$this->addColumn(
|
70 |
+
'title',
|
71 |
+
array(
|
72 |
+
'header' => Mage::helper('web4pro_attachments')->__('Title'),
|
73 |
+
'align' => 'left',
|
74 |
+
'index' => 'title',
|
75 |
+
)
|
76 |
+
);
|
77 |
+
|
78 |
+
$this->addColumn(
|
79 |
+
'status',
|
80 |
+
array(
|
81 |
+
'header' => Mage::helper('web4pro_attachments')->__('Status'),
|
82 |
+
'index' => 'status',
|
83 |
+
'type' => 'options',
|
84 |
+
'options' => array(
|
85 |
+
'1' => Mage::helper('web4pro_attachments')->__('Enabled'),
|
86 |
+
'0' => Mage::helper('web4pro_attachments')->__('Disabled'),
|
87 |
+
)
|
88 |
+
)
|
89 |
+
);
|
90 |
+
$this->addColumn(
|
91 |
+
'action',
|
92 |
+
array(
|
93 |
+
'header' => Mage::helper('web4pro_attachments')->__('Action'),
|
94 |
+
'width' => '100',
|
95 |
+
'type' => 'action',
|
96 |
+
'getter' => 'getId',
|
97 |
+
'actions' => array(
|
98 |
+
array(
|
99 |
+
'caption' => Mage::helper('web4pro_attachments')->__('Edit'),
|
100 |
+
'url' => array('base'=> '*/*/edit'),
|
101 |
+
'field' => 'id'
|
102 |
+
)
|
103 |
+
),
|
104 |
+
'filter' => false,
|
105 |
+
'is_system' => true,
|
106 |
+
'sortable' => false,
|
107 |
+
)
|
108 |
+
);
|
109 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('web4pro_attachments')->__('CSV'));
|
110 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('web4pro_attachments')->__('Excel'));
|
111 |
+
$this->addExportType('*/*/exportXml', Mage::helper('web4pro_attachments')->__('XML'));
|
112 |
+
return parent::_prepareColumns();
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* prepare mass action
|
117 |
+
*
|
118 |
+
* @access protected
|
119 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Grid
|
120 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
121 |
+
*/
|
122 |
+
protected function _prepareMassaction()
|
123 |
+
{
|
124 |
+
$this->setMassactionIdField('entity_id');
|
125 |
+
$this->getMassactionBlock()->setFormFieldName('attachment');
|
126 |
+
$this->getMassactionBlock()->addItem(
|
127 |
+
'delete',
|
128 |
+
array(
|
129 |
+
'label'=> Mage::helper('web4pro_attachments')->__('Delete'),
|
130 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
131 |
+
'confirm' => Mage::helper('web4pro_attachments')->__('Are you sure?')
|
132 |
+
)
|
133 |
+
);
|
134 |
+
$this->getMassactionBlock()->addItem(
|
135 |
+
'status',
|
136 |
+
array(
|
137 |
+
'label' => Mage::helper('web4pro_attachments')->__('Change status'),
|
138 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
139 |
+
'additional' => array(
|
140 |
+
'status' => array(
|
141 |
+
'name' => 'status',
|
142 |
+
'type' => 'select',
|
143 |
+
'class' => 'required-entry',
|
144 |
+
'label' => Mage::helper('web4pro_attachments')->__('Status'),
|
145 |
+
'values' => array(
|
146 |
+
'1' => Mage::helper('web4pro_attachments')->__('Enabled'),
|
147 |
+
'0' => Mage::helper('web4pro_attachments')->__('Disabled'),
|
148 |
+
)
|
149 |
+
)
|
150 |
+
)
|
151 |
+
)
|
152 |
+
);
|
153 |
+
return $this;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* get the row url
|
158 |
+
*
|
159 |
+
* @access public
|
160 |
+
* @param Web4pro_Attachments_Model_Attachment
|
161 |
+
* @return string
|
162 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
163 |
+
*/
|
164 |
+
public function getRowUrl($row)
|
165 |
+
{
|
166 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* get the grid url
|
171 |
+
*
|
172 |
+
* @access public
|
173 |
+
* @return string
|
174 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
175 |
+
*/
|
176 |
+
public function getGridUrl()
|
177 |
+
{
|
178 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* after collection load
|
183 |
+
*
|
184 |
+
* @access protected
|
185 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Grid
|
186 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
187 |
+
*/
|
188 |
+
protected function _afterLoadCollection()
|
189 |
+
{
|
190 |
+
$this->getCollection()->walk('afterLoad');
|
191 |
+
parent::_afterLoadCollection();
|
192 |
+
}
|
193 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Helper/File.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment file field renderer helper
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment_Helper_File extends Varien_Data_Form_Element_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* constructor
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @param array $data
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
public function __construct($data)
|
28 |
+
{
|
29 |
+
parent::__construct($data);
|
30 |
+
$this->setType('file');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* get element html
|
35 |
+
*
|
36 |
+
* @access public
|
37 |
+
* @return string
|
38 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
39 |
+
*/
|
40 |
+
public function getElementHtml()
|
41 |
+
{
|
42 |
+
$html = '';
|
43 |
+
$this->addClass('input-file');
|
44 |
+
$html .= parent::getElementHtml();
|
45 |
+
if ($this->getValue()) {
|
46 |
+
$url = $this->_getUrl();
|
47 |
+
if (!preg_match("/^http\:\/\/|https\:\/\//", $url)) {
|
48 |
+
$url = Mage::helper('web4pro_attachments/attachment')->getFileBaseUrl() . $url;
|
49 |
+
}
|
50 |
+
$html .= '<br /><a href="'.$url.'">'.$this->_getUrl().'</a> ';
|
51 |
+
}
|
52 |
+
$html .= $this->_getDeleteCheckbox();
|
53 |
+
return $html;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* get the delete checkbox HTML
|
58 |
+
*
|
59 |
+
* @access protected
|
60 |
+
* @return string
|
61 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
62 |
+
*/
|
63 |
+
protected function _getDeleteCheckbox()
|
64 |
+
{
|
65 |
+
$html = '';
|
66 |
+
if ($this->getValue()) {
|
67 |
+
$label = Mage::helper('web4pro_attachments')->__('Delete File');
|
68 |
+
$html .= '<span class="delete-image">';
|
69 |
+
$html .= '<input type="checkbox" name="'.
|
70 |
+
parent::getName().'[delete]" value="1" class="checkbox" id="'.
|
71 |
+
$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' disabled="disabled"': '').'/>';
|
72 |
+
$html .= '<label for="'.$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' class="disabled"' : '').'>';
|
73 |
+
$html .= $label.'</label>';
|
74 |
+
$html .= $this->_getHiddenInput();
|
75 |
+
$html .= '</span>';
|
76 |
+
}
|
77 |
+
return $html;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* get the hidden input
|
82 |
+
*
|
83 |
+
* @access protected
|
84 |
+
* @return string
|
85 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
86 |
+
*/
|
87 |
+
protected function _getHiddenInput()
|
88 |
+
{
|
89 |
+
return '<input type="hidden" name="'.parent::getName().'[value]" value="'.$this->getValue().'" />';
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* get the file url
|
94 |
+
*
|
95 |
+
* @access protected
|
96 |
+
* @return string
|
97 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
98 |
+
*/
|
99 |
+
protected function _getUrl()
|
100 |
+
{
|
101 |
+
return $this->getValue();
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* get the name
|
106 |
+
*
|
107 |
+
* @access public
|
108 |
+
* @return string
|
109 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
110 |
+
*/
|
111 |
+
public function getName()
|
112 |
+
{
|
113 |
+
return $this->getData('name');
|
114 |
+
}
|
115 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Attachment/Widget/Chooser.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment admin widget chooser
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
|
19 |
+
class Web4pro_Attachments_Block_Adminhtml_Attachment_Widget_Chooser extends Mage_Adminhtml_Block_Widget_Grid
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Block construction, prepare grid params
|
23 |
+
*
|
24 |
+
* @access public
|
25 |
+
* @param array $arguments Object data
|
26 |
+
* @return void
|
27 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
28 |
+
*/
|
29 |
+
public function __construct($arguments=array())
|
30 |
+
{
|
31 |
+
parent::__construct($arguments);
|
32 |
+
$this->setDefaultSort('entity_id');
|
33 |
+
$this->setDefaultDir('ASC');
|
34 |
+
$this->setUseAjax(true);
|
35 |
+
$this->setDefaultFilter(array('chooser_status' => '1'));
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Prepare chooser element HTML
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param Varien_Data_Form_Element_Abstract $element Form Element
|
43 |
+
* @return Varien_Data_Form_Element_Abstract
|
44 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
45 |
+
*/
|
46 |
+
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
|
47 |
+
{
|
48 |
+
$uniqId = Mage::helper('core')->uniqHash($element->getId());
|
49 |
+
$sourceUrl = $this->getUrl(
|
50 |
+
'web4pro_attachments/adminhtml_attachments_attachment_widget/chooser',
|
51 |
+
array('uniq_id' => $uniqId)
|
52 |
+
);
|
53 |
+
$chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
|
54 |
+
->setElement($element)
|
55 |
+
->setTranslationHelper($this->getTranslationHelper())
|
56 |
+
->setConfig($this->getConfig())
|
57 |
+
->setFieldsetId($this->getFieldsetId())
|
58 |
+
->setSourceUrl($sourceUrl)
|
59 |
+
->setUniqId($uniqId);
|
60 |
+
if ($element->getValue()) {
|
61 |
+
$attachment = Mage::getModel('web4pro_attachments/attachment')->load($element->getValue());
|
62 |
+
if ($attachment->getId()) {
|
63 |
+
$chooser->setLabel($attachment->getTitle());
|
64 |
+
}
|
65 |
+
}
|
66 |
+
$element->setData('after_element_html', $chooser->toHtml());
|
67 |
+
return $element;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Grid Row JS Callback
|
72 |
+
*
|
73 |
+
* @access public
|
74 |
+
* @return string
|
75 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
76 |
+
*/
|
77 |
+
public function getRowClickCallback()
|
78 |
+
{
|
79 |
+
$chooserJsObject = $this->getId();
|
80 |
+
$js = '
|
81 |
+
function (grid, event) {
|
82 |
+
var trElement = Event.findElement(event, "tr");
|
83 |
+
var attachmentId = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,"");
|
84 |
+
var attachmentTitle = trElement.down("td").next().innerHTML;
|
85 |
+
'.$chooserJsObject.'.setElementValue(attachmentId);
|
86 |
+
'.$chooserJsObject.'.setElementLabel(attachmentTitle);
|
87 |
+
'.$chooserJsObject.'.close();
|
88 |
+
}
|
89 |
+
';
|
90 |
+
return $js;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Prepare a static blocks collection
|
95 |
+
*
|
96 |
+
* @access protected
|
97 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Widget_Chooser
|
98 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
99 |
+
*/
|
100 |
+
protected function _prepareCollection()
|
101 |
+
{
|
102 |
+
$collection = Mage::getModel('web4pro_attachments/attachment')->getCollection();
|
103 |
+
$this->setCollection($collection);
|
104 |
+
return parent::_prepareCollection();
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Prepare columns for the a grid
|
109 |
+
*
|
110 |
+
* @access protected
|
111 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Widget_Chooser
|
112 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
113 |
+
*/
|
114 |
+
protected function _prepareColumns()
|
115 |
+
{
|
116 |
+
$this->addColumn(
|
117 |
+
'chooser_id',
|
118 |
+
array(
|
119 |
+
'header' => Mage::helper('web4pro_attachments')->__('Id'),
|
120 |
+
'align' => 'right',
|
121 |
+
'index' => 'entity_id',
|
122 |
+
'type' => 'number',
|
123 |
+
'width' => 50
|
124 |
+
)
|
125 |
+
);
|
126 |
+
|
127 |
+
$this->addColumn(
|
128 |
+
'chooser_title',
|
129 |
+
array(
|
130 |
+
'header' => Mage::helper('web4pro_attachments')->__('Title'),
|
131 |
+
'align' => 'left',
|
132 |
+
'index' => 'title',
|
133 |
+
)
|
134 |
+
);
|
135 |
+
$this->addColumn(
|
136 |
+
'chooser_status',
|
137 |
+
array(
|
138 |
+
'header' => Mage::helper('web4pro_attachments')->__('Status'),
|
139 |
+
'index' => 'status',
|
140 |
+
'type' => 'options',
|
141 |
+
'options' => array(
|
142 |
+
0 => Mage::helper('web4pro_attachments')->__('Disabled'),
|
143 |
+
1 => Mage::helper('web4pro_attachments')->__('Enabled')
|
144 |
+
),
|
145 |
+
)
|
146 |
+
);
|
147 |
+
return parent::_prepareColumns();
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* get url for grid
|
152 |
+
*
|
153 |
+
* @access public
|
154 |
+
* @return string
|
155 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
156 |
+
*/
|
157 |
+
public function getGridUrl()
|
158 |
+
{
|
159 |
+
return $this->getUrl(
|
160 |
+
'adminhtml/attachments_attachment_widget/chooser',
|
161 |
+
array('_current' => true)
|
162 |
+
);
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* after collection load
|
167 |
+
*
|
168 |
+
* @access protected
|
169 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Attachment_Widget_Chooser
|
170 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
171 |
+
*/
|
172 |
+
protected function _afterLoadCollection()
|
173 |
+
{
|
174 |
+
$this->getCollection()->walk('afterLoad');
|
175 |
+
parent::_afterLoadCollection();
|
176 |
+
}
|
177 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Catalog/Product/Edit/Tab/Attachment.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment tab on product edit form
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Adminhtml_Catalog_Product_Edit_Tab_Attachment extends Mage_Adminhtml_Block_Widget_Grid
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Set grid params
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
25 |
+
*/
|
26 |
+
|
27 |
+
public function __construct()
|
28 |
+
{
|
29 |
+
parent::__construct();
|
30 |
+
$this->setId('attachment_grid');
|
31 |
+
$this->setDefaultSort('entity_id');
|
32 |
+
$this->setDefaultDir('desc');
|
33 |
+
$this->setUseAjax(true);
|
34 |
+
if ($this->getProduct()->getId()) {
|
35 |
+
$this->setDefaultFilter(array('in_attachments'=>1));
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* prepare the attachment collection
|
41 |
+
*
|
42 |
+
* @access protected
|
43 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Catalog_Product_Edit_Tab_Attachment
|
44 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
45 |
+
*/
|
46 |
+
protected function _prepareCollection()
|
47 |
+
{
|
48 |
+
$collection = Mage::getResourceModel('web4pro_attachments/attachment_collection');
|
49 |
+
if ($this->getProduct()->getId()) {
|
50 |
+
$constraint = 'related.product_id='.$this->getProduct()->getId();
|
51 |
+
} else {
|
52 |
+
$constraint = 'related.product_id=0';
|
53 |
+
}
|
54 |
+
$collection->getSelect()->joinLeft(
|
55 |
+
array('related' => $collection->getTable('web4pro_attachments/attachment_product')),
|
56 |
+
'related.attachment_id=main_table.entity_id AND '.$constraint,
|
57 |
+
array('position')
|
58 |
+
);
|
59 |
+
$this->setCollection($collection);
|
60 |
+
parent::_prepareCollection();
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* prepare mass action grid
|
66 |
+
*
|
67 |
+
* @access protected
|
68 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Catalog_Product_Edit_Tab_Attachment
|
69 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
70 |
+
*/
|
71 |
+
protected function _prepareMassaction()
|
72 |
+
{
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* prepare the grid columns
|
78 |
+
*
|
79 |
+
* @access protected
|
80 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Catalog_Product_Edit_Tab_Attachment
|
81 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
82 |
+
*/
|
83 |
+
protected function _prepareColumns()
|
84 |
+
{
|
85 |
+
$this->addColumn(
|
86 |
+
'in_attachments',
|
87 |
+
array(
|
88 |
+
'header_css_class' => 'a-center',
|
89 |
+
'type' => 'checkbox',
|
90 |
+
'name' => 'in_attachments',
|
91 |
+
'values'=> $this->_getSelectedAttachments(),
|
92 |
+
'align' => 'center',
|
93 |
+
'index' => 'entity_id'
|
94 |
+
)
|
95 |
+
);
|
96 |
+
|
97 |
+
$this->addColumn(
|
98 |
+
'entity_id',
|
99 |
+
array(
|
100 |
+
'header' => Mage::helper('catalog')->__('ID'),
|
101 |
+
'width' => '1',
|
102 |
+
'align' => 'left',
|
103 |
+
'index' => 'entity_id',
|
104 |
+
)
|
105 |
+
);
|
106 |
+
|
107 |
+
$this->addColumn(
|
108 |
+
'title',
|
109 |
+
array(
|
110 |
+
'header' => Mage::helper('web4pro_attachments')->__('Title'),
|
111 |
+
'align' => 'left',
|
112 |
+
'index' => 'title',
|
113 |
+
'renderer' => 'web4pro_attachments/adminhtml_helper_column_renderer_relation',
|
114 |
+
'params' => array(
|
115 |
+
'id' => 'getId'
|
116 |
+
),
|
117 |
+
'base_link' => 'adminhtml/attachments_attachment/edit',
|
118 |
+
)
|
119 |
+
);
|
120 |
+
$this->addColumn(
|
121 |
+
'position',
|
122 |
+
array(
|
123 |
+
'header' => Mage::helper('web4pro_attachments')->__('Position'),
|
124 |
+
'name' => 'position',
|
125 |
+
'width' => 60,
|
126 |
+
'type' => 'number',
|
127 |
+
'validate_class' => 'validate-number',
|
128 |
+
'index' => 'position',
|
129 |
+
'editable' => true,
|
130 |
+
)
|
131 |
+
);
|
132 |
+
return parent::_prepareColumns();
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Retrieve selected attachments
|
137 |
+
*
|
138 |
+
* @access protected
|
139 |
+
* @return array
|
140 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
141 |
+
*/
|
142 |
+
protected function _getSelectedAttachments()
|
143 |
+
{
|
144 |
+
$attachments = $this->getProductAttachments();
|
145 |
+
if (!is_array($attachments)) {
|
146 |
+
$attachments = array_keys($this->getSelectedAttachments());
|
147 |
+
}
|
148 |
+
return $attachments;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Retrieve selected attachments
|
153 |
+
*
|
154 |
+
* @access protected
|
155 |
+
* @return array
|
156 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
157 |
+
*/
|
158 |
+
public function getSelectedAttachments()
|
159 |
+
{
|
160 |
+
$attachments = array();
|
161 |
+
//used helper here in order not to override the product model
|
162 |
+
$selected = Mage::helper('web4pro_attachments/product')->getSelectedAttachments(Mage::registry('current_product'));
|
163 |
+
if (!is_array($selected)) {
|
164 |
+
$selected = array();
|
165 |
+
}
|
166 |
+
foreach ($selected as $attachment) {
|
167 |
+
$attachments[$attachment->getId()] = array('position' => $attachment->getPosition());
|
168 |
+
}
|
169 |
+
return $attachments;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* get row url
|
174 |
+
*
|
175 |
+
* @access public
|
176 |
+
* @param Web4pro_Attachments_Model_Attachment
|
177 |
+
* @return string
|
178 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
179 |
+
*/
|
180 |
+
public function getRowUrl($item)
|
181 |
+
{
|
182 |
+
return '#';
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* get grid url
|
187 |
+
*
|
188 |
+
* @access public
|
189 |
+
* @return string
|
190 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
191 |
+
*/
|
192 |
+
public function getGridUrl()
|
193 |
+
{
|
194 |
+
return $this->getUrl(
|
195 |
+
'*/*/attachmentsGrid',
|
196 |
+
array(
|
197 |
+
'id'=>$this->getProduct()->getId()
|
198 |
+
)
|
199 |
+
);
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* get the current product
|
204 |
+
*
|
205 |
+
* @access public
|
206 |
+
* @return Mage_Catalog_Model_Product
|
207 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
208 |
+
*/
|
209 |
+
public function getProduct()
|
210 |
+
{
|
211 |
+
return Mage::registry('current_product');
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Add filter
|
216 |
+
*
|
217 |
+
* @access protected
|
218 |
+
* @param object $column
|
219 |
+
* @return Web4pro_Attachments_Block_Adminhtml_Catalog_Product_Edit_Tab_Attachment
|
220 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
221 |
+
*/
|
222 |
+
protected function _addColumnFilterToCollection($column)
|
223 |
+
{
|
224 |
+
if ($column->getId() == 'in_attachments') {
|
225 |
+
$attachmentIds = $this->_getSelectedAttachments();
|
226 |
+
if (empty($attachmentIds)) {
|
227 |
+
$attachmentIds = 0;
|
228 |
+
}
|
229 |
+
if ($column->getFilter()->getValue()) {
|
230 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$attachmentIds));
|
231 |
+
} else {
|
232 |
+
if ($attachmentIds) {
|
233 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$attachmentIds));
|
234 |
+
}
|
235 |
+
}
|
236 |
+
} else {
|
237 |
+
parent::_addColumnFilterToCollection($column);
|
238 |
+
}
|
239 |
+
return $this;
|
240 |
+
}
|
241 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Adminhtml/Helper/Column/Renderer/Relation.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* related entities column renderer
|
13 |
+
* @category Web4pro
|
14 |
+
* @package Web4pro_Attachments
|
15 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
16 |
+
*/
|
17 |
+
class Web4pro_Attachments_Block_Adminhtml_Helper_Column_Renderer_Relation extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* render the column
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @param Varien_Object $row
|
24 |
+
* @return string
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
public function render(Varien_Object $row)
|
28 |
+
{
|
29 |
+
$base = $this->getColumn()->getBaseLink();
|
30 |
+
if (!$base) {
|
31 |
+
return parent::render($row);
|
32 |
+
}
|
33 |
+
$paramsData = $this->getColumn()->getData('params');
|
34 |
+
$params = array();
|
35 |
+
if (is_array($paramsData)) {
|
36 |
+
foreach ($paramsData as $name=>$getter) {
|
37 |
+
if (is_callable(array($row, $getter))) {
|
38 |
+
$params[$name] = call_user_func(array($row, $getter));
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
$staticParamsData = $this->getColumn()->getData('static');
|
43 |
+
if (is_array($staticParamsData)) {
|
44 |
+
foreach ($staticParamsData as $key=>$value) {
|
45 |
+
$params[$key] = $value;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
return '<a href="'.$this->getUrl($base, $params).'" target="_blank">'.$this->_getValue($row).'</a>';
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Attachment/List.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment list block
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Attachment_List extends Mage_Core_Block_Template
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* initialize
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
25 |
+
*/
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
parent::__construct();
|
29 |
+
$attachments = Mage::getResourceModel('web4pro_attachments/attachment_collection')
|
30 |
+
->addFieldToFilter('status', 1);
|
31 |
+
$attachments->setOrder('title', 'asc');
|
32 |
+
$this->setAttachments($attachments);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* prepare the layout
|
37 |
+
*
|
38 |
+
* @access protected
|
39 |
+
* @return Web4pro_Attachments_Block_Attachment_List
|
40 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
41 |
+
*/
|
42 |
+
protected function _prepareLayout()
|
43 |
+
{
|
44 |
+
parent::_prepareLayout();
|
45 |
+
$pager = $this->getLayout()->createBlock(
|
46 |
+
'page/html_pager',
|
47 |
+
'web4pro_attachments.attachment.html.pager'
|
48 |
+
)
|
49 |
+
->setCollection($this->getAttachments());
|
50 |
+
$this->setChild('pager', $pager);
|
51 |
+
$this->getAttachments()->load();
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* get the pager html
|
57 |
+
*
|
58 |
+
* @access public
|
59 |
+
* @return string
|
60 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
61 |
+
*/
|
62 |
+
public function getPagerHtml()
|
63 |
+
{
|
64 |
+
return $this->getChildHtml('pager');
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Attachment/Widget/Link.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment link widget block
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Attachment_Widget_Link extends Web4pro_Attachments_Block_Attachment_Widget_View
|
19 |
+
{
|
20 |
+
protected $_htmlTemplate = 'web4pro_attachments/attachment/widget/link.phtml';
|
21 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Attachment/Widget/View.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment widget block
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Attachment_Widget_View extends Mage_Core_Block_Template implements
|
19 |
+
Mage_Widget_Block_Interface
|
20 |
+
{
|
21 |
+
protected $_htmlTemplate = 'web4pro_attachments/attachment/widget/view.phtml';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Prepare a for widget
|
25 |
+
*
|
26 |
+
* @access protected
|
27 |
+
* @return Web4pro_Attachments_Block_Attachment_Widget_View
|
28 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
29 |
+
*/
|
30 |
+
protected function _beforeToHtml()
|
31 |
+
{
|
32 |
+
parent::_beforeToHtml();
|
33 |
+
$attachmentId = $this->getData('attachment_id');
|
34 |
+
if ($attachmentId) {
|
35 |
+
$attachment = Mage::getModel('web4pro_attachments/attachment')
|
36 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
37 |
+
->load($attachmentId);
|
38 |
+
if ($attachment->getStatus()) {
|
39 |
+
$this->setCurrentAttachment($attachment);
|
40 |
+
$this->setTemplate($this->_htmlTemplate);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Web4pro/Attachments/Block/Catalog/Product/List/Attachment.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment list on product page block
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Block_Catalog_Product_List_Attachment extends Mage_Catalog_Block_Product_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* get the list of attachments
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @return Web4pro_Attachments_Model_Resource_Attachment_Collection
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
public function getAttachmentCollection()
|
28 |
+
{
|
29 |
+
if (!$this->hasData('attachment_collection')) {
|
30 |
+
$product = Mage::registry('product');
|
31 |
+
$collection = Mage::getResourceSingleton('web4pro_attachments/attachment_collection')
|
32 |
+
->addFieldToFilter('status', 1)
|
33 |
+
->addProductFilter($product);
|
34 |
+
$collection->getSelect()->order('related_product.position', 'ASC');
|
35 |
+
$this->setData('attachment_collection', $collection);
|
36 |
+
}
|
37 |
+
return $this->getData('attachment_collection');
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
}
|
app/code/community/Web4pro/Attachments/Controller/Adminhtml/Attachments.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* module base admin controller
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Controller_Adminhtml_Attachments extends Mage_Adminhtml_Controller_Action
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* upload file and get the uploaded name
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @param string $input
|
25 |
+
* @param string $destinationFolder
|
26 |
+
* @param array $data
|
27 |
+
* @return string
|
28 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
29 |
+
*/
|
30 |
+
protected function _uploadAndGetName($input, $destinationFolder, $data)
|
31 |
+
{
|
32 |
+
try {
|
33 |
+
if (isset($data[$input]['delete'])) {
|
34 |
+
return '';
|
35 |
+
} else {
|
36 |
+
$uploader = new Varien_File_Uploader($input);
|
37 |
+
$uploader->setAllowRenameFiles(true);
|
38 |
+
$uploader->setFilesDispersion(true);
|
39 |
+
$uploader->setAllowCreateFolders(true);
|
40 |
+
$result = $uploader->save($destinationFolder);
|
41 |
+
return $result['file'];
|
42 |
+
}
|
43 |
+
} catch (Exception $e) {
|
44 |
+
if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
|
45 |
+
throw $e;
|
46 |
+
} else {
|
47 |
+
if (isset($data[$input]['value'])) {
|
48 |
+
return $data[$input]['value'];
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return '';
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Web4pro/Attachments/Helper/Attachment.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment helper
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Helper_Attachment extends Mage_Core_Helper_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* check if breadcrumbs can be used
|
23 |
+
*
|
24 |
+
* @access public
|
25 |
+
* @return bool
|
26 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
27 |
+
*/
|
28 |
+
public function getUseBreadcrumbs()
|
29 |
+
{
|
30 |
+
return Mage::getStoreConfigFlag('web4pro_attachments/attachment/breadcrumbs');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* get base files dir
|
35 |
+
*
|
36 |
+
* @access public
|
37 |
+
* @return string
|
38 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
39 |
+
*/
|
40 |
+
public function getFileBaseDir()
|
41 |
+
{
|
42 |
+
return Mage::getBaseDir('media').DS.'attachment'.DS.'file';
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* get base file url
|
47 |
+
*
|
48 |
+
* @access public
|
49 |
+
* @return string
|
50 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
51 |
+
*/
|
52 |
+
public function getFileBaseUrl()
|
53 |
+
{
|
54 |
+
return Mage::getBaseUrl('media').'attachment'.'/'.'file';
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* get file size
|
60 |
+
*
|
61 |
+
* @access public
|
62 |
+
* @return string
|
63 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
64 |
+
*/
|
65 |
+
public function getFileSize($file)
|
66 |
+
{
|
67 |
+
$size = filesize($file);
|
68 |
+
$sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
|
69 |
+
if ($size == 0) {
|
70 |
+
return('n/a');
|
71 |
+
} else {
|
72 |
+
return (round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
app/code/community/Web4pro/Attachments/Helper/Data.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachments default helper
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Helper_Data extends Mage_Core_Helper_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* convert array to options
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @param $options
|
25 |
+
* @return array
|
26 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
27 |
+
*/
|
28 |
+
public function convertOptions($options)
|
29 |
+
{
|
30 |
+
$converted = array();
|
31 |
+
foreach ($options as $option) {
|
32 |
+
if (isset($option['value']) && !is_array($option['value']) &&
|
33 |
+
isset($option['label']) && !is_array($option['label'])) {
|
34 |
+
$converted[$option['value']] = $option['label'];
|
35 |
+
}
|
36 |
+
}
|
37 |
+
return $converted;
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Web4pro/Attachments/Helper/Product.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Product helper
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Helper_Product extends Web4pro_Attachments_Helper_Data
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* get the selected attachments for a product
|
23 |
+
*
|
24 |
+
* @access public
|
25 |
+
* @param Mage_Catalog_Model_Product $product
|
26 |
+
* @return array()
|
27 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
28 |
+
*/
|
29 |
+
public function getSelectedAttachments(Mage_Catalog_Model_Product $product)
|
30 |
+
{
|
31 |
+
if (!$product->hasSelectedAttachments()) {
|
32 |
+
$attachments = array();
|
33 |
+
foreach ($this->getSelectedAttachmentsCollection($product) as $attachment) {
|
34 |
+
$attachments[] = $attachment;
|
35 |
+
}
|
36 |
+
$product->setSelectedAttachments($attachments);
|
37 |
+
}
|
38 |
+
return $product->getData('selected_attachments');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* get attachment collection for a product
|
43 |
+
*
|
44 |
+
* @access public
|
45 |
+
* @param Mage_Catalog_Model_Product $product
|
46 |
+
* @return Web4pro_Attachments_Model_Resource_Attachment_Collection
|
47 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
48 |
+
*/
|
49 |
+
public function getSelectedAttachmentsCollection(Mage_Catalog_Model_Product $product)
|
50 |
+
{
|
51 |
+
$collection = Mage::getResourceSingleton('web4pro_attachments/attachment_collection')
|
52 |
+
->addProductFilter($product);
|
53 |
+
return $collection;
|
54 |
+
}
|
55 |
+
}
|
app/code/community/Web4pro/Attachments/Model/Adminhtml/Observer.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Adminhtml observer
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Adminhtml_Observer
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* check if tab can be added
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @param Mage_Catalog_Model_Product $product
|
25 |
+
* @return bool
|
26 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
27 |
+
*/
|
28 |
+
protected function _canAddTab($product)
|
29 |
+
{
|
30 |
+
if ($product->getId()) {
|
31 |
+
return true;
|
32 |
+
}
|
33 |
+
if (!$product->getAttributeSetId()) {
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
$request = Mage::app()->getRequest();
|
37 |
+
if ($request->getParam('type') == 'configurable') {
|
38 |
+
if ($request->getParam('attributes')) {
|
39 |
+
return true;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* add the attachment tab to products
|
47 |
+
*
|
48 |
+
* @access public
|
49 |
+
* @param Varien_Event_Observer $observer
|
50 |
+
* @return Web4pro_Attachments_Model_Adminhtml_Observer
|
51 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
52 |
+
*/
|
53 |
+
public function addProductAttachmentBlock($observer)
|
54 |
+
{
|
55 |
+
$block = $observer->getEvent()->getBlock();
|
56 |
+
$product = Mage::registry('product');
|
57 |
+
if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)) {
|
58 |
+
$block->addTab(
|
59 |
+
'attachments',
|
60 |
+
array(
|
61 |
+
'label' => Mage::helper('web4pro_attachments')->__('Attachments'),
|
62 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
63 |
+
'adminhtml/attachments_attachment_catalog_product/attachments',
|
64 |
+
array('_current' => true)
|
65 |
+
),
|
66 |
+
'class' => 'ajax',
|
67 |
+
)
|
68 |
+
);
|
69 |
+
}
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* save attachment - product relation
|
75 |
+
* @access public
|
76 |
+
* @param Varien_Event_Observer $observer
|
77 |
+
* @return Web4pro_Attachments_Model_Adminhtml_Observer
|
78 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
79 |
+
*/
|
80 |
+
public function saveProductAttachmentData($observer)
|
81 |
+
{
|
82 |
+
$post = Mage::app()->getRequest()->getPost('attachments', -1);
|
83 |
+
if ($post != '-1') {
|
84 |
+
$post = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post);
|
85 |
+
$product = Mage::registry('product');
|
86 |
+
$attachmentProduct = Mage::getResourceSingleton('web4pro_attachments/attachment_product')
|
87 |
+
->saveProductRelation($product, $post);
|
88 |
+
}
|
89 |
+
return $this;
|
90 |
+
}}
|
app/code/community/Web4pro/Attachments/Model/Adminhtml/Search/Attachment.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Admin search model
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Adminhtml_Search_Attachment extends Varien_Object
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Load search results
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @return Web4pro_Attachments_Model_Adminhtml_Search_Attachment
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
public function load()
|
28 |
+
{
|
29 |
+
$arr = array();
|
30 |
+
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
31 |
+
$this->setResults($arr);
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
$collection = Mage::getResourceModel('web4pro_attachments/attachment_collection')
|
35 |
+
->addFieldToFilter('title', array('like' => $this->getQuery().'%'))
|
36 |
+
->setCurPage($this->getStart())
|
37 |
+
->setPageSize($this->getLimit())
|
38 |
+
->load();
|
39 |
+
foreach ($collection->getItems() as $attachment) {
|
40 |
+
$arr[] = array(
|
41 |
+
'id' => 'attachment/1/'.$attachment->getId(),
|
42 |
+
'type' => Mage::helper('web4pro_attachments')->__('Attachment'),
|
43 |
+
'name' => $attachment->getTitle(),
|
44 |
+
'description' => $attachment->getTitle(),
|
45 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
46 |
+
'*/attachments_attachment/edit',
|
47 |
+
array('id'=>$attachment->getId())
|
48 |
+
),
|
49 |
+
);
|
50 |
+
}
|
51 |
+
$this->setResults($arr);
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Web4pro/Attachments/Model/Attachment.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment model
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Attachment extends Mage_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Entity code.
|
22 |
+
* Can be used as part of method name for entity processing
|
23 |
+
*/
|
24 |
+
const ENTITY = 'web4pro_attachments_attachment';
|
25 |
+
const CACHE_TAG = 'web4pro_attachments_attachment';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Prefix of model events names
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $_eventPrefix = 'web4pro_attachments_attachment';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Parameter name in event
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
protected $_eventObject = 'attachment';
|
40 |
+
protected $_productInstance = null;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* constructor
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @return void
|
47 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
48 |
+
*/
|
49 |
+
public function _construct()
|
50 |
+
{
|
51 |
+
parent::_construct();
|
52 |
+
$this->_init('web4pro_attachments/attachment');
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* before save attachment
|
57 |
+
*
|
58 |
+
* @access protected
|
59 |
+
* @return Web4pro_Attachments_Model_Attachment
|
60 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
61 |
+
*/
|
62 |
+
protected function _beforeSave()
|
63 |
+
{
|
64 |
+
parent::_beforeSave();
|
65 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
66 |
+
if ($this->isObjectNew()) {
|
67 |
+
$this->setCreatedAt($now);
|
68 |
+
}
|
69 |
+
$this->setUpdatedAt($now);
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* save attachment relation
|
75 |
+
*
|
76 |
+
* @access public
|
77 |
+
* @return Web4pro_Attachments_Model_Attachment
|
78 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
79 |
+
*/
|
80 |
+
protected function _afterSave()
|
81 |
+
{
|
82 |
+
$this->getProductInstance()->saveAttachmentRelation($this);
|
83 |
+
return parent::_afterSave();
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* get product relation model
|
88 |
+
*
|
89 |
+
* @access public
|
90 |
+
* @return Web4pro_Attachments_Model_Attachment_Product
|
91 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
92 |
+
*/
|
93 |
+
public function getProductInstance()
|
94 |
+
{
|
95 |
+
if (!$this->_productInstance) {
|
96 |
+
$this->_productInstance = Mage::getSingleton('web4pro_attachments/attachment_product');
|
97 |
+
}
|
98 |
+
return $this->_productInstance;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* get selected products array
|
103 |
+
*
|
104 |
+
* @access public
|
105 |
+
* @return array
|
106 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
107 |
+
*/
|
108 |
+
public function getSelectedProducts()
|
109 |
+
{
|
110 |
+
if (!$this->hasSelectedProducts()) {
|
111 |
+
$products = array();
|
112 |
+
foreach ($this->getSelectedProductsCollection() as $product) {
|
113 |
+
$products[] = $product;
|
114 |
+
}
|
115 |
+
$this->setSelectedProducts($products);
|
116 |
+
}
|
117 |
+
return $this->getData('selected_products');
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Retrieve collection selected products
|
122 |
+
*
|
123 |
+
* @access public
|
124 |
+
* @return Web4pro_Attachments_Resource_Attachment_Product_Collection
|
125 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
126 |
+
*/
|
127 |
+
public function getSelectedProductsCollection()
|
128 |
+
{
|
129 |
+
$collection = $this->getProductInstance()->getProductCollection($this);
|
130 |
+
return $collection;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* get default values
|
135 |
+
*
|
136 |
+
* @access public
|
137 |
+
* @return array
|
138 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
139 |
+
*/
|
140 |
+
public function getDefaultValues()
|
141 |
+
{
|
142 |
+
$values = array();
|
143 |
+
$values['status'] = 1;
|
144 |
+
return $values;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* get attachment url
|
149 |
+
*
|
150 |
+
* @access public
|
151 |
+
* @return attachment url
|
152 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
153 |
+
*/
|
154 |
+
public function getAttachmentUrl()
|
155 |
+
{
|
156 |
+
return Mage::helper('web4pro_attachments/attachment')->getFileBaseUrl() . $this->getUploadedFile();
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* get attachment path
|
161 |
+
*
|
162 |
+
* @access public
|
163 |
+
* @return attachment path
|
164 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
165 |
+
*/
|
166 |
+
public function getAttachmentPath()
|
167 |
+
{
|
168 |
+
return Mage::helper('web4pro_attachments/attachment')->getFileBaseDir() . $this->getData('uploaded_file');
|
169 |
+
}
|
170 |
+
|
171 |
+
|
172 |
+
/**
|
173 |
+
* get attachment extension
|
174 |
+
*
|
175 |
+
* @access public
|
176 |
+
* @return attachment extension
|
177 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
178 |
+
*/
|
179 |
+
public function getFileExtension($filename, $pos = 0)
|
180 |
+
{
|
181 |
+
return strtolower(substr($filename, strrpos($filename, '.') + $pos));
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
/**
|
186 |
+
* get attachment icon
|
187 |
+
*
|
188 |
+
* @access public
|
189 |
+
* @return attachment icon
|
190 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
191 |
+
*/
|
192 |
+
public function getIcon()
|
193 |
+
{
|
194 |
+
$attachmentPath = $this->getData('uploaded_file');
|
195 |
+
$ext = $this->getFileExtension($attachmentPath, 1);
|
196 |
+
$mediaIcon = Mage::getBaseUrl('media') . '/attachment/icons/' . $ext . '.png';
|
197 |
+
$html = '<span class="attach-img"><img src="' . $mediaIcon . '" alt="View File" style="margin-right: 5px;"/></span>';
|
198 |
+
return $html;
|
199 |
+
}
|
200 |
+
}
|
app/code/community/Web4pro/Attachments/Model/Attachment/Product.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment product model
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Attachment_Product extends Mage_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Initialize resource
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @return void
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
$this->_init('web4pro_attachments/attachment_product');
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Save data for attachment-product relation
|
34 |
+
* @access public
|
35 |
+
* @param Web4pro_Attachments_Model_Attachment $attachment
|
36 |
+
* @return Web4pro_Attachments_Model_Attachment_Product
|
37 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
38 |
+
*/
|
39 |
+
public function saveAttachmentRelation($attachment)
|
40 |
+
{
|
41 |
+
$data = $attachment->getProductsData();
|
42 |
+
if (!is_null($data)) {
|
43 |
+
$this->_getResource()->saveAttachmentRelation($attachment, $data);
|
44 |
+
}
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* get products for attachment
|
50 |
+
*
|
51 |
+
* @access public
|
52 |
+
* @param Web4pro_Attachments_Model_Attachment $attachment
|
53 |
+
* @return Web4pro_Attachments_Model_Resource_Attachment_Product_Collection
|
54 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
55 |
+
*/
|
56 |
+
public function getProductCollection($attachment)
|
57 |
+
{
|
58 |
+
$collection = Mage::getResourceModel('web4pro_attachments/attachment_product_collection')
|
59 |
+
->addAttachmentFilter($attachment);
|
60 |
+
return $collection;
|
61 |
+
}
|
62 |
+
}
|
app/code/community/Web4pro/Attachments/Model/Resource/Attachment.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment resource model
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Resource_Attachment extends Mage_Core_Model_Resource_Db_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* constructor
|
23 |
+
*
|
24 |
+
* @access public
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
public function _construct()
|
28 |
+
{
|
29 |
+
$this->_init('web4pro_attachments/attachment', 'entity_id');
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Web4pro/Attachments/Model/Resource/Attachment/Collection.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment collection resource model
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Resource_Attachment_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
19 |
+
{
|
20 |
+
protected $_joinedFields = array();
|
21 |
+
|
22 |
+
/**
|
23 |
+
* constructor
|
24 |
+
*
|
25 |
+
* @access public
|
26 |
+
* @return void
|
27 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
28 |
+
*/
|
29 |
+
protected function _construct()
|
30 |
+
{
|
31 |
+
parent::_construct();
|
32 |
+
$this->_init('web4pro_attachments/attachment');
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* get attachments as array
|
37 |
+
*
|
38 |
+
* @access protected
|
39 |
+
* @param string $valueField
|
40 |
+
* @param string $labelField
|
41 |
+
* @param array $additional
|
42 |
+
* @return array
|
43 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
44 |
+
*/
|
45 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='title', $additional=array())
|
46 |
+
{
|
47 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* get options hash
|
52 |
+
*
|
53 |
+
* @access protected
|
54 |
+
* @param string $valueField
|
55 |
+
* @param string $labelField
|
56 |
+
* @return array
|
57 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
58 |
+
*/
|
59 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='title')
|
60 |
+
{
|
61 |
+
return parent::_toOptionHash($valueField, $labelField);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* add the product filter to collection
|
66 |
+
*
|
67 |
+
* @access public
|
68 |
+
* @param mixed (Mage_Catalog_Model_Product|int) $product
|
69 |
+
* @return Web4pro_Attachments_Model_Resource_Attachment_Collection
|
70 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
71 |
+
*/
|
72 |
+
public function addProductFilter($product)
|
73 |
+
{
|
74 |
+
if ($product instanceof Mage_Catalog_Model_Product) {
|
75 |
+
$product = $product->getId();
|
76 |
+
}
|
77 |
+
if (!isset($this->_joinedFields['product'])) {
|
78 |
+
$this->getSelect()->join(
|
79 |
+
array('related_product' => $this->getTable('web4pro_attachments/attachment_product')),
|
80 |
+
'related_product.attachment_id = main_table.entity_id',
|
81 |
+
array('position')
|
82 |
+
);
|
83 |
+
$this->getSelect()->where('related_product.product_id = ?', $product);
|
84 |
+
$this->_joinedFields['product'] = true;
|
85 |
+
}
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get SQL for get record count.
|
91 |
+
* Extra GROUP BY strip added.
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @return Varien_Db_Select
|
95 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
96 |
+
*/
|
97 |
+
public function getSelectCountSql()
|
98 |
+
{
|
99 |
+
$countSelect = parent::getSelectCountSql();
|
100 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
101 |
+
return $countSelect;
|
102 |
+
}
|
103 |
+
}
|
app/code/community/Web4pro/Attachments/Model/Resource/Attachment/Product.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment - product relation model
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Resource_Attachment_Product extends Mage_Core_Model_Resource_Db_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* initialize resource model
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @see Mage_Core_Model_Resource_Abstract::_construct()
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
$this->_init('web4pro_attachments/attachment_product', 'rel_id');
|
30 |
+
}
|
31 |
+
/**
|
32 |
+
* Save attachment - product relations
|
33 |
+
*
|
34 |
+
* @access public
|
35 |
+
* @param Web4pro_Attachments_Model_Attachment $attachment
|
36 |
+
* @param array $data
|
37 |
+
* @return Web4pro_Attachments_Model_Resource_Attachment_Product
|
38 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
39 |
+
*/
|
40 |
+
public function saveAttachmentRelation($attachment, $data)
|
41 |
+
{
|
42 |
+
if (!is_array($data)) {
|
43 |
+
$data = array();
|
44 |
+
}
|
45 |
+
$deleteCondition = $this->_getWriteAdapter()->quoteInto('attachment_id=?', $attachment->getId());
|
46 |
+
$this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
|
47 |
+
|
48 |
+
foreach ($data as $productId => $info) {
|
49 |
+
$this->_getWriteAdapter()->insert(
|
50 |
+
$this->getMainTable(),
|
51 |
+
array(
|
52 |
+
'attachment_id' => $attachment->getId(),
|
53 |
+
'product_id' => $productId,
|
54 |
+
'position' => @$info['position']
|
55 |
+
)
|
56 |
+
);
|
57 |
+
}
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Save product - attachment relations
|
63 |
+
*
|
64 |
+
* @access public
|
65 |
+
* @param Mage_Catalog_Model_Product $prooduct
|
66 |
+
* @param array $data
|
67 |
+
* @return Web4pro_Attachments_Model_Resource_Attachment_Product
|
68 |
+
* @@author WEB4PRO <srepin@corp.web4pro.com.ua>
|
69 |
+
*/
|
70 |
+
public function saveProductRelation($product, $data)
|
71 |
+
{
|
72 |
+
if (!is_array($data)) {
|
73 |
+
$data = array();
|
74 |
+
}
|
75 |
+
$deleteCondition = $this->_getWriteAdapter()->quoteInto('product_id=?', $product->getId());
|
76 |
+
$this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
|
77 |
+
|
78 |
+
foreach ($data as $attachmentId => $info) {
|
79 |
+
$this->_getWriteAdapter()->insert(
|
80 |
+
$this->getMainTable(),
|
81 |
+
array(
|
82 |
+
'attachment_id' => $attachmentId,
|
83 |
+
'product_id' => $product->getId(),
|
84 |
+
'position' => @$info['position']
|
85 |
+
)
|
86 |
+
);
|
87 |
+
}
|
88 |
+
return $this;
|
89 |
+
}
|
90 |
+
}
|
app/code/community/Web4pro/Attachments/Model/Resource/Attachment/Product/Collection.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment - product relation resource model collection
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Resource_Attachment_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* remember if fields have been joined
|
22 |
+
*
|
23 |
+
* @var bool
|
24 |
+
*/
|
25 |
+
protected $_joinedFields = false;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* join the link table
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
* @return Web4pro_Attachments_Model_Resource_Attachment_Product_Collection
|
32 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
33 |
+
*/
|
34 |
+
public function joinFields()
|
35 |
+
{
|
36 |
+
if (!$this->_joinedFields) {
|
37 |
+
$this->getSelect()->join(
|
38 |
+
array('related' => $this->getTable('web4pro_attachments/attachment_product')),
|
39 |
+
'related.product_id = e.entity_id',
|
40 |
+
array('position')
|
41 |
+
);
|
42 |
+
$this->_joinedFields = true;
|
43 |
+
}
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* add attachment filter
|
49 |
+
*
|
50 |
+
* @access public
|
51 |
+
* @param Web4pro_Attachments_Model_Attachment | int $attachment
|
52 |
+
* @return Web4pro_Attachments_Model_Resource_Attachment_Product_Collection
|
53 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
54 |
+
*/
|
55 |
+
public function addAttachmentFilter($attachment)
|
56 |
+
{
|
57 |
+
if ($attachment instanceof Web4pro_Attachments_Model_Attachment) {
|
58 |
+
$attachment = $attachment->getId();
|
59 |
+
}
|
60 |
+
if (!$this->_joinedFields ) {
|
61 |
+
$this->joinFields();
|
62 |
+
}
|
63 |
+
$this->getSelect()->where('related.attachment_id = ?', $attachment);
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Web4pro/Attachments/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachments setup
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup
|
19 |
+
{
|
20 |
+
}
|
app/code/community/Web4pro/Attachments/controllers/Adminhtml/Attachments/Attachment/Catalog/ProductController.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment - product controller
|
13 |
+
* @category Web4pro
|
14 |
+
* @package Web4pro_Attachments
|
15 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
16 |
+
*/
|
17 |
+
require_once ("Mage/Adminhtml/controllers/Catalog/ProductController.php");
|
18 |
+
class Web4pro_Attachments_Adminhtml_Attachments_Attachment_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* construct
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @return void
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
// Define module dependent translate
|
30 |
+
$this->setUsedModuleName('Web4pro_Attachments');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* attachments in the catalog page
|
35 |
+
*
|
36 |
+
* @access public
|
37 |
+
* @return void
|
38 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
39 |
+
*/
|
40 |
+
public function attachmentsAction()
|
41 |
+
{
|
42 |
+
$this->_initProduct();
|
43 |
+
$this->loadLayout();
|
44 |
+
$this->getLayout()->getBlock('product.edit.tab.attachment')
|
45 |
+
->setProductAttachments($this->getRequest()->getPost('product_attachments', null));
|
46 |
+
$this->renderLayout();
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* attachments grid in the catalog page
|
51 |
+
*
|
52 |
+
* @access public
|
53 |
+
* @return void
|
54 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
55 |
+
*/
|
56 |
+
public function attachmentsGridAction()
|
57 |
+
{
|
58 |
+
$this->_initProduct();
|
59 |
+
$this->loadLayout();
|
60 |
+
$this->getLayout()->getBlock('product.edit.tab.attachment')
|
61 |
+
->setProductAttachments($this->getRequest()->getPost('product_attachments', null));
|
62 |
+
$this->renderLayout();
|
63 |
+
}
|
64 |
+
}
|
app/code/community/Web4pro/Attachments/controllers/Adminhtml/Attachments/Attachment/WidgetController.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment admin widget controller
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Adminhtml_Attachments_Attachment_WidgetController extends Mage_Adminhtml_Controller_Action
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Chooser Source action
|
22 |
+
*
|
23 |
+
* @access public
|
24 |
+
* @return void
|
25 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
26 |
+
*/
|
27 |
+
public function chooserAction()
|
28 |
+
{
|
29 |
+
$uniqId = $this->getRequest()->getParam('uniq_id');
|
30 |
+
$grid = $this->getLayout()->createBlock(
|
31 |
+
'web4pro_attachments/adminhtml_attachment_widget_chooser',
|
32 |
+
'',
|
33 |
+
array(
|
34 |
+
'id' => $uniqId,
|
35 |
+
)
|
36 |
+
);
|
37 |
+
$this->getResponse()->setBody($grid->toHtml());
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Web4pro/Attachments/controllers/Adminhtml/Attachments/AttachmentController.php
ADDED
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment admin controller
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_Adminhtml_Attachments_AttachmentController extends Web4pro_Attachments_Controller_Adminhtml_Attachments
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* init the attachment
|
22 |
+
*
|
23 |
+
* @access protected
|
24 |
+
* @return Web4pro_Attachments_Model_Attachment
|
25 |
+
*/
|
26 |
+
protected function _initAttachment()
|
27 |
+
{
|
28 |
+
$attachmentId = (int) $this->getRequest()->getParam('id');
|
29 |
+
$attachment = Mage::getModel('web4pro_attachments/attachment');
|
30 |
+
if ($attachmentId) {
|
31 |
+
$attachment->load($attachmentId);
|
32 |
+
}
|
33 |
+
Mage::register('current_attachment', $attachment);
|
34 |
+
return $attachment;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* default action
|
39 |
+
*
|
40 |
+
* @access public
|
41 |
+
* @return void
|
42 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
43 |
+
*/
|
44 |
+
public function indexAction()
|
45 |
+
{
|
46 |
+
$this->loadLayout();
|
47 |
+
$this->_title(Mage::helper('web4pro_attachments')->__('Web4pro'))
|
48 |
+
->_title(Mage::helper('web4pro_attachments')->__('Attachments'));
|
49 |
+
$this->renderLayout();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* grid action
|
54 |
+
*
|
55 |
+
* @access public
|
56 |
+
* @return void
|
57 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
58 |
+
*/
|
59 |
+
public function gridAction()
|
60 |
+
{
|
61 |
+
$this->loadLayout()->renderLayout();
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* edit attachment - action
|
66 |
+
*
|
67 |
+
* @access public
|
68 |
+
* @return void
|
69 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
70 |
+
*/
|
71 |
+
public function editAction()
|
72 |
+
{
|
73 |
+
$attachmentId = $this->getRequest()->getParam('id');
|
74 |
+
$attachment = $this->_initAttachment();
|
75 |
+
if ($attachmentId && !$attachment->getId()) {
|
76 |
+
$this->_getSession()->addError(
|
77 |
+
Mage::helper('web4pro_attachments')->__('This attachment no longer exists.')
|
78 |
+
);
|
79 |
+
$this->_redirect('*/*/');
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
$data = Mage::getSingleton('adminhtml/session')->getAttachmentData(true);
|
83 |
+
if (!empty($data)) {
|
84 |
+
$attachment->setData($data);
|
85 |
+
}
|
86 |
+
Mage::register('attachment_data', $attachment);
|
87 |
+
$this->loadLayout();
|
88 |
+
$this->_title(Mage::helper('web4pro_attachments')->__('Web4pro'))
|
89 |
+
->_title(Mage::helper('web4pro_attachments')->__('Attachments'));
|
90 |
+
if ($attachment->getId()) {
|
91 |
+
$this->_title($attachment->getTitle());
|
92 |
+
} else {
|
93 |
+
$this->_title(Mage::helper('web4pro_attachments')->__('Add attachment'));
|
94 |
+
}
|
95 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
96 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
97 |
+
}
|
98 |
+
$this->renderLayout();
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* new attachment action
|
103 |
+
*
|
104 |
+
* @access public
|
105 |
+
* @return void
|
106 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
107 |
+
*/
|
108 |
+
public function newAction()
|
109 |
+
{
|
110 |
+
$this->_forward('edit');
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* save attachment - action
|
115 |
+
*
|
116 |
+
* @access public
|
117 |
+
* @return void
|
118 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
119 |
+
*/
|
120 |
+
public function saveAction()
|
121 |
+
{
|
122 |
+
if ($data = $this->getRequest()->getPost('attachment')) {
|
123 |
+
try {
|
124 |
+
$attachment = $this->_initAttachment();
|
125 |
+
$attachment->addData($data);
|
126 |
+
$uploadedFileName = $this->_uploadAndGetName(
|
127 |
+
'uploaded_file',
|
128 |
+
Mage::helper('web4pro_attachments/attachment')->getFileBaseDir(),
|
129 |
+
$data
|
130 |
+
);
|
131 |
+
$attachment->setData('uploaded_file', $uploadedFileName);
|
132 |
+
$products = $this->getRequest()->getPost('products', -1);
|
133 |
+
if ($products != -1) {
|
134 |
+
$attachment->setProductsData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($products));
|
135 |
+
}
|
136 |
+
$attachment->save();
|
137 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
138 |
+
Mage::helper('web4pro_attachments')->__('Attachment was successfully saved')
|
139 |
+
);
|
140 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
141 |
+
if ($this->getRequest()->getParam('back')) {
|
142 |
+
$this->_redirect('*/*/edit', array('id' => $attachment->getId()));
|
143 |
+
return;
|
144 |
+
}
|
145 |
+
$this->_redirect('*/*/');
|
146 |
+
return;
|
147 |
+
} catch (Mage_Core_Exception $e) {
|
148 |
+
if (isset($data['uploaded_file']['value'])) {
|
149 |
+
$data['uploaded_file'] = $data['uploaded_file']['value'];
|
150 |
+
}
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
152 |
+
Mage::getSingleton('adminhtml/session')->setAttachmentData($data);
|
153 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
154 |
+
return;
|
155 |
+
} catch (Exception $e) {
|
156 |
+
Mage::logException($e);
|
157 |
+
if (isset($data['uploaded_file']['value'])) {
|
158 |
+
$data['uploaded_file'] = $data['uploaded_file']['value'];
|
159 |
+
}
|
160 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
161 |
+
Mage::helper('web4pro_attachments')->__('There was a problem saving the attachment.')
|
162 |
+
);
|
163 |
+
Mage::getSingleton('adminhtml/session')->setAttachmentData($data);
|
164 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
165 |
+
return;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
169 |
+
Mage::helper('web4pro_attachments')->__('Unable to find attachment to save.')
|
170 |
+
);
|
171 |
+
$this->_redirect('*/*/');
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* delete attachment - action
|
176 |
+
*
|
177 |
+
* @access public
|
178 |
+
* @return void
|
179 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
180 |
+
*/
|
181 |
+
public function deleteAction()
|
182 |
+
{
|
183 |
+
if ( $this->getRequest()->getParam('id') > 0) {
|
184 |
+
try {
|
185 |
+
$attachment = Mage::getModel('web4pro_attachments/attachment');
|
186 |
+
$attachment->setId($this->getRequest()->getParam('id'))->delete();
|
187 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
188 |
+
Mage::helper('web4pro_attachments')->__('Attachment was successfully deleted.')
|
189 |
+
);
|
190 |
+
$this->_redirect('*/*/');
|
191 |
+
return;
|
192 |
+
} catch (Mage_Core_Exception $e) {
|
193 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
194 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
195 |
+
} catch (Exception $e) {
|
196 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
197 |
+
Mage::helper('web4pro_attachments')->__('There was an error deleting attachment.')
|
198 |
+
);
|
199 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
200 |
+
Mage::logException($e);
|
201 |
+
return;
|
202 |
+
}
|
203 |
+
}
|
204 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
205 |
+
Mage::helper('web4pro_attachments')->__('Could not find attachment to delete.')
|
206 |
+
);
|
207 |
+
$this->_redirect('*/*/');
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* mass delete attachment - action
|
212 |
+
*
|
213 |
+
* @access public
|
214 |
+
* @return void
|
215 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
216 |
+
*/
|
217 |
+
public function massDeleteAction()
|
218 |
+
{
|
219 |
+
$attachmentIds = $this->getRequest()->getParam('attachment');
|
220 |
+
if (!is_array($attachmentIds)) {
|
221 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
222 |
+
Mage::helper('web4pro_attachments')->__('Please select attachments to delete.')
|
223 |
+
);
|
224 |
+
} else {
|
225 |
+
try {
|
226 |
+
foreach ($attachmentIds as $attachmentId) {
|
227 |
+
$attachment = Mage::getModel('web4pro_attachments/attachment');
|
228 |
+
$attachment->setId($attachmentId)->delete();
|
229 |
+
}
|
230 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
231 |
+
Mage::helper('web4pro_attachments')->__('Total of %d attachments were successfully deleted.', count($attachmentIds))
|
232 |
+
);
|
233 |
+
} catch (Mage_Core_Exception $e) {
|
234 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
235 |
+
} catch (Exception $e) {
|
236 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
237 |
+
Mage::helper('web4pro_attachments')->__('There was an error deleting attachments.')
|
238 |
+
);
|
239 |
+
Mage::logException($e);
|
240 |
+
}
|
241 |
+
}
|
242 |
+
$this->_redirect('*/*/index');
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* mass status change - action
|
247 |
+
*
|
248 |
+
* @access public
|
249 |
+
* @return void
|
250 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
251 |
+
*/
|
252 |
+
public function massStatusAction()
|
253 |
+
{
|
254 |
+
$attachmentIds = $this->getRequest()->getParam('attachment');
|
255 |
+
if (!is_array($attachmentIds)) {
|
256 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
257 |
+
Mage::helper('web4pro_attachments')->__('Please select attachments.')
|
258 |
+
);
|
259 |
+
} else {
|
260 |
+
try {
|
261 |
+
foreach ($attachmentIds as $attachmentId) {
|
262 |
+
$attachment = Mage::getSingleton('web4pro_attachments/attachment')->load($attachmentId)
|
263 |
+
->setStatus($this->getRequest()->getParam('status'))
|
264 |
+
->setIsMassupdate(true)
|
265 |
+
->save();
|
266 |
+
}
|
267 |
+
$this->_getSession()->addSuccess(
|
268 |
+
$this->__('Total of %d attachments were successfully updated.', count($attachmentIds))
|
269 |
+
);
|
270 |
+
} catch (Mage_Core_Exception $e) {
|
271 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
272 |
+
} catch (Exception $e) {
|
273 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
274 |
+
Mage::helper('web4pro_attachments')->__('There was an error updating attachments.')
|
275 |
+
);
|
276 |
+
Mage::logException($e);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
$this->_redirect('*/*/index');
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* get grid of products action
|
284 |
+
*
|
285 |
+
* @access public
|
286 |
+
* @return void
|
287 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
288 |
+
*/
|
289 |
+
public function productsAction()
|
290 |
+
{
|
291 |
+
$this->_initAttachment();
|
292 |
+
$this->loadLayout();
|
293 |
+
$this->getLayout()->getBlock('attachment.edit.tab.product')
|
294 |
+
->setAttachmentProducts($this->getRequest()->getPost('attachment_products', null));
|
295 |
+
$this->renderLayout();
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* get grid of products action
|
300 |
+
*
|
301 |
+
* @access public
|
302 |
+
* @return void
|
303 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
304 |
+
*/
|
305 |
+
public function productsgridAction()
|
306 |
+
{
|
307 |
+
$this->_initAttachment();
|
308 |
+
$this->loadLayout();
|
309 |
+
$this->getLayout()->getBlock('attachment.edit.tab.product')
|
310 |
+
->setAttachmentProducts($this->getRequest()->getPost('attachment_products', null));
|
311 |
+
$this->renderLayout();
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* export as csv - action
|
316 |
+
*
|
317 |
+
* @access public
|
318 |
+
* @return void
|
319 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
320 |
+
*/
|
321 |
+
public function exportCsvAction()
|
322 |
+
{
|
323 |
+
$fileName = 'attachment.csv';
|
324 |
+
$content = $this->getLayout()->createBlock('web4pro_attachments/adminhtml_attachment_grid')
|
325 |
+
->getCsv();
|
326 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* export as MsExcel - action
|
331 |
+
*
|
332 |
+
* @access public
|
333 |
+
* @return void
|
334 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
335 |
+
*/
|
336 |
+
public function exportExcelAction()
|
337 |
+
{
|
338 |
+
$fileName = 'attachment.xls';
|
339 |
+
$content = $this->getLayout()->createBlock('web4pro_attachments/adminhtml_attachment_grid')
|
340 |
+
->getExcelFile();
|
341 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* export as xml - action
|
346 |
+
*
|
347 |
+
* @access public
|
348 |
+
* @return void
|
349 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
350 |
+
*/
|
351 |
+
public function exportXmlAction()
|
352 |
+
{
|
353 |
+
$fileName = 'attachment.xml';
|
354 |
+
$content = $this->getLayout()->createBlock('web4pro_attachments/adminhtml_attachment_grid')
|
355 |
+
->getXml();
|
356 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Check if admin has permissions to visit related pages
|
361 |
+
*
|
362 |
+
* @access protected
|
363 |
+
* @return boolean
|
364 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
365 |
+
*/
|
366 |
+
protected function _isAllowed()
|
367 |
+
{
|
368 |
+
return Mage::getSingleton('admin/session')->isAllowed('web4pro_attachments/attachment');
|
369 |
+
}
|
370 |
+
}
|
app/code/community/Web4pro/Attachments/controllers/AttachmentController.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment front contrller
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
class Web4pro_Attachments_AttachmentController extends Mage_Core_Controller_Front_Action
|
19 |
+
{
|
20 |
+
}
|
app/code/community/Web4pro/Attachments/etc/adminhtml.xml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* WEB4PRO - Creating profitable online stores
|
5 |
+
*
|
6 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
7 |
+
* @category WEB4PRO
|
8 |
+
* @package Web4pro_Attachments
|
9 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
10 |
+
* @license http://www.web4pro.net/license.txt
|
11 |
+
*/
|
12 |
+
-->
|
13 |
+
<config>
|
14 |
+
<acl>
|
15 |
+
<resources>
|
16 |
+
<admin>
|
17 |
+
<children>
|
18 |
+
<system>
|
19 |
+
<children>
|
20 |
+
<config>
|
21 |
+
<children>
|
22 |
+
<web4pro_attachments translate="title" module="web4pro_attachments">
|
23 |
+
<title>Attachments</title>
|
24 |
+
</web4pro_attachments>
|
25 |
+
</children>
|
26 |
+
</config>
|
27 |
+
</children>
|
28 |
+
</system>
|
29 |
+
<web4pro_attachments translate="title" module="web4pro_attachments">
|
30 |
+
<title>Web4pro</title>
|
31 |
+
<children>
|
32 |
+
<attachment translate="title" module="web4pro_attachments">
|
33 |
+
<title>Attachment</title>
|
34 |
+
<sort_order>0</sort_order>
|
35 |
+
</attachment>
|
36 |
+
</children>
|
37 |
+
</web4pro_attachments>
|
38 |
+
</children>
|
39 |
+
</admin>
|
40 |
+
</resources>
|
41 |
+
</acl>
|
42 |
+
<menu>
|
43 |
+
<web4pro_attachments translate="title" module="web4pro_attachments">
|
44 |
+
<title>Web4pro</title>
|
45 |
+
<sort_order>25</sort_order>
|
46 |
+
<children>
|
47 |
+
<attachment translate="title" module="web4pro_attachments">
|
48 |
+
<title>Attachments</title>
|
49 |
+
<action>adminhtml/attachments_attachment</action>
|
50 |
+
<sort_order>0</sort_order>
|
51 |
+
</attachment>
|
52 |
+
</children>
|
53 |
+
</web4pro_attachments>
|
54 |
+
</menu>
|
55 |
+
</config>
|
app/code/community/Web4pro/Attachments/etc/config.xml
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* WEB4PRO - Creating profitable online stores
|
5 |
+
*
|
6 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
7 |
+
* @category WEB4PRO
|
8 |
+
* @package Web4pro_Attachments
|
9 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
10 |
+
* @license http://www.web4pro.net/license.txt
|
11 |
+
*/
|
12 |
+
-->
|
13 |
+
<config>
|
14 |
+
<modules>
|
15 |
+
<Web4pro_Attachments>
|
16 |
+
<version>1.0.0</version>
|
17 |
+
</Web4pro_Attachments>
|
18 |
+
</modules>
|
19 |
+
<global>
|
20 |
+
<resources>
|
21 |
+
<web4pro_attachments_setup>
|
22 |
+
<setup>
|
23 |
+
<module>Web4pro_Attachments</module>
|
24 |
+
<class>Web4pro_Attachments_Model_Resource_Setup</class>
|
25 |
+
</setup>
|
26 |
+
</web4pro_attachments_setup>
|
27 |
+
</resources>
|
28 |
+
<blocks>
|
29 |
+
<web4pro_attachments>
|
30 |
+
<class>Web4pro_Attachments_Block</class>
|
31 |
+
</web4pro_attachments>
|
32 |
+
</blocks>
|
33 |
+
<helpers>
|
34 |
+
<web4pro_attachments>
|
35 |
+
<class>Web4pro_Attachments_Helper</class>
|
36 |
+
</web4pro_attachments>
|
37 |
+
</helpers>
|
38 |
+
<models>
|
39 |
+
<web4pro_attachments>
|
40 |
+
<class>Web4pro_Attachments_Model</class>
|
41 |
+
<resourceModel>web4pro_attachments_resource</resourceModel>
|
42 |
+
</web4pro_attachments>
|
43 |
+
<web4pro_attachments_resource>
|
44 |
+
<class>Web4pro_Attachments_Model_Resource</class>
|
45 |
+
<entities>
|
46 |
+
<attachment>
|
47 |
+
<table>web4pro_attachments_attachment</table>
|
48 |
+
</attachment>
|
49 |
+
<attachment_product>
|
50 |
+
<table>web4pro_attachments_attachment_product</table>
|
51 |
+
</attachment_product>
|
52 |
+
</entities>
|
53 |
+
</web4pro_attachments_resource>
|
54 |
+
</models>
|
55 |
+
</global>
|
56 |
+
<adminhtml>
|
57 |
+
<layout>
|
58 |
+
<updates>
|
59 |
+
<web4pro_attachments>
|
60 |
+
<file>web4pro_attachments.xml</file>
|
61 |
+
</web4pro_attachments>
|
62 |
+
</updates>
|
63 |
+
</layout>
|
64 |
+
<translate>
|
65 |
+
<modules>
|
66 |
+
<Web4pro_Attachments>
|
67 |
+
<files>
|
68 |
+
<default>Web4pro_Attachments.csv</default>
|
69 |
+
</files>
|
70 |
+
</Web4pro_Attachments>
|
71 |
+
</modules>
|
72 |
+
</translate>
|
73 |
+
<events>
|
74 |
+
<core_block_abstract_prepare_layout_after>
|
75 |
+
<observers>
|
76 |
+
<web4pro_attachments_attachment_product>
|
77 |
+
<type>singleton</type>
|
78 |
+
<class>web4pro_attachments/adminhtml_observer</class>
|
79 |
+
<method>addProductAttachmentBlock</method>
|
80 |
+
</web4pro_attachments_attachment_product>
|
81 |
+
</observers>
|
82 |
+
</core_block_abstract_prepare_layout_after>
|
83 |
+
<catalog_product_save_after>
|
84 |
+
<observers>
|
85 |
+
<web4pro_attachments_attachment_product>
|
86 |
+
<type>singleton</type>
|
87 |
+
<class>web4pro_attachments/adminhtml_observer</class>
|
88 |
+
<method>saveProductAttachmentData</method>
|
89 |
+
</web4pro_attachments_attachment_product>
|
90 |
+
</observers>
|
91 |
+
</catalog_product_save_after>
|
92 |
+
</events>
|
93 |
+
<global_search>
|
94 |
+
<attachment>
|
95 |
+
<class>web4pro_attachments/adminhtml_search_attachment</class>
|
96 |
+
<acl>web4pro_attachments</acl>
|
97 |
+
</attachment>
|
98 |
+
</global_search>
|
99 |
+
</adminhtml>
|
100 |
+
<admin>
|
101 |
+
<routers>
|
102 |
+
<adminhtml>
|
103 |
+
<args>
|
104 |
+
<modules>
|
105 |
+
<Web4pro_Attachments before="Mage_Adminhtml">Web4pro_Attachments_Adminhtml</Web4pro_Attachments>
|
106 |
+
</modules>
|
107 |
+
</args>
|
108 |
+
</adminhtml>
|
109 |
+
</routers>
|
110 |
+
</admin>
|
111 |
+
<frontend>
|
112 |
+
<routers>
|
113 |
+
<web4pro_attachments>
|
114 |
+
<use>standard</use>
|
115 |
+
<args>
|
116 |
+
<module>Web4pro_Attachments</module>
|
117 |
+
<frontName>web4pro_attachments</frontName>
|
118 |
+
</args>
|
119 |
+
</web4pro_attachments>
|
120 |
+
</routers>
|
121 |
+
<layout>
|
122 |
+
<updates>
|
123 |
+
<web4pro_attachments>
|
124 |
+
<file>web4pro_attachments.xml</file>
|
125 |
+
</web4pro_attachments>
|
126 |
+
</updates>
|
127 |
+
</layout>
|
128 |
+
<translate>
|
129 |
+
<modules>
|
130 |
+
<Web4pro_Attachments>
|
131 |
+
<files>
|
132 |
+
<default>Web4pro_Attachments.csv</default>
|
133 |
+
</files>
|
134 |
+
</Web4pro_Attachments>
|
135 |
+
</modules>
|
136 |
+
</translate>
|
137 |
+
</frontend>
|
138 |
+
<default>
|
139 |
+
<web4pro_attachments>
|
140 |
+
<attachment>
|
141 |
+
<breadcrumbs>1</breadcrumbs>
|
142 |
+
</attachment>
|
143 |
+
</web4pro_attachments>
|
144 |
+
</default>
|
145 |
+
</config>
|
app/code/community/Web4pro/Attachments/etc/system.xml
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* WEB4PRO - Creating profitable online stores
|
5 |
+
*
|
6 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
7 |
+
* @category WEB4PRO
|
8 |
+
* @package Web4pro_Attachments
|
9 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
10 |
+
* @license http://www.web4pro.net/license.txt
|
11 |
+
*/
|
12 |
+
-->
|
13 |
+
<config>
|
14 |
+
<tabs>
|
15 |
+
<web4pro translate="label" module="web4pro_attachments">
|
16 |
+
<label>Web4pro</label>
|
17 |
+
<sort_order>2000</sort_order>
|
18 |
+
</web4pro>
|
19 |
+
</tabs>
|
20 |
+
<sections>
|
21 |
+
<web4pro_attachments translate="label" module="web4pro_attachments">
|
22 |
+
<class>separator-top</class>
|
23 |
+
<label>Web4pro</label>
|
24 |
+
<tab>web4pro</tab>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<sort_order>100</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>1</show_in_store>
|
30 |
+
<groups>
|
31 |
+
<attachment translate="label" module="web4pro_attachments">
|
32 |
+
<label>Attachment</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>0</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
<fields>
|
39 |
+
<breadcrumbs translate="label">
|
40 |
+
<label>Use Breadcrumbs</label>
|
41 |
+
<frontend_type>select</frontend_type>
|
42 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
43 |
+
<sort_order>10</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
</breadcrumbs>
|
48 |
+
</fields>
|
49 |
+
</attachment>
|
50 |
+
</groups>
|
51 |
+
</web4pro_attachments>
|
52 |
+
</sections>
|
53 |
+
</config>
|
app/code/community/Web4pro/Attachments/etc/widget.xml
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* WEB4PRO - Creating profitable online stores
|
5 |
+
*
|
6 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
7 |
+
* @category WEB4PRO
|
8 |
+
* @package Web4pro_Attachments
|
9 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
10 |
+
* @license http://www.web4pro.net/license.txt
|
11 |
+
*/
|
12 |
+
-->
|
13 |
+
<widgets>
|
14 |
+
<attachments_attachment_view type="web4pro_attachments/attachment_widget_view" translate="name description" module="web4pro_attachments">
|
15 |
+
<name>Attachment view</name>
|
16 |
+
<description>Attachment view widget</description>
|
17 |
+
<is_email_compatible>0</is_email_compatible>
|
18 |
+
<parameters>
|
19 |
+
<attachment_id type="complex" translate="label">
|
20 |
+
<visible>1</visible>
|
21 |
+
<required>1</required>
|
22 |
+
<label>Attachment</label>
|
23 |
+
<type>label</type>
|
24 |
+
<helper_block>
|
25 |
+
<type>web4pro_attachments/adminhtml_attachment_widget_chooser</type>
|
26 |
+
<data>
|
27 |
+
<button translate="open">
|
28 |
+
<open>Select Attachment</open>
|
29 |
+
</button>
|
30 |
+
</data>
|
31 |
+
</helper_block>
|
32 |
+
<sort_order>120</sort_order>
|
33 |
+
</attachment_id>
|
34 |
+
</parameters>
|
35 |
+
</attachments_attachment_view>
|
36 |
+
<attachments_attachment_link type="web4pro_attachments/attachment_widget_link" translate="name description" module="web4pro_attachments">
|
37 |
+
<name>Attachment link</name>
|
38 |
+
<description>Attachment link widget</description>
|
39 |
+
<is_email_compatible>0</is_email_compatible>
|
40 |
+
<parameters>
|
41 |
+
<attachment_id type="complex" translate="label">
|
42 |
+
<visible>1</visible>
|
43 |
+
<required>1</required>
|
44 |
+
<label>Attachment</label>
|
45 |
+
<type>label</type>
|
46 |
+
<helper_block>
|
47 |
+
<type>web4pro_attachments/adminhtml_attachment_widget_chooser</type>
|
48 |
+
<data>
|
49 |
+
<button translate="open">
|
50 |
+
<open>Select Attachment</open>
|
51 |
+
</button>
|
52 |
+
</data>
|
53 |
+
</helper_block>
|
54 |
+
<sort_order>130</sort_order>
|
55 |
+
</attachment_id>
|
56 |
+
</parameters>
|
57 |
+
</attachments_attachment_link>
|
58 |
+
</widgets>
|
app/code/community/Web4pro/Attachments/sql/web4pro_attachments_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachments module install script
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
$this->startSetup();
|
19 |
+
$table = $this->getConnection()
|
20 |
+
->newTable($this->getTable('web4pro_attachments/attachment'))
|
21 |
+
->addColumn(
|
22 |
+
'entity_id',
|
23 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
24 |
+
null,
|
25 |
+
array(
|
26 |
+
'identity' => true,
|
27 |
+
'nullable' => false,
|
28 |
+
'primary' => true,
|
29 |
+
),
|
30 |
+
'Attachment ID'
|
31 |
+
)
|
32 |
+
->addColumn(
|
33 |
+
'title',
|
34 |
+
Varien_Db_Ddl_Table::TYPE_TEXT, 255,
|
35 |
+
array(
|
36 |
+
'nullable' => false,
|
37 |
+
),
|
38 |
+
'Title'
|
39 |
+
)
|
40 |
+
->addColumn(
|
41 |
+
'uploaded_file',
|
42 |
+
Varien_Db_Ddl_Table::TYPE_TEXT, 255,
|
43 |
+
array(),
|
44 |
+
'Uploaded file'
|
45 |
+
)
|
46 |
+
->addColumn(
|
47 |
+
'status',
|
48 |
+
Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
|
49 |
+
array(),
|
50 |
+
'Enabled'
|
51 |
+
)
|
52 |
+
->addColumn(
|
53 |
+
'updated_at',
|
54 |
+
Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
55 |
+
null,
|
56 |
+
array(),
|
57 |
+
'Attachment Modification Time'
|
58 |
+
)
|
59 |
+
->addColumn(
|
60 |
+
'created_at',
|
61 |
+
Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
62 |
+
null,
|
63 |
+
array(),
|
64 |
+
'Attachment Creation Time'
|
65 |
+
)
|
66 |
+
->setComment('Attachment Table');
|
67 |
+
$this->getConnection()->createTable($table);
|
68 |
+
$table = $this->getConnection()
|
69 |
+
->newTable($this->getTable('web4pro_attachments/attachment_product'))
|
70 |
+
->addColumn(
|
71 |
+
'rel_id',
|
72 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
73 |
+
null,
|
74 |
+
array(
|
75 |
+
'unsigned' => true,
|
76 |
+
'identity' => true,
|
77 |
+
'nullable' => false,
|
78 |
+
'primary' => true,
|
79 |
+
),
|
80 |
+
'Relation ID'
|
81 |
+
)
|
82 |
+
->addColumn(
|
83 |
+
'attachment_id',
|
84 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
85 |
+
null,
|
86 |
+
array(
|
87 |
+
'unsigned' => true,
|
88 |
+
'nullable' => false,
|
89 |
+
'default' => '0',
|
90 |
+
),
|
91 |
+
'Attachment ID'
|
92 |
+
)
|
93 |
+
->addColumn(
|
94 |
+
'product_id',
|
95 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
96 |
+
null,
|
97 |
+
array(
|
98 |
+
'unsigned' => true,
|
99 |
+
'nullable' => false,
|
100 |
+
'default' => '0',
|
101 |
+
),
|
102 |
+
'Product ID'
|
103 |
+
)
|
104 |
+
->addColumn(
|
105 |
+
'position',
|
106 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
107 |
+
null,
|
108 |
+
array(
|
109 |
+
'nullable' => false,
|
110 |
+
'default' => '0',
|
111 |
+
),
|
112 |
+
'Position'
|
113 |
+
)
|
114 |
+
->addIndex(
|
115 |
+
$this->getIdxName(
|
116 |
+
'web4pro_attachments/attachment_product',
|
117 |
+
array('product_id')
|
118 |
+
),
|
119 |
+
array('product_id')
|
120 |
+
)
|
121 |
+
->addForeignKey(
|
122 |
+
$this->getFkName(
|
123 |
+
'web4pro_attachments/attachment_product',
|
124 |
+
'attachment_id',
|
125 |
+
'web4pro_attachments/attachment',
|
126 |
+
'entity_id'
|
127 |
+
),
|
128 |
+
'attachment_id',
|
129 |
+
$this->getTable('web4pro_attachments/attachment'),
|
130 |
+
'entity_id',
|
131 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE,
|
132 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE
|
133 |
+
)
|
134 |
+
->addForeignKey(
|
135 |
+
$this->getFkName(
|
136 |
+
'web4pro_attachments/attachment_product',
|
137 |
+
'product_id',
|
138 |
+
'catalog/product',
|
139 |
+
'entity_id'
|
140 |
+
),
|
141 |
+
'product_id',
|
142 |
+
$this->getTable('catalog/product'),
|
143 |
+
'entity_id',
|
144 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE,
|
145 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE
|
146 |
+
)
|
147 |
+
->addIndex(
|
148 |
+
$this->getIdxName(
|
149 |
+
'web4pro_attachments/attachment_product',
|
150 |
+
array('attachment_id', 'product_id'),
|
151 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
152 |
+
),
|
153 |
+
array('attachment_id', 'product_id'),
|
154 |
+
array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
|
155 |
+
)
|
156 |
+
->setComment('Attachment to Product Linkage Table');
|
157 |
+
$this->getConnection()->createTable($table);
|
158 |
+
$this->endSetup();
|
app/design/adminhtml/default/default/layout/web4pro_attachments.xml
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* WEB4PRO - Creating profitable online stores
|
5 |
+
*
|
6 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
7 |
+
* @category WEB4PRO
|
8 |
+
* @package Web4pro_Attachments
|
9 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
10 |
+
* @license http://www.web4pro.net/license.txt
|
11 |
+
*/
|
12 |
+
-->
|
13 |
+
<layout>
|
14 |
+
<adminhtml_attachments_attachment_index>
|
15 |
+
<reference name="menu">
|
16 |
+
<action method="setActive">
|
17 |
+
<menupath>web4pro_attachments/attachment</menupath>
|
18 |
+
</action>
|
19 |
+
</reference>
|
20 |
+
<reference name="content">
|
21 |
+
<block type="web4pro_attachments/adminhtml_attachment" name="attachment" />
|
22 |
+
|
23 |
+
</reference>
|
24 |
+
</adminhtml_attachments_attachment_index>
|
25 |
+
<adminhtml_attachments_attachment_grid>
|
26 |
+
<block type="core/text_list" name="root" output="toHtml">
|
27 |
+
<block type="web4pro_attachments/adminhtml_attachment_grid" name="attachment_grid"/>
|
28 |
+
</block>
|
29 |
+
</adminhtml_attachments_attachment_grid>
|
30 |
+
<!-- Attachment add/edit action -->
|
31 |
+
<adminhtml_attachments_attachment_edit>
|
32 |
+
<update handle="editor"/>
|
33 |
+
<reference name="menu">
|
34 |
+
<action method="setActive">
|
35 |
+
<menupath>web4pro_attachments/attachment</menupath>
|
36 |
+
</action>
|
37 |
+
</reference>
|
38 |
+
<reference name="content">
|
39 |
+
<block type="web4pro_attachments/adminhtml_attachment_edit" name="attachment_edit"></block>
|
40 |
+
</reference>
|
41 |
+
<reference name="left">
|
42 |
+
<block type="web4pro_attachments/adminhtml_attachment_edit_tabs" name="attachment_tabs"></block>
|
43 |
+
</reference>
|
44 |
+
</adminhtml_attachments_attachment_edit>
|
45 |
+
|
46 |
+
<adminhtml_attachments_attachment_catalog_product_attachments>
|
47 |
+
<block type="core/text_list" name="root" output="toHtml">
|
48 |
+
<block type="web4pro_attachments/adminhtml_catalog_product_edit_tab_attachment" name="product.edit.tab.attachment"/>
|
49 |
+
<block type="adminhtml/widget_grid_serializer" name="attachment_grid_serializer">
|
50 |
+
<reference name="attachment_grid_serializer">
|
51 |
+
<action method="initSerializerBlock">
|
52 |
+
<grid_block_name>product.edit.tab.attachment</grid_block_name>
|
53 |
+
<data_callback>getSelectedAttachments</data_callback>
|
54 |
+
<hidden_input_name>attachments</hidden_input_name>
|
55 |
+
<reload_param_name>product_attachments</reload_param_name>
|
56 |
+
</action>
|
57 |
+
<action method="addColumnInputName">
|
58 |
+
<input_name>position</input_name>
|
59 |
+
</action>
|
60 |
+
</reference>
|
61 |
+
</block>
|
62 |
+
</block>
|
63 |
+
</adminhtml_attachments_attachment_catalog_product_attachments>
|
64 |
+
<adminhtml_attachments_attachment_catalog_product_attachmentsgrid>
|
65 |
+
<block type="core/text_list" name="root" output="toHtml">
|
66 |
+
<block type="web4pro_attachments/adminhtml_catalog_product_edit_tab_attachment" name="product.edit.tab.attachment"/>
|
67 |
+
</block>
|
68 |
+
</adminhtml_attachments_attachment_catalog_product_attachmentsgrid>
|
69 |
+
<adminhtml_attachments_attachment_products>
|
70 |
+
<block type="core/text_list" name="root" output="toHtml">
|
71 |
+
<block type="web4pro_attachments/adminhtml_attachment_edit_tab_product" name="attachment.edit.tab.product"/>
|
72 |
+
<block type="adminhtml/widget_grid_serializer" name="product_grid_serializer">
|
73 |
+
<reference name="product_grid_serializer">
|
74 |
+
<action method="initSerializerBlock">
|
75 |
+
<grid_block_name>attachment.edit.tab.product</grid_block_name>
|
76 |
+
<data_callback>getSelectedProducts</data_callback>
|
77 |
+
<hidden_input_name>products</hidden_input_name>
|
78 |
+
<reload_param_name>attachment_products</reload_param_name>
|
79 |
+
</action>
|
80 |
+
<action method="addColumnInputName">
|
81 |
+
<input_name>position</input_name>
|
82 |
+
</action>
|
83 |
+
</reference>
|
84 |
+
</block>
|
85 |
+
</block>
|
86 |
+
</adminhtml_attachments_attachment_products>
|
87 |
+
<adminhtml_attachments_attachment_productsgrid>
|
88 |
+
<block type="core/text_list" name="root" output="toHtml">
|
89 |
+
<block type="web4pro_attachments/adminhtml_attachment_edit_tab_product" name="attachment.edit.tab.product"/>
|
90 |
+
</block>
|
91 |
+
</adminhtml_attachments_attachment_productsgrid>
|
92 |
+
</layout>
|
app/design/frontend/base/default/layout/web4pro_attachments.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* WEB4PRO - Creating profitable online stores
|
5 |
+
*
|
6 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
7 |
+
* @category WEB4PRO
|
8 |
+
* @package Web4pro_Attachments
|
9 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
10 |
+
* @license http://www.web4pro.net/license.txt
|
11 |
+
*/
|
12 |
+
-->
|
13 |
+
<layout>
|
14 |
+
|
15 |
+
<catalog_product_view>
|
16 |
+
<reference name="product.info">
|
17 |
+
<block type="web4pro_attachments/catalog_product_list_attachment" name="product.info.attachments" as="product_attachments" template="web4pro_attachments/catalog/product/list/attachment.phtml">
|
18 |
+
<action method="addToParentGroup"><group>detailed_info</group></action>
|
19 |
+
<action method="setTitle" translate="value" module="web4pro_attachments"><value>Attachments</value></action>
|
20 |
+
</block>
|
21 |
+
</reference>
|
22 |
+
</catalog_product_view>
|
23 |
+
</layout>
|
app/design/frontend/base/default/template/web4pro_attachments/attachment/widget/link.phtml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment link widget template
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
|
19 |
+
/** @see Web4pro_Attachments_Block_Attachment_Widget_Link */
|
20 |
+
?>
|
21 |
+
<?php $_attachment = $this->getCurrentAttachment();?>
|
22 |
+
<?php if ($_attachment) :?>
|
23 |
+
<div class="attachment-widget-link">
|
24 |
+
<h2><?php echo $this->__('Attachments'); ?></h2>
|
25 |
+
<?php echo $_attachment->getIcon(); ?>
|
26 |
+
<?php $test = $_attachment->getAttachmentUrl()?>
|
27 |
+
<a href="<?php echo $_attachment->getAttachmentUrl()?>"><?php echo $_attachment->getTitle()?></a>
|
28 |
+
</div>
|
29 |
+
<?php endif;?>
|
app/design/frontend/base/default/template/web4pro_attachments/attachment/widget/view.phtml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment view widget template
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
|
19 |
+
/** @see Web4pro_Attachments_Block_Attachment_Widget_View */
|
20 |
+
|
21 |
+
?>
|
22 |
+
<?php $_attachment = $this->getCurrentAttachment();?>
|
23 |
+
<?php if ($_attachment) :?>
|
24 |
+
<div class="attachment-widget-view">
|
25 |
+
<h3><?php echo $_attachment->getTitle()?></h3>
|
26 |
+
<div>
|
27 |
+
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
<?php endif;?>
|
app/design/frontend/base/default/template/web4pro_attachments/catalog/product/list/attachment.phtml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WEB4PRO - Creating profitable online stores
|
4 |
+
*
|
5 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
6 |
+
* @category WEB4PRO
|
7 |
+
* @package Web4pro_Attachments
|
8 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
9 |
+
* @license http://www.web4pro.net/license.txt
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Attachment list template on product page
|
13 |
+
*
|
14 |
+
* @category Web4pro
|
15 |
+
* @package Web4pro_Attachments
|
16 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
+
*/
|
18 |
+
|
19 |
+
/** @see Web4pro_Attachments_Block_Catalog_Product_List_Attachment */
|
20 |
+
?>
|
21 |
+
<?php
|
22 |
+
$attachments = $this->getAttachmentCollection();
|
23 |
+
$helper = Mage::helper('web4pro_attachments/attachment');
|
24 |
+
?>
|
25 |
+
<?php if ($attachments && $attachments->count() > 0) :?>
|
26 |
+
<div class="box-collateral box-attachments box-up-sell">
|
27 |
+
<?php foreach ($attachments as $_attachment) : ?>
|
28 |
+
<div class="item">
|
29 |
+
<?php $_fileSize = $helper->getFileSize($_attachment->getAttachmentPath()); ?>
|
30 |
+
<?php echo $_attachment->getIcon(); ?>
|
31 |
+
<a href="<?php echo $_attachment->getAttachmentUrl(); ?>"><?php echo $_attachment->getTitle()?></a>
|
32 |
+
<?php echo $this->__('Size: (' .$_fileSize . ')'); ?>
|
33 |
+
<br />
|
34 |
+
</div>
|
35 |
+
<?php endforeach; ?>
|
36 |
+
</div>
|
37 |
+
<?php endif;?>
|
app/etc/modules/Web4pro_Attachments.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* WEB4PRO - Creating profitable online stores
|
5 |
+
*
|
6 |
+
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
7 |
+
* @category WEB4PRO
|
8 |
+
* @package Web4pro_Attachments
|
9 |
+
* @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
|
10 |
+
* @license http://www.web4pro.net/license.txt
|
11 |
+
*/
|
12 |
+
-->
|
13 |
+
<config>
|
14 |
+
<modules>
|
15 |
+
<Web4pro_Attachments>
|
16 |
+
<active>true</active>
|
17 |
+
<codePool>community</codePool>
|
18 |
+
<depends>
|
19 |
+
<Mage_Catalog />
|
20 |
+
</depends>
|
21 |
+
</Web4pro_Attachments>
|
22 |
+
</modules>
|
23 |
+
</config>
|
app/locale/en_US/Web4pro_Attachments.csv
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"",""
|
2 |
+
"Action","Action"
|
3 |
+
"Add Attachment","Add Attachment"
|
4 |
+
"An error occurred while updating the attachments.","An error occurred while updating the attachments."
|
5 |
+
"Are you sure?","Are you sure?"
|
6 |
+
"Associated products","Associated products"
|
7 |
+
"Attachment was saved","Attachment was saved"
|
8 |
+
"Attachment was successfully deleted.","Attachment was successfully deleted."
|
9 |
+
"Attachment was successfully saved","Attachment was successfully saved"
|
10 |
+
"Attachment","Attachment"
|
11 |
+
"Attachments","Attachments"
|
12 |
+
"CSV","CSV"
|
13 |
+
"Change status","Change status"
|
14 |
+
"Could not find attachment to delete.","Could not find attachment to delete."
|
15 |
+
"Created at","Created at"
|
16 |
+
"Delete Attachment","Delete Attachment"
|
17 |
+
"Delete File","Delete File"
|
18 |
+
"Delete","Delete"
|
19 |
+
"Disabled","Disabled"
|
20 |
+
"Edit Attachment '%s'","Edit Attachment '%s'"
|
21 |
+
"Edit","Edit"
|
22 |
+
"Enabled","Enabled"
|
23 |
+
"Error saving attachment","Error saving attachment"
|
24 |
+
"Excel","Excel"
|
25 |
+
"Home","Home"
|
26 |
+
"Id","Id"
|
27 |
+
"No","No"
|
28 |
+
"None","None"
|
29 |
+
"Please select attachments to delete.","Please select attachments to delete."
|
30 |
+
"Please select attachments.","Please select attachments."
|
31 |
+
"Position","Position"
|
32 |
+
"Reset","Reset"
|
33 |
+
"Save And Continue Edit","Save And Continue Edit"
|
34 |
+
"Save Attachment","Save Attachment"
|
35 |
+
"Status","Status"
|
36 |
+
"Store views","Store views"
|
37 |
+
"The attachments has been deleted.","The attachments has been deleted."
|
38 |
+
"There was a problem saving the attachment.","There was a problem saving the attachment."
|
39 |
+
"There was an error deleting attachment.","There was an error deleting attachment."
|
40 |
+
"There was an error deleting attachments.","There was an error deleting attachments."
|
41 |
+
"There was an error updating attachments.","There was an error updating attachments."
|
42 |
+
"This attachment no longer exists.","This attachment no longer exists."
|
43 |
+
"Title","Title"
|
44 |
+
"Total of %d attachments were successfully deleted.","Total of %d attachments were successfully deleted."
|
45 |
+
"Total of %d attachments were successfully updated.","Total of %d attachments were successfully updated."
|
46 |
+
"Total of %d record(s) have been deleted.","Total of %d record(s) have been deleted."
|
47 |
+
"Total of %d record(s) have been updated.","Total of %d record(s) have been updated."
|
48 |
+
"Unable to find attachment to save.","Unable to find attachment to save."
|
49 |
+
"Updated at","Updated at"
|
50 |
+
"Uploaded file","Uploaded file"
|
51 |
+
"Use Breadcrumbs","Use Breadcrumbs"
|
52 |
+
"WYSIWYG Editor","WYSIWYG Editor"
|
53 |
+
"XML","XML"
|
54 |
+
"Yes","Yes"
|
media/attachment/icons/avi.png
ADDED
Binary file
|
media/attachment/icons/bmp.png
ADDED
Binary file
|
media/attachment/icons/css.png
ADDED
Binary file
|
media/attachment/icons/csv.png
ADDED
Binary file
|
media/attachment/icons/doc.png
ADDED
Binary file
|
media/attachment/icons/docx.png
ADDED
Binary file
|
media/attachment/icons/flv.png
ADDED
Binary file
|
media/attachment/icons/gif.png
ADDED
Binary file
|
media/attachment/icons/htm.png
ADDED
Binary file
|
media/attachment/icons/html.png
ADDED
Binary file
|
media/attachment/icons/jpeg.png
ADDED
Binary file
|
media/attachment/icons/jpg.png
ADDED
Binary file
|
media/attachment/icons/mov.png
ADDED
Binary file
|
media/attachment/icons/mp3.png
ADDED
Binary file
|
media/attachment/icons/pdf.png
ADDED
Binary file
|
media/attachment/icons/plain.png
ADDED
Binary file
|
media/attachment/icons/png.png
ADDED
Binary file
|
media/attachment/icons/ppt.png
ADDED
Binary file
|
media/attachment/icons/rtf.png
ADDED
Binary file
|
media/attachment/icons/swf.png
ADDED
Binary file
|
media/attachment/icons/txt.png
ADDED
Binary file
|
media/attachment/icons/wav.png
ADDED
Binary file
|
media/attachment/icons/wmv.png
ADDED
Binary file
|
media/attachment/icons/xls.png
ADDED
Binary file
|
media/attachment/icons/xlsx.png
ADDED
Binary file
|
media/attachment/icons/xml.png
ADDED
Binary file
|
media/attachment/icons/zip.png
ADDED
Binary file
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Web4pro_Attachments</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.web4pro.net/license.txt">GPL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Attach additional download files,</summary>
|
10 |
+
<description>Attach additional download files, manuals, media files, audio files with products for customer download. </description>
|
11 |
+
<notes>Version number: 1.1.0
|
12 |
+
Stability: Stable
|
13 |
+
Compatibility: 1.5, 1.6, 1.6.1, 1.6.2.0, 1.7, 1.8, 1.9
|
14 |
+
</notes>
|
15 |
+
<authors><author><name>Sergey Repin</name><user>srepin</user><email>srepin@corp.web4pro.com.ua</email></author></authors>
|
16 |
+
<date>2015-02-27</date>
|
17 |
+
<time>13:13:29</time>
|
18 |
+
<contents><target name="magecommunity"><dir name="Web4pro"><dir name="Attachments"><dir name="Block"><dir name="Adminhtml"><dir name="Attachment"><dir name="Edit"><file name="Form.php" hash="74159d2e86278a0952b1b63e37e76851"/><dir name="Tab"><file name="Form.php" hash="e7b8ddf29da1bdc492421062d98b6bad"/><file name="Product.php" hash="71bc7a5aeb5d26ad12b094cb18e3d803"/></dir><file name="Tabs.php" hash="b93dc50c79734cd19d2e05e486d5da3b"/></dir><file name="Edit.php" hash="379b58cda300c94afbe838a88e5851b9"/><file name="Grid.php" hash="f3f3f73e6dd676eb352c22bc3d2fa5ad"/><dir name="Helper"><file name="File.php" hash="3d936c71d4976c509db27a3452001cbc"/></dir><dir name="Widget"><file name="Chooser.php" hash="518fbdf4970d2975342398537e8d7654"/></dir></dir><file name="Attachment.php" hash="76e8983cf68c6ca60ce0f727d8a40370"/><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Attachment.php" hash="9240ced751d8d3e5b80e88ce0b14eb7b"/></dir></dir></dir></dir><dir name="Helper"><dir name="Column"><dir name="Renderer"><file name="Relation.php" hash="5e7c2e6f689850cca6afd191557e8cc4"/></dir></dir></dir></dir><dir name="Attachment"><file name="List.php" hash="b2c35eab430959dbe2a6b4da75d1ff77"/><dir name="Widget"><file name="Link.php" hash="4cb020a28aaf5479caa64f725ad7fba1"/><file name="View.php" hash="eb6066fdbbd691e46e7eb2c69343c80d"/></dir></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file name="Attachment.php" hash="33a0db5ac985072232e9921debdac29a"/></dir></dir></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="Attachments.php" hash="8a7ee1c174ea9318b21b3903ce53c353"/></dir></dir><dir name="Helper"><file name="Attachment.php" hash="4d61db9b52eb0b80ffc3d146030e9bf8"/><file name="Data.php" hash="9c992cb1aaccf1d08ac1552f5b7d546a"/><file name="Product.php" hash="36900b1d6f00dcdf4f2e66631a8a57ff"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="8e59205c8586dfdd5e4c7695345b749b"/><dir name="Search"><file name="Attachment.php" hash="448cff2ae24b1fa90d3eaf7562392fd5"/></dir></dir><dir name="Attachment"><file name="Product.php" hash="8b4edc5181ade4c24c145d7730a9d5a4"/></dir><file name="Attachment.php" hash="41dae9c3bc10de7b16e4d3cd9329ed6e"/><dir name="Resource"><dir name="Attachment"><file name="Collection.php" hash="496105c2d026e54ef053bd8e4eb7194b"/><dir name="Product"><file name="Collection.php" hash="0b5a31588f4eadaaa1d22f09f2b4808c"/></dir><file name="Product.php" hash="a5dd3a22b9c0c42e12322e86cc643cc8"/></dir><file name="Attachment.php" hash="595ba036a0f4b05b396811b78ab377df"/><file name="Setup.php" hash="56b4c9fb50f33a487315e9af44779f6a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Attachments"><dir name="Attachment"><dir name="Catalog"><file name="ProductController.php" hash="6a24f3ca5d8beb203a2dbe1e22ed5e3c"/></dir><file name="WidgetController.php" hash="dfceeec163058e74e5b757999a67d3f6"/></dir><file name="AttachmentController.php" hash="ed1f445b26248aad680f234c5e665b30"/></dir></dir><file name="AttachmentController.php" hash="e52f46b8268aebea7a8d9d26fb0a6826"/></dir><dir name="etc"><file name="adminhtml.xml" hash="00578db4ac5c15be9e8d2abaeefd0dae"/><file name="config.xml" hash="69c59ef86870a68de974659c40bc1db4"/><file name="system.xml" hash="75ae5408f27fc96ad608e12cfe1aeabc"/><file name="widget.xml" hash="8319f4cd508ccef8c121fe7e68c9042b"/></dir><dir name="sql"><dir name="web4pro_attachments_setup"><file name="install-1.0.0.php" hash="3e001ecfd1fb2ea0b027fef3eb517b1c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="web4pro_attachments"><dir name="attachment"><dir name="widget"><file name="link.phtml" hash="a162409f65ddaeaeb0a26c67fb75c950"/><file name="view.phtml" hash="56063d72dceb0d62b3c4ae9682934e8c"/></dir></dir><dir name="catalog"><dir name="product"><dir name="list"><file name="attachment.phtml" hash="ff29c3e94916ddc050e21a940aef7af9"/></dir></dir></dir></dir></dir><dir name="layout"><file name="web4pro_attachments.xml" hash="893ac94a5fcad8e3c24b43029ea4fb08"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="web4pro_attachments.xml" hash="7468ba3e03383738b1c581a6e52567c1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Web4pro_Attachments.xml" hash="727e7cc825964f1a9547ba1476d53052"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Web4pro_Attachments.csv" hash="a371f8ab59f227050d7187742e3189d6"/></dir></target><target name="magemedia"><dir name="attachment"><dir name="icons"><file name="avi.png" hash="09c6b0a7673f3e42e041598018c171b5"/><file name="bmp.png" hash="fcfec54b446f4d63c84b666a3fd37366"/><file name="css.png" hash="1b687145ab8b16d0e3115db2d8228171"/><file name="csv.png" hash="b2d999841a097ea15d5c55964a0a3c06"/><file name="doc.png" hash="3d2a75c77427d3e0fc35c8907233169c"/><file name="docx.png" hash="3d2a75c77427d3e0fc35c8907233169c"/><file name="flv.png" hash="7f190e2a065e3703f87b0f7568754641"/><file name="gif.png" hash="43f9a1879ac63c78feae547129551fc3"/><file name="htm.png" hash="f343c0d04a67e9803b4fb59ff694d72e"/><file name="html.png" hash="5c75b131f9a380723355afbe647cc5cc"/><file name="jpeg.png" hash="674f12f01482654df14e89f02cf5fff3"/><file name="jpg.png" hash="674f12f01482654df14e89f02cf5fff3"/><file name="mov.png" hash="4cbea719f33a4e29ddd2e083c5a0b0d1"/><file name="mp3.png" hash="888d7552ad7566a092494f39882d56cb"/><file name="pdf.png" hash="3d6afa6a2ed73b461846b8a13cfc730b"/><file name="plain.png" hash="48bf4302227f60c0bf8d9d531586d6ca"/><file name="png.png" hash="174af144f77a8affdb93c721240bc83a"/><file name="ppt.png" hash="4745d6c5fbc03eb6c46ee4d1d51a9d01"/><file name="rtf.png" hash="be33fb7c5bb2b8be60efc6d3b63b2bc8"/><file name="swf.png" hash="3522dc3e70b84f4cdf892caea7331164"/><file name="txt.png" hash="96361d93eb50ce99ec69b65a3733ba47"/><file name="wav.png" hash="0febbe202b8da6866aab471f4d681a20"/><file name="wmv.png" hash="ee71824919d89a30fd5251067333b389"/><file name="xls.png" hash="1060387404d16194006806dc08e25ab4"/><file name="xlsx.png" hash="1060387404d16194006806dc08e25ab4"/><file name="xml.png" hash="0d4446adbe445426d782934af4037a04"/><file name="zip.png" hash="1752876d0bff9bb8727cfe3f3c8aea8c"/></dir></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.3.0</min><max>5.5.5</max></php></required></dependencies>
|
21 |
+
</package>
|