Version Notes
none
Download this release
Release Info
Developer | Magento Core Team |
Extension | Downloadexports |
Version | 1.0 |
Comparing to | |
See all releases |
Code changes from version 0.2.0 to 1.0
- app/code/local/Mage/Downloadexports/Block/Grid.php +139 -0
- app/code/local/Mage/Downloadexports/controllers/Adminhtml/ExportviewController.php +57 -0
- app/code/local/Mage/Downloadexports/etc/config.xml +1 -0
- app/design/adminhtml/default/default/layout/downloadexports.xml +1 -0
- app/design/adminhtml/default/default/template/downloadexports/exportview.phtml +20 -11
- package.xml +8 -20
app/code/local/Mage/Downloadexports/Block/Grid.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Mage_Downloadexports_Block_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('downloadexports');
|
9 |
+
$this->setDefaultSort('file_id');
|
10 |
+
$this->setDefaultDir('desc');
|
11 |
+
$this->setSaveParametersInSession(false);
|
12 |
+
$this->setUseAjax(true);
|
13 |
+
$this->setVarNameFilter('export_filter');
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _getStore()
|
17 |
+
{
|
18 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
19 |
+
return Mage::app()->getStore($storeId);
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _prepareCollection()
|
23 |
+
{
|
24 |
+
$store = $this->_getStore();
|
25 |
+
$collection = Mage::getModel('varien/data_collection');
|
26 |
+
|
27 |
+
ob_start();
|
28 |
+
$lines = array();
|
29 |
+
$z = exec("ls -lht ".dirname(__FILE__)."/../../../../../../var/export", $lines);
|
30 |
+
array_shift($lines);
|
31 |
+
ob_end_clean();
|
32 |
+
$files = array();
|
33 |
+
foreach($lines as $k=>$line) {
|
34 |
+
$fileModel = new Varien_Object();
|
35 |
+
$matches = array();
|
36 |
+
preg_match("/(.*) (.*) (.*) (.*) (.*) (.*) (.*)/", $line, $matches);
|
37 |
+
$fullpath = dirname(__FILE__)."/../../../../../../var/export/".$matches[7];
|
38 |
+
$fileModel->setData('ctime', date('Y-m-d h:i:s', filectime($fullpath)));
|
39 |
+
$fileModel->setData('file_id', $k);
|
40 |
+
$fileModel->setData('size', round((filesize($fullpath)/1000),1).'kB');
|
41 |
+
$fileModel->setData('name', $matches[7]);
|
42 |
+
$collection->addItem($fileModel);
|
43 |
+
}
|
44 |
+
|
45 |
+
$this->setCollection($collection);
|
46 |
+
|
47 |
+
parent::_prepareCollection();
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _addColumnFilterToCollection($column)
|
52 |
+
{
|
53 |
+
return parent::_addColumnFilterToCollection($column);
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _prepareColumns()
|
57 |
+
{
|
58 |
+
$this->addColumn('file_id',
|
59 |
+
array(
|
60 |
+
'header'=> Mage::helper('catalog')->__('ID'),
|
61 |
+
'width' => '20px',
|
62 |
+
'type' => 'number',
|
63 |
+
'index' => 'file_id',
|
64 |
+
'filter' => false,
|
65 |
+
'sortable' => false,
|
66 |
+
));
|
67 |
+
$this->addColumn('name',
|
68 |
+
array(
|
69 |
+
'header'=> Mage::helper('catalog')->__('Name'),
|
70 |
+
'index' => 'name',
|
71 |
+
));
|
72 |
+
|
73 |
+
$this->addColumn('ctime',
|
74 |
+
array(
|
75 |
+
'header'=> Mage::helper('catalog')->__('Created'),
|
76 |
+
'width' => '160px',
|
77 |
+
'index' => 'ctime',
|
78 |
+
));
|
79 |
+
|
80 |
+
$this->addColumn('size',
|
81 |
+
array(
|
82 |
+
'header'=> Mage::helper('catalog')->__('Size (kB)'),
|
83 |
+
'width' => '100px',
|
84 |
+
'index' => 'size',
|
85 |
+
'sortable'=> false,
|
86 |
+
));
|
87 |
+
$this->addColumn('action',
|
88 |
+
array(
|
89 |
+
'header' => Mage::helper('catalog')->__('Action'),
|
90 |
+
'width' => '60px',
|
91 |
+
'type' => 'action',
|
92 |
+
'getter' => 'getName',
|
93 |
+
'actions' => array(
|
94 |
+
array(
|
95 |
+
'caption' => Mage::helper('catalog')->__('Delete'),
|
96 |
+
'url' => array(
|
97 |
+
'base'=>'*/*/delete' ),
|
98 |
+
'field' => 'name'
|
99 |
+
)
|
100 |
+
),
|
101 |
+
'filter' => false,
|
102 |
+
'sortable' => false,
|
103 |
+
));
|
104 |
+
return parent::_prepareColumns();
|
105 |
+
}
|
106 |
+
|
107 |
+
protected function _prepareMassaction()
|
108 |
+
{
|
109 |
+
$this->setMassactionIdField('name');
|
110 |
+
$this->getMassactionBlock()->setFormFieldName('downloadexports');
|
111 |
+
|
112 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
113 |
+
'label'=> Mage::helper('downloadexports')->__('Delete'),
|
114 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
115 |
+
'confirm' => Mage::helper('downloadexports')->__('Are you sure?')
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->getMassactionBlock()->addItem('status', array(
|
119 |
+
'label'=> Mage::helper('downloadexports')->__('Download'),
|
120 |
+
'url' => $this->getUrl('*/*/massDownload', array('_current'=>true))
|
121 |
+
));
|
122 |
+
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function getGridUrl()
|
127 |
+
{
|
128 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
129 |
+
}
|
130 |
+
|
131 |
+
public function getRowUrl($row)
|
132 |
+
{
|
133 |
+
return "#";
|
134 |
+
return $this->getUrl('*/*/edit', array(
|
135 |
+
'store'=>$this->getRequest()->getParam('store'),
|
136 |
+
'id'=>$row->getId())
|
137 |
+
);
|
138 |
+
}
|
139 |
+
}
|
app/code/local/Mage/Downloadexports/controllers/Adminhtml/ExportviewController.php
CHANGED
@@ -48,4 +48,61 @@ class Mage_Downloadexports_Adminhtml_ExportviewController extends Mage_Adminhtml
|
|
48 |
}
|
49 |
$this->_redirect('*/*');
|
50 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
48 |
}
|
49 |
$this->_redirect('*/*');
|
50 |
}
|
51 |
+
public function gridAction()
|
52 |
+
{
|
53 |
+
$this->loadLayout();
|
54 |
+
$this->getResponse()->setBody(
|
55 |
+
$this->getLayout()->createBlock('downloadexports/grid')->toHtml()
|
56 |
+
);
|
57 |
+
}
|
58 |
+
|
59 |
+
public function deleteAction() {
|
60 |
+
$file = $this->getRequest()->getParam('name');
|
61 |
+
if(unlink(dirname(__FILE__).'/../../../../../../../var/export/'.$file))
|
62 |
+
$this->_getSession()->addSuccess($this->__("Deleted file $file successfully"));
|
63 |
+
else
|
64 |
+
$this->_getSession()->addError($this->__("Could not delete file $file"));
|
65 |
+
|
66 |
+
$this->_redirect('*/*');
|
67 |
+
}
|
68 |
+
|
69 |
+
public function massDeleteAction() {
|
70 |
+
$deleteFiles = $this->getRequest()->getParam($this->getRequest()->getParam('massaction_prepare_key'));
|
71 |
+
$successful = 0;
|
72 |
+
$failed = 0;
|
73 |
+
|
74 |
+
if($deleteFiles) {
|
75 |
+
foreach($deleteFiles as $fileName) {
|
76 |
+
$result = unlink(dirname(__FILE__).'/../../../../../../../var/export/'.$fileName);
|
77 |
+
if($result) {
|
78 |
+
$successful++;
|
79 |
+
} else {
|
80 |
+
$failed++;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
if($successful>0)
|
84 |
+
$this->_getSession()->addSuccess($this->__("Deleted $successful files successfully"));
|
85 |
+
if($failed>0)
|
86 |
+
$this->_getSession()->addSuccess($this->__("Unable to delete $failed files"));
|
87 |
+
}
|
88 |
+
$this->_redirect('*/*');
|
89 |
+
}
|
90 |
+
|
91 |
+
public function massDownloadAction() {
|
92 |
+
$dlFiles = $this->getRequest()->getParam($this->getRequest()->getParam('massaction_prepare_key'));
|
93 |
+
|
94 |
+
if($dlFiles) {
|
95 |
+
$zip_str = '';
|
96 |
+
foreach($dlFiles as $fileName)
|
97 |
+
$zip_str .= dirname(__FILE__).'/../../../../../../../var/export/'.$fileName.' ';
|
98 |
+
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n");
|
99 |
+
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
100 |
+
header("Content-type: application/zip;\n");
|
101 |
+
header("Content-Transfer-Encoding: binary");
|
102 |
+
header("Cache-Control: no-cache");
|
103 |
+
header("Expires: -1");
|
104 |
+
header("Content-Disposition: attachment; filename=\"export_".date('m-d-Y').".zip\";\n\n");
|
105 |
+
die(passthru("zip -j - $zip_str | cat"));
|
106 |
+
}
|
107 |
+
}
|
108 |
}
|
app/code/local/Mage/Downloadexports/etc/config.xml
CHANGED
@@ -59,6 +59,7 @@
|
|
59 |
<downloadexports_adminform translate="title" module="downloadexports">
|
60 |
<title>Download Exported Files</title>
|
61 |
<action>downloadexports/adminhtml_exportview</action>
|
|
|
62 |
</downloadexports_adminform>
|
63 |
</children>
|
64 |
</convert>
|
59 |
<downloadexports_adminform translate="title" module="downloadexports">
|
60 |
<title>Download Exported Files</title>
|
61 |
<action>downloadexports/adminhtml_exportview</action>
|
62 |
+
<sort_order>50</sort_order>
|
63 |
</downloadexports_adminform>
|
64 |
</children>
|
65 |
</convert>
|
app/design/adminhtml/default/default/layout/downloadexports.xml
CHANGED
@@ -4,6 +4,7 @@
|
|
4 |
<update handle="downloadexports_exportview_index"/>
|
5 |
<reference name="content">
|
6 |
<block type="adminhtml/template" name="exportview" template="downloadexports/exportview.phtml"/>
|
|
|
7 |
</reference>
|
8 |
</downloadexports_adminhtml_exportview_index>
|
9 |
</layout>
|
4 |
<update handle="downloadexports_exportview_index"/>
|
5 |
<reference name="content">
|
6 |
<block type="adminhtml/template" name="exportview" template="downloadexports/exportview.phtml"/>
|
7 |
+
<block type="downloadexports/grid" name="exports_widget"/>
|
8 |
</reference>
|
9 |
</downloadexports_adminhtml_exportview_index>
|
10 |
</layout>
|
app/design/adminhtml/default/default/template/downloadexports/exportview.phtml
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
<table cellspacing="0" class="grid-header">
|
3 |
<tr>
|
4 |
<td><h3><?=$this->__('Download Exported Files')?></h3></td>
|
@@ -21,29 +21,38 @@
|
|
21 |
<th>File Size</th>
|
22 |
</tr>
|
23 |
<?php
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
$odd_or_even = 0;
|
26 |
-
|
27 |
-
|
28 |
-
$fullpath = dirname(__FILE__)."/../../../../../../../var/export/".$z;
|
29 |
?>
|
30 |
<tr class="<?=($odd_or_even%2)?'odd':'even'?>">
|
31 |
-
<td style="width:50px" class="a-center"><input type="checkbox" id="downloadform[export_<?=$odd_or_even?>]" name="downloadform[export][<?=$odd_or_even?>]" value="<?=$
|
32 |
-
<td><label for="downloadform[export_<?=$odd_or_even?>]"><?=$
|
33 |
<td><?=date('m-d-Y h:i:s', filectime($fullpath))?></td>
|
34 |
<td><?=round((filesize($fullpath)/1000),1)?> Kb</td>
|
35 |
</tr>
|
36 |
<?php
|
37 |
-
|
38 |
-
}
|
39 |
}?>
|
40 |
<!-- <tr>
|
41 |
<td class="label"><?=$this->__('Field label')?> <span class="required">*</span></td>
|
42 |
<td class="input-ele"><input class="input-text required-entry" name="myform[myfield]" /></td>
|
43 |
-
</tr>
|
44 |
</table>
|
45 |
</form>
|
46 |
-
</div
|
47 |
<script type="text/javascript">
|
48 |
var editForm = new varienForm('edit_form');
|
49 |
</script>
|
1 |
+
<!--<div class="content-header">
|
2 |
<table cellspacing="0" class="grid-header">
|
3 |
<tr>
|
4 |
<td><h3><?=$this->__('Download Exported Files')?></h3></td>
|
21 |
<th>File Size</th>
|
22 |
</tr>
|
23 |
<?php
|
24 |
+
ob_start();
|
25 |
+
$lines = array();
|
26 |
+
$z = exec("ls -lht ".dirname(__FILE__)."/../../../../../../../var/export", $lines);
|
27 |
+
array_shift($lines);
|
28 |
+
ob_end_clean();
|
29 |
+
$files = array();
|
30 |
+
foreach($lines as $line) {
|
31 |
+
$matches = array();
|
32 |
+
preg_match("/(.*) (.*) (.*) (.*) (.*) (.*) (.*)/", $line, $matches);
|
33 |
+
$files[] = $matches[7];
|
34 |
+
}
|
35 |
+
|
36 |
$odd_or_even = 0;
|
37 |
+
foreach($files as $file) {
|
38 |
+
$fullpath = dirname(__FILE__)."/../../../../../../../var/export/".$file;
|
|
|
39 |
?>
|
40 |
<tr class="<?=($odd_or_even%2)?'odd':'even'?>">
|
41 |
+
<td style="width:50px" class="a-center"><input type="checkbox" id="downloadform[export_<?=$odd_or_even?>]" name="downloadform[export][<?=$odd_or_even?>]" value="<?=$file?>" /></td>
|
42 |
+
<td><label for="downloadform[export_<?=$odd_or_even?>]"><?=$file?></label></td>
|
43 |
<td><?=date('m-d-Y h:i:s', filectime($fullpath))?></td>
|
44 |
<td><?=round((filesize($fullpath)/1000),1)?> Kb</td>
|
45 |
</tr>
|
46 |
<?php
|
47 |
+
$odd_or_even++;
|
|
|
48 |
}?>
|
49 |
<!-- <tr>
|
50 |
<td class="label"><?=$this->__('Field label')?> <span class="required">*</span></td>
|
51 |
<td class="input-ele"><input class="input-text required-entry" name="myform[myfield]" /></td>
|
52 |
+
</tr>
|
53 |
</table>
|
54 |
</form>
|
55 |
+
</div>-->
|
56 |
<script type="text/javascript">
|
57 |
var editForm = new varienForm('edit_form');
|
58 |
</script>
|
package.xml
CHANGED
@@ -1,32 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Downloadexports</name>
|
4 |
-
<version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
Once installed it is visible under the menu System > Import/Export > Download Exported Files
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
Installation
|
19 |
-
|
20 |
-
It is very important to chmod recursively the var directory in magento's document root to 0777. It's alright, the .htaccess on this directory will still prevent any unwanted eyes from downloading the files over the web.</description>
|
21 |
-
<notes>Nope.
|
22 |
-
|
23 |
-
12-10-2010
|
24 |
-
==========
|
25 |
-
- Added fix for selecting individual export files index.</notes>
|
26 |
<authors><author><name>Brad Zasada</name><user>auto-converted</user><email>zasadab03@gmail.com</email></author></authors>
|
27 |
-
<date>
|
28 |
-
<time>
|
29 |
-
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="downloadexports.xml" hash="
|
30 |
<compatible/>
|
31 |
<dependencies/>
|
32 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Downloadexports</name>
|
4 |
+
<version>1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Download exports through a web interface</summary>
|
10 |
+
<description>Magento's great, but it still doesn't provide a way for you to download your export files created through the export profiles.
|
11 |
|
12 |
+
This takes care of that, especially handy for pre 1.5 users who do not have the new ImportExport module!</description>
|
13 |
+
<notes>none</notes>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
<authors><author><name>Brad Zasada</name><user>auto-converted</user><email>zasadab03@gmail.com</email></author></authors>
|
15 |
+
<date>2011-03-17</date>
|
16 |
+
<time>20:51:05</time>
|
17 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="downloadexports.xml" hash="b45a2ddebe0f130e78fb01492a4c5d75"/></dir><dir name="template"><dir name="downloadexports"><file name="exportview.phtml" hash="df018e7d4b8bcd9963a09874a609f9b7"/></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Mage"><dir name="Downloadexports"><dir name="Block"><file name="Exportview.php" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Grid.php" hash="beb4980414cb56c1b11ea67357edb140"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportviewController.php" hash="d5d923112feaaa02b41ca59fff89e10f"/></dir></dir><dir name="etc"><file name="config.xml" hash="6ba5c8d013bc0d1806540b2f4e3cb736"/></dir><dir name="Helper"><file name="Data.php" hash="83c91780a78eb431619445de0a3c5284"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_Downloadexports.xml" hash="9cde0ce7caa45608e0de3052044d20ad"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies/>
|
20 |
</package>
|