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 Mage
22: * @package Mage_Connect
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Convert profile edit tab
29: *
30: * @category Mage
31: * @package Mage_Connect
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Connect_Block_Adminhtml_Extension_Custom_Edit_Tab_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: /**
37: * Initialize Grid block
38: *
39: */
40: public function __construct()
41: {
42: parent::__construct();
43: $this->_defaultLimit = 200;
44: $this->setId('extension_custom_edit_grid');
45: $this->setUseAjax(true);
46: }
47:
48: /**
49: * Creates extension collection if it has not been created yet
50: *
51: * @return Mage_Connect_Model_Extension_Collection
52: */
53: public function getCollection()
54: {
55: if (!$this->_collection) {
56: $this->_collection = Mage::getModel('connect/extension_collection');
57: }
58: return $this->_collection;
59: }
60:
61: /**
62: * Prepare Local Package Collection for Grid
63: *
64: * @return Mage_Connect_Block_Adminhtml_Extension_Custom_Edit_Tab_Grid
65: */
66: protected function _prepareCollection()
67: {
68: $this->setCollection($this->getCollection());
69: return parent::_prepareCollection();
70: }
71:
72: /**
73: * Prepare grid columns
74: *
75: * @return Mage_Adminhtml_Block_Extension_Custom_Edit_Tab_Grid
76: */
77: protected function _prepareColumns()
78: {
79: $this->addColumn('folder', array(
80: 'header' => Mage::helper('connect')->__('Folder'),
81: 'index' => 'folder',
82: 'width' => 100,
83: 'type' => 'options',
84: 'options' => $this->getCollection()->collectFolders()
85: ));
86:
87: $this->addColumn('package', array(
88: 'header' => Mage::helper('connect')->__('Package'),
89: 'index' => 'package',
90: ));
91:
92: return parent::_prepareColumns();
93: }
94:
95: /**
96: * Self URL getter
97: *
98: * @return string
99: */
100: public function getCurrentUrl($params = array())
101: {
102: if (!isset($params['_current'])) {
103: $params['_current'] = true;
104: }
105: return $this->getUrl('*/*/grid', $params);
106: }
107:
108: /**
109: * Row URL getter
110: *
111: * @return string
112: */
113: public function getRowUrl($row)
114: {
115: return $this->getUrl('*/*/load', array('id' => strtr(base64_encode($row->getFilenameId()), '+/=', '-_,')));
116: }
117: }
118: