Version Notes
Date:05-12-2013
Version:v0005
#First public free version via MC
Download this release
Release Info
Developer | Omar,Muhsin |
Extension | Zanbytes_Cdokus |
Version | 0.0.0.5 |
Comparing to | |
See all releases |
Version 0.0.0.5
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Catalog/Product/Edit/Tab/Cdokus.php +183 -0
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Catalog/Product/Edit/Tab/Links/Action/Renderer.php +67 -0
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Catalog/Product/Edit/Tab/Links/Grid.php +260 -0
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Document.php +45 -0
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Edit.php +62 -0
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Edit/Form.php +47 -0
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Edit/Tab/Form.php +115 -0
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Edit/Tabs.php +64 -0
- app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Grid.php +172 -0
- app/code/community/Zanbytes/Cdokus/Block/Download.php +99 -0
- app/code/community/Zanbytes/Cdokus/Helper/Data.php +49 -0
- app/code/community/Zanbytes/Cdokus/Model/Abstract.php +110 -0
- app/code/community/Zanbytes/Cdokus/Model/Link.php +56 -0
- app/code/community/Zanbytes/Cdokus/Model/Resource/Link.php +45 -0
- app/code/community/Zanbytes/Cdokus/Model/Resource/Link/Collection.php +118 -0
- app/code/community/Zanbytes/Cdokus/controllers/Adminhtml/Cdokus/Document/LinkController.php +149 -0
- app/code/community/Zanbytes/Cdokus/controllers/Adminhtml/Cdokus/Product/EditController.php +230 -0
- app/code/community/Zanbytes/Cdokus/controllers/DownloadController.php +132 -0
- app/code/community/Zanbytes/Cdokus/docs/TODO +4 -0
- app/code/community/Zanbytes/Cdokus/docs/readme +3 -0
- app/code/community/Zanbytes/Cdokus/docs/reset-cdoku-db-entries.sql +2 -0
- app/code/community/Zanbytes/Cdokus/etc/adminhtml.xml +73 -0
- app/code/community/Zanbytes/Cdokus/etc/config.xml +195 -0
- app/code/community/Zanbytes/Cdokus/etc/system.xml +122 -0
- app/code/community/Zanbytes/Cdokus/sql/cdokus_setup/mysql4-install-0.0.0.1.php +118 -0
- app/design/adminhtml/default/default/layout/cdokus.xml +89 -0
- app/design/adminhtml/default/default/template/cdokus/product/edit/cdokus.phtml +43 -0
- app/design/frontend/base/default/layout/cdokus.xml +54 -0
- app/design/frontend/base/default/template/cdokus/links.phtml +59 -0
- app/etc/modules/Zanbytes_Cdokus.xml +46 -0
- app/locale/en_US/Zanbytes_Cdokus.txt +47 -0
- package.xml +22 -0
- skin/frontend/base/default/cdokus/style.css +34 -0
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Catalog/Product/Edit/Tab/Cdokus.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Cdokus.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Catalog_Product_Edit_Tab_Cdokus extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface {
|
36 |
+
|
37 |
+
public function __construct() {
|
38 |
+
parent::__construct();
|
39 |
+
$this->setSkipGenerateContent(true);
|
40 |
+
$this->setTemplate('cdokus/product/edit/cdokus.phtml');
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getTabUrl() {
|
44 |
+
return $this->getUrl('*/cdokus_product_edit/form', array('_current' => true));
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getUpdateUrl() {
|
48 |
+
return $this->getUrl('*/cdokus_product_edit/update', array(
|
49 |
+
'back' => 'edit',
|
50 |
+
'id' => Mage::app()->getRequest()->getParam('id'),
|
51 |
+
'tab' => 'product_info_tabs_cdokus',
|
52 |
+
'store' => Mage::app()->getRequest()->getParam('store')
|
53 |
+
));
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getaddUrl() {
|
57 |
+
return $this->getUrl('*/cdokus_product_edit/add', array(
|
58 |
+
'back' => 'edit',
|
59 |
+
'id' => Mage::app()->getRequest()->getParam('id'),
|
60 |
+
'tab' => 'product_info_tabs_cdokus',
|
61 |
+
'store' => Mage::app()->getRequest()->getParam('store'),
|
62 |
+
));
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getTabClass() {
|
66 |
+
return 'ajax';
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Prepare layout
|
71 |
+
*
|
72 |
+
* @return Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle
|
73 |
+
*/
|
74 |
+
protected function _prepareLayout() {
|
75 |
+
$message = Mage::helper('catalog')->__('Are you sure?');
|
76 |
+
$this->setChild('add_button', $this->getLayout()->createBlock('adminhtml/widget_button')
|
77 |
+
->setData(array(
|
78 |
+
'label' => Mage::helper('cdokus')->__('Add New Option'),
|
79 |
+
'class' => 'add',
|
80 |
+
'id' => 'add_new_file',
|
81 |
+
'onclick' => 'if( confirm(\'' . $message . '\')) {productForm.submit(\'' . $this->getAddUrl() . '\');}return false;'
|
82 |
+
))
|
83 |
+
);
|
84 |
+
|
85 |
+
$this->setChild('update_button', $this->getLayout()->createBlock('adminhtml/widget_button')
|
86 |
+
->setData(array(
|
87 |
+
'label' => Mage::helper('cdokus')->__('Update Position'),
|
88 |
+
'class' => 'update',
|
89 |
+
'id' => 'update_link_position',
|
90 |
+
'onclick' => 'if( confirm(\'' . $message . '\')) {productForm.submit(\'' . $this->getUpdateUrl() . '\');}return false;'
|
91 |
+
))
|
92 |
+
);
|
93 |
+
|
94 |
+
$this->setChild('links_grid', $this->getLayout()->createBlock('cdokus/adminhtml_catalog_product_edit_tab_links_grid', 'adminhtml.catalog.product.edit.tab.links.grid')
|
95 |
+
);
|
96 |
+
|
97 |
+
return parent::_prepareLayout();
|
98 |
+
}
|
99 |
+
|
100 |
+
public function getAddButtonHtml() {
|
101 |
+
return $this->getChildHtml('add_button');
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getUpdateButtonHtml() {
|
105 |
+
return $this->getChildHtml('update_button');
|
106 |
+
}
|
107 |
+
|
108 |
+
public function getAvailableGridBoxHtml() {
|
109 |
+
return $this->getChildHtml('links_grid');
|
110 |
+
}
|
111 |
+
|
112 |
+
public function getFormHtml() {
|
113 |
+
$form = new Varien_Data_Form(
|
114 |
+
array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')
|
115 |
+
);
|
116 |
+
|
117 |
+
$form::setElementRenderer(
|
118 |
+
$this->getLayout()->createBlock('adminhtml/widget_form_renderer_element')
|
119 |
+
);
|
120 |
+
$form::setFieldsetRenderer(
|
121 |
+
$this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset')
|
122 |
+
);
|
123 |
+
$form::setFieldsetElementRenderer(
|
124 |
+
$this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')
|
125 |
+
);
|
126 |
+
|
127 |
+
$fieldset = $form->addFieldset('cdokus_fields', array('legend' => Mage::helper('cdokus')->__('Cdokus uploader'))
|
128 |
+
);
|
129 |
+
|
130 |
+
$fieldset->addField('cdokus_filename', 'file', array(
|
131 |
+
'name' => 'cdokus_filename',
|
132 |
+
'label' => Mage::helper('cdokus')->__('Upload file'),
|
133 |
+
'required' => false,
|
134 |
+
'note' => Mage::getSingleton('cdokus/link')->getConfigData('allowed_file_extension')
|
135 |
+
));
|
136 |
+
|
137 |
+
$fieldset->addField('cdokus_label', 'text', array(
|
138 |
+
'name' => 'cdokus_label',
|
139 |
+
'label' => Mage::helper('cdokus')->__('File label'),
|
140 |
+
'class' => 'input',
|
141 |
+
'required' => false,
|
142 |
+
));
|
143 |
+
|
144 |
+
$fieldset->addField('cdokus_is_active', 'select', array(
|
145 |
+
'label' => Mage::helper('cdokus')->__('Status'),
|
146 |
+
'name' => 'cdokus_is_active',
|
147 |
+
'required' => false,
|
148 |
+
'values' => array(
|
149 |
+
array(
|
150 |
+
'value' => Zanbytes_Cdokus_Model_Link::STATUS_DISABLED,
|
151 |
+
'label' => Mage::helper('cdokus')->__('Inactive'),
|
152 |
+
),
|
153 |
+
array(
|
154 |
+
'value' => Zanbytes_Cdokus_Model_Link::STATUS_ENABLED,
|
155 |
+
'label' => Mage::helper('cdokus')->__('Active'),
|
156 |
+
)
|
157 |
+
),
|
158 |
+
'value' => 1,
|
159 |
+
));
|
160 |
+
return $form->toHtml();
|
161 |
+
}
|
162 |
+
|
163 |
+
public function getProduct() {
|
164 |
+
return Mage::registry('product');
|
165 |
+
}
|
166 |
+
|
167 |
+
public function getTabLabel() {
|
168 |
+
return Mage::helper('cdokus')->__('Documents');
|
169 |
+
}
|
170 |
+
|
171 |
+
public function getTabTitle() {
|
172 |
+
return Mage::helper('cdokus')->__('Documents');
|
173 |
+
}
|
174 |
+
|
175 |
+
public function canShowTab() {
|
176 |
+
return true;
|
177 |
+
}
|
178 |
+
|
179 |
+
public function isHidden() {
|
180 |
+
return false;
|
181 |
+
}
|
182 |
+
|
183 |
+
}
|
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Catalog/Product/Edit/Tab/Links/Action/Renderer.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Renderer.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Catalog_Product_Edit_Tab_Links_Action_Renderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Render delete action link
|
39 |
+
* @param Varien_Object $row
|
40 |
+
* @return type
|
41 |
+
*/
|
42 |
+
public function render(Varien_Object $row) {
|
43 |
+
$label = $this->__('You are attempting link delete, you sure ?');
|
44 |
+
$out = $this->getLayout()->createBlock('adminhtml/widget_button')
|
45 |
+
->setData(array(
|
46 |
+
'label' => $this->__('Delete'),
|
47 |
+
'class' => 'delete icon-btn',
|
48 |
+
'on_click' => "if (confirm('$label')) { setLocation('" . $this->getDeleteUrl($row->getId()) . "');}"
|
49 |
+
));
|
50 |
+
return $out->toHtml();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get Delete URL
|
55 |
+
* @param type $id
|
56 |
+
* @return type
|
57 |
+
*/
|
58 |
+
public function getDeleteUrl($id) {
|
59 |
+
return $this->getUrl('*/cdokus_product_edit/deletelink', array(
|
60 |
+
'back' => 'edit',
|
61 |
+
'id' => Mage::app()->getRequest()->getParam('id'),
|
62 |
+
'tab' => 'product_info_tabs_cdokus',
|
63 |
+
'link_entity_id' => $id,
|
64 |
+
));
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Catalog/Product/Edit/Tab/Links/Grid.php
ADDED
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Grid.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Catalog_Product_Edit_Tab_Links_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Pager visibility
|
39 |
+
*
|
40 |
+
* @var boolean
|
41 |
+
*/
|
42 |
+
protected $_pagerVisibility = false;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Filter visibility
|
46 |
+
*
|
47 |
+
* @var boolean
|
48 |
+
*/
|
49 |
+
protected $_filterVisibility = false;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Set grid params
|
53 |
+
*
|
54 |
+
*/
|
55 |
+
public function __construct() {
|
56 |
+
parent::__construct();
|
57 |
+
$this->setId('cdokus_links_product_grid');
|
58 |
+
$this->setDefaultSort('entity_id');
|
59 |
+
$this->setUseAjax(true);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Retirve currently edited product model
|
64 |
+
*
|
65 |
+
* @return Mage_Catalog_Model_Product
|
66 |
+
*/
|
67 |
+
protected function _getProduct() {
|
68 |
+
return Mage::registry('current_product');
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Prepare collection
|
73 |
+
*
|
74 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
75 |
+
*/
|
76 |
+
protected function _prepareCollection() {
|
77 |
+
$collection = Mage::getResourceModel('cdokus/link_collection')
|
78 |
+
->addFieldToFilter('sku', $this->_getProduct()->getSku());
|
79 |
+
if ($storeId = Mage::app()->getRequest()->getParam('store', false)) {
|
80 |
+
$collection->addFieldToFilter('store_id', $storeId);
|
81 |
+
} else {
|
82 |
+
$collection->addFieldToFilter('store_id', Mage_Core_Model_App::ADMIN_STORE_ID);
|
83 |
+
}
|
84 |
+
$this->setCollection($collection);
|
85 |
+
return parent::_prepareCollection();
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Checks when this block is readonly
|
90 |
+
*
|
91 |
+
* @return boolean
|
92 |
+
*/
|
93 |
+
public function isReadonly() {
|
94 |
+
return $this->_getProduct()->getRelatedReadonly();
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Add columns to grid
|
99 |
+
*
|
100 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
101 |
+
*/
|
102 |
+
protected function _prepareColumns() {
|
103 |
+
|
104 |
+
$this->addColumn('in_products', array(
|
105 |
+
'header_css_class' => 'a-center',
|
106 |
+
'type' => 'checkbox',
|
107 |
+
'name' => 'in_products',
|
108 |
+
'align' => 'center',
|
109 |
+
'index' => 'entity_id'
|
110 |
+
));
|
111 |
+
|
112 |
+
|
113 |
+
$this->addColumn('entity_id', array(
|
114 |
+
'header' => Mage::helper('cdokus')->__('ID'),
|
115 |
+
'sortable' => true,
|
116 |
+
'width' => 60,
|
117 |
+
'index' => 'entity_id'
|
118 |
+
));
|
119 |
+
|
120 |
+
|
121 |
+
$this->addColumn('sku', array(
|
122 |
+
'header' => Mage::helper('cdokus')->__('SKU'),
|
123 |
+
'width' => 80,
|
124 |
+
'index' => 'sku'
|
125 |
+
));
|
126 |
+
|
127 |
+
$this->addColumn('filename', array(
|
128 |
+
'header' => Mage::helper('cdokus')->__('File Name'),
|
129 |
+
'width' => 80,
|
130 |
+
'index' => 'filename'
|
131 |
+
));
|
132 |
+
|
133 |
+
$this->addColumn('label', array(
|
134 |
+
'header' => Mage::helper('cdokus')->__('Label'),
|
135 |
+
'width' => 80,
|
136 |
+
'index' => 'label'
|
137 |
+
));
|
138 |
+
|
139 |
+
$this->addColumn('store_id', array(
|
140 |
+
'header' => Mage::helper('cdokus')->__('Store'),
|
141 |
+
'index' => 'store_id',
|
142 |
+
'type' => 'store',
|
143 |
+
'store_view' => false,
|
144 |
+
'display_deleted' => false,
|
145 |
+
'skipEmptyStoresLabel' => true,
|
146 |
+
));
|
147 |
+
|
148 |
+
$this->addColumn('is_active', array(
|
149 |
+
'header' => Mage::helper('cdokus')->__('Status'),
|
150 |
+
'width' => '70px',
|
151 |
+
'index' => 'is_active',
|
152 |
+
'type' => 'options',
|
153 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
154 |
+
));
|
155 |
+
|
156 |
+
$this->addColumn('created_at', array(
|
157 |
+
'header' => Mage::helper('cdokus')->__('Created On'),
|
158 |
+
'index' => 'created_at',
|
159 |
+
'type' => 'datetime',
|
160 |
+
'width' => '250px',
|
161 |
+
));
|
162 |
+
|
163 |
+
$this->addColumn('updated_at', array(
|
164 |
+
'header' => Mage::helper('cdokus')->__('Updated On'),
|
165 |
+
'index' => 'updated_at',
|
166 |
+
'type' => 'datetime',
|
167 |
+
'width' => '250px',
|
168 |
+
));
|
169 |
+
|
170 |
+
$this->addColumn('position', array(
|
171 |
+
'header' => Mage::helper('cdokus')->__('Position'),
|
172 |
+
'name' => 'position',
|
173 |
+
'type' => 'number',
|
174 |
+
'validate_class' => 'validate-number',
|
175 |
+
'index' => 'position',
|
176 |
+
'width' => 100,
|
177 |
+
'editable' => true,
|
178 |
+
'edit_only' => true
|
179 |
+
));
|
180 |
+
|
181 |
+
$this->addColumn('status', array(
|
182 |
+
'header' => Mage::helper('cdokus')->__('Activation'),
|
183 |
+
'width' => '100px',
|
184 |
+
'type' => 'action',
|
185 |
+
'getter' => 'getId',
|
186 |
+
'actions' => array(
|
187 |
+
array(
|
188 |
+
'caption' => Mage::helper('catalog')->__('Disable'),
|
189 |
+
'url' => array(
|
190 |
+
'base' => '*/cdokus_product_edit/status',
|
191 |
+
'params' => array(
|
192 |
+
'is_active' => Zanbytes_Cdokus_Model_Link::STATUS_DISABLED),
|
193 |
+
),
|
194 |
+
'field' => 'link_id'
|
195 |
+
),
|
196 |
+
array(
|
197 |
+
'caption' => Mage::helper('cdokus')->__('Enable'),
|
198 |
+
'url' => array(
|
199 |
+
'base' => '*/cdokus_product_edit/status',
|
200 |
+
'params' => array(
|
201 |
+
'is_active' => Zanbytes_Cdokus_Model_Link::STATUS_ENABLED),
|
202 |
+
),
|
203 |
+
'field' => 'link_id'
|
204 |
+
)
|
205 |
+
),
|
206 |
+
'filter' => false,
|
207 |
+
'sortable' => false,
|
208 |
+
'index' => 'entity_id',
|
209 |
+
));
|
210 |
+
|
211 |
+
$this->addColumn('delete', array(
|
212 |
+
'header' => Mage::helper('cdokus')->__('Delete'),
|
213 |
+
'type' => 'action',
|
214 |
+
'width' => '10px',
|
215 |
+
'getter' => 'getId',
|
216 |
+
'filter' => false,
|
217 |
+
'sortable' => false,
|
218 |
+
'renderer' => 'cdokus/adminhtml_catalog_product_edit_tab_links_action_renderer',
|
219 |
+
'is_system' => true,
|
220 |
+
));
|
221 |
+
|
222 |
+
return parent::_prepareColumns();
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Rerieve grid URL
|
227 |
+
*
|
228 |
+
* @return string
|
229 |
+
*/
|
230 |
+
public function getGridUrl() {
|
231 |
+
return $this->getUrl('*/cdokus_product_edit/tabgrid', array('_current' => true));
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Return row url for js event handlers
|
236 |
+
*
|
237 |
+
* @param Mage_Catalog_Model_Product|Varien_Object
|
238 |
+
* @return string
|
239 |
+
*/
|
240 |
+
public function getRowUrl($link) {
|
241 |
+
return $this->getUrl('*/cdokus_document_link/edit', array('link_id' => $link->getId(), '_current' => true));
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Retrieve Available links
|
246 |
+
*
|
247 |
+
* @return array
|
248 |
+
*/
|
249 |
+
public function getSelectedProducts() {
|
250 |
+
$collection = Mage::getResourceModel('cdokus/link_collection')
|
251 |
+
->addFieldToFilter('sku', $this->_getProduct()->getSku());
|
252 |
+
$products = array();
|
253 |
+
foreach ($collection as $link) {
|
254 |
+
$products[$link->getId()] = array('position' => $link->getPosition());
|
255 |
+
}
|
256 |
+
return $products;
|
257 |
+
}
|
258 |
+
|
259 |
+
}
|
260 |
+
|
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Document.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Document.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Cdokus_Document extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
36 |
+
|
37 |
+
public function __construct() {
|
38 |
+
parent::__construct();
|
39 |
+
$this->_controller = 'adminhtml_cdokus';
|
40 |
+
$this->_blockGroup = 'cdokus';
|
41 |
+
$this->_headerText = Mage::helper('cdokus')->__('Manage Document Links');
|
42 |
+
$this->_removeButton('add');
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Edit.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Edit.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Cdokus_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
36 |
+
|
37 |
+
public function __construct() {
|
38 |
+
parent::__construct();
|
39 |
+
$this->_objectId = 'id';
|
40 |
+
$this->_blockGroup = 'cdokus';
|
41 |
+
$this->_controller = 'adminhtml_cdokus';
|
42 |
+
$this->_removeButton('reset');
|
43 |
+
$this->_addButton('delete', array(
|
44 |
+
'label' => Mage::helper('adminhtml')->__('Delete'),
|
45 |
+
'class' => 'delete',
|
46 |
+
'onclick' => 'deleteConfirm(\'' . Mage::helper('adminhtml')->__('Are you sure you want to do this?')
|
47 |
+
. '\', \'' . $this->getDeleteUrl() . '\')',
|
48 |
+
));
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getHeaderText() {
|
52 |
+
if ($link = Mage::getModel('cdokus/link')->load($this->getRequest()->getParam('link_id', false))) {
|
53 |
+
Mage::getSingleton('adminhtml/session')->setLinkData($link->getData());
|
54 |
+
return Mage::helper('cdokus')->__('Link # %s | %s', $link->getEntityId(), $this->formatDate($link->getCreatedAt(), 'medium', true));
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getDeleteUrl() {
|
59 |
+
return $this->getUrl('*/*/delete', array('link_id' => $this->getRequest()->getParam('link_id')));
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Edit/Form.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Form.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Cdokus_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
36 |
+
|
37 |
+
protected function _prepareForm() {
|
38 |
+
$form = new Varien_Data_Form(array(
|
39 |
+
'id' => 'edit_form',
|
40 |
+
'enctype' => "multipart/form-data",
|
41 |
+
'action' => $this->getUrl('*/*/save', array('link_id' => $this->getRequest()->getParam('link_id'))), 'method' => 'post',));
|
42 |
+
$form->setUseContainer(true);
|
43 |
+
$this->setForm($form);
|
44 |
+
return parent::_prepareForm();
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Form.php 1103 2013-02-18 00:30:55Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Cdokus_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
36 |
+
|
37 |
+
protected function _prepareForm() {
|
38 |
+
$form = new Varien_Data_Form();
|
39 |
+
|
40 |
+
$this->setForm($form);
|
41 |
+
$form::setElementRenderer(
|
42 |
+
$this->getLayout()->createBlock('adminhtml/widget_form_renderer_element')
|
43 |
+
);
|
44 |
+
$form::setFieldsetRenderer(
|
45 |
+
$this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset')
|
46 |
+
);
|
47 |
+
$form::setFieldsetElementRenderer(
|
48 |
+
$this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')
|
49 |
+
);
|
50 |
+
|
51 |
+
$fieldset = $form->addFieldset('cdokus_fields', array('legend' => Mage::helper('cdokus')->__('Cdokus uploader'))
|
52 |
+
);
|
53 |
+
|
54 |
+
$fieldset->addField('sku', 'text', array(
|
55 |
+
'name' => 'sku',
|
56 |
+
'label' => Mage::helper('cdokus')->__('SKU'),
|
57 |
+
'class' => 'input',
|
58 |
+
'required' => true,
|
59 |
+
'readonly' => true,
|
60 |
+
'disabled' => true,
|
61 |
+
'note' => Mage::helper('cdokus')->__('read only')
|
62 |
+
));
|
63 |
+
|
64 |
+
$fieldset->addField('filename', 'text', array(
|
65 |
+
'name' => 'filename',
|
66 |
+
'label' => Mage::helper('cdokus')->__('File'),
|
67 |
+
'class' => 'input',
|
68 |
+
'required' => true,
|
69 |
+
'readonly' => true,
|
70 |
+
'disabled' => true,
|
71 |
+
'note' => Mage::helper('cdokus')->__('read only')
|
72 |
+
));
|
73 |
+
|
74 |
+
$fieldset->addField('store_id', 'select', array(
|
75 |
+
'label' => Mage::helper('cdokus')->__('Store ID'),
|
76 |
+
'name' => 'store_id',
|
77 |
+
'required' => true,
|
78 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
79 |
+
));
|
80 |
+
|
81 |
+
$fieldset->addField('label', 'text', array(
|
82 |
+
'name' => 'label',
|
83 |
+
'label' => Mage::helper('cdokus')->__('File label'),
|
84 |
+
'class' => 'input',
|
85 |
+
'required' => true,
|
86 |
+
));
|
87 |
+
|
88 |
+
$fieldset->addField('position', 'text', array(
|
89 |
+
'name' => 'position',
|
90 |
+
'label' => Mage::helper('cdokus')->__('Position'),
|
91 |
+
'class' => 'input',
|
92 |
+
'required' => true,
|
93 |
+
));
|
94 |
+
|
95 |
+
$fieldset->addField('is_active', 'select', array(
|
96 |
+
'label' => Mage::helper('cdokus')->__('Status'),
|
97 |
+
'name' => 'is_active',
|
98 |
+
'required' => false,
|
99 |
+
'values' => array(
|
100 |
+
array(
|
101 |
+
'value' => Zanbytes_Cdokus_Model_Link::STATUS_DISABLED,
|
102 |
+
'label' => Mage::helper('cdokus')->__('Inactive'),
|
103 |
+
),
|
104 |
+
array(
|
105 |
+
'value' => Zanbytes_Cdokus_Model_Link::STATUS_ENABLED,
|
106 |
+
'label' => Mage::helper('cdokus')->__('Active'),
|
107 |
+
)
|
108 |
+
),
|
109 |
+
));
|
110 |
+
if ($link = Mage::getModel('cdokus/link')->load($this->getRequest()->getParam('link_id'))) {
|
111 |
+
$form->setValues($link->getData());
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Edit/Tabs.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Tabs.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Cdokus_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
36 |
+
|
37 |
+
public function __construct() {
|
38 |
+
parent::__construct();
|
39 |
+
$this->setId('quotation_info_tabs');
|
40 |
+
$this->setDestElementId('edit_form');
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _beforeToHtml() {
|
44 |
+
$this->addTab('general', array(
|
45 |
+
'label' => Mage::helper('cdokus')->__('General'),
|
46 |
+
'title' => Mage::helper('cdokus')->__('General'),
|
47 |
+
'content' => $this->getLayout()->createBlock('cdokus/adminhtml_cdokus_edit_tab_form')->toHtml(),
|
48 |
+
));
|
49 |
+
$this->_updateActiveTab();
|
50 |
+
return parent::_beforeToHtml();
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function _updateActiveTab() {
|
54 |
+
$tabId = $this->getRequest()->getParam('tab');
|
55 |
+
if ($tabId) {
|
56 |
+
$tabId = preg_replace("#{$this->getId()}_#", '', $tabId);
|
57 |
+
if ($tabId) {
|
58 |
+
$this->setActiveTab($tabId);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
64 |
+
|
app/code/community/Zanbytes/Cdokus/Block/Adminhtml/Cdokus/Grid.php
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Grid.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Adminhtml_Cdokus_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
36 |
+
|
37 |
+
public function __construct() {
|
38 |
+
parent::__construct();
|
39 |
+
$this->setId('cdokus_links_grid');
|
40 |
+
$this->setUseAjax(true);
|
41 |
+
$this->setDefaultSort('created_at');
|
42 |
+
$this->setDefaultDir('DESC');
|
43 |
+
$this->setSaveParametersInSession(true);
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Retrieve collection class
|
48 |
+
*
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
protected function _getCollectionClass() {
|
52 |
+
return 'sales/quote_collection';
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Prepare collection
|
57 |
+
*
|
58 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
59 |
+
*/
|
60 |
+
protected function _prepareCollection() {
|
61 |
+
$collection = Mage::getResourceModel('cdokus/link_collection');
|
62 |
+
$this->setCollection($collection);
|
63 |
+
return parent::_prepareCollection();
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Add columns to grid
|
68 |
+
*
|
69 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
70 |
+
*/
|
71 |
+
protected function _prepareColumns() {
|
72 |
+
$this->addColumn('entity_id', array(
|
73 |
+
'header' => Mage::helper('cdokus')->__('ID'),
|
74 |
+
'sortable' => true,
|
75 |
+
'width' => 60,
|
76 |
+
'index' => 'entity_id'
|
77 |
+
));
|
78 |
+
|
79 |
+
|
80 |
+
$this->addColumn('sku', array(
|
81 |
+
'header' => Mage::helper('cdokus')->__('SKU'),
|
82 |
+
'width' => 80,
|
83 |
+
'index' => 'sku'
|
84 |
+
));
|
85 |
+
|
86 |
+
$this->addColumn('filename', array(
|
87 |
+
'header' => Mage::helper('cdokus')->__('File Name'),
|
88 |
+
'width' => 80,
|
89 |
+
'index' => 'filename'
|
90 |
+
));
|
91 |
+
|
92 |
+
$this->addColumn('label', array(
|
93 |
+
'header' => Mage::helper('cdokus')->__('Label'),
|
94 |
+
'width' => 80,
|
95 |
+
'index' => 'label'
|
96 |
+
));
|
97 |
+
|
98 |
+
$this->addColumn('store_id', array(
|
99 |
+
'header' => Mage::helper('cdokus')->__('Store'),
|
100 |
+
'index' => 'store_id',
|
101 |
+
'type' => 'store',
|
102 |
+
'store_view' => false,
|
103 |
+
'display_deleted' => false,
|
104 |
+
'skipEmptyStoresLabel' => true,
|
105 |
+
));
|
106 |
+
|
107 |
+
$this->addColumn('is_active', array(
|
108 |
+
'header' => Mage::helper('cdokus')->__('Status'),
|
109 |
+
'width' => '70px',
|
110 |
+
'index' => 'is_active',
|
111 |
+
'type' => 'options',
|
112 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
113 |
+
));
|
114 |
+
|
115 |
+
$this->addColumn('created_at', array(
|
116 |
+
'header' => Mage::helper('cdokus')->__('Created On'),
|
117 |
+
'index' => 'created_at',
|
118 |
+
'type' => 'datetime',
|
119 |
+
'width' => '250px',
|
120 |
+
));
|
121 |
+
|
122 |
+
$this->addColumn('updated_at', array(
|
123 |
+
'header' => Mage::helper('cdokus')->__('Updated On'),
|
124 |
+
'index' => 'updated_at',
|
125 |
+
'type' => 'datetime',
|
126 |
+
'width' => '250px',
|
127 |
+
));
|
128 |
+
|
129 |
+
|
130 |
+
|
131 |
+
return parent::_prepareColumns();
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function _prepareMassaction() {
|
135 |
+
$this->setMassactionIdField('entity_id');
|
136 |
+
$this->getMassactionBlock()->setFormFieldName('cdokus');
|
137 |
+
|
138 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
139 |
+
'label' => Mage::helper('catalog')->__('Delete'),
|
140 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
141 |
+
'confirm' => Mage::helper('catalog')->__('Are you sure?')
|
142 |
+
));
|
143 |
+
|
144 |
+
$statuses = Mage::getSingleton('catalog/product_status')->getOptionArray();
|
145 |
+
|
146 |
+
array_unshift($statuses, array('label' => '', 'value' => ''));
|
147 |
+
$this->getMassactionBlock()->addItem('status', array(
|
148 |
+
'label' => Mage::helper('catalog')->__('Change status'),
|
149 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
|
150 |
+
'additional' => array(
|
151 |
+
'visibility' => array(
|
152 |
+
'name' => 'status',
|
153 |
+
'type' => 'select',
|
154 |
+
'class' => 'required-entry',
|
155 |
+
'label' => Mage::helper('catalog')->__('Status'),
|
156 |
+
'values' => $statuses
|
157 |
+
)
|
158 |
+
)
|
159 |
+
));
|
160 |
+
return $this;
|
161 |
+
}
|
162 |
+
|
163 |
+
public function getRowUrl($row) {
|
164 |
+
return $this->getUrl('*/*/edit', array('link_id' => $row->getEntityId()));
|
165 |
+
}
|
166 |
+
|
167 |
+
public function getGridUrl() {
|
168 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
169 |
+
}
|
170 |
+
|
171 |
+
}
|
172 |
+
|
app/code/community/Zanbytes/Cdokus/Block/Download.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Download.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Block_Download extends Mage_Core_Block_Template {
|
36 |
+
|
37 |
+
protected $_collection;
|
38 |
+
|
39 |
+
protected function _beforeToHtml() {
|
40 |
+
if (!$this->getProductSku()) {
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
return parent::_beforeToHtml();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* The final moment of truth i.e html
|
48 |
+
* @desc Assumptions the last entry will be set at default store
|
49 |
+
* @see Mage_Catalog_Model_Resource_Product_Link_Product_Collection::setStoreOrder
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
public function getAllLinks() {
|
53 |
+
$links = array();
|
54 |
+
$collection = $this->_getCollection();
|
55 |
+
if ($collection->count() <= 0)
|
56 |
+
return false;
|
57 |
+
$_exclArray = array();
|
58 |
+
foreach ($collection as $link) {
|
59 |
+
$path = $link->getFilename();
|
60 |
+
$filename = basename($path);
|
61 |
+
if (empty($filename) || !file_exists($path) || in_array($filename, $_exclArray)) {
|
62 |
+
continue;
|
63 |
+
}
|
64 |
+
$_exclArray[] = $filename;
|
65 |
+
$links[] = $link;
|
66 |
+
}
|
67 |
+
return $links;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Create link
|
72 |
+
* @param Zanbytes_Cdokus_Model_Link $link
|
73 |
+
* @return type
|
74 |
+
*/
|
75 |
+
public function getDownloadUrl(Zanbytes_Cdokus_Model_Link $link) {
|
76 |
+
return $this->getUrl('cdokus/download/index', array('link_id' => $link->getId()));
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function _getCollection() {
|
80 |
+
if (!$this->_collection && $this->getProductSku()) {
|
81 |
+
$model = Mage::getModel('cdokus/link');
|
82 |
+
$this->_collection = $model->getResourceCollection()
|
83 |
+
->addSkuToSelect($this->getProductSku())
|
84 |
+
->addProductFilter()
|
85 |
+
->addStoreFilter(Mage::app()->getStore()->getId())
|
86 |
+
->addActiveFilter(Zanbytes_Cdokus_Model_Link::STATUS_ENABLED)
|
87 |
+
->setPositionOrder();
|
88 |
+
}
|
89 |
+
return $this->_collection;
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getProductSku() {
|
93 |
+
if ($product = Mage::registry('current_product')) {
|
94 |
+
return $product->getSku();
|
95 |
+
}
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
app/code/community/Zanbytes/Cdokus/Helper/Data.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Data.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Helper_Data extends Mage_Core_Helper_Abstract {
|
36 |
+
|
37 |
+
/**
|
38 |
+
* false if guest not allowed && user not logged in, otherwise true
|
39 |
+
* @return boolean
|
40 |
+
*/
|
41 |
+
public function isAllowed() {
|
42 |
+
$allowed = (bool) Mage::getSingleton('cdokus/link')->getConfigData('allow_guest');
|
43 |
+
$isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
|
44 |
+
if (false === $allowed && false === $isLoggedIn)
|
45 |
+
return false;
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
|
49 |
+
}
|
app/code/community/Zanbytes/Cdokus/Model/Abstract.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Abstract.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
abstract class Zanbytes_Cdokus_Model_Abstract extends Mage_Core_Model_Abstract {
|
36 |
+
|
37 |
+
protected $_dirPath = null;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Model initialization
|
41 |
+
*
|
42 |
+
* @param string $resourceModel
|
43 |
+
* @param string $idFieldName
|
44 |
+
* @return Mage_Core_Model_Abstract
|
45 |
+
*/
|
46 |
+
protected function _construct() {
|
47 |
+
$this->_init('cdokus/link');
|
48 |
+
$this->setDirpath();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @desc Get Directory Path
|
53 |
+
* @return type string path used to store docs
|
54 |
+
*/
|
55 |
+
public function getDirpath() {
|
56 |
+
return $this->setDirpath();
|
57 |
+
}
|
58 |
+
|
59 |
+
public function setDirpath($dir = null) {
|
60 |
+
if (null === $dir)
|
61 |
+
$this->_dirPath = Mage::getBaseDir() . DS . 'media' . DS . 'catalog' . DS . 'docs' . DS;
|
62 |
+
$this->setData('dir_path', $dir);
|
63 |
+
return $this->_dirPath;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Retrieve information from configuration
|
68 |
+
*
|
69 |
+
* @param string $field
|
70 |
+
* @param int|string|null|Mage_Core_Model_Store $storeId
|
71 |
+
*
|
72 |
+
* @return mixed
|
73 |
+
*/
|
74 |
+
public function getConfigData($field, $storeId = null, $code = 'general') {
|
75 |
+
if (null === $storeId) {
|
76 |
+
$storeId = $this->getStore();
|
77 |
+
}
|
78 |
+
$path = 'cdokus/' . $code . '/' . $field;
|
79 |
+
return Mage::getStoreConfig($path, $storeId);
|
80 |
+
}
|
81 |
+
|
82 |
+
public function getStore() {
|
83 |
+
if ($storeId = $this->getData('store_id')) {
|
84 |
+
return $storeId;
|
85 |
+
}
|
86 |
+
return Mage::app()->getStore()->getId();
|
87 |
+
}
|
88 |
+
|
89 |
+
public function verifyLicence($host = null) {
|
90 |
+
if (null === $host) {
|
91 |
+
$url = new Varien_Object(parse_url(Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)));
|
92 |
+
$host = $url->getHost();
|
93 |
+
}
|
94 |
+
$signMac = Zend_Crypt_Hmac::compute('0JCC9KvtSGJZIFwlFuwhG1Ai4Sy4nTnd', 'sha1', $host);
|
95 |
+
$license = base64_encode(pack('H*', $signMac));
|
96 |
+
$backendKey = trim($this->getConfigData('license'));
|
97 |
+
if (strcmp($backendKey, $license) === 0) {
|
98 |
+
return true;
|
99 |
+
}
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
public function execute($observer) {
|
104 |
+
if (!Mage::getModel('cdokus/link')->verifyLicence())
|
105 |
+
Mage::getSingleton('adminhtml/session')
|
106 |
+
->addError('Your license is invalid, please consult me via <a href="mailto:info@zanbytes.com">info@zanbytes.com</a>');
|
107 |
+
return $this;
|
108 |
+
}
|
109 |
+
|
110 |
+
}
|
app/code/community/Zanbytes/Cdokus/Model/Link.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Link.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Model_Link extends Zanbytes_Cdokus_Model_Abstract {
|
36 |
+
|
37 |
+
const STATUS_ENABLED = 1;
|
38 |
+
const STATUS_DISABLED = 2;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Re-attach the directory path to the basename
|
42 |
+
* @return type
|
43 |
+
*/
|
44 |
+
public function getFilename() {
|
45 |
+
return $this->getDirpath() . $this->getData('filename');
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getLabel() {
|
49 |
+
$label = $this->getData('label');
|
50 |
+
if (!empty($label))
|
51 |
+
return $label;
|
52 |
+
$pathinfo = pathinfo($this->getData('filename'));
|
53 |
+
return $pathinfo['filename'];
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
app/code/community/Zanbytes/Cdokus/Model/Resource/Link.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Link.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Model_Resource_Link extends Mage_Core_Model_Mysql4_Abstract {
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Resource initialization
|
39 |
+
*
|
40 |
+
*/
|
41 |
+
protected function _construct() {
|
42 |
+
$this->_init('cdokus/links', 'entity_id');
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
app/code/community/Zanbytes/Cdokus/Model/Resource/Link/Collection.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Collection.php 1105 2013-03-17 22:41:47Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Model_Resource_Link_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
36 |
+
|
37 |
+
protected $_sku = null;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Resource initialization
|
41 |
+
*/
|
42 |
+
protected function _construct() {
|
43 |
+
$this->_init('cdokus/link');
|
44 |
+
}
|
45 |
+
|
46 |
+
public function addSkuToSelect($sku) {
|
47 |
+
$this->_sku = $sku;
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Add filter by store
|
53 |
+
*
|
54 |
+
* @param array | int $storeId
|
55 |
+
* @return Mage_Tag_Model_Resource_Tag_Collection
|
56 |
+
*/
|
57 |
+
public function addStoreFilter($storeId) {
|
58 |
+
/**
|
59 |
+
* All links on the store view level
|
60 |
+
*/
|
61 |
+
$this->getSelect()->where('main_table.store_id = ?', $storeId);
|
62 |
+
$files = array();
|
63 |
+
if ($storeLinks = $this->getConnection()->fetchAll($this->getSelect())) {
|
64 |
+
foreach ($storeLinks as $link) {
|
65 |
+
$files[] = $link['filename'];
|
66 |
+
}
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* All links on default level, duplicate handled here
|
70 |
+
*/
|
71 |
+
$sql = $this->getConnection()
|
72 |
+
->select()
|
73 |
+
->from(array('s' => $this->getMainTable()), array('entity_id'))
|
74 |
+
->where('s.store_id IN(?)', array($storeId, Mage_Core_Model_App::ADMIN_STORE_ID))
|
75 |
+
->where('s.sku = ?', $this->_sku);
|
76 |
+
if (!empty($files))
|
77 |
+
$sql->where('s.filename NOT IN(?)', $files);
|
78 |
+
/**
|
79 |
+
* Getll all the links
|
80 |
+
*/
|
81 |
+
$this->getSelect()->orWhere('main_table.entity_id IN(?)', $sql);
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Adds filter by status
|
87 |
+
*
|
88 |
+
* @param int $status
|
89 |
+
* @return Mage_Tag_Model_Resource_Tag_Collection
|
90 |
+
*/
|
91 |
+
public function addActiveFilter($status) {
|
92 |
+
$this->getSelect()->where('main_table.is_active = ?', $status);
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Add filter by SKU
|
98 |
+
*
|
99 |
+
* @param array | int $sku
|
100 |
+
* @return Mage_Tag_Model_Resource_Tag_Collection
|
101 |
+
*/
|
102 |
+
public function addProductFilter() {
|
103 |
+
$this->getSelect()->where('main_table.sku = ?', $this->_sku);
|
104 |
+
return $this;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Enable sorting links by position
|
109 |
+
*
|
110 |
+
* @param string $dir sort type asc|desc
|
111 |
+
* @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection
|
112 |
+
*/
|
113 |
+
public function setPositionOrder($dir = self::SORT_ORDER_DESC) {
|
114 |
+
$this->getSelect()->order('main_table.position ' . $dir);
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
|
118 |
+
}
|
app/code/community/Zanbytes/Cdokus/controllers/Adminhtml/Cdokus/Document/LinkController.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: LinkController.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_Adminhtml_Cdokus_Document_LinkController extends Mage_Adminhtml_Controller_Action {
|
36 |
+
|
37 |
+
protected function _construct() {
|
38 |
+
$this->setUsedModuleName('Zanbytes_Cdokus');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function indexAction() {
|
42 |
+
$this->loadLayout();
|
43 |
+
$this->_title($this->__('Catalog Links Overview'));
|
44 |
+
$this->_setActiveMenu('catalog/cdokus');
|
45 |
+
$this->renderLayout();
|
46 |
+
}
|
47 |
+
|
48 |
+
public function editAction() {
|
49 |
+
$this->loadLayout();
|
50 |
+
$this->_title($this->__('Catalog Links Overview'));
|
51 |
+
$this->_setActiveMenu('catalog/cdokus');
|
52 |
+
$this->renderLayout();
|
53 |
+
}
|
54 |
+
|
55 |
+
public function massStatusAction() {
|
56 |
+
$collection = $this->_getCollection();
|
57 |
+
if ($collection->count() <= 0) {
|
58 |
+
$this->_getSession()->addError($this->__('Please select link(s).'));
|
59 |
+
$this->_redirect('*/*/');
|
60 |
+
}
|
61 |
+
try {
|
62 |
+
foreach ($collection as $link) {
|
63 |
+
$link->setIsActive($this->getRequest()->getPost('status'))
|
64 |
+
->save();
|
65 |
+
}
|
66 |
+
$this->_getSession()->addSuccess($this->__('%s link(s) status updated.', $collection->count()));
|
67 |
+
} catch (Mage_Core_Exception $e) {
|
68 |
+
$this->_getSession()->addError($e->getMessage());
|
69 |
+
} catch (Exception $e) {
|
70 |
+
Mage::logException($e);
|
71 |
+
$this->_getSession()->addError($e->getMessage());
|
72 |
+
}
|
73 |
+
$this->_redirect('*/*/');
|
74 |
+
}
|
75 |
+
|
76 |
+
public function massDeleteAction() {
|
77 |
+
$collection = $this->_getCollection();
|
78 |
+
if ($collection->count() <= 0) {
|
79 |
+
$this->_getSession()->addError($this->__('Please select link(s).'));
|
80 |
+
$this->_redirect('*/*/');
|
81 |
+
}
|
82 |
+
try {
|
83 |
+
foreach ($collection as $link) {
|
84 |
+
$link->delete();
|
85 |
+
}
|
86 |
+
$this->_getSession()->addSuccess($this->__('%s link(s) status deleted.', $collection->count()));
|
87 |
+
} catch (Mage_Core_Exception $e) {
|
88 |
+
$this->_getSession()->addError($e->getMessage());
|
89 |
+
} catch (Exception $e) {
|
90 |
+
Mage::logException($e);
|
91 |
+
$this->_getSession()->addError($e->getMessage());
|
92 |
+
}
|
93 |
+
$this->_redirect('*/*/');
|
94 |
+
}
|
95 |
+
|
96 |
+
protected function _getCollection() {
|
97 |
+
return Mage::getResourceModel('cdokus/link_collection')
|
98 |
+
->addFieldToFilter('entity_id', array('in' => $this->getRequest()->getPost('cdokus', array())));
|
99 |
+
}
|
100 |
+
|
101 |
+
public function gridAction() {
|
102 |
+
$this->loadLayout();
|
103 |
+
$this->renderLayout();
|
104 |
+
}
|
105 |
+
|
106 |
+
public function saveAction() {
|
107 |
+
$data = $this->getRequest()->getPost();
|
108 |
+
if ($data) {
|
109 |
+
try {
|
110 |
+
if ($linkId = $this->getRequest()->getParam('link_id', false)) {
|
111 |
+
if ($link = Mage::getModel('cdokus/link')->load($linkId)) {
|
112 |
+
$link->setStoreId($this->getRequest()->getPost('store_id'))
|
113 |
+
->setLabel($this->getRequest()->getPost('label'))
|
114 |
+
->setPosition($this->getRequest()->getPost('position'))
|
115 |
+
->setIsActive($this->getRequest()->getPost('is_active'))
|
116 |
+
->save();
|
117 |
+
$this->_getSession()->addSuccess($this->__('The link # %s updated.', $link->getId()));
|
118 |
+
}
|
119 |
+
}
|
120 |
+
} catch (Mage_Core_Exception $e) {
|
121 |
+
$this->_getSession()->addError($e->getMessage());
|
122 |
+
} catch (Exception $e) {
|
123 |
+
Mage::logException($e);
|
124 |
+
$this->_getSession()->addError($e->getMessage());
|
125 |
+
}
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
public function deleteAction() {
|
131 |
+
try {
|
132 |
+
if ($linkId = $this->getRequest()->getParam('link_id', false)) {
|
133 |
+
if ($link = Mage::getModel('cdokus/link')->load($linkId)) {
|
134 |
+
$link->delete();
|
135 |
+
$storeId = $link->getStoreId();
|
136 |
+
$this->_getSession()->addSuccess($this->__("The link is now removed."));
|
137 |
+
$this->_getSession()->addNotice($this->__("File %s is left for you to manually delete it.", $link->getData('filename')));
|
138 |
+
}
|
139 |
+
}
|
140 |
+
} catch (Mage_Core_Exception $e) {
|
141 |
+
$this->_getSession()->addError($e->getMessage());
|
142 |
+
} catch (Exception $e) {
|
143 |
+
Mage::logException($e);
|
144 |
+
$this->_getSession()->addError($e->getMessage());
|
145 |
+
}
|
146 |
+
$this->_redirect('*/*/');
|
147 |
+
}
|
148 |
+
|
149 |
+
}
|
app/code/community/Zanbytes/Cdokus/controllers/Adminhtml/Cdokus/Product/EditController.php
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
/**
|
28 |
+
* @desc Catalog Product Documents
|
29 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
30 |
+
* @version $Id: EditController.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
31 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
32 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
33 |
+
*/
|
34 |
+
require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Adminhtml bundle product edit
|
38 |
+
*
|
39 |
+
* @category Mage
|
40 |
+
* @package Mage_Bundle
|
41 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
42 |
+
*/
|
43 |
+
class Zanbytes_Cdokus_Adminhtml_Cdokus_Product_EditController extends Mage_Adminhtml_Catalog_ProductController {
|
44 |
+
|
45 |
+
protected function _construct() {
|
46 |
+
$this->setUsedModuleName('Zanbytes_Cdokus');
|
47 |
+
}
|
48 |
+
|
49 |
+
public function formAction() {
|
50 |
+
$product = $this->_initProduct();
|
51 |
+
$this->loadLayout();
|
52 |
+
$this->getLayout()->getBlock('admin.product.cdokus.items')
|
53 |
+
->setProductId($product->getId());
|
54 |
+
$this->renderLayout();
|
55 |
+
}
|
56 |
+
|
57 |
+
public function addAction() {
|
58 |
+
$product = $this->_initProduct();
|
59 |
+
$storeId = $this->getRequest()->getParam('store', Mage_Core_Model_App::ADMIN_STORE_ID);
|
60 |
+
$redirectBack = $this->getRequest()->getParam('back', false);
|
61 |
+
$productId = $this->getRequest()->getParam('id');
|
62 |
+
$isEdit = (int) ($this->getRequest()->getParam('id') != null);
|
63 |
+
|
64 |
+
$data = $this->getRequest()->getPost();
|
65 |
+
if ($data) {
|
66 |
+
try {
|
67 |
+
$sku = $product->getSku();
|
68 |
+
if (empty($sku))
|
69 |
+
Mage::throwException($this->__('System error, sku can not be retrieved!'));
|
70 |
+
$link = Mage::getModel('cdokus/link');
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Upload handler
|
74 |
+
*/
|
75 |
+
$uploader = new Varien_File_Uploader('cdokus_filename');
|
76 |
+
$uploader->setFilesDispersion((bool) $link->getConfigData('allow_file_dispersion'));
|
77 |
+
$uploader->setAllowRenameFiles((bool) $link->getConfigData('allow_file_rename'));
|
78 |
+
$uploader->setAllowedExtensions(explode(',', $link->getConfigData('allowed_file_extension')));
|
79 |
+
$result = $uploader->save($link->getDirpath());
|
80 |
+
$label = $this->getRequest()->getParam('cdokus_label', null);
|
81 |
+
$isActive = $this->getRequest()->getParam('cdokus_is_active', true);
|
82 |
+
$link->setSku($sku)
|
83 |
+
->setFilename($result['file'])
|
84 |
+
->setLabel($label)
|
85 |
+
->setStoreId($storeId)
|
86 |
+
->setIsActive($isActive)
|
87 |
+
->setCreatedAt(now())
|
88 |
+
->setUpdatedAt(now())
|
89 |
+
->save();
|
90 |
+
/**
|
91 |
+
* Generate event , just incase someone want to dive in here
|
92 |
+
*/
|
93 |
+
Mage::dispatchEvent('catalog_product_cdokus_upload_document_after', array(
|
94 |
+
'result' => $result,
|
95 |
+
'action' => $link
|
96 |
+
));
|
97 |
+
$this->_getSession()->addSuccess($this->__('The link has been saved.'));
|
98 |
+
} catch (Mage_Core_Exception $e) {
|
99 |
+
$this->_getSession()->addError($e->getMessage())
|
100 |
+
->setProductData($data);
|
101 |
+
$redirectBack = true;
|
102 |
+
} catch (Exception $e) {
|
103 |
+
Mage::logException($e);
|
104 |
+
$this->_getSession()->addError($e->getMessage());
|
105 |
+
$redirectBack = true;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
if ($redirectBack) {
|
109 |
+
$this->_redirect('*/catalog_product/edit', array(
|
110 |
+
'id' => $productId,
|
111 |
+
'_current' => true
|
112 |
+
));
|
113 |
+
} elseif ($this->getRequest()->getParam('popup')) {
|
114 |
+
$this->_redirect('*/catalog_product/created', array(
|
115 |
+
'_current' => true,
|
116 |
+
'id' => $productId,
|
117 |
+
'edit' => $isEdit
|
118 |
+
));
|
119 |
+
} else {
|
120 |
+
$this->_redirect('*/catalog_product/', array('id' => $productId, 'store' => $storeId, '_current' => true,));
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
public function updateAction() {
|
125 |
+
$storeId = $this->getRequest()->getParam('store');
|
126 |
+
$redirectBack = $this->getRequest()->getParam('back', false);
|
127 |
+
$productId = $this->getRequest()->getParam('id');
|
128 |
+
$isEdit = (int) ($this->getRequest()->getParam('id') != null);
|
129 |
+
|
130 |
+
$data = $this->getRequest()->getPost();
|
131 |
+
if ($data) {
|
132 |
+
try {
|
133 |
+
if ($links = $this->getRequest()->getParam('links', array())) {
|
134 |
+
$links = Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['cdocus']);
|
135 |
+
foreach ($links as $linkId => $position) {
|
136 |
+
if ($link = Mage::getModel('cdokus/link')->load($linkId)) {
|
137 |
+
$link->setPosition($position['position'])->setUpdatedAt(now())->save();
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
$this->_getSession()->addSuccess($this->__('The link position updated.'));
|
142 |
+
} catch (Mage_Core_Exception $e) {
|
143 |
+
$this->_getSession()->addError($e->getMessage())
|
144 |
+
->setProductData($data);
|
145 |
+
$redirectBack = true;
|
146 |
+
} catch (Exception $e) {
|
147 |
+
Mage::logException($e);
|
148 |
+
$this->_getSession()->addError($e->getMessage());
|
149 |
+
$redirectBack = true;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
if ($redirectBack) {
|
154 |
+
$this->_redirect('*/catalog_product/edit', array(
|
155 |
+
'id' => $productId,
|
156 |
+
'_current' => true
|
157 |
+
));
|
158 |
+
} elseif ($this->getRequest()->getParam('popup')) {
|
159 |
+
$this->_redirect('*/catalog_product/created', array(
|
160 |
+
'_current' => true,
|
161 |
+
'id' => $productId,
|
162 |
+
'edit' => $isEdit
|
163 |
+
));
|
164 |
+
} else {
|
165 |
+
$this->_redirect('*/catalog_product/', array('id' => $productId, 'store' => $storeId));
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
public function deletelinkAction() {
|
170 |
+
$productId = $this->getRequest()->getParam('id');
|
171 |
+
try {
|
172 |
+
if ($linkId = $this->getRequest()->getParam('link_entity_id', false)) {
|
173 |
+
if ($link = Mage::getModel('cdokus/link')->load($linkId)) {
|
174 |
+
$link->delete();
|
175 |
+
$storeId = $link->getStoreId();
|
176 |
+
$this->_getSession()->addSuccess($this->__("The link is now removed."));
|
177 |
+
$this->_getSession()->addNotice($this->__("File %s is left for you to manually delete it.", $link->getData('filename')));
|
178 |
+
}
|
179 |
+
}
|
180 |
+
} catch (Mage_Core_Exception $e) {
|
181 |
+
$this->_getSession()->addError($e->getMessage());
|
182 |
+
} catch (Exception $e) {
|
183 |
+
Mage::logException($e);
|
184 |
+
$this->_getSession()->addError($e->getMessage());
|
185 |
+
}
|
186 |
+
$this->_redirect('*/catalog_product/edit', array(
|
187 |
+
'id' => $productId,
|
188 |
+
'_current' => true,
|
189 |
+
'tab' => 'product_info_tabs_cdokus',
|
190 |
+
'store' => $storeId
|
191 |
+
));
|
192 |
+
}
|
193 |
+
|
194 |
+
public function statusAction() {
|
195 |
+
try {
|
196 |
+
if ($linkId = $this->getRequest()->getParam('link_id', false)) {
|
197 |
+
if ($link = Mage::getModel('cdokus/link')->load($linkId)) {
|
198 |
+
$link->setIsActive($this->getRequest()->getParam('is_active'))
|
199 |
+
->setUpdatedAt(now())
|
200 |
+
->save();
|
201 |
+
$storeId = $link->getStoreId();
|
202 |
+
$productId = Mage::getResourceModel('catalog/product')->getIdBySku($link->getSku());
|
203 |
+
$status = $link->getIsActive() == Zanbytes_Cdokus_Model_Link::STATUS_ENABLED ?
|
204 |
+
$this->__('enabled') : $this->__('disabled');
|
205 |
+
$this->_getSession()->addSuccess($this->__("The link %s status is to %s.", $link->getId(), $status));
|
206 |
+
}
|
207 |
+
}
|
208 |
+
} catch (Mage_Core_Exception $e) {
|
209 |
+
$this->_getSession()->addError($e->getMessage());
|
210 |
+
} catch (Exception $e) {
|
211 |
+
Mage::logException($e);
|
212 |
+
$this->_getSession()->addError($e->getMessage());
|
213 |
+
}
|
214 |
+
$this->_redirect('*/catalog_product/edit', array(
|
215 |
+
'id' => $productId,
|
216 |
+
'_current' => true,
|
217 |
+
'tab' => 'product_info_tabs_cdokus',
|
218 |
+
'store' => $storeId
|
219 |
+
));
|
220 |
+
}
|
221 |
+
|
222 |
+
public function tabgridAction() {
|
223 |
+
$product = $this->_initProduct();
|
224 |
+
$this->loadLayout();
|
225 |
+
$this->getLayout()->getBlock('adminhtml.catalog.product.edit.tab.links.grid')
|
226 |
+
->setProductId($product->getId());
|
227 |
+
$this->renderLayout();
|
228 |
+
}
|
229 |
+
|
230 |
+
}
|
app/code/community/Zanbytes/Cdokus/controllers/DownloadController.php
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: DownloadController.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
class Zanbytes_Cdokus_DownloadController extends Mage_Core_Controller_Front_Action {
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Retrieve customer session object
|
39 |
+
*
|
40 |
+
* @return Mage_Customer_Model_Session
|
41 |
+
*/
|
42 |
+
protected function _getSession() {
|
43 |
+
return Mage::getSingleton('customer/session');
|
44 |
+
}
|
45 |
+
|
46 |
+
public function preDispatch() {
|
47 |
+
if (Mage::helper('cdokus')->isAllowed())
|
48 |
+
return $this;
|
49 |
+
parent::preDispatch();
|
50 |
+
if (!Mage::getSingleton('customer/session')->authenticate($this)) {
|
51 |
+
$this->setFlag('', 'no-dispatch', true);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
public function indexAction() {
|
56 |
+
if ($linkId = $this->getRequest()->getParam('link_id', false)) {
|
57 |
+
if ($link = Mage::getSingleton('cdokus/link')->load($linkId)) {
|
58 |
+
$this->_prepareDownloadResponse(basename($link->getFilename()), array('type' => 'filename', 'value' => $link->getFilename(), 'rm' => false));
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @desc If you running > magento 1.6.x feel free to delete/deprecate this function.
|
65 |
+
* @desc It is here for compatibility reasons.
|
66 |
+
* Declare headers and content file in response for file download
|
67 |
+
*
|
68 |
+
* @param string $fileName
|
69 |
+
* @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
|
70 |
+
* that case
|
71 |
+
* @param string $contentType
|
72 |
+
* @param int $contentLength explicit content length, if strlen($content) isn't applicable
|
73 |
+
* @return Mage_Adminhtml_Controller_Action
|
74 |
+
*/
|
75 |
+
protected function _prepareDownloadResponse($fileName, $content, $contentType = 'application/octet-stream', $contentLength = null
|
76 |
+
) {
|
77 |
+
$session = Mage::getSingleton('admin/session');
|
78 |
+
if ($session->isFirstPageAfterLogin()) {
|
79 |
+
$this->_redirect($session->getUser()->getStartupPageUrl());
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
+
|
83 |
+
$isFile = false;
|
84 |
+
$file = null;
|
85 |
+
if (is_array($content)) {
|
86 |
+
if (!isset($content['type']) || !isset($content['value'])) {
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
if ($content['type'] == 'filename') {
|
90 |
+
$isFile = true;
|
91 |
+
$file = $content['value'];
|
92 |
+
$contentLength = filesize($file);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
$this->getResponse()
|
97 |
+
->setHttpResponseCode(200)
|
98 |
+
->setHeader('Pragma', 'public', true)
|
99 |
+
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
|
100 |
+
->setHeader('Content-type', $contentType, true)
|
101 |
+
->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength)
|
102 |
+
->setHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"')
|
103 |
+
->setHeader('Last-Modified', date('r'));
|
104 |
+
|
105 |
+
if (!is_null($content)) {
|
106 |
+
if ($isFile) {
|
107 |
+
$this->getResponse()->clearBody();
|
108 |
+
$this->getResponse()->sendHeaders();
|
109 |
+
|
110 |
+
$ioAdapter = new Varien_Io_File();
|
111 |
+
if (!$ioAdapter->fileExists($file)) {
|
112 |
+
Mage::throwException(Mage::helper('core')->__('File not found'));
|
113 |
+
}
|
114 |
+
$ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
|
115 |
+
$ioAdapter->streamOpen($file, 'r');
|
116 |
+
while ($buffer = $ioAdapter->streamRead()) {
|
117 |
+
print $buffer;
|
118 |
+
}
|
119 |
+
$ioAdapter->streamClose();
|
120 |
+
if (!empty($content['rm'])) {
|
121 |
+
$ioAdapter->rm($file);
|
122 |
+
}
|
123 |
+
|
124 |
+
exit(0);
|
125 |
+
} else {
|
126 |
+
$this->getResponse()->setBody($content);
|
127 |
+
}
|
128 |
+
}
|
129 |
+
return $this;
|
130 |
+
}
|
131 |
+
|
132 |
+
}
|
app/code/community/Zanbytes/Cdokus/docs/TODO
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
Pending feature:
|
2 |
+
@todo Adds own upload interface with a grid to create links {1 doc to many products}
|
3 |
+
@todo Adds cdokus column in the catalog/product grid to notify admin that documents exists
|
4 |
+
@todo Adds validation against upload size exceeds server settings.
|
app/code/community/Zanbytes/Cdokus/docs/readme
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
Date:17-03-2013
|
2 |
+
Version:v0004
|
3 |
+
#Fixes links collector with store view support.
|
app/code/community/Zanbytes/Cdokus/docs/reset-cdoku-db-entries.sql
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'cdokus_setup';
|
2 |
+
DROP TABLE IF EXISTS `zanbytes_cdokus`;
|
app/code/community/Zanbytes/Cdokus/etc/adminhtml.xml
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: adminhtml.xml 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
-->
|
36 |
+
<config>
|
37 |
+
<menu>
|
38 |
+
<catalog>
|
39 |
+
<children>
|
40 |
+
<cdokus translate="title" module="cdokus">
|
41 |
+
<title>Cdokus</title>
|
42 |
+
<children>
|
43 |
+
<cdokus translate="title" module="cdokus">
|
44 |
+
<title>Manage Documents</title>
|
45 |
+
<action>adminhtml/cdokus_document_link/index</action>
|
46 |
+
</cdokus>
|
47 |
+
</children>
|
48 |
+
<sort_order>50</sort_order>
|
49 |
+
</cdokus>
|
50 |
+
</children>
|
51 |
+
</catalog>
|
52 |
+
</menu>
|
53 |
+
<acl>
|
54 |
+
<resources>
|
55 |
+
<admin>
|
56 |
+
<children>
|
57 |
+
<catalog>
|
58 |
+
<children>
|
59 |
+
<cdokus translate="title" module="cdokus">
|
60 |
+
<title>Cdokus</title>
|
61 |
+
<children>
|
62 |
+
<cdokus translate="title">
|
63 |
+
<title>Manage Documents</title>
|
64 |
+
</cdokus>
|
65 |
+
</children>
|
66 |
+
</cdokus>
|
67 |
+
</children>
|
68 |
+
</catalog>
|
69 |
+
</children>
|
70 |
+
</admin>
|
71 |
+
</resources>
|
72 |
+
</acl>
|
73 |
+
</config>
|
app/code/community/Zanbytes/Cdokus/etc/config.xml
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: config.xml 1105 2013-03-17 22:41:47Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
-->
|
36 |
+
<config>
|
37 |
+
<modules>
|
38 |
+
<Zanbytes_Cdokus>
|
39 |
+
<version>0.0.0.5</version>
|
40 |
+
</Zanbytes_Cdokus>
|
41 |
+
</modules>
|
42 |
+
<frontend>
|
43 |
+
<routers>
|
44 |
+
<cdokus>
|
45 |
+
<use>standard</use>
|
46 |
+
<args>
|
47 |
+
<module>Zanbytes_Cdokus</module>
|
48 |
+
<frontName>cdokus</frontName>
|
49 |
+
</args>
|
50 |
+
</cdokus>
|
51 |
+
</routers>
|
52 |
+
<layout>
|
53 |
+
<updates>
|
54 |
+
<cdokus>
|
55 |
+
<file>cdokus.xml</file>
|
56 |
+
</cdokus>
|
57 |
+
</updates>
|
58 |
+
</layout>
|
59 |
+
<translate>
|
60 |
+
<modules>
|
61 |
+
<Zanbytes_Cdokus>
|
62 |
+
<files>
|
63 |
+
<default>Zanbytes_Cdokus.csv</default>
|
64 |
+
</files>
|
65 |
+
</Zanbytes_Cdokus>
|
66 |
+
</modules>
|
67 |
+
</translate>
|
68 |
+
</frontend>
|
69 |
+
<global>
|
70 |
+
<models>
|
71 |
+
<cdokus>
|
72 |
+
<class>Zanbytes_Cdokus_Model</class>
|
73 |
+
<resourceModel>cdokus_resource</resourceModel>
|
74 |
+
</cdokus>
|
75 |
+
<cdokus_resource>
|
76 |
+
<class>Zanbytes_Cdokus_Model_Resource</class>
|
77 |
+
<entities>
|
78 |
+
<links>
|
79 |
+
<table>zanbytes_cdokus</table>
|
80 |
+
</links>
|
81 |
+
</entities>
|
82 |
+
</cdokus_resource>
|
83 |
+
</models>
|
84 |
+
<resources>
|
85 |
+
<cdokus_setup>
|
86 |
+
<setup>
|
87 |
+
<module>Zanbytes_Cdokus</module>
|
88 |
+
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
|
89 |
+
</setup>
|
90 |
+
<connection>
|
91 |
+
<use>core_setup</use>
|
92 |
+
</connection>
|
93 |
+
</cdokus_setup>
|
94 |
+
<cdokus_write>
|
95 |
+
<connection>
|
96 |
+
<use>core_write</use>
|
97 |
+
</connection>
|
98 |
+
</cdokus_write>
|
99 |
+
<cdokus_read>
|
100 |
+
<connection>
|
101 |
+
<use>core_read</use>
|
102 |
+
</connection>
|
103 |
+
</cdokus_read>
|
104 |
+
</resources>
|
105 |
+
<helpers>
|
106 |
+
<cdokus>
|
107 |
+
<class>Zanbytes_Cdokus_Helper</class>
|
108 |
+
</cdokus>
|
109 |
+
</helpers>
|
110 |
+
<blocks>
|
111 |
+
<cdokus>
|
112 |
+
<class>Zanbytes_Cdokus_Block</class>
|
113 |
+
</cdokus>
|
114 |
+
</blocks>
|
115 |
+
</global>
|
116 |
+
|
117 |
+
<admin>
|
118 |
+
<routers>
|
119 |
+
<adminhtml>
|
120 |
+
<args>
|
121 |
+
<modules>
|
122 |
+
<Zanbytes_Cdokus before="Mage_Adminhtml">Zanbytes_Cdokus_Adminhtml</Zanbytes_Cdokus>
|
123 |
+
</modules>
|
124 |
+
</args>
|
125 |
+
</adminhtml>
|
126 |
+
</routers>
|
127 |
+
</admin>
|
128 |
+
<adminhtml>
|
129 |
+
<events>
|
130 |
+
<admin_system_config_changed_section_cdokus>
|
131 |
+
<observers>
|
132 |
+
<admin_system_config_changed_section_cdokus>
|
133 |
+
<type>model</type>
|
134 |
+
<class>cdokus/link</class>
|
135 |
+
<method>execute</method>
|
136 |
+
</admin_system_config_changed_section_cdokus>
|
137 |
+
</observers>
|
138 |
+
</admin_system_config_changed_section_cdokus>
|
139 |
+
<catalog_product_cdokus_upload_document_after>
|
140 |
+
<observers>
|
141 |
+
<catalog_product_cdokus_upload_document_after_cdokus>
|
142 |
+
<type>model</type>
|
143 |
+
<class>cdokus/link</class>
|
144 |
+
<method>execute</method>
|
145 |
+
</catalog_product_cdokus_upload_document_after_cdokus>
|
146 |
+
</observers>
|
147 |
+
</catalog_product_cdokus_upload_document_after>
|
148 |
+
</events>
|
149 |
+
<layout>
|
150 |
+
<updates>
|
151 |
+
<cdokus>
|
152 |
+
<file>cdokus.xml</file>
|
153 |
+
</cdokus>
|
154 |
+
</updates>
|
155 |
+
</layout>
|
156 |
+
<translate>
|
157 |
+
<modules>
|
158 |
+
<Zanbytes_Cdokus>
|
159 |
+
<files>
|
160 |
+
<default>Zanbytes_Cdokus.csv</default>
|
161 |
+
</files>
|
162 |
+
</Zanbytes_Cdokus>
|
163 |
+
</modules>
|
164 |
+
</translate>
|
165 |
+
<acl>
|
166 |
+
<resources>
|
167 |
+
<admin>
|
168 |
+
<children>
|
169 |
+
<system>
|
170 |
+
<children>
|
171 |
+
<config>
|
172 |
+
<children>
|
173 |
+
<cdokus>
|
174 |
+
<title>Cdokus Configuration Panel</title>
|
175 |
+
</cdokus>
|
176 |
+
</children>
|
177 |
+
</config>
|
178 |
+
</children>
|
179 |
+
</system>
|
180 |
+
</children>
|
181 |
+
</admin>
|
182 |
+
</resources>
|
183 |
+
</acl>
|
184 |
+
</adminhtml>
|
185 |
+
<default>
|
186 |
+
<cdokus>
|
187 |
+
<general>
|
188 |
+
<allow_guest>1</allow_guest>
|
189 |
+
<allowed_file_extension>pdf,txt,doc,docx</allowed_file_extension>
|
190 |
+
<allow_file_dispersion>1</allow_file_dispersion>
|
191 |
+
<allow_file_rename>1</allow_file_rename>
|
192 |
+
</general>
|
193 |
+
</cdokus>
|
194 |
+
</default>
|
195 |
+
</config>
|
app/code/community/Zanbytes/Cdokus/etc/system.xml
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: system.xml 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
-->
|
36 |
+
<config>
|
37 |
+
<tabs>
|
38 |
+
<zanbytes>
|
39 |
+
<label>ZANBYTES</label>
|
40 |
+
<sort_order>500</sort_order>
|
41 |
+
</zanbytes>
|
42 |
+
</tabs>
|
43 |
+
<sections>
|
44 |
+
<cdokus>
|
45 |
+
<label>Cdokus</label>
|
46 |
+
<tab>zanbytes</tab>
|
47 |
+
<frontend_type>text</frontend_type>
|
48 |
+
<sort_order>100</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
<groups>
|
53 |
+
<general>
|
54 |
+
<label>General Settings</label>
|
55 |
+
<frontend_type>text</frontend_type>
|
56 |
+
<sort_order>10</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>1</show_in_website>
|
59 |
+
<show_in_store>1</show_in_store>
|
60 |
+
<fields>
|
61 |
+
<allowed_file_extension>
|
62 |
+
<label>Supported File Extensions</label>
|
63 |
+
<frontend_type>textarea</frontend_type>
|
64 |
+
<sort_order>0</sort_order>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>1</show_in_website>
|
67 |
+
<show_in_store>1</show_in_store>
|
68 |
+
<comment><![CDATA[Comma seperated e.g pdf,txt,doc]]>
|
69 |
+
</comment>
|
70 |
+
</allowed_file_extension>
|
71 |
+
<allow_guest>
|
72 |
+
<label>Allow guest</label>
|
73 |
+
<frontend_type>select</frontend_type>
|
74 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
75 |
+
<backend_model>adminhtml/system_config_backend_cache</backend_model>
|
76 |
+
<sort_order>5</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>1</show_in_store>
|
80 |
+
<comment><![CDATA[Set this to no, if you intend to let only logged in customers to download.Default Yes]]>
|
81 |
+
</comment>
|
82 |
+
</allow_guest>
|
83 |
+
<allow_file_dispersion>
|
84 |
+
<label>Allow file dispersion</label>
|
85 |
+
<frontend_type>select</frontend_type>
|
86 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
87 |
+
<backend_model>adminhtml/system_config_backend_cache</backend_model>
|
88 |
+
<sort_order>10</sort_order>
|
89 |
+
<show_in_default>1</show_in_default>
|
90 |
+
<show_in_website>1</show_in_website>
|
91 |
+
<show_in_store>1</show_in_store>
|
92 |
+
<comment><![CDATA[All uploaded files will be dispersed e.g foo.pdf to /f/o/foo.pdf]]>
|
93 |
+
</comment>
|
94 |
+
</allow_file_dispersion>
|
95 |
+
<allow_file_rename>
|
96 |
+
<label>Allow file rename</label>
|
97 |
+
<frontend_type>select</frontend_type>
|
98 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
99 |
+
<backend_model>adminhtml/system_config_backend_cache</backend_model>
|
100 |
+
<sort_order>15</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>1</show_in_store>
|
104 |
+
<comment><![CDATA[If file exist it will be renamed to foo_1.pdf]]>
|
105 |
+
</comment>
|
106 |
+
</allow_file_rename>
|
107 |
+
<license>
|
108 |
+
<label>License key</label>
|
109 |
+
<frontend_type>text</frontend_type>
|
110 |
+
<sort_order>20</sort_order>
|
111 |
+
<show_in_default>1</show_in_default>
|
112 |
+
<show_in_website>1</show_in_website>
|
113 |
+
<show_in_store>1</show_in_store>
|
114 |
+
<comment><![CDATA[If you dont have one, please consult me info@zanbytes.com]]>
|
115 |
+
</comment>
|
116 |
+
</license>
|
117 |
+
</fields>
|
118 |
+
</general>
|
119 |
+
</groups>
|
120 |
+
</cdokus>
|
121 |
+
</sections>
|
122 |
+
</config>
|
app/code/community/Zanbytes/Cdokus/sql/cdokus_setup/mysql4-install-0.0.0.1.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
/**
|
28 |
+
* @desc Catalog Product Documents
|
29 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
30 |
+
* @version $Id: mysql4-install-0.0.0.1.php 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
31 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
32 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
33 |
+
*/
|
34 |
+
$installer = $this;
|
35 |
+
|
36 |
+
/* @var $installer Mage_Catalog_Model_Resource_Setup */
|
37 |
+
$installer->startSetup();
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Create table 'zanbytes/links'
|
41 |
+
*/
|
42 |
+
if (version_compare(Mage::getVersion(), '1.5.1.0', '>') === true) {
|
43 |
+
$table = $installer->getConnection()
|
44 |
+
->newTable($installer->getTable('cdokus/links'))
|
45 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
46 |
+
'identity' => true,
|
47 |
+
'nullable' => false,
|
48 |
+
'primary' => true,
|
49 |
+
), 'Entity ID')
|
50 |
+
->addColumn('sku', Varien_Db_Ddl_Table::TYPE_CHAR, 55, array(
|
51 |
+
'nullable' => false,
|
52 |
+
), 'Sku')
|
53 |
+
->addColumn('filename', Varien_Db_Ddl_Table::TYPE_VARCHAR, 155, array(
|
54 |
+
'nullable' => false,
|
55 |
+
), 'File Name')
|
56 |
+
->addColumn('label', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
57 |
+
'nullable' => false,
|
58 |
+
), 'Label')
|
59 |
+
->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
60 |
+
'nullable' => false,
|
61 |
+
'default' => 0,
|
62 |
+
), 'Store Id')
|
63 |
+
->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
64 |
+
'nullable' => false,
|
65 |
+
'default' => 0,
|
66 |
+
), 'Position')
|
67 |
+
->addColumn('is_active', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
68 |
+
'nullable' => false,
|
69 |
+
'default' => 1,
|
70 |
+
), 'Is Active')
|
71 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
72 |
+
'nullable' => false,
|
73 |
+
), 'Created At')
|
74 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
75 |
+
'nullable' => false,
|
76 |
+
), 'Updated At')
|
77 |
+
->addIndex($installer->getIdxName('cdokus/links', array('filename')), array('filename'))
|
78 |
+
->addIndex(
|
79 |
+
$installer->getIdxName(
|
80 |
+
array('cdokus/links', 'decimal'), array('filename', 'store_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
81 |
+
), array('filename', 'store_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
|
82 |
+
->addForeignKey($installer->getFkName('cdokus/links', 'sku', 'catalog/product', 'sku'), 'sku', $installer->getTable('catalog/product'), 'sku', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
83 |
+
->addForeignKey($installer->getFkName('cdokus/links', 'store_id', 'core/store', 'store_id'), 'store_id', $installer->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
84 |
+
->setComment('Cdokus Links');
|
85 |
+
$installer->getConnection()->dropTable($installer->getTable('cdokus/links'));
|
86 |
+
$installer->getConnection()->createTable($table);
|
87 |
+
} else {
|
88 |
+
|
89 |
+
$installer->run("
|
90 |
+
DROP TABLE IF EXISTS `{$this->getTable('cdokus/links')}`;
|
91 |
+
CREATE TABLE `{$this->getTable('cdokus/links')}` (
|
92 |
+
`entity_id` int NOT NULL auto_increment COMMENT 'Entity ID',
|
93 |
+
`sku` varchar(55) NOT NULL COMMENT 'Sku',
|
94 |
+
`filename` varchar(155) NOT NULL COMMENT 'File Name',
|
95 |
+
`label` text NOT NULL COMMENT 'Label',
|
96 |
+
`store_id` smallint unsigned NOT NULL default '0' COMMENT 'Store Id',
|
97 |
+
`position` int NOT NULL default '0' COMMENT 'Position',
|
98 |
+
`is_active` int NOT NULL default '1' COMMENT 'Is Active',
|
99 |
+
`created_at` datetime NOT NULL COMMENT 'Created At',
|
100 |
+
`updated_at` datetime NOT NULL COMMENT 'Updated At',
|
101 |
+
PRIMARY KEY (`entity_id`),
|
102 |
+
INDEX `IDX_ZANBYTES_CDOKUS_FILENAME` (`filename`),
|
103 |
+
UNIQUE `UNQ_ZANBYTES_CDOKUS_DECIMAL_FILENAME_STORE_ID` (`filename`, `store_id`),
|
104 |
+
CONSTRAINT `FK_ZANBYTES_CDOKUS_SKU_CATALOG_PRODUCT_ENTITY_SKU` FOREIGN KEY (`sku`) REFERENCES `catalog_product_entity` (`sku`) ON DELETE CASCADE ON UPDATE CASCADE,
|
105 |
+
CONSTRAINT `FK_ZANBYTES_CDOKUS_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
106 |
+
) COMMENT='Cdokus Links' ENGINE=INNODB charset=utf8 COLLATE=utf8_general_ci
|
107 |
+
");
|
108 |
+
}
|
109 |
+
$installer->endSetup();
|
110 |
+
|
111 |
+
//create the dirs
|
112 |
+
$_dir = Mage::getBaseDir() . DS . 'media' . DS . 'catalog' . DS . 'docs' . DS;
|
113 |
+
if (!file_exists($_dir)) {
|
114 |
+
if (!mkdir($_dir, 0777, true)) {
|
115 |
+
throw new Exception('failed to create dir, check your permission in var');
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
app/design/adminhtml/default/default/layout/cdokus.xml
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: cdokus.xml 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
-->
|
36 |
+
<layout>
|
37 |
+
<adminhtml_catalog_product_edit>
|
38 |
+
<reference name="product_tabs">
|
39 |
+
<block type="cdokus/adminhtml_catalog_product_edit_tab_cdokus" name="tab_cdokus" />
|
40 |
+
<action method="addTab">
|
41 |
+
<name>cdokus</name><block>tab_cdokus</block>
|
42 |
+
</action>
|
43 |
+
<action method="bindShadowTabs"><first>tab_cdokus</first><second>customer_options</second></action>
|
44 |
+
</reference>
|
45 |
+
</adminhtml_catalog_product_edit>
|
46 |
+
<adminhtml_cdokus_product_edit_form>
|
47 |
+
<block type="core/text_list" name="root">
|
48 |
+
<block type="cdokus/adminhtml_catalog_product_edit_tab_cdokus" name="admin.product.cdokus.items"/>
|
49 |
+
<block type="adminhtml/widget_grid_serializer" name="tabgrid_grid_serializer">
|
50 |
+
<reference name="tabgrid_grid_serializer">
|
51 |
+
<action method="initSerializerBlock">
|
52 |
+
<grid_block_name>adminhtml.catalog.product.edit.tab.links.grid</grid_block_name>
|
53 |
+
<data_callback>getSelectedProducts</data_callback>
|
54 |
+
<hidden_input_name>links[cdocus]</hidden_input_name>
|
55 |
+
<reload_param_name>products_links</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_cdokus_product_edit_form>
|
64 |
+
<adminhtml_cdokus_product_edit_tabgrid>
|
65 |
+
<block type="core/text_list" name="root">
|
66 |
+
<block type="cdokus/adminhtml_catalog_product_edit_tab_links_grid" name="adminhtml.catalog.product.edit.tab.links.grid"/>
|
67 |
+
</block>
|
68 |
+
</adminhtml_cdokus_product_edit_tabgrid>
|
69 |
+
<!-- document manager -->
|
70 |
+
<adminhtml_cdokus_document_link_index>
|
71 |
+
<reference name="content">
|
72 |
+
<block type="cdokus/adminhtml_cdokus_document" name="adminhtml.cdokus.document" />
|
73 |
+
</reference>
|
74 |
+
</adminhtml_cdokus_document_link_index>
|
75 |
+
<adminhtml_cdokus_document_link_grid>
|
76 |
+
<block type="core/text_list" name="root">
|
77 |
+
<block type="cdokus/adminhtml_cdokus_grid" name="adminhtml.cdokus.grid" />
|
78 |
+
</block>
|
79 |
+
</adminhtml_cdokus_document_link_grid>
|
80 |
+
<adminhtml_cdokus_document_link_edit>
|
81 |
+
<reference name="content">
|
82 |
+
<block type="cdokus/adminhtml_cdokus_edit" name="adminhtml.cdokus.edit"></block>
|
83 |
+
</reference>
|
84 |
+
<reference name="left">
|
85 |
+
<block type="cdokus/adminhtml_cdokus_edit_tabs" name="adminhtml.cdokus.edit.tabs">
|
86 |
+
</block>
|
87 |
+
</reference>
|
88 |
+
</adminhtml_cdokus_document_link_edit>
|
89 |
+
</layout>
|
app/design/adminhtml/default/default/template/cdokus/product/edit/cdokus.phtml
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Zanbytes
|
22 |
+
* @package Zanbytes_Cdokus
|
23 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @desc Catalog Product Documents
|
29 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
30 |
+
* @version $Id: cdokus.phtml 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
31 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
32 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
33 |
+
*/
|
34 |
+
?>
|
35 |
+
<div class="entry-edit">
|
36 |
+
<div class="right"><?php echo $this->getAddButtonHtml() ?></div>
|
37 |
+
<?php echo $this->getFormHtml(); ?>
|
38 |
+
<div class="entry-edit-head">
|
39 |
+
<h4><?php echo $this->__('Available') ?></h4>
|
40 |
+
<div class="right"><?php echo $this->getUpdateButtonHtml() ?></div>
|
41 |
+
</div>
|
42 |
+
<?php echo $this->getAvailableGridBoxHtml() ?>
|
43 |
+
</div>
|
app/design/frontend/base/default/layout/cdokus.xml
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: cdokus.xml 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
-->
|
36 |
+
<layout version="0.1.0">
|
37 |
+
<catalog_product_view>
|
38 |
+
<reference name="head">
|
39 |
+
<action method="addCss">
|
40 |
+
<stylesheet>cdokus/style.css</stylesheet>
|
41 |
+
</action>
|
42 |
+
</reference>
|
43 |
+
<label>Catalog Product View</label>
|
44 |
+
<!-- Zanbytes_Cdokus -->
|
45 |
+
<reference name="product.info.additional">
|
46 |
+
<block type="cdokus/download" name="cdokus_download" before="-" template="cdokus/links.phtml">
|
47 |
+
<block type="page/html_wrapper" name="cdokus.download" as="list_before" translate="label">
|
48 |
+
<label>Links</label>
|
49 |
+
<action method="setMayBeInvisible"><value>1</value></action>
|
50 |
+
</block>
|
51 |
+
</block>
|
52 |
+
</reference>
|
53 |
+
</catalog_product_view>
|
54 |
+
</layout>
|
app/design/frontend/base/default/template/cdokus/links.phtml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Zanbytes
|
22 |
+
* @package Zanbytes_Cdokus
|
23 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
/**
|
27 |
+
* @desc Catalog Product Documents
|
28 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
29 |
+
* @version $Id: links.phtml 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
30 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
31 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
32 |
+
*/
|
33 |
+
?>
|
34 |
+
<?php if(Mage::helper('cdokus')->isAllowed()): ?>
|
35 |
+
<div class="box-collateral box-additional cdokus-download">
|
36 |
+
<?php if ($_links = $this->getAllLinks()): ?>
|
37 |
+
<h2><?php echo $this->__('Available Download Links') ?></h2>
|
38 |
+
<table class="data-table" id="cdoku-available-links">
|
39 |
+
<col />
|
40 |
+
<col width="25%" />
|
41 |
+
<tbody>
|
42 |
+
<?php foreach ($_links as $_link): ?>
|
43 |
+
<tr>
|
44 |
+
<th class="label"><?php echo $this->htmlEscape($this->__($_link->getLabel())) ?></th>
|
45 |
+
<td class="data">
|
46 |
+
<button onclick="setLocation('<?php echo $this->getDownloadUrl($_link) ?>')" class="button action-link" title="<?php echo $this->__('Download') ?>" type="button">
|
47 |
+
<span>
|
48 |
+
<span><?php echo $this->__('Download') ?></span>
|
49 |
+
</span>
|
50 |
+
</button>
|
51 |
+
</td>
|
52 |
+
</tr>
|
53 |
+
<?php endforeach; ?>
|
54 |
+
</tbody>
|
55 |
+
</table>
|
56 |
+
<script type="text/javascript">decorateTable('cdoku-available-links')</script>
|
57 |
+
<?php endif; ?>
|
58 |
+
</div>
|
59 |
+
<?php endif;?>
|
app/etc/modules/Zanbytes_Cdokus.xml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Zanbytes
|
23 |
+
* @package Zanbytes_Cdokus
|
24 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @desc Catalog Product Documents
|
30 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
31 |
+
* @version $Id: Zanbytes_Cdokus.xml 1104 2013-02-18 00:33:21Z muhsin $ $LastChangedBy: muhsin $
|
32 |
+
* @copyright Copyright (c) 2013 Zanbytes Inc. (http://www.zanbytes.com)
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
*/
|
35 |
+
-->
|
36 |
+
<config>
|
37 |
+
<modules>
|
38 |
+
<Zanbytes_Cdokus>
|
39 |
+
<active>true</active>
|
40 |
+
<codePool>community</codePool>
|
41 |
+
<depends>
|
42 |
+
<Mage_Catalog/>
|
43 |
+
</depends>
|
44 |
+
</Zanbytes_Cdokus>
|
45 |
+
</modules>
|
46 |
+
</config>
|
app/locale/en_US/Zanbytes_Cdokus.txt
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"%s link(s) status deleted."
|
2 |
+
"%s link(s) status updated."
|
3 |
+
"Activation"
|
4 |
+
"Active"
|
5 |
+
"Add New Option"
|
6 |
+
"Are you sure you want to do this?"
|
7 |
+
"Are you sure?"
|
8 |
+
"Catalog Links Overview"
|
9 |
+
"Cdokus uploader"
|
10 |
+
"Change status"
|
11 |
+
"Created On"
|
12 |
+
"Delete"
|
13 |
+
"Disable"
|
14 |
+
"Documents"
|
15 |
+
"Enable"
|
16 |
+
"File"
|
17 |
+
"File %s is left for you to manually delete it."
|
18 |
+
"File Name"
|
19 |
+
"File label"
|
20 |
+
"General"
|
21 |
+
"ID"
|
22 |
+
"Inactive"
|
23 |
+
"Label"
|
24 |
+
"Link # %s | %s"
|
25 |
+
"Manage Document Links"
|
26 |
+
"Please select link(s)."
|
27 |
+
"Position"
|
28 |
+
"SKU"
|
29 |
+
"Status"
|
30 |
+
"Store"
|
31 |
+
"Store ID"
|
32 |
+
"System error, sku can not be retrieved!"
|
33 |
+
"The link # %s updated."
|
34 |
+
"The link %s status is to %s."
|
35 |
+
"The link has been saved."
|
36 |
+
"The link is now removed."
|
37 |
+
"The link position updated."
|
38 |
+
"Update Position"
|
39 |
+
"Updated On"
|
40 |
+
"Upload file"
|
41 |
+
"You are attempting link delete, you sure ?"
|
42 |
+
"disabled"
|
43 |
+
"enabled"
|
44 |
+
"read only"
|
45 |
+
"Available"
|
46 |
+
"Available Download Links"
|
47 |
+
"Download"
|
package.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Zanbytes_Cdokus</name>
|
4 |
+
<version>0.0.0.5</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GPL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Product Document, the extension includes admin tab on the Admin Product Interface.And it also provides a way to show the download link per store.</summary>
|
10 |
+
<description>Plugin that gives a nice user interface for administrator to upload product documents like manuals via a nice product tab in the Magento Backoffice.
|
11 |
+

|
12 |
+
As a bonus the plugin, allow administrators to control the visibility of the links per store and by using the translation file the label can be translated into multiple languages.</description>
|
13 |
+
<notes>Date:05-12-2013
|
14 |
+
Version:v0005
|
15 |
+
#First public free version via MC</notes>
|
16 |
+
<authors><author><name>Omar,Muhsin</name><user>omarmadian</user><email>info@zanbytes.com</email></author></authors>
|
17 |
+
<date>2013-12-05</date>
|
18 |
+
<time>22:25:47</time>
|
19 |
+
<contents><target name="mage"><dir name="app"><dir name="locale"><dir name="en_US"><file name="Zanbytes_Cdokus.txt" hash="118e7eb832b943a17b8aff74c4489f23"/></dir></dir><dir name="etc"><dir name="modules"><file name="Zanbytes_Cdokus.xml" hash="f35529ad415197c9c47994fdf5d39760"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="cdokus"><file name="links.phtml" hash="fbdad7a3c6ab227e8af07a9dc716ffd0"/></dir></dir><dir name="layout"><file name="cdokus.xml" hash="fa642f1af0c9e8c5ae4367a14e591c07"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="cdokus.xml" hash="67360c986435c888f76f1b812dc13235"/></dir><dir name="template"><dir name="cdokus"><dir name="product"><dir name="edit"><file name="cdokus.phtml" hash="cb5f49fef2a3c6245534433f4231bc44"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Zanbytes"><dir name="Cdokus"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Cdokus.php" hash="896005f84145fc17eb17dea20c76be6e"/><dir name="Links"><dir name="Action"><file name="Renderer.php" hash="b00dc833ce031a0a8dbcb27e1b29a4f7"/></dir><file name="Grid.php" hash="a5334855e66d678fac34c6c596abf3eb"/></dir></dir></dir></dir></dir><dir name="Cdokus"><file name="Document.php" hash="46d83555b36eefa5d98c790e0130c1a2"/><dir name="Edit"><file name="Form.php" hash="7e455f198a4ad99a7980a12bdc5bb5c1"/><dir name="Tab"><file name="Form.php" hash="a5ba23a18fc605e1d63920f5270eb5d1"/></dir><file name="Tabs.php" hash="27bf63f362a4beb8d7bbc8160a7dd616"/></dir><file name="Edit.php" hash="a2eaf9e5a6f84d006cc019b7267d4a1e"/><file name="Grid.php" hash="f75e9b846f75c8aba051aa3d60121ae8"/></dir></dir><file name="Download.php" hash="4d67891e6f6ca73a253fcafe7b73f711"/></dir><dir name="Helper"><file name="Data.php" hash="0c1fd1143b27f6f68e817ace1850297d"/></dir><dir name="Model"><file name="Abstract.php" hash="cfa4f3041727b1c850a47d01fc3da798"/><file name="Link.php" hash="fad64c620f7a07ceec353c5e3509c1d1"/><dir name="Resource"><dir name="Link"><file name="Collection.php" hash="6705b6a82772d0ded6d1ed3d6222607a"/></dir><file name="Link.php" hash="51be49587945af59ee68b20b3530b8f3"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Cdokus"><dir name="Document"><file name="LinkController.php" hash="bb8a54f9632938a7f0b7aee691846c04"/></dir><dir name="Product"><file name="EditController.php" hash="012e2af6df06fe652f562e4eba6a609b"/></dir></dir></dir><file name="DownloadController.php" hash="96f22f2bebf4cd41ef61d8f6e1117e99"/></dir><dir name="docs"><file name="TODO" hash="508dd0c06bfdfbb5feb20de141428de1"/><file name="readme" hash="bc712bcbe9863e36a1d2c6790ea662bd"/><file name="reset-cdoku-db-entries.sql" hash="e2272e9d913d45415d40dcaebdc06e21"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4319b163cd795ab35a7069cb26c7b3ce"/><file name="config.xml" hash="1127aed82793c2c833f3826bf38cb955"/><file name="system.xml" hash="8962b6d7e62ca3097700e703cdfeef25"/></dir><dir name="sql"><dir name="cdokus_setup"><file name="mysql4-install-0.0.0.1.php" hash="26a56a360e20980878eb3a92880e67eb"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="cdokus"><file name="style.css" hash="289cd7956266a91ef9d6c36d12a071e5"/></dir></dir></dir></dir></dir></target></contents>
|
20 |
+
<compatible/>
|
21 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
+
</package>
|
skin/frontend/base/default/cdokus/style.css
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Magento
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt.
|
8 |
+
* It is also available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
* If you did not receive a copy of the license and are unable to
|
11 |
+
* obtain it through the world-wide-web, please send an email
|
12 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
13 |
+
*
|
14 |
+
* DISCLAIMER
|
15 |
+
*
|
16 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
17 |
+
* versions in the future. If you wish to customize Magento for your
|
18 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
19 |
+
*
|
20 |
+
* @category Zanbytes
|
21 |
+
* @package Zanbytes_Cdokus
|
22 |
+
* @copyright Copyright (c) 2012 Zanbytes Inc. (http://www.zanbytes.com)
|
23 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
24 |
+
*/
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @desc Catalog Product Documents
|
28 |
+
* @author Omar,Muhsin <info@zanbytes.com>
|
29 |
+
* @version $Id: Abstract.php 1076 2013-01-01 22:25:08Z muhsin $ $LastChangedBy: muhsin $
|
30 |
+
* @copyright Copyright (c) 2012 Zanbytes Inc. (http://www.zanbytes.com)
|
31 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
32 |
+
*/
|
33 |
+
/* @TODO put your style here*/
|
34 |
+
|