crearedataflowexportdownloads - Version 0.1.0

Version Notes

Initial Release

Download this release

Release Info

Developer Magento Core Team
Extension crearedataflowexportdownloads
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Creare/Exportdownloads/Block/Adminhtml/Exportdownloads.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * package Creare_Exportdownloads
16
+ * copyright Copyright (c) 2013 Adam Moss (Creare Communications Ltd) http://www.creare.co.uk
17
+ * license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Creare_Exportdownloads_Block_Adminhtml_Exportdownloads extends Mage_Adminhtml_Block_Widget_Grid_Container
21
+ {
22
+ public function __construct()
23
+ {
24
+ $this->_blockGroup = 'exportdownloads';
25
+ $this->_controller = 'adminhtml_exportdownloads';
26
+ $this->_headerText = Mage::helper('exportdownloads')->__('Creare Dataflow Exports');
27
+ parent::__construct();
28
+ $this->removeButton('add');
29
+ }
30
+ }
app/code/local/Creare/Exportdownloads/Block/Adminhtml/Exportdownloads/Grid.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * package Creare_Exportdownloads
16
+ * copyright Copyright (c) 2013 Adam Moss (Creare Communications Ltd) http://www.creare.co.uk
17
+ * license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Creare_Exportdownloads_Block_Adminhtml_Exportdownloads_Grid extends Mage_Adminhtml_Block_Widget_Grid
21
+ {
22
+ public function __construct()
23
+ {
24
+ parent::__construct();
25
+ $this->setId('exportdownloads_grid');
26
+ $this->setDefaultSort('file_created');
27
+ $this->setDefaultDir('desc');
28
+ $this->setSaveParametersInSession(true);
29
+ }
30
+
31
+ protected function _prepareCollection()
32
+ {
33
+ $collection = new Creare_Exportdownloads_Model_Csv_Collection();
34
+ $this->setCollection($collection);
35
+
36
+ return parent::_prepareCollection();
37
+ }
38
+
39
+ protected function _prepareColumns()
40
+ {
41
+ $this->addColumn('file', array(
42
+ 'header' => Mage::helper('exportdownloads')->__('File Name'),
43
+ 'index' => 'file',
44
+ 'filter' => false
45
+ ));
46
+
47
+ $this->addColumn('file_created', array(
48
+ 'header' => Mage::helper('exportdownloads')->__('Created Date'),
49
+ 'index' => 'file_created',
50
+ 'type' => 'datetime'
51
+ ));
52
+
53
+ return parent::_prepareColumns();
54
+ }
55
+
56
+ public function getRowUrl($row)
57
+ {
58
+ return $this->getUrl('*/*/download', array('file'=> $row->getFile()));
59
+ }
60
+
61
+ }
app/code/local/Creare/Exportdownloads/Helper/Data.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * package Creare_Exportdownloads
16
+ * copyright Copyright (c) 2013 Adam Moss (Creare Communications Ltd) http://www.creare.co.uk
17
+ * license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Creare_Exportdownloads_Helper_Data extends Mage_Core_Helper_Abstract
21
+ {
22
+ }
app/code/local/Creare/Exportdownloads/Model/Csv.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * package Creare_Exportdownloads
16
+ * copyright Copyright (c) 2013 Adam Moss (Creare Communications Ltd) http://www.creare.co.uk
17
+ * license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Creare_Exportdownloads_Model_Csv extends Varien_Object
21
+ {
22
+ public function load($fileName, $filePath)
23
+ {
24
+ $this->addData(array(
25
+ 'file' => $fileName,
26
+ 'file_created' => new Zend_Date((int)filemtime($filePath . DS . $fileName), Mage::app()->getLocale()->getLocaleCode())
27
+ ));
28
+
29
+ return $this;
30
+ }
31
+ }
app/code/local/Creare/Exportdownloads/Model/Csv/Collection.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * package Creare_Exportdownloads
16
+ * copyright Copyright (c) 2013 Adam Moss (Creare Communications Ltd) http://www.creare.co.uk
17
+ * license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Creare_Exportdownloads_Model_Csv_Collection extends Varien_Data_Collection_Filesystem
21
+ {
22
+
23
+ protected $_baseDir;
24
+
25
+ public function __construct()
26
+ {
27
+ parent::__construct();
28
+
29
+ $this->_baseDir = Mage::getBaseDir('export');
30
+
31
+ // check for valid base dir
32
+ $ioProxy = new Varien_Io_File();
33
+ $ioProxy->mkdir($this->_baseDir);
34
+ if (!is_file($this->_baseDir . DS . '.htaccess')) {
35
+ $ioProxy->open(array('path' => $this->_baseDir));
36
+ $ioProxy->write('.htaccess', 'deny from all', 0644);
37
+ }
38
+
39
+ $this
40
+ ->setOrder('file_created', self::SORT_ORDER_DESC)
41
+ ->addTargetDir($this->_baseDir)
42
+ ->setCollectRecursively(false);
43
+ }
44
+
45
+ protected function _generateRow($filename)
46
+ {
47
+ $row = parent::_generateRow($filename);
48
+ foreach (Mage::getSingleton('exportdownloads/csv')->load($row['basename'], $this->_baseDir)
49
+ ->getData() as $key => $value) {
50
+ $row[$key] = $value;
51
+ }
52
+ return $row;
53
+ }
54
+
55
+ protected function _collectRecursive($dir)
56
+ {
57
+ $collectedResult = array();
58
+
59
+ if (!is_array($dir)) {
60
+ $dir = array($dir);
61
+ }
62
+
63
+ foreach ($dir as $folder) {
64
+ if ($nodes = glob($folder . DIRECTORY_SEPARATOR . '*')) {
65
+ foreach ($nodes as $node) {
66
+ $collectedResult[] = $node;
67
+ }
68
+ }
69
+ }
70
+
71
+ if (empty($collectedResult)) {
72
+ return;
73
+ }
74
+
75
+ foreach ($collectedResult as $item) {
76
+ if (substr($item, -3, 3) == "csv")
77
+ {
78
+ $this->_collectedFiles[] = $item;
79
+ }
80
+ }
81
+ }
82
+ }
app/code/local/Creare/Exportdownloads/controllers/Adminhtml/ExportdownloadsController.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * package Creare_Exportdownloads
16
+ * copyright Copyright (c) 2013 Adam Moss (Creare Communications Ltd) http://www.creare.co.uk
17
+ * license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Creare_Exportdownloads_Adminhtml_ExportdownloadsController extends Mage_Adminhtml_Controller_Action
21
+ {
22
+ public function indexAction()
23
+ {
24
+ $this->_title($this->__('Creare Dataflow Exports'));
25
+ $this->loadLayout();
26
+
27
+ $content = $this->getLayout()
28
+ ->createBlock('exportdownloads/adminhtml_exportdownloads');
29
+ $this->_addContent($content);
30
+
31
+ $this->_setActiveMenu('system/convert');
32
+ $this->renderLayout();
33
+ }
34
+
35
+ public function downloadAction()
36
+ {
37
+ if (Mage::app()->getRequest()->getParam('file'))
38
+ {
39
+ $file = Mage::app()->getRequest()->getParam('file');
40
+
41
+ header('Content-disposition: attachment; filename='.$file);
42
+ header('Content-type: text/csv');
43
+ readfile(Mage::getBaseDir('export') . DS . $file);
44
+
45
+ } else {
46
+
47
+ Mage::getSingleton('core/session')->addError(Mage::helper('exportdownloads')->__('Unable to find download file'));
48
+ $this->_redirect('*/*/');
49
+
50
+ }
51
+ }
52
+ }
app/code/local/Creare/Exportdownloads/etc/adminhtml.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <system>
5
+ <children>
6
+ <convert>
7
+ <children>
8
+ <exportdownloads>
9
+ <title>Creare Dataflow Exports</title>
10
+ <action>adminhtml/exportdownloads</action>
11
+ </exportdownloads>
12
+ </children>
13
+ </convert>
14
+ </children>
15
+ </system>
16
+ </menu>
17
+ <acl>
18
+ <resources>
19
+ <all>
20
+ <title>Allow Everything</title>
21
+ </all>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <convert>
27
+ <children>
28
+ <exportdownloads>
29
+ <title>Creare Dataflow Exports</title>
30
+ <sort_order>10</sort_order>
31
+ </exportdownloads>
32
+ </children>
33
+ </convert>
34
+ </children>
35
+ </system>
36
+ </children>
37
+ </admin>
38
+ </resources>
39
+ </acl>
40
+ </config>
app/code/local/Creare/Exportdownloads/etc/config.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Creare_Exportdownloads>
5
+ <version>0.1.0</version>
6
+ </Creare_Exportdownloads>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <adminhtml>
11
+ <args>
12
+ <modules>
13
+ <exportdownloads before="Mage_Adminhtml">Creare_Exportdownloads_Adminhtml</exportdownloads>
14
+ </modules>
15
+ </args>
16
+ </adminhtml>
17
+ </routers>
18
+ </admin>
19
+ <global>
20
+ <blocks>
21
+ <exportdownloads>
22
+ <class>Creare_Exportdownloads_Block</class>
23
+ </exportdownloads>
24
+ </blocks>
25
+ <helpers>
26
+ <exportdownloads>
27
+ <class>Creare_Exportdownloads_Helper</class>
28
+ </exportdownloads>
29
+ </helpers>
30
+ <models>
31
+ <exportdownloads>
32
+ <class>Creare_Exportdownloads_Model</class>
33
+ </exportdownloads>
34
+ </models>
35
+ </global>
36
+ </config>
app/etc/modules/Creare_Exportdownloads.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Creare_Exportdownloads>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>1.0</version>
8
+ </Creare_Exportdownloads>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>crearedataflowexportdownloads</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Download your Dataflow CSV exports through the Magento admin panel.</summary>
10
+ <description>Using this module you can download your dataflow export CSVs through the Magento administration interface - no FTP knowledge required.</description>
11
+ <notes>Initial Release</notes>
12
+ <authors><author><name>Adam Moss</name><user>auto-converted</user><email>magento@creare.co.uk</email></author></authors>
13
+ <date>2013-02-12</date>
14
+ <time>17:25:52</time>
15
+ <contents><target name="magelocal"><dir name="Creare"><dir name="Exportdownloads"><dir name="Block"><dir name="Adminhtml"><dir name="Exportdownloads"><file name="Grid.php" hash="eb281168df8e6bb0e6791e7097b62752"/></dir><file name="Exportdownloads.php" hash="db25fcc92d6c8cc9c6a8b14ca2c37a7e"/></dir></dir><dir name="Helper"><file name="Data.php" hash="5e6f30c62fec97125fdfbca76dfc93bc"/></dir><dir name="Model"><dir name="Csv"><file name="Collection.php" hash="d019ee28d1fe7b8c32ee1c05d1542f32"/></dir><file name="Csv.php" hash="56df7fee296d8c39dc364acd3999e81c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportdownloadsController.php" hash="197b87ed0fe097baa43aaa27f0ea09cd"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b7c2c1e8662a671cb0f738aa8cbf3514"/><file name="config.xml" hash="82c5241e46a23dd5090bba4c98d5f1a4"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Creare_Exportdownloads.xml" hash="f1d817487bf9d81637261b8f9e464aa0"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>